Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

Erro ao executar comando python manage.py makemigrations

Toda vez que tento executar a migração aparece esse erro, tô quase desistindo já de fazer o curso.

(venv) C:\aplicacao>python manage.py makemigrations Traceback (most recent call last): File "manage.py", line 22, in main() File "manage.py", line 18, in main execute_from_command_line(sys.argv) File "C:\Users\iagoa\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management_init__.py", line 401, in executefrom_command_line utility.execute() File "C:\Users\iagoa\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management_init__.py", line 377, in execute django.setup() File "C:\Users\iagoa\AppData\Local\Programs\Python\Python37\lib\site-packages\django_init_.py", line 24, in setup apps.populate(settings.INSTALLEDAPPS) File "C:\Users\iagoa\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\registry.py", line 114, in populate app_config.import_models() File "C:\Users\iagoa\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\config.py", line 211, in import_models self.models_module = import_module(models_module_name) File "C:\Users\iagoa\AppData\Local\Programs\Python\Python37\lib\importlib_init__.py", line 127, in importmodule return bootstrap.gcd_import(name[level:], package, level) File "", line 1006, in gcdimport File "", line 983, in findand_load File "", line 967, in findand_load_unlocked File "", line 677, in loadunlocked File "", line 728, in exec_module File "", line 219, in callwith_frames_removed File "C:\aplicacao\receitas\models.py", line 6, in class Receita(models.Model): File "C:\aplicacao\receitas\models.py", line 7, in Receita nome_receita = models.CharField(max_lenght=200) File "C:\Users\iagoa\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\fields_init__.py", line 986, in init super().init(args, *kwargs) TypeError: init() got an unexpected keyword argument 'maxlenght'

(venv) C:\aplicacao>python manage.py makemigrations Traceback (most recent call last): File "manage.py", line 22, in main() File "manage.py", line 18, in main execute_from_command_line(sys.argv) File "C:\Users\iagoa\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management_init__.py", line 401, in executefrom_command_line utility.execute() File "C:\Users\iagoa\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management_init__.py", line 377, in execute django.setup() File "C:\Users\iagoa\AppData\Local\Programs\Python\Python37\lib\site-packages\django_init_.py", line 24, in setup apps.populate(settings.INSTALLEDAPPS) File "C:\Users\iagoa\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\registry.py", line 114, in populate app_config.import_models() File "C:\Users\iagoa\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\config.py", line 211, in import_models self.models_module = import_module(models_module_name) File "C:\Users\iagoa\AppData\Local\Programs\Python\Python37\lib\importlib_init__.py", line 127, in importmodule return bootstrap.gcd_import(name[level:], package, level) File "", line 1006, in gcdimport File "", line 983, in findand_load File "", line 967, in findand_load_unlocked File "", line 677, in loadunlocked File "", line 728, in exec_module File "", line 219, in callwith_frames_removed File "C:\aplicacao\receitas\models.py", line 6, in class Receita(models.Model): File "C:\aplicacao\receitas\models.py", line 7, in Receita nome_receita = models.CharField(max_lenght=200) File "C:\Users\iagoa\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\fields_init__.py", line 986, in init super().init(args, *kwargs) TypeError: init() got an unexpected keyword argument 'maxlenght'

Codigo do models.py

from django.db import models from datetime import datetime

class Receita(models.Model): nome_receita = models.CharField(max_lenght = 200) ingredientes = models.TextField() modo_preparo = models.TextField() tempo_preparo = models.IntegerField() rendimento = models.CharField(max_lenght = 100) categoria = models.CharField(max_lenght= 100 ) date_receita = models.DateTimeField(default=datetime.now, blank=True)

2 respostas
solução!

Grande Iago! Como vai?

Esses erros são comuns, fique tranquilo. Vou tentar te ajudar, tá bom?

Aparentemente é erro de sintaxe, pois você escreveu: max_lenght, porém, o correto é: max_length. Altere isso em todos os campos e tente compilar novamente.

Código alterado:

class Receita(models.Model):
    nome_receita = models.CharField(max_length=200)
    ingredientes = models.TextField()
    modo_preparo = models.TextField()
    tempo_preparo = models.IntegerField()
    rendimento = models.CharField(max_length=100)
    categoria = models.CharField(max_length=100)
    data_receita = models.DateTimeField(default=datetime.now, blank=True)

Fico no aguardo.

Qualquer dúvida estou por aqui.

Abraços e bons estudos!

Meu Deus, não acredito que era só isso... Desculpa por isso, muito obrigado!!!