Friday, May 4, 2012

Re: UpdateView issue

In your form (template), are you trying to modify the is_active? I don't see anything that pops out at me that's missing. If you want to explicitly set this, you could do someting like this:

class UserForm(ModelForm):

    # ....
    def save(self):
        m = super(UserForm, self).save(commit = False)
        m.is_active = self.cleaned_data['is_active'] # Or for testing, set it to True or what-not
        m.save()
        return m

On Fri, May 4, 2012 at 4:40 PM, William Ibarra Rodriguez <legolasw20@gmail.com> wrote:
i start working with django 1.3 class based views
so i have the following problem:

when i try to update a user using django,contrib,auth.models (in this
case User model)
the is_active field doesn't update.

so i have the following view:

 class UpdateUserView(UpdateView):
       model = User    # User is taken from django.contrib.auth.models
       form_class = UserForm   # I use UserForm to hide some fields
       template_name = 'admin/user_form.html'
       success_url = '/admin/usuarios/'


the form is the following:

 class UserForm(forms.ModelForm):
       class Meta:
               model = User  # User is taken from django.contrib.auth.models
               exclude =('email','last_login','date_joined')
       def __init__(self, *args, **kwargs):
               super(UserForm, self).__init__(*args, **kwargs)


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate