
django
文章平均质量分 57
vivian_wanjin
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
django 数据库迁移(migrate)
首先数据库迁移的两大命令:python manage.py makemigrations & python manage.py migrate前者是将model层转为迁移文件migration,后者将新版本的迁移文件执行,更新数据库。这两中命令调用默认为全局,即对所有最新更改的model或迁移文件进行操作。如果想对部分app进行操作,就要在其后追加app name:$ python...转载 2018-11-09 09:52:35 · 31381 阅读 · 0 评论 -
django_blog_error
django 兼容mysql数据库配置文件写错了原创 2018-12-05 11:37:57 · 155 阅读 · 0 评论 -
框架重写, django注册的执行顺序
继承的调用重写框架的类,如果想被框架调用,需要在设置文件中配置重写的类如果是自己调用这不需要设置例如import refrom django.contrib.auth.backends import ModelBackendfrom users.models import Userdef jwt_response_payload_handler(token, user=None...原创 2018-11-19 21:27:13 · 380 阅读 · 0 评论 -
options
HTTP 的 OPTIONS 方法 用于获取目的资源所支持的通信选项。客户端可以对特定的 URL 使用 OPTIONS 方法,也可以对整站(通过将 URL 设置为“*”)使用该方法。Request has bodyNoSuccessful response has bodyNoSafeYesIdempotentYesCacheableNo...原创 2018-11-19 20:21:48 · 560 阅读 · 0 评论 -
RetrieveAPIView执行顺序
# users/views.pyclass UserDetailView(RetrieveAPIView): """ 获取用户信息 """ serializer_class = UserDetailSerialzier permission_classes = [IsAuthenticated] # 登录后可以查看 # 重写generics/...原创 2018-11-22 10:54:25 · 1836 阅读 · 1 评论 -
django_models_fields_types
nullIf True, Django will store empty values as NULL in the database. Default is False.Avoid using null on string-based fields such as CharField and TextField. If a string-based field has null=True, ...原创 2018-11-21 23:31:27 · 294 阅读 · 0 评论 -
Add Indexes (db_index=True)
This is not really django specific; more to do with databases. You add indexes on columns when you want to speed up searches on that column.Typically, only the primary key is indexed by the database....原创 2018-11-21 10:51:14 · 1076 阅读 · 0 评论 -
django.db.models.ForeignKey.on_delete
I’ll go through the values for on_delete as they apply to this case. As it notes in the docs, these are all in that models module, so you’d use it as models.ForeignKey(UserProfile, on_delete=models.CA...原创 2018-11-14 16:23:44 · 540 阅读 · 0 评论 -
assert renderer, '.accept renderer not set on Response'
视图响应了方法写错了,不支h持Response,请使用HttpResponseJsonResponseHttpResponse的子类HttpResponseRedirect 301HttpResponsePermanentRedirect 302HttpResponseNotModified 304HttpResponseBadRequest 400HttpResponseNot...原创 2018-11-12 13:59:35 · 3583 阅读 · 0 评论 -
Django运行方式及处理流程总结
Django运行方式及处理流程总结一 Django运行方式一种是在开发和调试中经常用到的runserver方法,使用django自己的web server第二种使用fastcgi, uWSGIt等协议运行的Django项目1. runserver方法runserver方法是调试Django时经常用到的运行方式,它使用Django自带的WSGI Server运行,主要在测试和开发中使用,使...转载 2018-11-10 21:23:54 · 2009 阅读 · 0 评论 -
Invalid HTTP_HOST header
ProblemsolutionThe error log is straightforward. As it suggested,You need to add 198.211.99.20 to your ALLOWED_HOSTS setting.In your project settings.py file,set ALLOWED_HOSTS like this :ALLOWED_...原创 2018-11-04 21:52:27 · 1050 阅读 · 0 评论 -
Running migrations: No migrations to apply.(django不能创建数据库中的表的问题)
第一步:删除该app名字下的migrations下的__init__.py等文件。第二步:进入数据库,找到django_migrations的表,删除该app名字的所有记录。第三步:执行下面这两条命令:(在项目目录下)python manage.py makemigrationspython manage.py migrate原因:django_migrations表记录着数据...转载 2018-12-03 11:48:59 · 434 阅读 · 2 评论