Can't get hello world in django

I tried writing hello world program in django, but I did not get the expected result. Please help - 2nd day stuck here. My version of Python is 2.7. Django 1.6.2

Directory List:

  • Mysite
    • manage.py
    • Mysite
      • init.py
      • _init.pyc
      • settings.py
      • settings.pyc
      • urls.py
      • urls.pyc
      • wsgi.py
      • wsgi.pyc
      • views.py

1. Code in the views file

from django.http import HttpResponse

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

2. Code in urls file

from django.conf.urls import patterns, include, url

from mysite.views import hello


#from django.contrib import admin
#admin.autodiscover()

#urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'mysite.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),

    #url(r'^admin/', include(admin.site.urls)),

    url(r'^$', 'mysite.views.hello’, name=‘hello’)

)

SyntaxError on "":

Exception value:
Non-ASCII character '\ xe2' in the file / Users / ** /**/djcode/mysite/mysite/urls.py on line 16, but no encoding is declared; see http://www.python.org/peps/pep-0263.html for more information (urls.py, line 16) [note: an asterisk is used to hide the path above]

+4
1

:

url(r'^$', 'mysite.views.hello’, name=‘hello’)

:

url(r'^$', 'mysite.views.hello', name='hello')

' .

+4

Source: https://habr.com/ru/post/1531886/


All Articles