I am trying to save a form using UpdateView in Django 1.3 and it seems to run into a problem. When I save the form, it goes to the current URL, and the success URL is the same URL.
When you save the form, the data seems to change because all the fields on the page are updated, but when I update, everything seems to be returned.
The shape is the shape of the model, and here is my opinion:
class UserProfileView(UpdateView):
context_object_name = 'profile'
def get_template_names(self):
return ['webapp/user_profile.html']
def get_queryset(self):
pk = self.kwargs.get('pk', None)
if pk is not None:
user = User.objects.get(pk=pk)
else:
raise AttributeError(u"Could not locate user with pk %s"
% pk)
if user.contributor_profile.all():
queryset = Contributor.objects.filter(user__pk=pk)
else:
queryset = Member.objects.filter(user__pk=pk)
return queryset
def get_object(self, queryset=None):
if queryset is None:
queryset = self.get_queryset()
return queryset.get()
I donβt see what could be wrong, since Django saves the form through the UpdateView class and the Mixin extension. Has anyone encountered this problem before?
source
share