django带后台管理功能的网站
2024-10-19 09:37:59
一、原起:
我大学是学的.Net平台、在那个平台上开发网站用的是ASP.NET这门技术;在那里对数据库的处理、为了
方便写代码,通常也是会用ORM(对象关系模型映射);毕业后搞起了MySQL数据库、自学了python、到现
在用起了django、才发现django中比ASP.NET做的还要过分、就是在你定义完ORM后只要对项目进行一点点
小的改动,那的项目就有后台管理功能了。 下面讲一下django官方文档中的例子
二、创建project :
django-admin startproject project3
三、在project3 项目中创建一个名叫polls 的app:
python3 manage.py startapp polls
三、修改polls/models.py 文件增加两表的模型:
四、注测polls到项目:
五、配置后台数据库:
六、迁移三中定义好的数据库模型到后台数据库:
python3 manage.py makemigrations polls
Migrations for 'polls':
polls/migrations/0001_initial.py
- Create model Choice
- Create model Question
- Add field question to choice
JianglexingdeMacBook-Pro:project3 jianglexing$ python3 manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, polls, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying polls.0001_initial... OK
Applying sessions.0001_initial... OK
七、把数据库模型注测到admin网站:
八、创建admin用户:
python3 manage.py createsuperuser
Username (leave blank to use 'jianglexing'): admin
Email address: @qq.com
Password:
Password (again):
Superuser created successfully.
九、启动django项目:
python3 manage.py runserver 127.0.0.1:
Performing system checks... System check identified no issues ( silenced).
November , - ::
Django version 1.11., using settings 'project3.settings'
Starting development server at http://127.0.0.1:8080/
Quit the server with CONTROL-C.
十、从web访问:
----
最新文章
- C#课外实践——校园二手平台(技术篇2)
- 12 day 1
- Linux命令之env:显示当前用户的环境变量
- uva - 10833 Supermean(二项式系数,对指数)
- linux 知识整理1linux 常见的目录
- NEU月赛Segment Balls(线段树)
- ABAP字符串操作 截取字符长度 取位数
- hibernate java.sql.SQLException
- java常用字节流
- [Swift]LeetCode899. 有序队列 | Orderly Queue
- LeetCode(84): 柱状图中最大的矩形
- 《Visual C# 从入门到精通》第三章使用判断语句——读书笔记
- cordova获取app版本信息插件的使用:cordova-plugin-app-version
- (9/24) 图片跳坑大战--css分离与图片路径处理
- (O)WEB:前端网站性能优化(原创)
- [CodeVS4438]YJQ Runs Upstairs
- lesson7-图像描述 -小象cv
- static关键字的使用(有个深刻领悟)
- 20155229《网络对抗技术》Exp6:信息收集与漏洞扫描
- vue父组件中获取子组件中的数据
热门文章
- Systemd 三部曲 之 PHP7
- SSIS包部署错误之运行环境设置
- mybatis结果的组装(springboot)
- [Javascript] Funciton Expression
- 4. Add override methods to class
- LuaCURL
- Linux之nohup命令:实现退出终端后程序继续后台运行
- 代理(Proxy)模式简介
- 算法笔记_125:算法集训之编程大题集一(Java)
- exception PLS-00403: expression 'V_END' cannot be used as an INTO-target of a SELECT/FETCH statement