2
Greetings to you all. I’m having trouble creating the tables for my apps by Django. I run the PYTHON MANAGE.PY MAKEMIGRATIONS command and it responds: NO CHANGES DETECTED. Then I run the PYTHON MANAGE.PY MIGRATE command and it responds: NO MIGRATIONS TO APPLY.
It’s just not creating the tables I need.
What I’ve already tried:
- Delete Django tables in the database;
- Erase the database and recreate it using Mysql Workbench.
My code in models.py:
class Cliente(models.Model):
nome = models.CharField(max_length=100, unique=True)
slug_c = models.SlugField(blank=True, unique=True)
cpf_cnpj = models.CharField(verbose_name="CPF/CNPJ", max_length=18, unique=True)
email = models.EmailField(unique=True)
fone = models.CharField(verbose_name="Telefone fixo", max_length=25, blank=True)
celular = models.CharField(max_length=25)
endereco = models.CharField(verbose_name="Endereço", max_length=200, blank=True)
numero = models.CharField(verbose_name="nº", max_length=7, blank=True)
compl = models.CharField(verbose_name="Complemento", max_length=50, blank=True)
bairro = models.CharField(max_length=25, blank=True)
cidade = models.CharField(max_length=50, blank=True)
estado = models.CharField(max_length=2, blank=True)
cep = models.CharField(max_length=10, blank=True)
objects = ClienteMan()
class Meta:
verbose_name_plural = "Clientes"
def __str__(self):
return self.nome
class Obra(models.Model):
nomeid = models.ForeignKey(Cliente, to_field="nome", verbose_name="ID Cliente", on_delete=models.DO_NOTHING)
titulo = models.CharField(verbose_name="Título", max_length=200, unique=True)
slug_o = models.SlugField(blank=True, unique=True)
tipo_obra = models.CharField(verbose_name="Tipo de obra", max_length=50)
endereco = models.CharField(verbose_name="Endereço", max_length=200)
numero = models.CharField(verbose_name="nº", max_length=7)
compl = models.CharField(verbose_name="Complemento", max_length=50, blank=True)
bairro = models.CharField(max_length=25)
cidade = models.CharField(max_length=50)
estado = models.CharField(max_length=2)
cep = models.CharField(max_length=10)
obs = models.TextField(verbose_name="observações", blank=True)
objects = ObraMan()
class Meta:
verbose_name_plural = "Obras"
def __str__(self):
return self.titulo
class Diario(models.Model):
obraid = models.ForeignKey(Obra, verbose_name="Obra", on_delete=models.DO_NOTHING)
data = models.DateTimeField(blank=False, null=False)
slug_d = models.SlugField(blank=True, unique=True)
imagem = models.ImageField(upload_to='diarios/', null=True, blank=True)
arquivo = models.FileField(upload_to='diarios/', null=True, blank=True)
descricao = models.TextField(verbose_name="descrição", blank=True)
objects = DiarioMan()
class Meta:
verbose_name = "Diário"
def __str__(self):
return self.data.strftime('%d/%m/%Y')
Thanks so much for your help.
To resolve this issue, remove the contents from the folder
migrations
leaving only the file__init__.py
. For each of the apps that is having this problem. Do not run this procedure in production.– Danizavtz
Briefcase Migrations application is empty. I tried to run the commands again and the problem persists.
– HPaz
That’s the problem, you have to have the file
__init__.py
– Danizavtz
IT WORKED!!! Thank you very much plea your help! I created a blank file with the name of
__init__.py
inside the briefcasemigrations
from my app and rotated the makemigrations commands again and then migrate. It worked perfectly.– HPaz