I’m not sure I explained myself that well. Our system has two models, Product
and ProductSearch. The Product tables come from third party sources, and can’t
be edited from the front end. Users can setup their own ProductSearches, which
are then used to construct the queryset. So our code actuall
Wow, that's quite the queryset!
If I understand your snippet right, it looks as though you always run an
initial large query against one of the tables, and if it doesn't find
anything, run the similar query against the other table. If the filters,
etc. are exactly the same, you could take the raw
I’m already doing all of that. The problem is we often have logic that goes
like:
model = Product.get_subtable(‘foo’)
queryset = model.objects.
filter(…).
select_related(…).
exclude(…).
extra(…)
… and so on and so on. Seriously, the method that constructs the queryset
is some
That sounds more like an exact use case for model inheritance. You would
define a single model that matches the columns in both tables. You can
define that model as abstract, then have the two real models (one for each
table) inherit from that abstract model. In the definition for the child
models,
4 matches
Mail list logo