当我执行Python manage.py makemigrations并迁移时,未检测到任何更改

时间:2022-01-11 18:00:38

I tried to make migration using python manage.py migrations tithe but nothing is detected. I have even changed my database to postgres, but nothing has changed. Even python manage.py migrate is not working. What could be the problem?

我试图使用python manage.py迁移tithe进行迁移但没有检测到任何东西。我甚至将我的数据库更改为postgres,但没有任何改变。即使是python manage.py migrate也无法正常工作。可能是什么问题呢?

@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

1 个解决方案

#1


0  

the program works by removing abstract = Truein the class meta.after removing it when i run python manage.py makemigrations tithe and python manage.py migrate tithe it works wells

该程序的工作原理是删除抽象= True在类meta.after运行python manage.py makemigrations tithe和python manage.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:
        unique_together = ["receipt_code"]

#1


0  

the program works by removing abstract = Truein the class meta.after removing it when i run python manage.py makemigrations tithe and python manage.py migrate tithe it works wells

该程序的工作原理是删除抽象= True在类meta.after运行python manage.py makemigrations tithe和python manage.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:
        unique_together = ["receipt_code"]