0

I use the Django built-in models.User as basic user model, plus a model called Profile containing other user information, which has a one-to-one field relation to User.

class Profile:
    user = models.OneToOneField(User)
    nickname = models.CharField()
    bio = models.CharField

I would like to use modelform for both model in the register view.

And in the register page, the html form literally contains field in both User and Profile, and this form will be submitted with all params in the POST, which means in the view function I have to handle two modelform with one POST params dictionary.

I have no idea how to implement this view function.

Ziqi Liu
  • 2,931
  • 5
  • 31
  • 64
  • did you try `class Profile(User)` ? required: `from django.contrib.auth.models import User` – w411 3 Nov 15 '17 at 16:37
  • May be this can help you https://stackoverflow.com/questions/2770810/multiple-models-in-a-single-django-modelform – Nagesh Dhope Nov 15 '17 at 16:40
  • @waLLe I've tried that, but the authentication modules doesn't work anymore....So that's why I use another Profile model to store extra information..... – Ziqi Liu Nov 15 '17 at 17:19

0 Answers0