æ°Admin Interface(ã»âã»)ã¤ã¤ï¼
ç¾å¨ãã¡ã¼ã«æ稿ãä¸å¿ã¨ããBlogãä½ãããã¨æã£ã¦ã¾ãã
ä»æ¥ã¯ãã¢ã«ã¦ã³ãã®é¨åãä½ã£ã¦ã¿ãã
æ¬æ¥ãªããdjango.contrib.auth.models.Userã使ã£ã¦ç®¡çããã°ããã®ã§ãã
- ãã³ãã«ãã¼ã ãã¦ã¼ã¶åã¨ã¯å¥ã®ååã«ãããã
- æºå¸¯ã»PCãªã©è¤æ°ã®ã¡ã¼ã«ã¢ãã¬ã¹ããæ稿ãããã
ãªã©ããä»åã¯django.contrib.auth.models.Userãæ¡å¼µãã¾ãã
models.py
#-*- encoding:utf-8 -*- from django.db import models from django.contrib.auth.models import User class Nickname(models.Model): user = models.ForeignKey(User) nickname = models.CharField(max_length=10) def __unicode__(self): return self.nickname def save(self): if not self.id: super(Nickname, self).save() class Allowlist(models.Model): author = models.ForeignKey(Nickname) email = models.EmailField(unique=True) def __unicode__(self): return "%s (%s)" % (self.email, self.author) def save(self): if not self.id: super(Allowlist, self).save()
admin.py
#-*- encoding:utf-8 -*- from django.contrib import admin from accounts.models import * class Email_Inline(admin.StackedInline): model = Allowlist extra = 2 class NicknameOption(admin.ModelAdmin): ordering = ['nickname',] inlines = [Email_Inline, ] admin.site.register(Nickname, NicknameOption)
ç´40è¡ããã(è¨å®çã®é¨åã¯æãã¾ãã)ã³ã¼ãã£ã³ã°ããã ãã§
以ä¸ã®ãããªãã©ã¼ã ãèªåçæãã¾ãï¼
以åã®Admin Interfaceã§ã¯ããæ°ã¯èµ·ããªãã£ããªããã¼ãä¾¿å© ;-)
admininterface posted by (C)常山
ãã£ã¨django-registrationãdjango-profilesãªã©ãåèã«ãã¦ã¿ãã :-)