KyleNehman
KyleNehman

Reputation: 55

Django 1.9 No module named 'django.urls'

Trying to install pcapdb on a fresh debian install (requires django==1.9) installed via 'sudo pip3 install django==1.9' Other parts of django can be imported without issue e.g. django.conf, django.db, django.utils, etc.

Output of 'pip3 list | grep -i django'

Django (1.9)
django-auth-ldap-ng (1.7.6)
django-braces (1.12.0)
django-celery (3.2.2)
django-filebrowser (3.9.1)
django-grappelli (2.10.2)
django-hosts (3.0)
django-url-tools (0.0.8)
djangorestframework (3.7.7)
djangorestframework-jwt (1.11.0)

pip3 --version

pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

django version from interpreter

import django
print(django.get_version())
# 1.9

Ideas?

Edit: The code in question is a dependency for pcapDB, not my code. See one of the files in question (django.urls imports) here

Upvotes: 1

Views: 2882

Answers (2)

Astik Anand
Astik Anand

Reputation: 13047

Try this line in urls.py

from django.conf.urls import url

There is no module name django.urls in before django2, urls are present in django.conf package.

Starting Django-2.0

urls are part of django.urls.

Upvotes: 1

Pankaj
Pankaj

Reputation: 939

In django 1.9 version or above until 1.11 version url module was in the django.conf package. In new release 2.0 version, it merged into django.url.
So now you can use from django.urls import include, path, re_path in your URLconfs.

for more info, you can check the release note.
https://docs.djangoproject.com/en/2.0/releases/2.0/#what-s-new-in-django-2-0

Upvotes: 1

Related Questions