7 questions
0 votes
1 answer
576 views
Select2 widget showing on Django Admin site but not on the form template in Django4
I have two object models, NewsObject and StockObject. The stock object is a foreign key in the news object. class stockObject(models.Model): stock_name = CharField(max_length=100, blank=True, null=...
1 vote
0 answers
139 views
Background-color of AutocompleteSelect field not working
I want to set the background-color of a AutocompleteSelect field. When the page loads, the background-color is applied, but will be overwritten immediately (When loading the page, I see the background-...
0 votes
1 answer
54 views
What is the connection between autocomplete_fields and JS in Media class?
I use Django. My admin.py: class CardInlineAdmin(admin.StackedInline): model = Card autocomplete_fields = ['project', 'course', 'vacancy', 'news', ] @admin.register(Section) class ...
2 votes
0 answers
287 views
Is there any way to limit the choices displaying in autocomplete fields in Django admin based on the foreign key just selected in another field?
I encounter a problem when using the autocomplete fields in Django admin. #model.py class Party(models.Model): pass class Address(models.Model): party = models.ManyToManyField(Party,through='...
0 votes
1 answer
1k views
Sort added elements inside Django autocomplete_fields
I have Django application and admin page. Inside admin page, I have one model that has autocomplete_fields. I can sort results but, I can't sort the results. It always sort by pk and not by value ...
0 votes
1 answer
1k views
Filter queryset for foreign key in Django autocomplete_fields
class InstitutionProfileAdmin(admin.ModelAdmin): def institute_pic_tag(self, obj): if obj.institute_pic: return format_html('<img src="{}" width="30x"/&...
1 vote
1 answer
3k views
Django admin page autocomplete on reverse ForeignKey
Disclamer: This is an edit question because I got some answers until now. I would like to create an autocomplete field in InlineModelAdmin, with similar behavior as autocomplete_fields. I know, ...