-2

I have an old Django project that I haven't kept up, and now I'd like to make necessary changes to work with current versions of Django and related software. I'm not sure what to make of the current error; it appears to me that it doesn't have something under the django.core umbrella, but my Django 1.9.2 installation is up to date:

[2016-02-14 17:23:10 +0000] [4605] [ERROR] Exception in worker process:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 515, in spawn_worker
    worker.init_process()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 122, in init_process
    self.load_wsgi()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 130, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/djangoapp.py", line 141, in load
    mod = util.import_module("gunicorn.app.django_wsgi")
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/django_wsgi.py", line 21, in 
    from django.core.management.validation import get_validation_errors
ImportError: No module named validation
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 515, in spawn_worker
    worker.init_process()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 122, in init_process
    self.load_wsgi()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 130, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/djangoapp.py", line 141, in load
    mod = util.import_module("gunicorn.app.django_wsgi")
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/django_wsgi.py", line 21, in 
    from django.core.management.validation import get_validation_errors
ImportError: No module named validation
[2016-02-14 17:23:10 +0000] [4605] [INFO] Worker exiting (pid: 4605)
[2016-02-14 17:23:11 +0000] [4597] [INFO] Shutting down: Master
[2016-02-14 17:23:11 +0000] [4597] [INFO] Reason: Worker failed to boot.
root@localhost:~/unixytalk# pip install Django==1.9.2
Requirement already satisfied (use --upgrade to upgrade): Django==1.9.2 in /usr/local/lib/python2.7/dist-packages

How can I port my project to newer Django? How, for instance, can I provide (or tell that it is provided) django.core.management.validation?

And if I may include another archaic question, what takes the place of a "python manage.py syncdb" to initialize a database to a project an application can take care of?

--UPDATE--

There was something I was walking away from this note thinking...

I posted about a screenful of output in which Gunicorn was failing to work appropriately, through an import from django.core.management.validation that was placed there apparently by Gunicorn's process, and not in any sense an initiative on my part to directly interact with that module. (As I had stated, I was trying to get an older system to work with newer code. At least for this project, that does not in any sense include initiative to use django.core.management.validation.)

Not to put too fine a point on it, but the person responding related to my screenful of pasted output as TL;DR.

That's not me who has set the pace for TL;DR; it's the person helping me.

By a copy-and-paste metric in terms of rendered characters on a "select all and copy," TL;DR is 2412 characters.

The hefty release notes, then, being 53714 characters, qualifies as TL;DR TL;DR TL;DR TL;DR TL;DR TL;DR TL;DR TL;DR TL;DR TL;DR TL;DR TL;DR TL;DR TL;DR TL;DR TL;DR TL;DR TL;DR TL;DR TL;DR TL;DR TL;DR in its last installment alone, reminiscent of both Jakob Nielsen's article on why user education is not the answer to security issues, and the Nix packaging system which is meant to let everything keep its own needed versions of its package system instead of making everything fit a single Procrustean bed of whatever is the currently installed version.

This is kind of deviating from my original question, except that it's not. My original question was intended as, "How can I give a slight sprinkling of pixel dust and reanimate a fairly simple older Django project?" Now things look more like "The fact that I can no longer run what I left as a working project is the tip of the iceberg. Given that I'm a decent Django developer but not a super-focused Django specialist, and I work with many technologies, bitrot looks like a source of a lot of pain."

Ok; enough complaining, although I suspect there's a Programmers post to be found in this.

Christos Hayward
  • 5,777
  • 17
  • 58
  • 113

1 Answers1

0

1) To port to newer versions of Django, I would read every set of release notes from the version you started with to the version you're going to. Definitely read the release notes for Django 1.9, taking special care to read about the deprecated, backwards incompatible, and removed features near the bottom.

2) To check if django.core.management.validation is provided you can do a try/except around your import:

try:
    from django.core.management.validation import get_validation_errors
    validation_errors_imported = True
except ImportError:
    get_validation_errors = None
    validation_errors_imported = False

3) Lastly, you will no longer run python manage.py syncdb. As of Django 1.7 it is python manage.py migrate. Good luck!

grantmcconnaughey
  • 10,130
  • 10
  • 37
  • 66
  • 1
    With due respect, your suggestion of "To port to newer versions of Django, I would read every set of release notes from the version you started with to the version you're going to" is excessive: if that's true, Django's tagline should be more accurately, "The Web Framework for Perfectionists with Novel-Grade Spare Reading Time"! Adding a bit to the give-and-take of SO community with concise, on-topic work is much more attractive if you have a deadline. – Christos Hayward Feb 14 '16 at 23:52
  • P.S. I'm not directly attempting to import django.core.management.validation; I posted, and have received errors, of a Gunicorn-heavy traceback for the exception. Is there any way I can properly install ``django.core.management.validation`` after I am told Django 1.9.2 is properly installed, or identify what in Django I can exercise your ``2)`` option? – Christos Hayward Feb 14 '16 at 23:57
  • (Thanks for the note regarding migration.) – Christos Hayward Feb 14 '16 at 23:57
  • I am currently doing a similar thing with a project, I am just fixing the errors as they come. – pycod333 Feb 15 '16 at 01:43
  • 1
    Every 1.x release of Django contains numerous backwards incompatibilities and removed features. In my experience, the only way to upgrade any project from one version to the next is to read through the release notes point by point and fix issues as they pop up. I've upgraded my big project at work from 1.6 to 1.7 to 1.8 and now to 1.9. The only way that's possible is to do what I've mentioned above. – grantmcconnaughey Feb 15 '16 at 05:09
  • Anywho, see [this SO post](http://stackoverflow.com/questions/28664535/deploying-django-with-gunicorn-no-module-named-importerror-no-module-named-vali). It seems to be your exact issue. Basically django_wsgi is no longer compatible with new versions of Django. – grantmcconnaughey Feb 15 '16 at 05:13