1๐
Hi Simeon Todorov!
The problem seems to be in your template file add_organization.html
In the <form>
tag. The two <input>
fields are conflicting with the same name=name
attributes.
<div class="flex flex-col mb-4">
<label class="mb-2 text-lg text-gray-900" for="name">Organization Name</label> {{ organization_form.name.errors|striptags }}
<input class="border py-2 px-3 text-grey-800 rounded-lg" type="text" name="name" id="name">
</div>
<div class="flex flex-col mb-4">
<label class="mb-2 text-lg text-gray-900" for="email">Organization Owner email</label> {{ user_form.email.errors|striptags }}
<input class="border py-2 px-3 text-grey-800 rounded-lg" type="text" name="email" id="email">
</div>
<div class="flex flex-col mb-4">
<label class="mb-2 text-lg text-gray-900" for="name">Organization Admin Team Name</label> {{ team_form.name.errors|striptags }}
<input class="border py-2 px-3 text-grey-800 rounded-lg" type="text" name="name" id="name">
</div>
Since they both have the name="name"
, when the form is submitted, the value of the Organization Admin Team Name is overwriting the value of the Organization Name.
Iโd suggest to use different naming for both <input>
tags name and id attributes.
For Organization Name:
<input name="organization_name" id="organization_name">
For Organization Admin Team Name:
<input name="team_name" id="team_name">
Then handle them in the backend accordingly!
Hope I helped you with this.
0๐
Thank you all for the quick and thorough replies. After I made the change from "name" to "organization_name" and the corresponding change in the Organization and Team forms, everything worked as it should.
forms.py
class AddOrganizationForm(forms.ModelForm):
custom_names = {'name': 'organization_name'}
def add_prefix(self, field_name):
field_name = self.custom_names.get(field_name, field_name)
return super(AddOrganizationForm, self).add_prefix(field_name)
class Meta:
model = Organization
fields = ['name']
- [Answered ]-Deploy python/django app to gae
- [Answered ]-How can I order a Django query against a custom list of values?
- [Answered ]-Django FilePathField Best Practice
- [Answered ]-Django filtering by a value which might be in a many-to-many field