Sunday, October 29, 2017

Re: Following tutoria: View not defined

Thanks again :)

That was it.

On Monday, October 30, 2017 at 10:56:34 AM UTC+13, cjacq...@gmail.com wrote:
Did you try http://127.0.0.1:8000/hello/ ?

Le dimanche 29 octobre 2017 21:39:12 UTC+1, Andre Basel a écrit :
I am totally new to Django, and working through the following tutorial https://djangobook.com/views-urlconfs/

Ihavecreatddf the following view in views.py

from django.http import HttpResponse

def hello(request):
   
return HttpResponse("Hello world")


 And then as per the tutorial updated urls.py as follows:
from django.conf.urls import url
from django.contrib import admin

urlpatterns
= [
    url
(r'^admin/', admin.site.urls),
    url
(r'^hello/$', hello),
]


 When I try an browse http://127.0.0.1:8000/ I now no can no longer connect and the console shows the following error.

System check identified no issues (0 silenced).
October 29, 2017 - 20:14:10
Django version 1.11.6, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[29/Oct/2017 20:14:14] "GET / HTTP/1.1" 200 1716
Performing system checks...

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f1eae0c4268>
Traceback (most recent call last):
 
File "/home/abasel/Dajango_Projects/my_first_project/project_venv/lib64/python3.6/site-packages/django/utils/autoreload.py", line 228, in wrapper
    fn
(*args, **kwargs)
 
File "/home/abasel/Dajango_Projects/my_first_project/project_venv/lib64/python3.6/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run
   
self.check(display_num_errors=True)
 
File "/home/abasel/Dajango_Projects/my_first_project/project_venv/lib64/python3.6/site-packages/django/core/management/base.py", line 359, in check
    include_deployment_checks
=include_deployment_checks,
 
File "/home/abasel/Dajango_Projects/my_first_project/project_venv/lib64/python3.6/site-packages/django/core/management/base.py", line 346, in _run_checks
   
return checks.run_checks(**kwargs)
 
File "/home/abasel/Dajango_Projects/my_first_project/project_venv/lib64/python3.6/site-packages/django/core/checks/registry.py", line 81, in run_checks
    new_errors
= check(app_configs=app_configs)
 
File "/home/abasel/Dajango_Projects/my_first_project/project_venv/lib64/python3.6/site-packages/django/core/checks/urls.py", line 16, in check_url_config
   
return check_resolver(resolver)
 
File "/home/abasel/Dajango_Projects/my_first_project/project_venv/lib64/python3.6/site-packages/django/core/checks/urls.py", line 26, in check_resolver
   
return check_method()
 
File "/home/abasel/Dajango_Projects/my_first_project/project_venv/lib64/python3.6/site-packages/django/urls/resolvers.py", line 254, in check
   
for pattern in self.url_patterns:
 
File "/home/abasel/Dajango_Projects/my_first_project/project_venv/lib64/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
    res
= instance.__dict__[self.name] = self.func(instance)
 
File "/home/abasel/Dajango_Projects/my_first_project/project_venv/lib64/python3.6/site-packages/django/urls/resolvers.py", line 405, in url_patterns
    patterns
= getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
 
File "/home/abasel/Dajango_Projects/my_first_project/project_venv/lib64/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
    res
= instance.__dict__[self.name] = self.func(instance)
 
File "/home/abasel/Dajango_Projects/my_first_project/project_venv/lib64/python3.6/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
   
return import_module(self.urlconf_name)
 
File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
   
return _bootstrap._gcd_import(name[level:], package, level)
 
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
 
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
 
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
 
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
 
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
 
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
 
File "/home/abasel/Dajango_Projects/my_first_project/mysite/mysite/urls.py", line 21, in <module>
    url
(r'^hello/$', hello),
NameError: name 'hello' is not defined

I am not sure how to proceed.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/663e4f9a-4cba-4cbb-a702-566798935a1c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment