app-engine-patchã使ã£ã¦ã¿ã
Django on Google App Engineã§ã¡ããã¡ããéçºãã¦ãããã©ãããã£ã±ãDjangoãªã®ã«ãã®ããããªadminç»é¢ã使ããªãã®ã§ã¯Django人çã®80%ããããæãã¦ããã¨æãã®ã§id:voluntasã«ããããããapp-engine-patchã使ã£ã¦ã¿ãã
http://code.google.com/p/app-engine-patch/
ãã¼ã¸ã§ã³1.0ããªãªã¼ã¹ããã¦2é±éãããçµã£ãããå®å®çã¨è¦ãªãã¦ããã ãããã¨ãã¾ãã¯GettingStartedãèªãããªãã»ã©ã
- ãµã³ãã«ããã¸ã§ã¯ãããã¦ã³ãã¼ããã
- app.yamlã®applicationã®ã¨ãããGAEã®create applicationã§ä½ã£ãã¢ããªã±ã¼ã·ã§ã³åã«ãã
- settings.pyã®SECRET_KEYãã©ã³ãã ãªæååã§æ¸ãæãããããã¯Djangoã«æ¨æºæè¼ã®CSRF対çã³ã¼ãã¨ãã§ä½¿ããã: http://www.mail-archive.com/[email protected]/msg00434.html
- myappãåé¤ãããã¾ãæ¬å½ã«åé¤ããªãã§ã³ã¡ã³ãã¢ã¦ãã ãã«ãããã©ã
INSTALLED_APPS = (
...
- 'myapp',
'registration',
'mediautils',
)
chmod +x manage.pyãã¦./manage.py runserverã§éçºç¨ãµã¼ããèµ·åãããhttp://localhost:8000/ã«ã¢ã¯ã»ã¹ããã
ããã¼ããCaught an exception while rendering: unknown encoding: X-MAC-JAPANESEãã ã¼ã
ãµããè½ã¡çããããããã«settings.pyã®åé ã§X-MAC-JAPANESEãutf-8ã«ããããã¦ãã¾ãã°ãããã ããã
def register_x_max_ja(): "workaround of 'Caught an exception while rendering: unknown encoding: X-MAC-JAPANESE'" import codecs from encodings.utf_8 import getregentry codecs.register(lambda name: getregentry() if name == 'x-mac-japanese' else None) register_x_max_ja()
ãã¦ããªãã¼ãã£ã¨ãããã¨ã©ã¼ã¡ãã»ã¼ã¸ãå¤ãã£ãããCaught an exception while rendering: Reverse for 'settings.myapp.views.list_people' with arguments '()' and keyword arguments '{}' not found.ããªãã ãããReverseï¼
ãã³ãã¬ã¼ãã®ããã§ã¨ã©ã¼ã«ãªã£ã¦ãã
<a href="{% url myapp.views.list_people %}">Generic views sample</a> |
urlã¿ã°ã£ã¦ãªãã ï¼id:voluntasãããããã¯URLãããã¼ã®æ å ±ãå©ç¨ãã¦/some/url/prefix/of/func1/and/{{ arg1 }}/{{ arg2 }} ã¨ãæ¸ããããã« {% url func1 arg1 arg2 %} ã¨æ¸ããããã«ããæ©è½ã ãããªããµããmyappãæ¶ããããè¦ã¤ãããªãã£ã¦æããã¦ããã ããããã£ããæ»ããã
åããï¼
ãããgenerate admin userãªãã¦ã®ããããããããã®ã¾ã¾å ¬éããããããªããããadminã¢ã«ã¦ã³ããä½ã£ã¦adminç»é¢ã«ã¢ã¯ã»ã¹ãã¦ã¿ãã
ã°ã£ã¡ãåãã¦ãã¾ããããã¡ããæ¥æ¬èªãå ¥ãã¦ã大ä¸å¤«ããã¹ããæ¥æ¬èªã§è¡¨ç¤ºããã¦ããã ãã大ä¸å¤«ã ã¨ã¯æããã©ãã
ãããå ¨ãå±ãªããªãåãã¦ãããç°¡åã ãããã¥ã¡ã³ããèªãã¨ããããå§ãã¦1æéã§ã§ãããã¨ããããä»æ¥ã¯Googleã«ã¢ãããã¼ãããã¨ããã¾ã§ãããã
追è¨ï¼
- startappã§ã¢ããªã±ã¼ã·ã§ã³foobarãä½ã
- myapp/urlauto.pyãè¦ã¦ã¾ãããã
- foobar/url.pyãæ¸ã
- foobar/template/index.htmlãã¤ãã
- foobar/views.pyãæ¸ã
- foobar/models.pyãæ¸ã
- /adminãè¦ã¦ã¿ããã©ããã£ãä½ã£ãã¢ãã«ã管çç»é¢ã«åºã¦ããªããï¼
- myapp/admin.pyãè¦ã¦ã¾ãããã
- 管çç»é¢ã«åºãï¼
- ã¢ããªãä½ã
- manage.py update
- ã§ããã
ããæã®6æã§ä¸å¯§ã«è§£èª¬ãæ¸ãæ°ãèµ·ãã¾ããã