Django import error - no module named django.conf.urls.defaults

I am trying to run statsd / graphite which uses django 1.6.

When accessing a graphic url I get a django module error

File "/opt/graphite/webapp/graphite/urls.py", line 15, from django.conf.urls.defaults import * ImportError: not a single module with default settings

However, I did not find defaults django package inside /Library/Python/2.7/site-packages/django/conf/urls/

Please help fix this problem.

+85
python django graphite
Nov 13 '13 at 19:32
source share
2 answers

django.conf.urls.defaults been removed in Django 1.6 . If the problem was in your own code, you will fix it by changing the import to

 from django.conf.urls import patterns, url, include 

However, in your case, the problem is a third-party graffiti application. The problem has been fixed in the graphite branch and version 0.9.14 +.

In Django 1.8+, you can remove patterns from imports and use the url() list instead.

 from django.conf.urls import url, include 
+182
Nov 13 '13 at 19:38
source share

If for some reason you do not want to upgrade to Django 1.5.x or update Graphite, you can apply the fix to your older Graphite with:

 find ./ -type f -exec sed -i -e 's/from\ django\.conf\.urls\.defaults\ import\ \*/from\ django\.conf\.urls\ import\ \*/g' {} \; 

.. in the directory <graphite_dir>/webapp/graphite .

This helped me with graphics 0.9.12 and Django 1.7 (.5).

(I also had to do:

 find ./ -type f -exec sed -i -e 's/mimetype\=/content_type\=/g' {} \; find ./ -type f -exec sed -i -e 's/content_type\=mimetype/content_type\=content_type/g' {} \; 

.. later, after I managed to start Graphite, some of its functions did not work. Now they work for me, but YMMV.)

+2
Feb 28 '15 at 11:30
source share



All Articles