小编lef*_*oud的帖子

Djoser 用户激活电子邮件 POST 示例

我正在使用 Django rest 框架和 Djoser 进行身份验证和用户注册。

当新用户注册时,Djoser 会发送一封包含执行 GET 请求链接的激活电子邮件。为了激活,我需要从激活 URL 中提取 uid 和令牌,并向 Djoser 发出 POST 请求,以便能够激活用户。

我的环境是 Python 3 和 Django 1.11,Djoser 1.0.1。

我想做的是在Django中处理get请求,提取uid和token,然后进行POST请求。我已经提取了 uid 和令牌,并希望进行 POST(在此 GET 请求中)。我不知道如何在后台发出这个 POST 请求。

我的网址是这样的:

http://127.0.0.1:8000/auth/users/activate/MQ/4qu-584cc6772dd62a3757ee
Run Code Online (Sandbox Code Playgroud)

当我在电子邮件中单击它时,它会发出一个 GET 请求。

我在 Django 视图中处理这个。

视图需要发出这样的 POST 请求:

http://127.0.0.1:8000/auth/users/activate/

data= [(‘uid’=‘MQ’), (‘token’=‘4qu-584cc6772dd62a3757ee’),]
Run Code Online (Sandbox Code Playgroud)

我处理 GET 的观点是:

http://127.0.0.1:8000/auth/users/activate/MQ/4qu-584cc6772dd62a3757ee
Run Code Online (Sandbox Code Playgroud)

python django django-rest-framework djoser

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

Django oauth 工具包:迁移给出类型错误 - 入门教程

我正在尝试遵循以下django oauth工具包的入门教程:

https://django-oauth-toolkit.readthedocs.io/en/latest/rest-framework/getting_started.html

当我运行时migrate,我收到此错误:

文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/backends/base/schema.py”,第 1003 行,在 _constraint_names 中(如果 type_ 不是 None 和 infodict) ['类型'] != type_: KeyError: '类型'

任何帮助,将不胜感激。

完整的堆栈跟踪

Operations to perform:
  Apply all migrations: admin, auth, contenttypes, oauth2_provider, sessions
Running migrations:
  Applying oauth2_provider.0004_auto_20160525_1623...Traceback (most recent call last):
  File "/Users/lr/lrapp1/manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
    output …
Run Code Online (Sandbox Code Playgroud)

python django-rest-framework django-oauth

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