摘要:
1.导入相应的包 2.HttpResponse(返回字符串给浏览器) 3.render(可以将后台的数据传给前端,三个参数:request,url,context) 3.redirect(跳转到指定的url) 主要还是使用render。 阅读全文
摘要:
1.NoReverseMatch at / Reverse for 'about' not found. 'about' is not a valid view function or pattern name. 这是因为自己指定了app_name,app_name='person' 在html界面 阅读全文
摘要:
1.建立django项目 django-admin startproject myblog 2.进入myblog目录 建立app存储自己的基本信息 python manage.py startapp person 3.在settings.py中注册app,在INSTALLED_APPS里面加入'ps 阅读全文
摘要:
models.py forms.py views.py index.html 点击提交: 阅读全文
摘要:
class StudentForms(forms.ModelForm): formats=[ '%Y-%m-%d', '%m/%d/%Y', ] birthday = forms.DateField(label='出生日期', input_formats=formats) class Meta: m 阅读全文
摘要:
{{title}} 这是主界面--> {{fo... 阅读全文
摘要:
要注意是模板元素 和 表单元素的对应。 阅读全文
摘要:
models.py-->forms.py-->views.py(get)--index.html-->views.py(post)-->home.html urls.py models.py forms.py views.py index.html home.html 阅读全文
摘要:
urls.py forms.py views.py index.html home.html index界面: 输入相应信息,点击提交,信息会传到home界面,并显示 阅读全文
摘要:
1.在book app目录下新建一个forms.py,并加入 urls.py配置路径: views.py中配置视图: index.html 具体页面: 我们只测试接受birthday:注意输入的日期格式。 阅读全文