2006-10-31
タグは固定で:-) by ueBLOG
Django勉強会 Disc1 の日程と時間が決まりましたので、こちらでお知らせします。
申し込みはここでは出来ませんので、公式サイトでの発表をお待ちください。
下記の予定は公式の発表ではありません。
予定は未定という事でお考えいただければ。
- 内容
- mopemopeさん
- PyJSとか(未定)
- ...
- ...
- 寺子屋
- ...
定員がまだ未定です。
ご興味のある方は是非ご参加ください
RandomNoteを作ってみる(パクリ)
Django再入門 RandomNoteを作る vol.1 下準備 (ueBLOG)
http://ash1no0to.dyndns.org/htdocs/archives/2006/10/djangorandomnot.html
Django再入門 RandomNoteを作る vol.2 汎用ビュー(Generic.view) (ueBLOG)
http://ash1no0to.dyndns.org/htdocs/archives/2006/11/django_randomno2.html
まちゅダイアリー - Rails に(再)挑戦 , model と scaffold を作る
http://www.machu.jp/diary/20061002.html
自分も勉強がてら作ってみようと思います:-p
やる気がないのバレバレ。
/randomnote/models.py
from django.db import models
class Page(models.Model):
body = models.TextField(blank=False, null=False)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
class Admin:
pass
class Meta:
verbose_name_plural = 'pages'
ordering = ['updated']
def get_title(self):
return unicode(self.body, 'utf-8')[:10].encode('utf-8') + '...'
def get_absolute_url(self):
return '/randomnote/%d/' % (self.id)
def get_updated_date(self):
return self.updated.strftime('%Y-%m-%d %H:%M')
def get_created_date(self):
return self.created.strftime('%Y-%m-%d %H:%M')
/randomnote/urls.py
from django.conf.urls.defaults import *
from randomnote.models import Page
query_dict = dict(queryset=Page.objects.all())
urlpatterns = patterns('django.views.generic.list_detail',
(r'^$', 'object_list', dict(query_dict, allow_empty=True)),
# (r'^show/(?P<object_id>\d+)/$', 'object_detail', dict(query_dict)),
)
model_dict = dict(model=Page)
urlpatterns += patterns('django.views.generic.create_update',
(r'^create/$', 'create_object', model_dict),
(r'^edit/(?P<object_id>\d+)$', 'update_object', model_dict),
(r'^destory/(?P<object_id>\d+)$', 'delete_object', dict(model_dict,
post_delete_redirect='/randomnote/')),
)
