Hello All,
How can I override options of choices in django model form from the model field ?
Below is my code -
models.py:
class XXX(models.Model):
StatusType = models.TextChoices('StatusType', const.status_values)
status = models.CharField(max_length=100, default='abc', choices=StatusType.choices,)
StatusType = models.TextChoices('StatusType', const.status_values)
status = models.CharField(max_length=100, default='abc', choices=StatusType.choices,)
views.py:
class XXXUpdateView(LoginRequiredMixin, UserPassesTestMixin, UpdateView):
model = XXX
fields = ['aaa', 'bbb', 'status']
def get_form(self):
form = super().get_form()
form.title = self.kwargs['title']
model = XXX
fields = ['aaa', 'bbb', 'status']
def get_form(self):
form = super().get_form()
form.title = self.kwargs['title']
# NOW HERE I WANT TO RESET THE VALUE OF STATUS DROPDOWN BASED ON CERTAIN CONDITION.
return form
-- return form
Can anyone suggest something
Thanks in advance !
Thanks & Regards!
Sujata S. Aghor
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJCP8KB06LxS8m8iNfpe0h30Sa%3Dro2N1AuyGM4sQXreW4f-Pig%40mail.gmail.com.
No comments:
Post a Comment