nephila / djangocms-installer

Console wizard to bootstrap django CMS projects
https://djangocms-installer.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
177 stars 78 forks source link

ImportError context_processors: needs update to django.template.context_processors #304

Closed fvgoto closed 6 years ago

fvgoto commented 7 years ago

After using djangocms-installer for a fresh project, my site shows an ImportError: No module named context_processors.

Problem: settings.py generated by djangocms-installer contains context_processors that are wrongly taken from django.core.context_processors instead of django.template.context_processors for Django 1.8+. Manually replacing core by template fixes the ImportError.

From Django documentation:

 Changed in Django 1.8:

Built-in template context processors were moved from django.core.context_processors 
to django.template.context_processors in Django 1.8.

Sources: https://docs.djangoproject.com/en/1.8/ref/settings/#template-context-processors https://docs.djangoproject.com/en/1.8/ref/templates/api/#django.template.RequestContext

Djangocms-installer code point with old-style django.core.context_processors: https://github.com/nephila/djangocms-installer/blob/master/djangocms_installer/config/settings.py#L28

Strange that this has not yet been updated since...

PS: The context_processors and loaders lines in generated settings.py have also a wrong indentation (except the first array element).

Relevant bits of my context:

Django==1.10.6
django-cms==3.4.2
djangocms-installer==0.9.5

# System A (hosted, without true shell access)
$ python -c 'import sys; print(sys.version)'
 2.7.5 (default, Jun 24 2015, 00:41:19) 
 [GCC 4.8.3 20140911 (Red Hat 4.8.3-9)]

# System B (same issue with Py 3.5)
Ubuntu 16.04.1 LTS
Linux **** 4.4.0-64-generic #85-Ubuntu SMP Mon Feb 20 11:50:30 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Python:
3.5.2 (default, Nov 17 2016, 17:05:23) 
[GCC 5.4.0 20160609]

# Fresh project with
djangocms --verbose --config-file ./django-installer.ini --skip-empty-check main
django-version = stable
cms-version = stable
parent-dir = .
pip-options =
template =
extra-settings =
yakky commented 7 years ago

Installer used to be compatible with many versions of Django, we took then the lowest common denominator approach when adding django versions. This issue, though, has been completely missed when working on Django 1.10 Attached PR should resolve this, as well as having a better approach at new middleware classes

fvgoto commented 7 years ago

@yakky Wow! what a speed! Thanks!

In the meantime, I finally got rid of 'WSGIRequest' object has no attribute 'current_page', which is exactly what you PR'ed in the same go:

Tanks and Happy hacking!

yakky commented 7 years ago

thanks for your feedback I think I will release 0.9.6 today

yakky commented 6 years ago

Fixed in #305