high time to see the effects of some of their own work, because so far, is mostly automatic performed for me all the steps.
time configurations used URLs, which had already changed (the file urls.py
). The first exercise in the DB (Chapter 3) as simplified by me as follows:
django.http import from
HttpResponse import datetime def current_datetime (request)::
html = "This is% s"% datetime.datetime. now () return HttpResponse(html)
You are once again on the side to fire up a terminal and
Save this file
views.py
.
. / Manage.py shell and then
from mdjango.mbegin.views import *
(wszystkie kolejne sprawdzenia będę najpierw przeprowadzał w konsoli, więc nie będę juz pisał o jej odpalaniu). Odpalamy
current_datetime()
, powinien nam się pojawić błąd. Wynika on z tego, że próbowałem wykorzystać konsolę do wypisania HTTPResponse. Teraz już zmiana konfiguracji URL-i: dodajemy import pliku z widokami i konfiguracje przekierowania w przypadku wywołania adresu http://localhost:8080/czas/.
plik urls.py
wygląda teraz tak:
from django.conf.urls.defaults import *
from mdjango.mbegin.views import * urlpatterns = patterns ('',
(r '^ time /', current_datetime)(r '^ admin /', include ('django.contrib.admin.urls')),
)
I results show .... error. By the way it shows up as a django errors, as for me, quite clearly and that is what I would expect the information about the error. There is a stack, is to ask, is the configuration. I guess I no longer have to write about yet another plus. I also noticed the ability to switch between viewing modes, information about the error. Same error is:
AttributeError at / time / 'function' object has no attribute 'rindex'
it means that the DB is to the front for my Ubuntu. Like I said destination URLs, you can write only from version 0.96 and I have 0.95. For now, I will not lift version (we know the different workaround.) The solution is to write the function name as a string preceded by the name of the application and module. So finally it looks like this:
from django.conf.urls.defaults
import * import * from mdjango.mbegin.views urlpatterns = patterns ('',
(r '^ time /', 'mbegin . views.current_datetime '),(r' ^ admin / ', include (' django.contrib.admin.urls'));
)
simplifying the way I made yet another error: In terms of simplification is not written request parameter for the function current_datetime, it is clearly needed. After you fix bugs you will see a modest, but his own, the first page made using django. Now I will go downhill, but that's the next episode. And today, the last element to have the correct time, set
TIME_ZONE = 'Europe / Warsaw'
(or, if you will be set) in settings.py
, no, unless you live in the same time zone as Chicago
0 comments:
Post a Comment