django admin扩展 相关备忘录
生活随笔
收集整理的這篇文章主要介紹了
django admin扩展 相关备忘录
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
porject相關 settings.py INSTALLED_APPS = (?
????????'django.contrib.auth',?
????????'django.contrib.contenttypes',?
????????'django.contrib.sessions',?
????????'django.contrib.sites',?
??'django.contrib.admin',?
??'mypyblog.polls',?
) urls.py from django.conf.urls.defaults import *?
# Uncomment the?next?two lines?to?enable the admin:?
from django.contrib import admin?
admin.autodiscover()?
urlpatterns = patterns('',?
????????# Example:?
????????# (r'^mypyblog/', include('mypyblog.foo.urls')),?
????????# Uncomment the admin/doc line below?and?add?'django.contrib.admindocs'????
????????#?to?INSTALLED_APPS?to?enable admin documentation:?
????????# (r'^admin/doc/', include('django.contrib.admindocs.urls')),?
????????# Uncomment the?next?line?to?enable the admin:?
??(r'^admin/(.*)', admin.site.root),????
) app相關 建立app之后 添加models # -*- coding: utf-8 -*-?
from django.db import models?
# Create your models here.?
class?Topic(models.Model):?
????????title = models.CharField(max_length=100)?
????????content = models.CharField(max_length=50)?
????????
class?Admin(models.Model):?
????????username = models.CharField(max_length=10)?
????????password = models.CharField(max_length=16) ORM模型正確性檢驗 python manage.py validate 查看數據庫結構 python manage.py sql polls 同步數據庫 python manage.py syncdb 在app下建立一個admin.py
from django.contrib import admin?
from mypyblog.polls.models import Topic, Admin?
admin.site.register(Topic)?
admin.site.register(Admin)?
啟動測試服務器 python manage.py runserver
本文轉自阿汐 51CTO博客,原文鏈接:http://blog.51cto.com/axiii/180994,如需轉載請自行聯系原作者
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀
????????'django.contrib.auth',?
????????'django.contrib.contenttypes',?
????????'django.contrib.sessions',?
????????'django.contrib.sites',?
??'django.contrib.admin',?
??'mypyblog.polls',?
) urls.py from django.conf.urls.defaults import *?
# Uncomment the?next?two lines?to?enable the admin:?
from django.contrib import admin?
admin.autodiscover()?
urlpatterns = patterns('',?
????????# Example:?
????????# (r'^mypyblog/', include('mypyblog.foo.urls')),?
????????# Uncomment the admin/doc line below?and?add?'django.contrib.admindocs'????
????????#?to?INSTALLED_APPS?to?enable admin documentation:?
????????# (r'^admin/doc/', include('django.contrib.admindocs.urls')),?
????????# Uncomment the?next?line?to?enable the admin:?
??(r'^admin/(.*)', admin.site.root),????
) app相關 建立app之后 添加models # -*- coding: utf-8 -*-?
from django.db import models?
# Create your models here.?
class?Topic(models.Model):?
????????title = models.CharField(max_length=100)?
????????content = models.CharField(max_length=50)?
????????
class?Admin(models.Model):?
????????username = models.CharField(max_length=10)?
????????password = models.CharField(max_length=16) ORM模型正確性檢驗 python manage.py validate 查看數據庫結構 python manage.py sql polls 同步數據庫 python manage.py syncdb 在app下建立一個admin.py
from django.contrib import admin?
from mypyblog.polls.models import Topic, Admin?
admin.site.register(Topic)?
admin.site.register(Admin)?
啟動測試服務器 python manage.py runserver
本文轉自阿汐 51CTO博客,原文鏈接:http://blog.51cto.com/axiii/180994,如需轉載請自行聯系原作者
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀
總結
以上是生活随笔為你收集整理的django admin扩展 相关备忘录的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux安装压缩版的mysql
- 下一篇: 怎么找回失踪的NTLDR文件