how to get initial parameters during updating a form in Django with TemplateView -


i have following class based templateview, want templateview updateview.but not sure set form instance parameters. try in get_context_data didn't work. ideas ?

class profileupdateview(generic.templateview):     template_name = "profile/update_profile.html"      def dispatch(self, *args, **kwargs):         if self.request.user.is_authenticated():             return super(profileupdateview, self).dispatch(*args, **kwargs)         else:             return httpresponseredirect('/profiles/login')      def get_context_data(self, *args, **kwargs):         context = {}         try:             profile.objects.get(user__id=self.request.user.id)             user = profile.objects.get(user__id=self.request.user.id)             context['profile_form'] = profile_form(data=request.post, instance=user)         except:             context['profile_form'] = profileform(data=self.request.post)             context['profile'] = profile.objects.filter(user=self.request.user.id)             context['experiences'] = experience.objects.filter(user=self.request.user.id)             context['education'] = education.objects.filter(user=self.request.user.id)             context['award'] = award.objects.filter(user=self.request.user.id)             context['publication'] = publication.objects.filter(user=self.request.user.id)             context['membership'] = membership.objects.filter(user=self.request.user.id)             context['patent'] = patent.objects.filter(user=self.request.user.id)             context['certificate'] = certificate.objects.filter(user=self.request.user.id)             context['language'] = language.objects.filter(user=self.request.user.id)         return context      def post(self, request, *args, **kwargs):         if self.request.post:             profile_form = profileform(data=request.post)             if profile_form.is_valid():                 profile = profile_form.save(commit=false)                 profile.user = request.user                 profile.save()                 return httpresponseredirect('/') 


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -