I’m trying to solve a problem that i don’t find on google ( apparently ).
I got a Django Project which allows People to get registered.
I got my form which is something like this:
forms.py
class RegistrationForm(UserCreationForm):
"""docstring for RegistrationForm"""
email = forms.EmailField(required=True)
studio_associato = forms.CharField(required=True)
nome = forms.CharField(required=True)
cognome = forms.CharField(required=True)
class Meta: # define a metadata related to this class
model = User
fields = (
'username',
'nome',
'cognome',
'studio_associato',
'password1',
'password2'
)
I managed to correctly store and visualize the User in the DB and the admin page.
What i’m trying to get is to let this field ‘studio_associato’ be a field that when a User register himself through the registration form, he have to specify from which (in Italian Studio = Office ) Office he’s working for.
Each User can only work with an Office unlike Office could have obviously more Users linked to it.
My final product i’m trying to achieve is a field: “Studio associato” (showed during the registration form of the User) which displays all the Offices registered till that moment and let you Click or Search a specific Office to link that user for.
Note that my html page is just a normal recall to the form i linked above:
register.html
<body>
<h1>Register!</h1>
<form method="post">
{% csrf_token %}
{{form.as_p}}
<button type="submit">Submit</button>
</form>
(Note that studio_associato is just some name, so a text field)
Thanks in advance, hope i explained it clearly