· 7 years ago · Jul 31, 2018, 07:48 PM
1Environment:
2
3
4Request Method: GET
5Request URL: http://127.0.0.1:8000/accounts/login/
6
7Django Version: 2.0.7
8Python Version: 3.7.0
9Installed Applications:
10('django.contrib.admin',
11 'django.contrib.auth',
12 'django.contrib.contenttypes',
13 'django.contrib.sessions',
14 'django.contrib.messages',
15 'django.contrib.staticfiles',
16 'bootstrap3',
17 'reviews')
18Installed Middleware:
19[]
20
21
22Template error:
23In template C:UserstymotDesktopaktualny_projekt-Podejscie_2envmy_appwineramatemplatesbase.html, error at line 21
24 'auth' is not a registered namespace
25 11 : </div>
26 12 : <div id="navbar" class="navbar-collapse collapse">
27 13 : <ul class="nav navbar-nav">
28 14 : <li><a href="{% url 'reviews:wine_list' %}">Wine list</a></li>
29 15 : <li><a href="{% url 'reviews:review_list' %}">Home</a></li>
30 16 : </ul>
31 17 : <ul class="nav navbar-nav navbar-right">
32 18 : {% if user.is_authenticated %}
33 19 : <li><a href="{% url 'auth:logout' %}">Logout</a></li>
34 20 : {% else %}
35 21 : <li><a href=" {% url 'auth:login' %} ">Login</a></li>
36 22 : {% endif %}
37 23 : </ul>
38 24 : </div>
39 25 : </nav>
40 26 :
41 27 :
42 28 : <h1>{% block title %}(no title){% endblock %}</h1>
43 29 :
44 30 : {% bootstrap_messages %}
45 31 :
46
47
48Traceback:
49
50File "C:UserstymotAppDataLocalProgramsPythonPython37-32libsite-packagesdjangourlsbase.py" in reverse
51 75. extra, resolver = resolver.namespace_dict[ns]
52
53During handling of the above exception ('auth'), another exception occurred:
54
55File "C:UserstymotAppDataLocalProgramsPythonPython37-32libsite-packagesdjangocorehandlersexception.py" in inner
56 35. response = get_response(request)
57
58File "C:UserstymotAppDataLocalProgramsPythonPython37-32libsite-packagesdjangocorehandlersbase.py" in _get_response
59 158. response = self.process_exception_by_middleware(e, request)
60
61File "C:UserstymotAppDataLocalProgramsPythonPython37-32libsite-packagesdjangocorehandlersbase.py" in _get_response
62 156. response = response.render()
63
64File "C:UserstymotAppDataLocalProgramsPythonPython37-32libsite-packagesdjangotemplateresponse.py" in render
65 106. self.content = self.rendered_content
66
67File "C:UserstymotAppDataLocalProgramsPythonPython37-32libsite-packagesdjangotemplateresponse.py" in rendered_content
68 83. content = template.render(context, self._request)
69
70File "C:UserstymotAppDataLocalProgramsPythonPython37-32libsite-packagesdjangotemplatebackendsdjango.py" in render
71 61. return self.template.render(context)
72
73File "C:UserstymotAppDataLocalProgramsPythonPython37-32libsite-packagesdjangotemplatebase.py" in render
74 175. return self._render(context)
75
76File "C:UserstymotAppDataLocalProgramsPythonPython37-32libsite-packagesdjangotemplatebase.py" in _render
77 167. return self.nodelist.render(context)
78
79File "C:UserstymotAppDataLocalProgramsPythonPython37-32libsite-packagesdjangotemplatebase.py" in render
80 943. bit = node.render_annotated(context)
81
82File "C:UserstymotAppDataLocalProgramsPythonPython37-32libsite-packagesdjangotemplatebase.py" in render_annotated
83 910. return self.render(context)
84
85File "C:UserstymotAppDataLocalProgramsPythonPython37-32libsite-packagesdjangotemplateloader_tags.py" in render
86 155. return compiled_parent._render(context)
87
88File "C:UserstymotAppDataLocalProgramsPythonPython37-32libsite-packagesdjangotemplatebase.py" in _render
89 167. return self.nodelist.render(context)
90
91File "C:UserstymotAppDataLocalProgramsPythonPython37-32libsite-packagesdjangotemplatebase.py" in render
92 943. bit = node.render_annotated(context)
93
94File "C:UserstymotAppDataLocalProgramsPythonPython37-32libsite-packagesdjangotemplatebase.py" in render_annotated
95 910. return self.render(context)
96
97File "C:UserstymotAppDataLocalProgramsPythonPython37-32libsite-packagesdjangotemplateloader_tags.py" in render
98 67. result = block.nodelist.render(context)
99
100File "C:UserstymotAppDataLocalProgramsPythonPython37-32libsite-packagesdjangotemplatebase.py" in render
101 943. bit = node.render_annotated(context)
102
103File "C:UserstymotAppDataLocalProgramsPythonPython37-32libsite-packagesdjangotemplatebase.py" in render_annotated
104 910. return self.render(context)
105
106File "C:UserstymotAppDataLocalProgramsPythonPython37-32libsite-packagesdjangotemplatedefaulttags.py" in render
107 314. return nodelist.render(context)
108
109File "C:UserstymotAppDataLocalProgramsPythonPython37-32libsite-packagesdjangotemplatebase.py" in render
110 943. bit = node.render_annotated(context)
111
112File "C:UserstymotAppDataLocalProgramsPythonPython37-32libsite-packagesdjangotemplatebase.py" in render_annotated
113 910. return self.render(context)
114
115File "C:UserstymotAppDataLocalProgramsPythonPython37-32libsite-packagesdjangotemplatedefaulttags.py" in render
116 447. url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)
117
118File "C:UserstymotAppDataLocalProgramsPythonPython37-32libsite-packagesdjangourlsbase.py" in reverse
119 86. raise NoReverseMatch("%s is not a registered namespace" % key)
120
121Exception Type: NoReverseMatch at /accounts/login/
122Exception Value: 'auth' is not a registered namespace
123
124urlpatterns = [
125 path('reviews/', include('reviews.urls', namespace="reviews")),
126 path('admin/', admin.site.urls),
127 path('accounts/', include('django.contrib.auth.urls',))
128
129]
130
131import os
132
133BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
134
135
136# Quick-start development settings - unsuitable for production
137# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
138
139# SECURITY WARNING: keep the secret key used in production secret!
140SECRET_KEY = ')g@^(l6+_uc*ckf%rj2i+89v^4^r3k!$l76husfgc74nk1#&g+'
141
142# SECURITY WARNING: don't run with debug turned on in production!
143DEBUG = True
144
145ALLOWED_HOSTS = []
146
147
148# Application definition
149
150INSTALLED_APPS = (
151 'django.contrib.admin',
152 'django.contrib.auth',
153 'django.contrib.contenttypes',
154 'django.contrib.sessions',
155 'django.contrib.messages',
156 'django.contrib.staticfiles',
157 'bootstrap3',
158 'reviews',
159)
160
161MIDDLEWARE_CLASSES = (
162 'django.contrib.sessions.middleware.SessionMiddleware',
163 'django.middleware.common.CommonMiddleware',
164 'django.middleware.csrf.CsrfViewMiddleware',
165 'django.contrib.auth.middleware.AuthenticationMiddleware',
166 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
167 'django.contrib.messages.middleware.MessageMiddleware',
168 'django.middleware.clickjacking.XFrameOptionsMiddleware',
169 'django.middleware.security.SecurityMiddleware',
170)
171
172
173ROOT_URLCONF = 'winerama.urls'
174
175TEMPLATES = [
176 {
177 'BACKEND': 'django.template.backends.django.DjangoTemplates',
178 'DIRS': [os.path.join(BASE_DIR, 'templates')],
179 'APP_DIRS': True,
180 'OPTIONS': {
181 'context_processors': [
182 'django.template.context_processors.debug',
183 'django.template.context_processors.request',
184 'django.contrib.auth.context_processors.auth',
185 'django.contrib.messages.context_processors.messages',
186 ],
187 },
188 },
189]
190
191WSGI_APPLICATION = 'winerama.wsgi.application'
192
193
194# Database
195# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
196
197DATABASES = {
198 'default': {
199 'ENGINE': 'django.db.backends.sqlite3',
200 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
201 }
202}
203
204
205# Internationalization
206# https://docs.djangoproject.com/en/1.8/topics/i18n/
207
208LANGUAGE_CODE = 'en-us'
209
210TIME_ZONE = 'UTC'
211
212USE_I18N = True
213
214USE_L10N = True
215
216USE_TZ = True
217
218
219# Static files (CSS, JavaScript, Images)
220# https://docs.djangoproject.com/en/1.8/howto/static-files/
221
222STATIC_URL = '/static/'
223
224-templates
225--base.html
226--registration
227---logged_out.html
228---login.html
229-winerama
230--__init__.py
231--settings.py
232--urls.py
233--wsgi
234-reviews(all files from applications that work well)
235
236from django.contrib import admin
237from django.urls import path, include
238
239app_name = 'auth'
240
241urlpatterns = [
242 path('reviews/', include('reviews.urls', namespace="reviews")),
243 path('admin/', admin.site.urls),
244 path('accounts/', include('django.contrib.auth.urls', namespace='auth'))
245
246]
247
248'Specifying a namespace in include() without providing an app_name '
249
250'<li><a href="{% url 'login' %}">Login</a></li>' (login file)
251'path('accounts/', include('django.contrib.auth.urls', namespace=auth))' (urls file)