"django choice field" Code Answer's
You're definitely familiar with the best coding language Python that developers use to develop their projects and they get all their queries like "django choice field" answered properly. Developers are finding an appropriate answer about django choice field related to the Python coding language. By visiting this online portal developers get answers concerning Python codes question like django choice field. Enter your desired code related query in the search bar and get every piece of information about Python code related question on django choice field.
django choice field
First I recommend you as @ChrisHuang-Leaver suggested to define a new file with all the choices you need it there, like choices.py:
STATUS_CHOICES = (
(1, _("Not relevant")),
(2, _("Review")),
(3, _("Maybe relevant")),
(4, _("Relevant")),
(5, _("Leading candidate"))
)
RELEVANCE_CHOICES = (
(1, _("Unread")),
(2, _("Read"))
)
Now you need to import them on the models, so the code is easy to understand like this(models.py):
from myApp.choices import *
class Profile(models.Model):
user = models.OneToOneField(User)
status = models.IntegerField(choices=STATUS_CHOICES, default=1)
relevance = models.IntegerField(choices=RELEVANCE_CHOICES, default=1)
And you have to import the choices in the forms.py too:
forms.py:
from myApp.choices import *
class CViewerForm(forms.Form):
status = forms.ChoiceField(choices = STATUS_CHOICES, label="", initial='', widget=forms.Select(), required=True)
relevance = forms.ChoiceField(choices = RELEVANCE_CHOICES, required=True)
Anyway you have an issue with your template, because you're not using any {{form.field}}, you generate a table but there is no inputs only hidden_fields.
When the user is staff you should generate as many input fields as users you can manage. I think django form is not the best solution for your situation.
I think it will be better for you to use html form, so you can generate as many inputs using the boucle: {% for user in users_list %} and you generate input with an ID related to the user, and you can manage all of them in the view
All those coders who are working on the Python based application and are stuck on django choice field can get a collection of related answers to their query. Programmers need to enter their query on django choice field related to Python code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about django choice field for the programmers working on Python code while coding their module. Coders are also allowed to rectify already present answers of django choice field while working on the Python language code. Developers can add up suggestions if they deem fit any other answer relating to "django choice field". Visit this developer's friendly online web community, CodeProZone, and get your queries like django choice field resolved professionally and stay updated to the latest Python updates.