I'm reading the django docs, and I come across the following:

from django.contrib.auth.models import User

class UserProfile(models.Model):
    # This field is required.
    user = models.OneToOneField(User)

    # Other fields here
    accepted_eula = models.BooleanField()
    favorite_animal = models.CharField(max_length=20,
default="Dragons.")

But, I've also seen it done this way:

class UserProfile(User):
    # Other fields here
    accepted_eula = models.BooleanField()
    favorite_animal = models.CharField(max_length=20,
default="Dragons.")

Are there any differences between the two ways?

Also, can someone explain to me the post_save concept?

def create_user_profile(sender, instance, created, **kwargs):
    if created:
        UserProfile.objects.create(user=instance)

post_save.connect(create_user_profile, sender=User).
Would this function work with only the first UserProfile class above?
Or will it also work with the second UserProfile Class. Thank you.

-- 
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