[Django] The admin interface
2024-08-31 20:05:39
Now let's see how to access admin interface.
1. Create a super user which can access admin interface:
python manage.py createsuperuser
2. Inside admin.py, we import the Models we have defined:
from django.contrib import admin # Register your models here.
from .models import List, Card admin.site.register(List)
admin.site.register(Card)
---
The models:
from django.db import models
from django.utils.encoding import python_2_unicode_compatible @python_2_unicode_compatible
class List(models.Model):
name = models.CharField(max_length=) def __str__(self):
return "List {}".format(self.name) @python_2_unicode_compatible
class Card(models.Model):
title = models.CharField(max_length=)
description = models.TextField(blank=True)
list = models.ForeignKey(List, related_name="cards")
story_points = models.IntegerField(null=True, blank=True)
business_value = models.IntegerField(null=True, blank=True) def __str__(self):
return "Card {}".format(self.title)
Notice that if you change models.py file, you need to run migrations again:
python manage.py makemigrations
If you see the terminal warning that "You have 1 unapplied migration(s)... Run 'python manage.py mifate' to apply then."
python mange.py migrate
3. Run the server:
python manage.py runserver
Go to the url: localhost:8000/admin
最新文章
- 为什么js加事件时不要写括号
- VS2013编译python源码
- ArcGIS Engine中的数据访问
- DFS
- synchronized(this) 和synchronized(xxx.class)的区别和联系
- Searching in a rotated and sorted array
- (4)ARP:地址解析协议
- DD_belatedPNG,IE6下PNG透明解决方案
- 从1500万用户巅峰跌落的app,血泪回顾图片社交那些坑
- .Cannot create an NSPersistentStoreCoordinator with a nil model
- solr安装血泪史
- Dockerfile怎么创建镜像
- Dynamics CRM2013 定制你的系统登录后的首页面
- 2018-2019-2 20175317 实验二《Java面向对象程序设计》实验报告
- Javascript学习---倒计时
- C#计算时间差 TimeSpan
- T-SQL:排除阻塞(十六)
- Cassandra基础3
- Flume 安装和配置
- jQuery中的deferred对象和extend方法
热门文章
- 利用安卓手机的OTG共享有线网络
- 终于研究出如何设置新版paypal付款时汇率损失方的问题了
- 14.ZooKeeper Java API 使用样例
- 119.WIN32窗口原理
- 1.3 Quick Start中 Step 1: Download the code官网剖析(博主推荐)
- vue实现多语言国际化(vue-i18n),结合element ui、vue-router、echarts以及joint等。
- 关于js盒子模型的知识梳理
- POJ 2284 That Nice Euler Circuit (LA 3263 HDU 1665)
- (转) centos安装oracle11.2 pdksh软件包的说明
- 使用 JS 关闭警告框及监听自定义事件(amaze ui)