I can not understand why I can not link the url? urls.py

# -*- coding: utf-8 -*- from django.conf.urls import * from mysite.views import hello urlpatterns = patterns('', # error here, why? ('^hello/$', hello), ) 

views.py

 # -*- coding: utf-8 -*- from django.http import HttpResponse def hello(request): return HttpResponse("Здравствуй, Мир") 

He did everything according to the book, one to one.

  • Show us your error please. - Dex
  • SyntaxError at / Non-ASCII character '\ xc7' in file c: \ Python27 \ Lib \ site-packages \ django \ bin \ mysite \ mysite \ views.py on line 4 - johniek_comp
  • Yes, the file was in the wrong encoding, missed the moment, but do not tell me how to set up the url for the main page, i.e. for '/'? I tried something like this ('^ /', index) - it didn't work ... - johniek_comp
  • Try '^ \ $', take a look at the djangoproject site, there are many examples. If the answer came in handy, I think you know what to do with this rating. - Dex
  • Yes, I know, thank you for quickly clarifying a few moments on django! - johniek_comp

2 answers 2

Your file is probably not stored in the encoding that you want. Or copied from somewhere, wormed the extra character. If you did not manually write this code, overwrite it from scratch. This is only an encoding problem, since for me your version works just copied from here.

    Here is an example of a live root URL that includes an admin panel:

     from django.conf.urls import patterns, include, url from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', url(r'^admin/', include(admin.site.urls)), ) 
    • In urlpatterns everything is correct and true. - Dex