Presentation is loading. Please wait.

Presentation is loading. Please wait.

. 2 3 4 5 6 >> django-admin.py startproject mysite /mysite __init__.py manage.py settings.py urls.py.

Similar presentations


Presentation on theme: ". 2 3 4 5 6 >> django-admin.py startproject mysite /mysite __init__.py manage.py settings.py urls.py."— Presentation transcript:

1

2 2

3 3

4 4

5 5

6 6 >> django-admin.py startproject mysite /mysite __init__.py manage.py settings.py urls.py

7 7 >> python manage.py syncdb >> python manage.py runserver «port number»

8 8

9 9

10 from django.conf.urls.defaults import * from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', (r'^polls/$', 'polls.views.index'), (r'^polls/(?P \d+)/$', 'polls.views.detail'), (r'^polls/(?P \d+)/results/$', 'polls.views.results'), (r'^polls/(?P \d+)/vote/$', 'polls.views.vote'), (r'^admin/', include(admin.site.urls)), ) 10

11 11 >> django-admin.py startapp myapp /myapp __init__.py models.py tests.py views.py

12 12

13 13

14 14

15 from django.db import models class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') class Choice(models.Model): poll = models.ForeignKey(Poll) choice = models.CharField(max_length=200) votes = models.IntegerField() 15

16 16

17 17

18 18

19 19

20 20

21 21

22 22

23 def example_view: template = get_template(”mytemplate.html”) #1 data = Context({ ’foo’: ’hello’, ’bar’: ’world’ }) #2 output = template.render(data) #3 return HttpResponse(output) #4 23

24 24

25 25

26 26

27 27

28 28

29

30 30

31 31

32 32

33 33 Application: mysite

34 34 >> django-admin.py startapp myapp

35 from django.db import models class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') class Choice(models.Model): poll = models.ForeignKey(Poll) choice = models.CharField(max_length=200) votes = models.IntegerField() from appengine_django.models import BaseModel from google.appengine.ext import db class Poll(BaseModel): question = db.StringProperty() pub_date = db.DateTimeProperty('date published') class Choice(BaseModel): poll = db.ReferenceProperty(Poll) choice = db.StringProperty() votes = db.IntegerProperty() 35

36 36

37 37 - url: /static static_dir: static

38 38 - url: /.* script: main.py

39 39 DATABASE_ENGINE = 'appengine' DEBUG = True INSTALLED_APPS = ['appengine_django'] MIDDLEWARE_CLASSES = () ROOT_URLCONF = 'urls' ### SETTINGS_MODULE = 'mysite.settings' ### SITE_ID = 1 ### TEMPLATE_DEBUG = True TIME_ZONE = 'UTC'

40 40

41 41

42  42


Download ppt ". 2 3 4 5 6 >> django-admin.py startproject mysite /mysite __init__.py manage.py settings.py urls.py."

Similar presentations


Ads by Google