Monday, May 14, 2007

Electric Blanket Battery Operated

begin with Django 4 - first page

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)




Save this file
views.py
.
You are once again on the side to fire up a terminal and
. / 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

Sunday, May 6, 2007

Cities & Knightsunlock

begin with Django 3 - Database

I begin with Django 3
Since I have already prepared a database, then it would be worthwhile to use it. Until that is found only in the 17th chapter DB python mysite / manage.py inspectdb
(DB:
python mysite / manage.py inspectdb> mysite / myapp / models.py ). Generated is something like this:
class Categorie (models.Model): id = models.IntegerField (primary_key = True) name =
models.CharField (maxlength = 600)
models.TextField description = (blank = True) class Meta
: db_table = 'categories'



Because the tables have different names adapted to the framework, so their names are in the plural. It seems that Django uses a simple rule, subtract from the plural 's' and you have the singular. Does not always verify that the DB write to review and clean up the generated model will do it later, according to the principles described in the said 17th section The other puzzling thing is the value of maxlength (database fields are varchar (200) and model 600), you will need to decipher how the character encoding. Unfortunately, directly in the DB's on this subject did not write.
To check whether the model works, you can use
. / Manage.py shell
. If you have previously installed the ipython, we have at the moment quite a nice work environment with a database, and in fact with its model. I dare to believe that it will also be a good place to start such unit tests. To use the model of some table, enough to enter
project.app.models import from nazwa_modelu

ie to import from mdjango.mbegin.models Categorie
, then you're ready Categorie.objects.values \u200b\u200b() (the value of the records), or Categorie.objects.count () (number of records). Another big plus for Django, you can see immediately how the model before using it in an application. For now, only I used phpmyadmin to check whether the model is correct, most of the required operations can now be done from the shell, with the assurance that you are connected to the right base, etc.

Thursday, May 3, 2007

How To Get 25 Credits On Poptropica

begin with Django 2

We go further, according to what is written on the previously created (http://piotrbla.blogspot.com/2007/05/zaczynam-z-django.html) project site. In the settings.py file for a set portion of the database (since
DATABASE_ENGINE to DATABASE_PORT After setting up the database generate the first application: . / manage.py startapp mbegin (generated on the project website: mdjango python / manage. py startapp [appname] ). arises directory (For me
mbegin
) where there are empty files for models and views (and models.py views.py ). In the generation of a small problem with the encoding pliterek in the name of the administrator, for now forgive (resigns pliterek), and then you will need it explores the topic. Another thing which gives quick results is the admin panel (small instantaneous jumps to 6 of Chapter DB). In the file settings.py section INSTALLED_APPS add an entry
'django.contrib.admin'
later run. / Manage.py syncdb (DB: python manage.py syncdb ), which generates administrative tables in the database. When asked about the superuser should immediately create it (later it is done according to the DB using a script / django / contrib / auth / create_superuser.py . I am using locate create_superuser.py I found this script at the following locations: / var/lib/python-support/python2.4/django/contrib/auth/create_superuser.py / var/lib/python-support/python2.5/django/contrib/auth/create_superuser.py / usr / share / python-support/python-django/django/contrib/auth/create_superuser.py
The third stage of the DB generation panel is to append urls.py
(The draft)
urlpatterns = patterns ('',
(r '^ admin /', include ('django.contrib.admin.urls')),
)
in my case it was uncommenting this line in rzeczonym file. I'm trying to check, I consider that unnecessarily restarted before the mini server (changes occur immediately after recording the file). Unfortunately (but somehow I survived) resulted in new changes that the existing home page reports an error (at this point it is worth noting that all the messages about Django that I've seen so far led to the solution). Works while subpage / admin

http://localhost:8080/admin/
log in, and appears fully READY aesthetic administrative side, the ability to view and filter data, add users, groups, etc. In other words, something that should be everywhere.
Basic user management completely out of my head, as compared to other frameworks again looks promising.

Samantha Anderson At Hom

begin Django

just started trying to use django, which is so much good had read (at least here
). I would like the
Curious: the occasion to talk about Django, he went out as usual, the problem of pronunciation. Well-informed sources say that it is said dżangoh (d voiceless, oh oh passing in;)). As I went walking companion:
DjangoBook
, will seek solutions to problems in the first and accessible to the terms of the GNU

book. At the moment, not all its chapters are written (most are), so sometimes you will need to support the search engine.

starter kit I already have: Linux (Ubuntu DD-> EE-> FF), Python, Django, MySQL. All to find in Synaptic. Of course, you can use django with other common databases (and without any database, which also used to verify). In DjangoBooku (hereinafter DB) write that check whether you have the mysql-python, I have in Ubuntu python-MySQLdb and it seems that it is precisely this package. In addition, of course, one can check if it works phpmyadmin (unfortunately, at the moment of Linux IMHO the lack of a better tool, you can still try to kexi). worth mentioning on the occasion of my knowledge of Python. I wrote a few (very few) scripts (in size, as I say, the screen). I read a little about the language (including one mid-sized book), is interested in him for a long time. Professionally, however, always was programming in other languages. What _mi_ in Python like the most is attached batteries as indentation and force (as someone will take classes in programming for beginners in any language like C, you will know why this is a plus language). Knowledge of Django: I heard that a good and nothing more. Meaning: Python 4 / 10, Django 1 / 10.

database to my project, I was almost ready, so you probably will not be specifically bent over her. At the beginning of the terminal, go to your directory with the parties (in my public_html directory and write: django-admin
startproject mdjango
(DB write:
django-admin.py startproject mysite
, but the installation package django added somewhere in an elegant script and knows that it starts python). From what I know at the moment, Django can store several applications in one project.
project database stores settings, options, Django, and App.
arise following files: __init__.py , manage.py, settings.py, urls.py . What you will need to write what they are. Yes resulting page, you can immediately check with the built-in mini http server. Just run it (in the directory mdjango):
. / Manage.py runserver
(DB again given the long version: python manage.py runserver ). I just have a default port (8000) busy, so get the error: Error: That port is already in use. Port changes trywalnie:
. / Manage.py runserver
8080 (DB: python manage.py runserver 8080). After entering the http://localhost:8080/ acting immediately see the project page with instructions. Time for a first evaluation: I have a few tried and tested frameworks (including RoR and CakePHP) Django wins at this stage, the time to come to that point was just short as possible.