Hello All, I had created multiModelForm in Django, I can view, and save data, I don't know how to Update data into the database. I want if user id exists in database then update else insert.exist in the database then update else insert.
This Code is working for me but I don't know how to update existing data? # forms.py from django import forms from authtools.forms import UserCreationForm from betterforms.multiform import MultiModelForm from .models import UserProfile class UserProfileForm(forms.ModelForm): class Meta: fields = ('favorite_color',) class UserCreationMultiForm(MultiModelForm): form_classes = { 'user': UserCreationForm, 'profile': UserProfileForm, } # views.py from django.views.generic import CreateView from django.core.urlresolvers import reverse_lazy from django.shortcuts import redirect from .forms import UserCreationMultiForm class UserSignupView(CreateView): form_class = UserCreationMultiForm success_url = reverse_lazy('home') def form_valid(self, form): # Save the user first, because the profile needs a user before it # can be saved. user = form['user'].save() profile = form['profile'].save(commit=False) profile.user = user profile.save() return redirect(self.get_success_url()) -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9da43e2a-6246-4e8e-9798-6092bd336c8d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.