Django 学习

使用Django表格   使用Django view 视图 polls/views.py 将视图绑定到url链接 polls/urls.py 使用Django template 创建index.html文件 polls/template/polls/index.html # return HttpResponse(template.render(context, request)) return render(request, ‘polls/index.html’, context) * context is a dictionary polls/templates/polls/detail.html Raising 404 get_object_or_404() Template system Tags: if, for, url 使用API操作数据库 python manage.py shell 数据显示为Object 在models.py中使用__str__方法: def __str__(self): return self.textField 这个很重要,这不仅帮助在shell中显示,同时也帮助在数据库管理后台的显示优化。 增加自定义方法 polls/models.py 使用Django数据库后台 创建管理员用户 python manage.py createsuperuser 将子应用模型注册到数据库后台中 polls/admin.py …

Django 学习 Read More »