django admin擴充套件 相關備忘錄
porject相關
settings.py
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'mypyblog.polls',
)
'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),
)
# 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)
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,如需轉載請自行聯絡原作者
相關文章
- Dcat Admin 表格排序擴充套件排序套件
- Laravel-admin 新增擴充套件介紹Laravel套件
- Laravel-admin 快速開發擴充套件(一)Laravel套件
- 樹莓派擴充套件板 sense HAT 的相關介面樹莓派套件
- 摸魚.....分享一個dcat-admin擴充套件套件
- Django內建許可權擴充套件案例Django套件
- 擴充套件.Django-許可權系統套件Django
- kotlin 擴充套件(擴充套件函式和擴充套件屬性)Kotlin套件函式
- 【記錄】安裝 maxminddb 擴充套件套件
- [記錄] 安裝 maxminddb 擴充套件套件
- [記錄] 安裝 Xdebug 擴充套件套件
- 【記錄】安裝 Xdebug 擴充套件套件
- PHP的命令列擴充套件Readline相關函式學習PHP命令列套件函式
- django 2.0 擴充套件使用者欄位 示例Django套件
- django實現自定義manage命令的擴充套件Django套件
- 介紹兩個好玩的和Github相關的Chrome擴充套件GithubChrome套件
- Dcat Admin 擴充徵集
- Laravel-admin 自定義擴充套件,jQuery 語法錯誤?Laravel套件jQuery
- Larave-admin 微信海外地圖 (HereMap) 擴充套件包地圖REM套件
- 【Kotlin】擴充套件屬性、擴充套件函式Kotlin套件函式
- 備忘錄
- 【備忘錄】
- 【記錄】編譯安裝 SeasLog 擴充套件編譯套件
- 【記錄】編譯安裝 YAML 擴充套件編譯YAML套件
- 【記錄】編譯安裝 ProtoBuf 擴充套件編譯套件
- [記錄] 編譯安裝 IgBinary 擴充套件編譯套件
- [記錄] 編譯安裝 YAML 擴充套件編譯YAML套件
- 【記錄】編譯安裝 IgBinary 擴充套件編譯套件
- [記錄] 編譯安裝 ProtoBuf 擴充套件編譯套件
- [記錄] 編譯安裝 SeasLog 擴充套件編譯套件
- 記錄Laravel開發常用擴充套件包Laravel套件
- Swift在擴充套件中關聯物件Swift套件物件
- Robot Framework(15)- 擴充套件關鍵字Framework套件
- 基本於dcat-admin 的介面文件擴充套件-開箱即用套件
- dcat-login-captcha - dcat admin 登入驗證碼擴充套件APT套件
- 擴充套件工具套件
- Sanic 擴充套件套件
- Mybatis擴充套件MyBatis套件
- SpringMVC 擴充套件SpringMVC套件