Question

I am using django registration form and I want to add an extra field age to sign up form and i want to save that field to my model named profile.How can i do it.What will be my view?

my models.py

class Profile(models.Model):
    age = models.IntegerField()
Was it helpful?

Solution

You mention you have a model class which is my models.py

class Profile(models.Model):
    age = models.IntegerField()

I think in this case you may get help from this : Python/Django django-registration add an extra field

OTHER TIPS

from django.contrib.auth.models import User
class Profile(models.Model):
    user = models.OneToOneField(User)
    age = models.IntegerField()

for more detail: https://docs.djangoproject.com/en/dev/topics/auth/customizing/#extending-the-existing-user-model

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top