要求及文件

  用户可以添加新主题,添加新条目,以及编辑既有条目

   forms.py  urls.py  views.py  html

   new_topic.html  new_entry.html

   edit_entry.html

 

添加新主题

new_topic.html

 博客基础_django_python从入门到实践_添加主题_添加条目_编辑条目

 

topics.html

 博客基础_django_python从入门到实践_添加主题_添加条目_编辑条目

 

添加新条目

new_entry.html

 博客基础_django_python从入门到实践_添加主题_添加条目_编辑条目

 

topic.html

博客基础_django_python从入门到实践_添加主题_添加条目_编辑条目

 

编辑条目

edit_entry.html

博客基础_django_python从入门到实践_添加主题_添加条目_编辑条目

 

topic.html

博客基础_django_python从入门到实践_添加主题_添加条目_编辑条目

 

代码

forms.py

 1 from django import forms
 2 from  .models import Topic, Entry
 3 
 4 class TopicForm(forms.modelForm):
 5     def Meta:
 6         model = Topic
 7         text = ['text']
 8         labels = {'text': ''} # 不为字段生成标签
 9 
10 class EntryForm(forms.modelForm):
11     def Meta:
12         model = Entry
13         text = ['text']
14         labels = {'text': ''}
15         widget = {'text': forms.Textarea(attrs={'cols': 80})}
View Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-09
  • 2022-12-23
  • 2021-05-07
  • 2021-05-04
  • 2021-09-30
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-20
  • 2022-12-23
  • 2022-12-23
  • 2022-03-05
相关资源
相似解决方案