巡回

Pyspa:

[ pyspa ] 第3回Python温泉に参加してきました
[pyspa]温泉行ってきました


Django Snippets:

(en-US) Humanized Decimal Field
Class ModeInfo for show object info
Update All Apps to Latest Revision


Blog:

[ Django ] Django の管理画面で特定のモデルの特定のフィールドのtextareaだけcolsやrowsを変えたい
Plugging a RSS feed into a Django template
Ian Holsman: when it rains it pours - whats new in monitoring and metrics
Ryan Berg: The basics of creating a tumblelog with Django (part 2)
Django Unit Tests and Transactions
This Week in Django 28 - 2008-06-30
Django and PyTextile Revisited

巡回

Pyspa:

[pyspa]第三回分一応まとめておくかな


Django Snippets:

ActiveManager
Google Charts Templatetags (Python)
Add multiple parameters to the current url
More after the jump


Google Code:

django-rosetta A Django application that eases the translation process of your Django projects
django-fireeagle Fire Eagle tools for Django
trespams Blog software based on Blogmaker


Blog:

Using Django QuerySet Refactor, Newforms-Admin, Trunk and Pre-Autoescape on the Same Laptop
Django and Relativity
Create a Timeline in JavaScript with SIMILE

FreeBSD, Nginx and Django
ConceptNet 3 アプリかな? ちょっと調べてみよう:)
Django File Uploads


Google App Engine:

no matching index found. This query needs this index
[gae]Google App Engineのタイムアウト時間は約8秒

Python温泉のまとめ

次回も同じところでするようなので、メモ的なものを。
熱海駅から来宮駅に行くには伊豆鉄道を使っていくのですが
なんといっても、本数が少ない。
ということで、とる行動は

  • 富豪的行動をしたい人は、熱海駅で降りタクシーで旅館まで行く。(ただし最後のほうは道案内が必要になってくるかも)
  • 富豪的行動は熱海駅からタクシーを乗り来宮駅付近で降り、徒歩で旅館まで。
  • 平民的行動は、電車が来るまで待つ。その間に食事など済ませたり構内にあるドトールで待つ。

になると思います。


あと、帰りに気づいたのが旅館の近くにベーカリーみたいなものがあったような気がする。
今度覗いてみよう:)
それと、来宮神社でそば・うどんが食べられるようなので食べてみたい。


今回もid:VoluntasMercurialの伝道師になっていた :)


newforms-admin(今後のDjango trunk)は、モデル定義とアドミン定義をファイル的に分離することが出来るようになります。
ということで、前回のモデル定義を参考にして分離してみたいと思います。
前回は、

from django.db import models
from django.contrib import admin
# Create your models here.

class Address(models.Model):
	short_name = models.CharField(max_length=20)
	long_name = models.CharField(max_length=80)
	addr_line_1 = models.CharField(max_length=80, blank=True)
	addr_line_2 = models.CharField(max_length=80, blank=True)
	city = models.CharField(max_length=50)
	state = models.USStateField()
	zip = models.CharField(max_length=10, blank=True)

	def __str__(self):
		#return self.short_name
		return "%s (%s %s)" % (self.short_name, self.city, self.state)

	class Meta:
		verbose_name_plural = 'Addresses'


class PhoneType(models.Model):
	description = models.CharField(max_length=20)

	def __str__(self):
		return self.description

class Phone(models.Model):
	description = models.CharField(max_length=80)
	number = models.PhoneNumberField()
	number_type = models.ForeignKey(PhoneType)
	address = models.ForeignKey(Address)

	def __str__(self):
		return self.number

class Date(models.Model):
	description = models.CharField(max_length=80)
	start_date = models.DateField()
	annual_event = models.BooleanField()
	address = models.ForeignKey(Address)

class Note(models.Model):
	note_text = models.TextField()
	address = models.ForeignKey(Address)

class Group(models.Model):
	description = models.CharField(max_length=80)
	addresses = models.ManyToManyField(Address)

	def __str__(self):
		return self.description

class PhoneInline(admin.TabularInline):
	model = Phone
	extra = 3

class DateInline(admin.TabularInline):
	model = Date
	extra = 2

class NoteInline(admin.StackedInline):
	model = Note
	extra = 1

class GroupOptions(admin.ModelAdmin):
	filter_horizontal = ('addresses',)

class AddressOptions(admin.ModelAdmin):
	search_fields = ['short_name', 'long_name']
	fieldsets = (
		('Name', {'fields': ('short_name', 'long_name')}),
		('Address', {'fields': ('addr_line_1', 'addr_line_2', 'city', 'state', 'zip')}),
	)
	list_display = ('short_name', 'city', 'state')
	ordering = ('short_name',)
	list_filter = ('state',)
	inlines = [PhoneInline, DateInline, NoteInline]

admin.site.register(Address, AddressOptions)
admin.site.register(PhoneType)
admin.site.register(Group, GroupOptions)

でした。
アドミン定義の部分を保存するファイルを作成します。
分かりやすいようにadmin.pyとします。
配置場所は、分割するmodels.pyと同じところに置きます。
models.pyは

from django.db import models

# Create your models here.

class Address(models.Model):
	short_name = models.CharField(max_length=20)
	long_name = models.CharField(max_length=80)
	addr_line_1 = models.CharField(max_length=80, blank=True)
	addr_line_2 = models.CharField(max_length=80, blank=True)
	city = models.CharField(max_length=50)
	state = models.USStateField()
	zip = models.CharField(max_length=10, blank=True)

	def __str__(self):
		#return self.short_name
		return "%s (%s %s)" % (self.short_name, self.city, self.state)

	class Meta:
		verbose_name_plural = 'Addresses'


class PhoneType(models.Model):
	description = models.CharField(max_length=20)

	def __str__(self):
		return self.description

class Phone(models.Model):
	description = models.CharField(max_length=80)
	number = models.PhoneNumberField()
	number_type = models.ForeignKey(PhoneType)
	address = models.ForeignKey(Address)

	def __str__(self):
		return self.number

class Date(models.Model):
	description = models.CharField(max_length=80)
	start_date = models.DateField()
	annual_event = models.BooleanField()
	address = models.ForeignKey(Address)

class Note(models.Model):
	note_text = models.TextField()
	address = models.ForeignKey(Address)

class Group(models.Model):
	description = models.CharField(max_length=80)
	addresses = models.ManyToManyField(Address)

	def __str__(self):
		return self.description

admin.pyは

from django.contrib import admin
from appname.models import Group, Note, Date, Phone, PhoneType, Address

class PhoneInline(admin.TabularInline):
	model = Phone
	extra = 3

class DateInline(admin.TabularInline):
	model = Date
	extra = 2

class NoteInline(admin.StackedInline):
	model = Note
	extra = 1

class GroupOptions(admin.ModelAdmin):
	filter_horizontal = ('addresses',)

class AddressOptions(admin.ModelAdmin):
	search_fields = ['short_name', 'long_name']
	fieldsets = (
		('Name', {'fields': ('short_name', 'long_name')}),
		('Address', {'fields': ('addr_line_1', 'addr_line_2', 'city', 'state', 'zip')}),
	)
	list_display = ('short_name', 'city', 'state')
	ordering = ('short_name',)
	list_filter = ('state',)
	inlines = [PhoneInline, DateInline, NoteInline]

admin.site.register(Address, AddressOptions)
admin.site.register(PhoneType)
admin.site.register(Group, GroupOptions)

urls.pyも少し変更します。
admin.pyファイルを認識させるコードを1行追記するだけです。

from django.conf.urls.defaults import *

# Uncomment this for admin:
from django.contrib import admin
from appname.admin import *

urlpatterns = patterns('',
    # Example:
    # (r'^newforms/', include('newforms.foo.urls')),

    # Uncomment this for admin docs:
    #(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment this for admin:
    ('^admin/(.*)', admin.site.root),
)

以上です。
簡単ですね。


現在最新のnewforms-adminは__str__ではなく__unicode__に変更されています。


参加メンバーの一人ymasudaさんが日経ソフトウェアで執筆したしたそうです。
それがこれ


いろいろと楽しい集まりでした。
今度はネタを提供できるようにしたい><

巡回

Google Code:

django-weather django application to display the current weather/forecast.
coltrane-blog


Blog:

第三回Python温泉
djangoのsitemapフレームワークの使い方 その3
[Python][Django]Django -その1:LeopardにMySQLdbをインストール
Graphite using Django and ExtJS for the frontend
Michael Krause Software Development Djangoで作ったサイトやPython/Jythonで作ったアプリがあります。
Eclipseでdjango開発する方法


Google App Engine:

Google App Engine Helper for Django を使おうとしてみた
don't add support for other languages の気持
Model.get_or_insert(key_name, **kwds)
EclipseでGAE+Django
[Web] Google App Engineをお試し
URLのリクエストパラメータを取得する方法