Django: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(3 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
[[Kategorie:Framework]] | [[Kategorie:Framework]] | ||
== DB anlegen (mysql): == | |||
<pre> | |||
mysqladmin -u jones -p create guestbook --default-character-set=utf8 | |||
</pre> | |||
== Admin freischalten == | == Admin freischalten == | ||
* | * Es fehlt ein Eintrag in djange_site: | ||
<pre> | <pre> | ||
mysql -u jones -p guestbook | mysql -u jones -p guestbook | ||
insert into django_site (domain, name) values('localhost', 'admin'); | insert into django_site (domain, name) values('localhost', 'admin'); | ||
commit; | commit; | ||
</pre> | </pre> | ||
* Admin anlegen: | |||
<pre> | |||
cd $PROJ | |||
python manage.py createsuperuser | |||
</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>/ | |||
== Entwicklung == | |||
<pre>python manage.py runserver | |||
</pre> | |||
In Eclipse: | |||
* Project: sidu-installer2 | |||
* Main Module: ${workspace_loc:sidu-installer2/manage.py} | |||
* Arguments: runserver --noreload |
Aktuelle Version vom 21. April 2013, 14:10 Uhr
DB anlegen (mysql):[Bearbeiten]
mysqladmin -u jones -p create guestbook --default-character-set=utf8
Admin freischalten[Bearbeiten]
- 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[Bearbeiten]
- 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>/
Entwicklung[Bearbeiten]
python manage.py runserver
In Eclipse:
- Project: sidu-installer2
- Main Module: ${workspace_loc:sidu-installer2/manage.py}
- Arguments: runserver --noreload