Python django 1.11未检测到任何更改
您好,我在django迁移中遇到了一个问题,我已经在“connection”应用程序的model.py中创建了一个模型类,但是我的ubantu 14.04终端在运行“python manage.py makemigrations”时仍然说没有检测到任何更改,我也在上面的命令中指定了应用程序名称,但没有起作用。请帮帮我。谢谢 以下是我的迁移:Python django 1.11未检测到任何更改,python,django,django-models,Python,Django,Django Models,您好,我在django迁移中遇到了一个问题,我已经在“connection”应用程序的model.py中创建了一个模型类,但是我的ubantu 14.04终端在运行“python manage.py makemigrations”时仍然说没有检测到任何更改,我也在上面的命令中指定了应用程序名称,但没有起作用。请帮帮我。谢谢 以下是我的迁移: admin [X] 0001_initial [X] 0002_logentry_remove_auto_add analytics (no migr
admin
[X] 0001_initial
[X] 0002_logentry_remove_auto_add
analytics
(no migrations)
auth
[X] 0001_initial
[X] 0002_alter_permission_name_max_length
[X] 0003_alter_user_email_max_length
[X] 0004_alter_user_username_opts
[X] 0005_alter_user_last_login_null
[X] 0006_require_contenttypes_0002
[X] 0007_alter_validators_add_error_messages
[X] 0008_alter_user_username_max_length
connection
[X] 0001_initial
contenttypes
[X] 0001_initial
[X] 0002_remove_content_type_name
reports
(no migrations)
sessions
[X] 0001_initial
是否还有其他要求,请在评论中询问
这是我想通过connection app的model.py文件添加到db中的表
class BModel(models.Model):
user = models.ForeignKey(User, related_name="reports_user")
dataset = models.ForeignKey(DatasetRecord, related_name="dataset_record")
name = models.CharField(max_length=100)
created_date = models.DateTimeField(default=timezone.now, blank=True, null=True)
updated_date = models.DateTimeField(default=timezone.now)
def __unicode__(self):
return '%s' % self.id
class Meta:
app_label = 'daas'
下面是model.py文件代码
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.utils import timezone
from django.db import models
from daas.models import *
# Create your models here.
#on_delete=models.DO_NOTHING,
class Dbconnection(models.Model):
user = models.ForeignKey(User, related_name="db_user")
hostname = models.CharField(max_length=50)
port = models.CharField(max_length=10,default=3306)
dbname = models.CharField(max_length=50)
dbuser = models.CharField(max_length=50)
dbpassword = models.CharField(max_length=50)
connection_type = models.CharField(max_length=50)
connection_name = models.CharField(max_length=50)
def __unicode__(self):
return '%s' % self.id
class Meta:
app_label = 'daas'
class DatasetRecord(models.Model):
user = models.ForeignKey(User, related_name="dataset_user")
dataset = models.CharField(max_length=50)
sqlquery = models.TextField()
connection = models.ForeignKey(Dbconnection, related_name="db_connection")
created_date = models.DateTimeField(default=timezone.now, blank=True, null=True)
updated_date = models.DateTimeField(default=timezone.now)
def __unicode__(self):
return '%s' % self.id
class Meta:
app_label = 'daas'
class Reports(models.Model):
user = models.ForeignKey(User, related_name="reports_user")
dataset = models.ForeignKey(DatasetRecord, related_name="dataset_record")
row_dimension = models.TextField()
col_metrics = models.TextField()
report_type = models.CharField(max_length=50)
status = models.CharField(max_length=50)
report_name = models.CharField(max_length=100)
custom_data = models.TextField()
query_json = models.TextField()
created_date = models.DateTimeField(default=timezone.now, blank=True, null=True)
updated_date = models.DateTimeField(default=timezone.now)
def __unicode__(self):
return '%s' % self.id
class Meta:
app_label = 'daas'
class CustomDashboard(models.Model):
user = models.ForeignKey(User, related_name="daas_userdashboard")
dashboard_name = models.TextField()
created_date = models.DateTimeField(default=timezone.now, blank=True, null=True)
updated_date = models.DateTimeField(default=timezone.now)
def __unicode__(self):
return '%s' % self.id
class Meta:
app_label = 'daas'
class CustomDashboardReport(models.Model):
customdashboard = models.ForeignKey(CustomDashboard, related_name="daas_customdashboardreport")
report = models.ForeignKey(Reports, related_name="Reports_daas_customdashboardreport")
report_title = models.TextField()
custom_data = models.TextField()
created_date = models.DateTimeField(default=timezone.now, blank=True, null=True)
updated_date = models.DateTimeField(default=timezone.now)
class Meta:
app_label = 'daas'
class Dashboard_Drill_Report(models.Model):
user = models.ForeignKey(User, related_name="daas_dashboarddrillreport")
customdashboard = models.ForeignKey(CustomDashboard, related_name="daas_dashboarddrillreport")
parent_report = models.ForeignKey(Reports, related_name="parentreports_daas_dashboarddrillreport")
child_report = models.ForeignKey(Reports, related_name="childreports_daas_dashboarddrillreport")
canvas_id = models.TextField()
created_date = models.DateTimeField(default=timezone.now, blank=True, null=True)
updated_date = models.DateTimeField(default=timezone.now)
class Meta:
app_label = 'daas'
class SalesMetadata(models.Model):
id = models.AutoField(primary_key=True)
column_name = models.CharField(max_length=255)
data_type = models.CharField(max_length=255, blank=True, null=True)
identifier = models.CharField(max_length=45, blank=True, null=True)
definition = models.CharField(max_length=255, blank=True, null=True)
aggregation = models.CharField(max_length=50, blank=True, null=True)
table_name = models.CharField(max_length=50, blank=True, null=True)
type = models.CharField(max_length=45, blank=True, null=True)
class Meta:
managed = False
db_table = 'sales_metadata'
class SalesMetadataDemo(models.Model):
id = models.AutoField(primary_key=True)
column_name = models.CharField(max_length=255)
data_type = models.CharField(max_length=255, blank=True, null=True)
identifier = models.CharField(max_length=45, blank=True, null=True)
definition = models.CharField(max_length=255, blank=True, null=True)
aggregation = models.CharField(max_length=50, blank=True, null=True)
table_name = models.CharField(max_length=50, blank=True, null=True)
type = models.CharField(max_length=45, blank=True, null=True)
class Meta:
managed = False
db_table = 'sales_metadata_demo'
class FactOrderDemo(models.Model):
business_date = models.IntegerField(db_column='Business_Date', blank=True, null=True) # Field name made lowercase.
product = models.CharField(db_column='Product', max_length=250, blank=True, null=True) # Field name made lowercase.
brand = models.CharField(db_column='Brand', max_length=50, blank=True, null=True) # Field name made lowercase.
category = models.CharField(db_column='Category', max_length=100, blank=True, null=True)
channel = models.CharField(db_column='Channel', max_length=50, blank=True, null=True) # Field name made lowercase.
payment_method = models.CharField(db_column='Payment_Method', max_length=50, blank=True, null=True) # Field name made lowercase.
city = models.CharField(db_column='City', max_length=200, blank=True, null=True) # Field name made lowercase.
state = models.CharField(db_column='State', max_length=200, blank=True, null=True) # Field name made lowercase.
sales = models.DecimalField(db_column='Sales', max_digits=34, decimal_places=3, blank=True, null=True) # Field name made lowercase.
discount = models.DecimalField(db_column='Discount', max_digits=34, decimal_places=4, blank=True, null=True) # Field name made lowercase.
cancellations = models.DecimalField(db_column='Cancellations', max_digits=34, decimal_places=4) # Field name made lowercase.
total_orders = models.BigIntegerField(db_column='Total_Orders') # Field name made lowercase.
returns = models.CharField(db_column='Returns', max_length=200, blank=True, null=True) # Field name made lowercase.
class Meta:
managed = False
db_table = 'fact_order_demo'
#unique_together = (('business_date', 'product', 'category', 'promotion', 'channel', 'payment_method', 'city', 'state', 'country'),)
请帮助我,我正在使用python verison 3.4.3和django 1.11版您需要将app_标签更改为您在安装的apps inside settings.py中添加的app的名称 应用程序标签='连接' 参考:
对于“但我仍然很困惑,我所有的东西都是用app_label='daas'运行的文件,并且创建了others表,但是为什么这次它不运行”的回答可能是“如果在已安装的app中的应用程序之外定义了一个模型,那么它必须声明它属于哪个应用程序”在我看到实际的应用程序之前不确定。还有其他需要解决的问题吗?请发表评论。确保您已在已安装的应用程序中添加了
连接应用程序已添加了它可以添加您的settings.py文件来问问题应用程序标签='daas'有什么问题吗?
?据我从迁移输出中看到的,您的应用程序标签应该是connection
。