小编Leo*_*123的帖子

如何修复 Field 定义了与模型“auth.User”的关系,该模型已被换出

我正在尝试将我的用户模型更改为自定义模型。我不介意删除我的数据库并只使用一个新数据库,但是当我尝试运行 makemigrations 时,我收到此错误

bookings.Session.session_client: (fields.E301) Field defines a relation with the model 'auth.User', which has been swapped out.
        HINT: Update the relation to point at 'settings.AUTH_USER_MODEL'.
Run Code Online (Sandbox Code Playgroud)

预订/views.py

from django.shortcuts import render, get_object_or_404
from django.http import HttpResponse, HttpResponseRedirect
from bookings.models import Session
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User

# Create your views here.

def book(request, Session_id):
    lesson = get_object_or_404(Session, pk=Session_id)
    try:
        client = request.user.id
    except (KeyError, Choice.DoesNotExist):
        return render(request, 'booking/details.html', {
            'lesson': lesson,
            'error_message': "You need to login first", …
Run Code Online (Sandbox Code Playgroud)

python django

6
推荐指数
3
解决办法
7208
查看次数

标签 统计

django ×1

python ×1