Cannot override SearchForm class

Hi everyone,

I’m using Oscar + Django and I have a functioning website.
I’m trying to override the SearhForm class by the usual steps (app forking) but seems that the ‘search’ method cannot be override from the child class…

Here the code in my custom app:

from oscar.apps.search.forms import SearchForm as CoreSearchForm

class SearchForm(CoreSearchForm):

    def search(self):
        print(" --------- CHILD METHOD -----------")

I’ve added to the original parent class (inside oscar.apps.search.forms) for the debug some prints like so:

class SearchForm(FacetedSearchForm):

    ...

    def search(self):

        print(" --------- PARENT METHOD -----------")
        sqs = super(FacetedSearchForm, self).search()
        print("1. sqs: ", list([e['pk'] for e in sqs.values('pk')]))

       ...

        print("2. sqs: ", list([e['pk'] for e in sqs.values('pk')]))

        return sqs

Here the output when I perform some product sorting:

 --------- PARENT METHOD -----------
haystack.forms - SearchForm: 'search()'
1. sqs:  ['10', '1', '4', '7']
2. sqs:  ['4', '1', '10', '7']
[05/Jul/2025 17:34:50] "GET /shop/catalogue/?q=&sort_by=price-asc HTTP/1.1" 200 65452

So it seems the child method has not been called…

Anyone can understand what is happening?

Thank you in advance for any help!

Welcome @ciccio91 !

You don’t mention whether or not you’ve checked other resources for answers to your question, so in case you haven’t, I’ll point out that Oscar is a third-party package with its own recommendations for getting assistance.

These are identified on their Getting Help page.

There’s not a lot of discussion or activity here about Oscar - and nothing of any real substance, so I think there’s a good chance that you will find an answer more quickly in one of those other areas.

Hi Ken,

Yes, you’re right! Oscar is a third-party package. I’ve followed your suggest =)

Thank you for your help.