0

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()
mariodev
  • 13,928
  • 3
  • 49
  • 61
Thameem
  • 3,426
  • 4
  • 26
  • 32

2 Answers2

1

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

Community
  • 1
  • 1
hizbul25
  • 3,829
  • 4
  • 26
  • 39
-1
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

Daniel Qiu
  • 617
  • 5
  • 14