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

Support supplying only field name in lookups #9

Closed
bruth opened this Issue Jul 20, 2013 · 0 comments

Comments

Projects
None yet
1 participant
@bruth
Member

bruth commented Jul 20, 2013

Currently, the model and field must be specified for lookups, however most field (of interest) have unique names across models. The implementation to resolve the lookup is the same as the with models (i.e. ensure no collisions).

One detail that will make lookups faster is indexing the location of fields and models. This would be a simple dictionary in reverse order:

self._field_index = {
    'common_name': [ModelA, ModelB, ModelC],
    'uncommon_name': [ModelC],
}

The model index will be the same structure, but with apps:

self._model_cache = {
    'ModelA': [app1],
    'ModelB': [app1],
    ...
}

The M(...) lookup in the example on the website would change from:

m = M(mt, title__salary__gt=50000)

to

m = M(mt, salary__gt=50000)

@bruth bruth added the status:wontfix label Feb 3, 2017

@bruth bruth closed this Feb 3, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment