in Education by
I followed the accepted answer here to alter the order of items in a foreign key select list in my Django admin. The reordering works great, but the little add icon has disappeared from after the select list. How can I get it back? class GameForm(forms.ModelForm): publisher = forms.ModelChoiceField(queryset=Publisher.objects.order_by('name')) platform = forms.ModelChoiceField(queryset=Platform.objects.order_by('platform')) class Meta: model = Game class GameAdmin(admin.ModelAdmin): list_display = ('name','platform','publisher','age_rating','buy_date','pub_date') form = GameForm admin.site.register(Game, GameAdmin) JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Your form overrides admin application fields RelatedFieldWidgetWrapper widget To prevent this queryset should be changed in __init__ method class GameForm(forms.ModelForm): class Meta: model = Game def __init__(self, *args, **kwargs): super(GameForm, self).__init__(*args, **kwargs) self.fields['publisher'].queryset = Publisher.objects.order_by('name') self.fields['platform'].queryset = Platform.objects.order_by('platform')

Related questions

0 votes
    I followed the accepted answer here to alter the order of items in a foreign key select list in my ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    My code for download files and save them in the internal storage is: val downloadManager = context!!. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    Is there any way to add a custom parameter to identityserver auth request. I tried this way. but it ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    Is there a way of adding custom assertions to the NodeUnit test object that gets passed to each test? ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    How to add custom color in Tableau?...
asked Oct 30, 2020 in Technology by JackTerrance
0 votes
    The search algorithm which is similar to the minimax search, but removes the branches that don't affect the final ... Breadth-first search Alpha-beta pruning None of the above...
asked Mar 8, 2021 in Technology by JackTerrance
0 votes
    Which of the following function of Array object removes the last element from an array and returns that element? push() delete() pop() link()...
asked Dec 24, 2020 in Technology by JackTerrance
0 votes
    i have creadted in admin side one form along with text area.I need to apply Tiny MICE Editor to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    i have creadted in admin side one form along with text area.I need to apply Tiny MICE Editor to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    a) Harshita wants to create an HTML form. Which tag should she use to create this form? Her teacher has asked ... plz answer this fast Select the correct answer from above options...
asked Dec 14, 2021 in Education by JackTerrance
0 votes
    If I have a UserControl: Foo.Bar.MyClass, I know I can reference it in XAML by declaring: xmlns: ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    In Javascript, I can do something like this let list = [1, 2, 3] let list2 = [4, 5, 6, ...list] And ... the += after declaring a list? Select the correct answer from above options...
asked Jan 8, 2022 in Education by JackTerrance
0 votes
    What Is The Purpose Of Declaring A Variable As Final? Select the correct answer from above options...
asked Dec 24, 2021 in Education by JackTerrance
0 votes
    What is the advantage of declaring void pointers?...
asked Jan 17, 2021 in Technology by JackTerrance
...