New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add another popup #1140
Comments
Mystery solved. When using a ModelForm that declares a widget like this: class TForm(forms.ModelForm):
class Meta:
model = TModel
fields = ('name', 'test')
widgets = {
'test': autocomplete.ModelSelect2(url='select2_fk')
} Then the admin will generate its own ModelChoiceField and wrap its widget with the RelatedFieldWidgetWrapper. When you register a ModelForm that declares a custom foreign key field as such: class PersonForm(forms.ModelForm):
birth_country = forms.ModelChoiceField(
queryset=Country.objects.all(),
widget=autocomplete.ModelSelect2(url='country-autocomplete')
)
class Meta:
model = Person
fields = ('__all__') Then Django will override it's foreign key field that has its widget decorated with RelatedFieldWidgetWrapper, with your declared one which does not have the decorator. This is pretty annoying but understandable: if you specify your own field then Django does not know if it's compatible with its RelatedFieldWidgetWrapper. Proof:
Here you can see that Django is about to override it's default field that has the RelatedFieldWidgetWrapper with my own declared field that does not have it. |
Solutions:
|
Ticket created @ Django https://code.djangoproject.com/ticket/33321 Let's hope they'll agree to do something about it ... 😂 |
The "add another" functionality of django admin (with related object popup) doesn't work with
ModelSelect2
. The + sign is not displayed on the field.The functionality seems to appear in v2 documentation but not in v3 documentation.
The text was updated successfully, but these errors were encountered: