python - Combine two ModelForm fields in Django -
I have a boolean field and a foreign key model
class ModelA (model) Model): is_anonymous = BooleanField (default = Incorrect) page = External key (ModelB, null = true) I want to add these two fields to a selected field.
There is an option between and ModelB should have an option for each object.
& lt; Select & gt; If selected in the area is_anonymous , then it should be incorrect and if anonymous selection is selected, then the field should be typed page and is_anonymous Must be correct. I think I must add ModelB.objects.all () to the options list in the query
Self. Field ['field_name']. Widget = form. Select (option = [(false, "not unknown"), (true, "anonymous"),]) but this will save the field f Ield_name which is wrong.
There is no need to combine the area here. You can only use 'anonymous' for the foreign key field Set up, and handover it in a clean way.
Comments
Post a Comment