On Sun, 2009-08-09 at 13:35 -0700, Léon Dignòn wrote:
> Hi,
> 
> I have a ModelForm of my UserProfile model with two additional fields.
> I need to override save(), to save the additional fields to the
> django.contrib.auth.model.User model.
> I tried to do that with a subclass of my UserProfile model class to
> have the code separated. But I get a NameError: name
> 'ProfileFormExtended' is not defined.
> 
> from django.contrib.auth.models import User
> from django.db import models
> from django.forms.models import ModelForm
> from django import forms
> from myproject.myapp.models import UserProfile
> 
> class ProfileForm(ModelForm):
>     first_name = forms.CharField(max_length=30)
>     last_name = forms.CharField(max_length=30)
> 
>     class Meta:
>         model = ProfileFormExtended

At the time this line of code is executed, this class doesn't exist yet
(you don't define it until later in the file). The error message is
telling you the right thing. Reorder the code in the file.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to