简体   繁体   English

我执行Python manage.py makemigrations和迁移时未检测到更改

[英]No changes detected when i excute Python manage.py makemigrations and migrate

I tried to make migration using python manage.py migrations tithe but nothing is detected. 我尝试使用python manage.py migrations tithe进行迁移,但未检测到任何东西。 I have even changed my database to postgres, but nothing has changed. 我什至将数据库更改为postgres,但没有任何改变。 Even python manage.py migrate is not working. 甚至python manage.py migrate也无法正常工作。 What could be the problem? 可能是什么问题呢?

@localhost church]$ python manage.py migrate tithe
Operations to perform:
  Apply all migrations: (none)
Running migrations:
  No migrations to apply.

this is my model.py code 这是我的model.py代码

from __future__ import unicode_literals
from django.utils import timezone
from django.contrib.auth.models import User
from django.conf import settings
from django.contrib.auth import get_user_model
from django.core.signals import setting_changed
from django.dispatch import receiver
from django.db import models

# Create your models here.
class tithe(models.Model):
    member_code = models.ForeignKey(settings.AUTH_USER_MODEL)
    member = models.CharField(max_length=45)
    receipt_code = models.CharField(max_length=45, unique=True)
    tithes = models.IntegerField()
    combinedoffering = models.IntegerField()
    campmeetingoffering = models.IntegerField()
    churchbuilding = models.IntegerField()
    conference = models.IntegerField()
    localchurch = models.IntegerField()
    funds = models.IntegerField()
    total = models.IntegerField()
    created_date = models.DateTimeField(
            default=timezone.now)
    published_date = models.DateTimeField(
            blank=True, null=True)

    def publish(self):
        self.published_date = timezone.now()
        self.save()

    def __str__(self):
        return self.receitcode

    class Meta:
        abstract = True

the program works by removing abstract = True in the class meta.after removing it when i run python manage.py makemigrations tithe and python manage.py migrate tithe it works wells 该程序通过在类meta中删除abstract = True 。在我运行python manage.py makemigrations tithepython manage.py migrate tithe python manage.py makemigrations tithe一税后将其删除

from __future__ import unicode_literals
from django.utils import timezone
from django.contrib.auth.models import User
from django.conf import settings
from django.contrib.auth import get_user_model
from django.core.signals import setting_changed
from django.dispatch import receiver
from django.db import models

# Create your models here.
class tithe(models.Model):
    member_code = models.ForeignKey(settings.AUTH_USER_MODEL)
    member = models.CharField(max_length=45)
    receipt_code = models.CharField(max_length=45, unique=True)
    tithes = models.IntegerField()
    combinedoffering = models.IntegerField()
    campmeetingoffering = models.IntegerField()
    churchbuilding = models.IntegerField()
    conference = models.IntegerField()
    localchurch = models.IntegerField()
    funds = models.IntegerField()
    total = models.IntegerField()
    created_date = models.DateTimeField(
            default=timezone.now)
    published_date = models.DateTimeField(
            blank=True, null=True)

    def publish(self):
        self.published_date = timezone.now()
        self.save()

    def __str__(self):
        return self.receitcode

    class Meta:
        unique_together = ["receipt_code"]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 python manage.py makemigrations:未检测到更改 - python manage.py makemigrations : No changes detected python manage.py makemigrations给出没有检测到变化? - python manage.py makemigrations gives No changes detected? python manage.py makemigrations博客未在应用“博客”中返回未检测到的更改 - python manage.py makemigrations blog returns no changes detected in app 'blog' 无法使用Python的manage.py makemigrations迁移数据库 - Not able to migrate DB, using Python's manage.py makemigrations manage.py makemigrations有效,但manage.py migration无效 - manage.py makemigrations works but manage.py migrate did not 当我在models.py中的python django中运行此命令python manage.py makemigrations博客时出错 - Error when I run this command python manage.py makemigrations blog in python django in models.py 无法从源/py manage.py makemigrations 解析导入“django.db.models”未检测到更改 - Import "django.db.models" could not be resolved from source / py manage.py makemigrations No changes detected python manage.py迁移时发生TypeError - TypeError when python manage.py migrate manage.py (python manage.py makemigrations) 错误 - manage.py (python manage.py makemigrations) Error 当我运行 python manage.py makemigrations 时出现此错误 - I have got this error when i run python manage.py makemigrations
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM