Search code examples
pythondjangodeprecatedsix

Django 1.9.13 complains SubfieldBase is deprecated, but I'm not using it. How to resolve?


I am upgrading an old Django project from Django 1.8.3 to the current Django 1.11, but to be cautious, I am upgrading to each major release of Django along the way, so I can find errors & deprecations and fix them before taking the next step. (I haven't touched this code in almost two years, so I'm a little rusty; forgive me if I'm making a simple mistake.)

I first upgraded to Django 1.9.13 (the last before 1.10), and when I manage.py runserver, I get this error:

/Users/mboszko/.virtualenvs/opticaldev/lib/python2.7/site-packages/django/utils/six.py:808: RemovedInDjango110Warning: SubfieldBase has been deprecated. Use Field.from_db_value instead.

return meta(name, bases, d)

If I'm reading this error right, the error stems from the custom version of six that Django embeds. I have searched my code, and I don't seem to be using SubfieldBase anywhere in my own code. (I have also googled, with not much success, for this particular error in six.)

Is this just a situation where I should upgrade to Django 1.10, and the new version of six in that package will be compatible, or is there something that I need to resolve myself before I upgrade?


Solution

  • Ahaaaa. Nothing like posting your question to jog a thought that leads you to the answer.

    I realized I should dig deeper into the error:

    $ python -Werror manage.py runserver
    

    With that stack trace, I get a line showing:

    File "/Users/mboszko/.virtualenvs/opticaldev/lib/python2.7/site-packages/django_date_extensions/fields.py", line 99, in

    class ApproximateDateField(with_metaclass(models.SubfieldBase, models.CharField)):

    So, the use of SubfieldBase is actually inside a package, I had installed, django-date-extensions. This was at 1.1.0 in my virtualenv, and once I did pip install --upgrade django-date-extensions to bring it up to 2.0, the error disappears.

    Fixed!