**** Я использую Python v3.7 для создания веб-сайта с использованием Django Framework.
Я мог бы хорошо запустить веб-сервер. Но когда я попытался выполнить миграцию базы данных, запустив эту команду: python3 manage.py makemigrations
, возникает ошибка: ****
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\yangyj\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\core\management\__init__.py", line 371, in execute_from_command_line
utility.execute()
File "C:\Users\yangyj\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\core\management\__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\yangyj\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\core\management\base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\yangyj\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\core\management\base.py", line 335, in execute
output = self.handle(*args, **options)
File "C:\Users\yangyj\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\core\management\commands\makemigrations.py", line 132, in handle
loader.project_state(),
File "C:\Users\yangyj\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\db\migrations\loader.py", line 316, in project_state
return self.graph.make_state(nodes=nodes, at_end=at_end, real_apps=list(self
.unmigrated_apps))
File "C:\Users\yangyj\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\db\migrations\graph.py", line 376, in make_state
project_state = self.nodes[node].mutate_state(project_state, preserve=False)
File "C:\Users\yangyj\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\db\migrations\migration.py", line 85, in mutate_state
operation.state_forwards(self.app_label, new_state)
File "C:\Users\yangyj\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\db\migrations\operations\fields.py", line 144, in state_forwards
delay = not old_field.is_relation
AttributeError: 'NoneType' object has no attribute 'is_relation'
Код models.py
:
from __future__ import unicode_literals
from django.db import models
from django.urls import reverse #Used to generate urls by reversing the URL patterns
from django.utils.html import format_html
from django.urls import reverse
from django.conf.urls import url
from .forms import *
from django.http import HttpResponseRedirect
from django.template.response import TemplateResponse
from getsqlite import *
from django.db import models
from django.contrib import admin
from django.contrib.auth.models import User
class FW(models.Model):
ODM_name = models.CharField(max_length=20)
project_name = models.CharField(max_length=20)
NAP = models.CharField(max_length=4)
UAP = models.CharField(max_length=2)
LAP = models.CharField(max_length=6)
num_address = models.CharField(max_length=4)
download = models.CharField(max_length=1000, blank=True)
#level = models.CharField(max_length=10)
#sg_sz = models.CharField(max_length=10)
approve_time = models.DateField(null=True, blank=True)
applier = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True)
APPROVE_STATUS = (
('a', 'approved'),
('d', 'disapproved'),
)
status = models.CharField(max_length=1, choices=APPROVE_STATUS, blank=True, default='d', help_text='FW APPROVE_STATUS')
@property
def is_approved(self):
if self.status == 'a':
return True
return False
class Meta:
ordering = ["approve_time"]
permissions = (("can_mark_used", "Set FW as used"),)
def __str__(self):
"""
String for representing the Model object.
"""
#return '%s (%s)' % (self.id,self.FW.title)
return '{0} ({1})'.format(self.id,self.FW.title)
def display_project(self):
"""
Creates a string for the project. This is required to display project in Admin.
"""
return ', '.join([ project.name for project in self.project.all()[:3] ])
display_project.short_description = 'project'
def get_absolute_url(self):
"""
Returns the url to access a particular FW instance.
"""
return reverse('FW-detail', args=[str(self.id)])
def __str__(self):
"""
String for representing the Model object.
"""
return self.project_name
def call_exe(self):
try:
when_call_exe()
except:
return None
#class UserAdmin(admin.ModelAdmin):
#list_display = ('ODM_name', 'project_name', 'NAP', 'UAP', 'LAP', 'num_address')
#admin.site.register(FW, UserAdmin)
import uuid # Required for unique FW instances
from datetime import date
from django.db import models
from django.contrib import admin
class FW_INSTANCE(models.Model):
ODM_name = models.CharField(max_length=20)
project_name = models.CharField(max_length=20)
NAP = models.CharField(max_length=4)
UAP = models.CharField(max_length=2)
LAP = models.CharField(max_length=6)
level = models.CharField(max_length=10)
sg_sz = models.CharField(max_length=10)
Как я могу справиться с этой проблемой? Когда я использую свой предыдущий, он может работать хорошо. Но после смены нового компьютера возникает эта ошибка.