Django generic view initial value in form
问题 i want to have default value in my form which should be current user's choice. For example, user chooses to give 5 for a movie and he should see 5 in form until he changes it. views.py class MovieDetailView(FormMixin, DetailView): model = Movie template_name = 'main/detail_movie.html' context_object_name = 'movie' form_class = RateForm def get_context_data(self, **kwargs): context = super(MovieDetailView, self).get_context_data(**kwargs) context['form'] = RateForm(initial={'movie': self