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

models: remove obsolete method overrides #108

Merged
merged 1 commit into from
Apr 6, 2020

Conversation

ortholeviator
Copy link
Contributor

From Django 1.7 release notes:

Schema migrations
-----------------

Django now has built-in support for schema migrations. It allows models
to be updated, changed, and deleted by creating migration files that represent
the model changes and which can be run on any development, staging or production
database.
Django 1.7 replaced South with its own migration framework.

From Django 1.10 release notes:

``Field.get_prep_lookup()`` and ``Field.get_db_prep_lookup()`` methods are removed
----------------------------------------------------------------------------------

If you have a custom field that implements either of these methods, register a
custom lookup for it. For example::

    from django.db.models import Field
    from django.db.models.lookups import Exact

    class MyField(Field):
        ...

    class MyFieldExact(Exact):
        def get_prep_lookup(self):
            # do_custom_stuff_for_myfield
            ....

    MyField.register_lookup(MyFieldExact)

@timabbott
Copy link
Collaborator

The South stuff should clearly be removed; what's your thinking on why we shouldn't replace the custom lookups with the new 1.10+ API?

@ortholeviator
Copy link
Contributor Author

@timabbott django-bitfield already implemented two mechanisms for exposing the custom lookup class: the Field.get(_db)?_prep_lookup and RegisterLookupMixin.register_lookup. In Django 1.10+ they entirely removed the two functions, and therefore BitQueryLookupWrapper has been exclusively used for exact since then (an issue resolved together in #106).

From Django 1.7 release notes:

    Schema migrations
    -----------------

    Django now has built-in support for schema migrations. It allows models
    to be updated, changed, and deleted by creating migration files that represent
    the model changes and which can be run on any development, staging or production
    database.
    Django 1.7 replaced South with its own migration framework.

From Django 1.10 release notes:

    ``Field.get_prep_lookup()`` and ``Field.get_db_prep_lookup()`` methods are removed
    ----------------------------------------------------------------------------------

    If you have a custom field that implements either of these methods, register a
    custom lookup for it. For example::

        from django.db.models import Field
        from django.db.models.lookups import Exact

        class MyField(Field):
            ...

        class MyFieldExact(Exact):
            def get_prep_lookup(self):
                # do_custom_stuff_for_myfield
                ....

        MyField.register_lookup(MyFieldExact)
@timabbott timabbott merged commit beadee0 into disqus:master Apr 6, 2020
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

Successfully merging this pull request may close these issues.

2 participants