Django: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Zeile 18: | Zeile 18: | ||
python manage.py createsuperuser | python manage.py createsuperuser | ||
</pre> | </pre> | ||
== Neues Projekt == | |||
* Eclipse: File - new - other: Django Project | |||
* Neue Applikation: python manage.py startapp <appl> | |||
** Modell anlegen: z.B. Poll | |||
<pre> | |||
from django.db import models | |||
class Poll(models.Model): | |||
question = models.CharField(max_length=200) | |||
pub_date = models.DateTimeField('date published') | |||
</pre> | |||
** Modell prüfen: python manage.py sql polls | |||
** DB anlegen/abgleichen: python manage.py syncdb | |||
* URLs verwalten: <proj>/ |
Version vom 30. Januar 2013, 00:53 Uhr
DB anlegen (mysql):
mysqladmin -u jones -p create guestbook --default-character-set=utf8
Admin freischalten
- Es fehlt ein Eintrag in djange_site:
mysql -u jones -p guestbook insert into django_site (domain, name) values('localhost', 'admin'); commit;
- Admin anlegen:
cd $PROJ python manage.py createsuperuser
Neues Projekt
- Eclipse: File - new - other: Django Project
- Neue Applikation: python manage.py startapp <appl>
- Modell anlegen: z.B. Poll
from django.db import models class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published')
- Modell prüfen: python manage.py sql polls
- DB anlegen/abgleichen: python manage.py syncdb
- URLs verwalten: <proj>/