小编gji*_*nya的帖子

会话数据在django中被破坏

每次当我去我的注册页面时,我都会收到此错误

Session data corrupted
Run Code Online (Sandbox Code Playgroud)

当我正在尝试注册时,POST请求状态为302,但仍然创建了用户,但没有将任何电子邮件保存到注册用户.

为什么我收到该错误,我该如何解决?

谢谢!

python django session

12
推荐指数
2
解决办法
4614
查看次数

nginx: [警告] 0.0.0.0:80 上的冲突服务器名称“example.com”,被忽略

当我尝试重新启动 nginx 时,出现以下错误

nginx: [warn] conflicting server name "example.io" on 0.0.0.0:80, ignored
Run Code Online (Sandbox Code Playgroud)

我使用我的部署脚本来为 2 个域进行部署。对于第一个,它工作正常,但对于第二个,它会出错。

这是我的 nginx.conf 文件

#
worker_processes 2;

#
user nginx nginx;

#
pid /opt/nginx/pids/nginx.pid;
error_log /opt/nginx/logs/error.log;

#
events {
    worker_connections  4096;
}

#
http {
    #
    log_format full_log '$remote_addr - $remote_user $request_time $upstream_response_time '
                        '[$time_local] "$request" $status $body_bytes_sent $request_body "$http_referer" '
                        '"$http_user_agent" "$http_x_forwarded_for"';

    #
    access_log  /opt/nginx/logs/access.log;

    ssl on;
    ssl_certificate /opt/nginx/cert/example.crt;
    ssl_certificate_key /opt/nginx/cert/example.key;

    #
    include /opt/nginx/conf/vhosts/*.conf;

    # Deny access to any other host
    server {
        server_name example.io; …
Run Code Online (Sandbox Code Playgroud)

python deployment django nginx

6
推荐指数
1
解决办法
2万
查看次数

Django 发布请求数据

我有以下 POST 请求

curl -v --dump-header --H "Content-Type: application/json" -X POST --data '{"name": "John", "age": 27}' "http://localhost:8300/api/v1/create_contact?username=gegham&api_key=3efc6df6023534279d2183a696044a8cfec964a9"
Run Code Online (Sandbox Code Playgroud)

我打印 request.POST 后的结果是

POST:<QueryDict: {u'{"name": "John", "age": 27}': [u'']}>
Run Code Online (Sandbox Code Playgroud)

但不是

POST: <QueryDict: {u'name': [u'John'], u'age': [u'27']}>
Run Code Online (Sandbox Code Playgroud)

所以,我不能将它用作字典并通过键获取值。为什么 POST 数据格式与平常不同??

python django curl django-models

1
推荐指数
1
解决办法
1941
查看次数

标签 统计

django ×3

python ×3

curl ×1

deployment ×1

django-models ×1

nginx ×1

session ×1