Hi, sorry I didn’t get back as quick, but here is my urls and settings. Before looking through the code please note that the urls I have does not import include nor patterns because it just did not come like that when I installed python or django. Idk but it just didnt. I never wanted to mess with that code and it did not make a difference so far.
-
This did not make a difference because it seemed everything was working properly in the urlpatterns [] list in my code. In the book urlpatterns = a function named patterns( ) and that is why it seems it needs to import include. (I guess)
-
I didn’t need include until chapter 10 page 65 when the book requires it for
""" url(r’^accounts/’, include( ‘registration.backends.simple.urls’ )) “”"
I don’t know what the function include does and why my code did not need it then and why it needs it know
Also know that I installed with “”“pip install django-registration-redux==1.1"”"" while in the venv inside
projects/myhellowebapp.
And thank you beforehand
#the book in page 24 has include and patterns for importing
from django.conf.urls import url #this is how i got it from the begining
from django.contrib import admin
from django.views.generic import TemplateView
urlpatterns = [
url(r’^$’, ‘collection.views.index’, name=‘home’),
url(r'^about/$',
TemplateView.as_view(template_name='about.html'),
name='about'),
url(r'^contact/$',
TemplateView.as_view(template_name='contact.html'),
name='contact'),
url(r'^things/(?P<slug>[-\w]+)/$',
'collection.views.thing_detail',
name='thing_detail'),
url(r'^things/(?P<slug>[-\w]+)/edit/$',
'collection.views.edit_thing', name='edit_thing'),
#in the book page 65 indicates to write the following:
url(r'^accounts/', include('registration.backends.simple.urls')),
#The following line is how it started without any changes but the book shows it in a different way
url(r’^admin/’, admin.site.urls),#in the book this shows “, include(admin.site.urls)”
#the book shows:
url(r’^admin/’, include( admin.site.urls)),
]
import os
INSTALLED_APPS = [
‘collection’, #this is the app we added
’django.contrib.admin’,
‘django.contrib.auth’,
‘django.contrib.contenttypes’,
‘django.contrib.sessions’,
‘django.contrib.messages’,
‘django.contrib.staticfiles’,
‘django.contrib.humanize’,
‘registration’, #Page 64 MyHelloWebApp
]
#This is the error Im having in the terminal
(venv) renato@renato-Lenovo-G50-70:~/projects/myhellowebapp$ python manage.py runserver
Unhandled exception in thread started by <function wrapper at 0x7f3aec0d6b90>
Traceback (most recent call last):
File “/home/renato/projects/myhellowebapp/venv/local/lib/python2.7/site-packages/django/utils/autoreload.py”, line 226, in wrapper
fn(*args, **kwargs)
File “/home/renato/projects/myhellowebapp/venv/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py”, line 109, in inner_run
autoreload.raise_last_exception()
File “/home/renato/projects/myhellowebapp/venv/local/lib/python2.7/site-packages/django/utils/autoreload.py”, line 249, in raise_last_exception
six.reraise(*_exception)
File “/home/renato/projects/myhellowebapp/venv/local/lib/python2.7/site-packages/django/utils/autoreload.py”, line 226, in wrapper
fn(*args, **kwargs)
File “/home/renato/projects/myhellowebapp/venv/local/lib/python2.7/site-packages/django/init.py”, line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File “/home/renato/projects/myhellowebapp/venv/local/lib/python2.7/site-packages/django/apps/registry.py”, line 115, in populate
app_config.ready()
File “/home/renato/projects/myhellowebapp/venv/local/lib/python2.7/site-packages/django/contrib/admin/apps.py”, line 22, in ready
self.module.autodiscover()
File “/home/renato/projects/myhellowebapp/venv/local/lib/python2.7/site-packages/django/contrib/admin/init.py”, line 26, in autodiscover
autodiscover_modules(‘admin’, register_to=site)
File “/home/renato/projects/myhellowebapp/venv/local/lib/python2.7/site-packages/django/utils/module_loading.py”, line 50, in autodiscover_modules
import_module(’%s.%s’ % (app_config.name, module_to_search))
File “/usr/lib/python2.7/importlib/init.py”, line 37, in import_module
import(name)
File “/home/renato/projects/myhellowebapp/venv/local/lib/python2.7/site-packages/registration/admin.py”, line 2, in
from django.contrib.sites.models import RequestSite
File “/home/renato/projects/myhellowebapp/venv/local/lib/python2.7/site-packages/django/contrib/sites/models.py”, line 83, in
class Site(models.Model):
File “/home/renato/projects/myhellowebapp/venv/local/lib/python2.7/site-packages/django/db/models/base.py”, line 102, in new
"INSTALLED_APPS." % (module, name)
RuntimeError: Model class django.contrib.sites.models.Site doesn’t declare an explicit app_label and isn’t in an application in INSTALLED_APPS.