30π
You donβt need those imports. The only thing you need in your urls.py (to start) is:
from django.conf.urls.defaults import *
# This two if you want to enable the Django Admin: (recommended)
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
# ... your url patterns
)
NOTE: This solution was intended for Django <1.6. This was actually the code generated by Django itself. For newer version, see Jacob Humeβs answer.
162π
As of Django 1.10, the patterns
module has been removed (it had been deprecated since 1.8).
Luckily, it should be a simple edit to remove the offending code, since the urlpatterns
should now be stored in a plain-old list:
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
# ... your url patterns
]
- [Django]-Duplicate column name
- [Django]-Django β how to create a file and save it to a model's FileField?
- [Django]-No URL to redirect to. Either provide a url or define a get_absolute_url method on the Model
21π
Yes:
from django.conf.urls.defaults import ... # is for django 1.3
from django.conf.urls import ... # is for django 1.4
I met this problem too.
- [Django]-OneToOneField() vs ForeignKey() in Django
- [Django]-Rendering a value as text instead of field inside a Django Form
- [Django]-Choose test database?
12π
patterns module is not supported.. mine worked with this.
from django.conf.urls import *
from django.contrib import admin
admin.autodiscover()
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
# ... your url patterns
]
- [Django]-Why does django's prefetch_related() only work with all() and not filter()?
- [Django]-Token Authentication for RESTful API: should the token be periodically changed?
- [Django]-Django Rest Framework β Authentication credentials were not provided
6π
This is the code which worked for me. My django version is 1.10.4 final
from django.conf.urls import url, include
from django.contrib import admin
admin.autodiscover()
urlpatterns = [
# Examples:
# url(r'^$', 'blog.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
]
- [Django]-How can I see the raw SQL queries Django is running?
- [Django]-Django: How to check if the user left all fields blank (or to initial values)?
- [Django]-How to display the current year in a Django template?
4π
Pattern module in not available from django 1.8. So you need to remove pattern from your import and do something similar to the following:
from django.conf.urls import include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = [
# here we are not using pattern module like in previous django versions
url(r'^admin/', include(admin.site.urls)),
]
- [Django]-How to 'bulk update' with Django?
- [Django]-Invalid http_host header
- [Django]-How to add multiple objects to ManyToMany relationship at once in Django ?
1π
I Resolved it by cloning my project directly into Eclipse from GIT,
Initially I was cloning it at specific location on file system then importing it as existing project into Eclipse.
- [Django]-Unit testing with django-celery?
- [Django]-Django apps aren't loaded yet when using asgi
- [Django]-Do we need to upload virtual env on github too?
0π
Seems you are using outdated version of django..
Simply update django and try again..
Following command will update your django version..
pip install --upgrade django
- [Django]-Get SQL query count during a Django shell session
- [Django]-Django FileField with upload_to determined at runtime
- [Django]-Pulling data to the template from an external database with django
0π
from django.contrib import admin
from django.urls import path
urlpatterns = [
path('admin/', admin.site.urls),
]
- [Django]-In the Django admin interface, is there a way to duplicate an item?
- [Django]-Add rich text format functionality to django TextField
- [Django]-Django reverse lookup of foreign keys