Skip to content
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

The selected filter does not filter the model in the admin panel #1353

Open
SiberMix opened this issue Feb 4, 2024 · 0 comments
Open

The selected filter does not filter the model in the admin panel #1353

SiberMix opened this issue Feb 4, 2024 · 0 comments

Comments

@SiberMix
Copy link

SiberMix commented Feb 4, 2024

The selected filter does not filter the model in the admin panel

I migrated DAL==3.5.1 for django 4 (replace ugettext to gettext)
I did this because the dropdown with the autocomplete did not work and there was ----
Now I select an entry from the dropdown, but the model in the admin panel is not filtered - what could be the matter?

class OfferFilter(AutocompleteFilter):
    title = _('Оффер')
    field_name = 'name'
    autocomplete_url = 'admin:offer-search-select'


    
    def get_queryset_for_field(self, model, name):
        return Offer.objects.all()

    def queryset(self, request, queryset):
        if self.value() and self.value().isdigit():
            return queryset.filter(id=int(self.value()))
        return queryset
@admin.register(Offer)
class OfferAdmin(ExportMixinAdmin, ArchiveMixin, TabbedTranslationAdmin, NestedModelAdmin, AdminConfirmMixin):
    inlines = [OfferSourceTypeNoteInline, OfferPageInline, OfferTargetInline, OfferContestConfigInline]
    filter_horizontal = ['countries', 'custom_webmasters', 'offer_source_types']
    list_display = (
        'id', 'name', 'advertiser_link', 'offer_manager', 'publish_dt', 'offer_type', 'is_hidden', 'status',
        'last_start', 'stat_refresh_info', 'integration_method', 'is_sponsor_display', 'get_sponsor_position'
    )
    search_fields = ['name', 'search_options', '=id']

    list_filter = (
        OfferFilter, )

Please help me.

I am migrating a very large project from django version 1.9 to >4

I want to cry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant