Django1.6以åã®ãã¼ã¸ã§ã³ã§ã¯ã管çãµã¤ãã§è¡¨ç¤ºãããã¢ããªã±ã¼ã·ã§ã³åãå¤æ´ããæ¹æ³ã¯é常ã®ä½¿ãæ¹ã§ã¯æä¾ããã¦ãã¾ããã§ããã
å¤ãããã®ã¯ãã®ãMyappãã¨ããé¨åã
Django1.7ã§ã¯ã¢ããªã±ã¼ã·ã§ã³ãã¨ã®è¨å®ãæ½è±¡åãåå©ç¨å¯è½ãªä»çµã¿ãå°å
¥ãããã¢ããªã±ã¼ã·ã§ã³åãè¨å®ã§ããããã«ãªãã¾ããã
ã½ã¼ã¹ã³ã¼ã
django.apps.AppConfigã¯ã©ã¹ãç¶æ¿ãã¦ãã¢ããªã±ã¼ã·ã§ã³è¨å®ã®ã¯ã©ã¹ãä½æããã¢ããªã±ã¼ã·ã§ã³åãè¨å®ãã¾ãã
ä½æããã¢ããªã±ã¼ã·ã§ã³è¨å®ã®ã¯ã©ã¹ããã¢ããªã±ã¼ã·ã§ã³ã®ããã©ã«ãã«ãã¾ãã
試ãããã¼ã¸ã§ã³ã¯Python3.4, Django1.7ã§ãã
myapp/models.py
ã¢ãã«ã¯ãã¤ãéãã
from django.db import models class Item(models.Model): name = models.CharField(max_length=50) price = models.PositiveIntegerField(default=0) created_at = models.DateTimeField(auto_now_add=True) class Meta: verbose_name = verbose_name_plural = "åå"
myapp/apps.py
Django1.7ã§è¿½å ãããAppConfigã使ãã¾ããnameã«ã¯ä»ã®ã¢ããªã±ã¼ã·ã§ã³ã¨è¢«ããªãããã«ã¢ããªã±ã¼ã·ã§ã³ã®èå¥åã代å
¥ãã¾ããã¨ããããã¯ã¢ã¸ã¥ã¼ã«åã§å¤§ä¸å¤«ã§ãã
verbose_nameã«ã¢ããªã±ã¼ã·ã§ã³ã®è¡¨ç¤ºåã代å
¥ãã¾ããããã管çãµã¤ãã§è¡¨ç¤ºããã¾ãã
from django.apps import AppConfig class MyAppConfig(AppConfig): name = 'myapp' verbose_name = "ç§ã®ã¢ããªã±ã¼ã·ã§ã³"
myapp/__init__.py
default_app_configå¤æ°ã«æååã§ã¢ããªã±ã¼ã·ã§ã³è¨å®ã®ã¯ã©ã¹ãæå®ãã¾ãã
default_app_config = 'myapp.apps.MyAppConfig'