1

I have a UserProfile model defined in settings.py. Now I want to create a registration form that has fields from both the User and UserProfile models. Is there an easy way to do it?

I'm using uni_form to create nice-looking forms if this helps.

eksortso
  • 1,273
  • 3
  • 12
  • 21
suda
  • 2,604
  • 1
  • 27
  • 38
  • https://stackoverflow.com/questions/38164582/get-user-onetoonefield-fields-in-modelforms/66913779#66913779 – josue Apr 02 '21 at 05:09

1 Answers1

1

Just put two children of Form in the view and display them in the template. Use the prefix argument in the constructors to prevent field name collisions.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
  • Problem is, my UserProfile has fields that should be visible between fields of User model (like "Title: Mr/Mrs"). Maybe will be easier to create form from UserProfile model and manually add fields missing from User model... – suda Jan 29 '10 at 16:44
  • Or you could just output the fields from the appropriate form yourself, in the order you need them. – Ignacio Vazquez-Abrams Jan 29 '10 at 16:46