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
Rubyが読めないという致命的な欠点をどう克服しよう。

以下適当に作ったソース。
やる気がないのバレバレ。

/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/')),
)