我試圖擴展Django應用程序的用戶模型中的現有用戶模式,但我不斷收到錯誤:在/管理/認證/用戶
OperationalError/3/
異常值:沒有這樣的列:subjects_subject.user_id擴展在Django 1.7
我的代碼:
#subjects/models.py
from django.contrib.auth.models import User
from django.db import models
class Subject(models.Model):
user = models.OneToOneField(User)
description = models.CharField(max_length=100)
models.signals.post_save
#_admin/admin.py
from django.contrib.auth.models import User, Group
from django.contrib.auth.admin import UserAdmin, GroupAdmin
from .extended_admin import new_admin
from django.contrib import admin
from subjects.models import Subject
class SubjectInline(admin.StackedInline):
model = Subject
can_delete = False
verbose_name_plural = 'subject'
class UserAdmin(UserAdmin):
inlines = (SubjectInline,)
new_admin.register(User, UserAdmin)
new_admin.register(Group, GroupAdmin)
我幾乎一字不差地複製了Django自己的documentation。任何幫助真的會很感激!
編輯: 我還想說,我已經跑了syndb
和flush
您是否運行遷移? – dgel 2014-11-07 02:47:52
你添加了'user'字段_after_進行初始syncdb/migrate嗎?如果是這樣,您可能需要運行['makemigrations'](https://docs.djangoproject.com/en/dev/ref/django-admin/#makemigrations-app-label) – karthikr 2014-11-07 02:48:15
我已經跑過'makemigrations' – Wallace 2014-11-07 02:50:06