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 表格排序擴充套件排序套件
- PHPWAMP安裝Redis擴充套件的方式與相關擴充套件的下載PHPRedis套件
- Activity相關備忘
- Laravel-admin 新增擴充套件介紹Laravel套件
- 如何擴充套件Django使用者模組套件Django
- 樹莓派擴充套件板 sense HAT 的相關介面樹莓派套件
- Laravel-admin 快速開發擴充套件(一)Laravel套件
- 擴充套件.Django-許可權系統套件Django
- Django內建許可權擴充套件案例Django套件
- 【記錄】安裝 maxminddb 擴充套件套件
- [記錄] 安裝 maxminddb 擴充套件套件
- kotlin 擴充套件(擴充套件函式和擴充套件屬性)Kotlin套件函式
- 摸魚.....分享一個dcat-admin擴充套件套件
- django實現自定義manage命令的擴充套件Django套件
- django 2.0 擴充套件使用者欄位 示例Django套件
- 【記錄】安裝 Xdebug 擴充套件套件
- [記錄] 安裝 Xdebug 擴充套件套件
- linux擴充套件根目錄大小Linux套件
- 介紹兩個好玩的和Github相關的Chrome擴充套件GithubChrome套件
- 關於Interceptor擴充套件問題套件
- Larave-admin 微信海外地圖 (HereMap) 擴充套件包地圖REM套件
- WCF擴充套件:行為擴充套件Behavior Extension套件
- 【Kotlin】擴充套件屬性、擴充套件函式Kotlin套件函式
- Dcat Admin 擴充徵集
- 【記錄】編譯安裝 ProtoBuf 擴充套件編譯套件
- [記錄] 編譯安裝 ProtoBuf 擴充套件編譯套件
- 【記錄】編譯安裝 YAML 擴充套件編譯YAML套件
- [記錄] 編譯安裝 YAML 擴充套件編譯YAML套件
- 記錄Laravel開發常用擴充套件包Laravel套件
- Laravel-admin 自定義擴充套件,jQuery 語法錯誤?Laravel套件jQuery
- 基本於dcat-admin 的介面文件擴充套件-開箱即用套件
- Robot Framework(15)- 擴充套件關鍵字Framework套件
- Swift在擴充套件中關聯物件Swift套件物件
- 備忘錄
- 【備忘錄】
- Sanic 擴充套件套件
- ORACLE 擴充套件Oracle套件
- 擴充套件工具套件