【发布时间】:2015-12-19 19:52:53
【问题描述】:
我正在使用 Django REST 框架设置一个新的 API,我需要向所有现有用户添加 Auth 令牌。文档说要做:
from django.contrib.auth.models import User
from rest_framework.authtoken.models import Token
for user in User.objects.all():
Token.objects.get_or_create(user=user)
但理想情况下,这应该使用 Django 的新迁移框架来实现。
有没有简单的方法可以做到这一点?
【问题讨论】:
标签: django django-rest-framework django-migrations http-token-authentication