0
I’m a beginner in the Django platform and the Python language and I’m developing a website in Django 2.2 and Python 3.7.3,
and I have a problem with my code on models.py
from my app "Courses".
class Enrollment(models.Model):
STATUS_CHOICES = (
(0, 'Pendente'),
(1, 'Aprovado'),
(2, 'Cancelado'),
)
user = models.ForeignKey(
settings.AUTH_USER_MODEL, verbose_name='Usuário',
models.CASCADE,
related_name='enrollments'
)
course = models.ForeignKey(
Course, verbose_name='Curso', related_name='enrollments'
)
status = models.IntegerField(
'Situação', choices=STATUS_CHOICES, default=1, blank=True
)
created_at = models.DateTimeField('Criado em', auto_now_add=True)
updated_at = models.DateTimeField('Atualizado em', auto_now=True)
def active(self):
self.status = 1
self.save()
class Meta:
verbose_name = 'Inscrição'
verbose_name_plural = 'Inscrições'
unique_together = (('user', 'course'),)
And you’re making that mistake:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Users\Luciano\ambientes_virtuais\ambientes_virtuais\virtual_01\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\Luciano\ambientes_virtuais\ambientes_virtuais\virtual_01\lib\site-packages\django\core\management\__init__.py", line 357, in execute
django.setup()
File "C:\Users\Luciano\ambientes_virtuais\ambientes_virtuais\virtual_01\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Luciano\ambientes_virtuais\ambientes_virtuais\virtual_01\lib\site-packages\django\apps\registry.py", line 114, in populate
app_config.import_models()
File "C:\Users\Luciano\ambientes_virtuais\ambientes_virtuais\virtual_01\lib\site-packages\django\apps\config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "C:\Users\Luciano\ambientes_virtuais\ambientes_virtuais\virtual_01\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\Luciano\ambientes_virtuais\ConnectU\ConnectU\courses\models.py", line 53, in <module>
class Enrollment(models.Model):
File "C:\Users\Luciano\ambientes_virtuais\ConnectU\ConnectU\courses\models.py", line 67, in Enrollment
Course, verbose_name='Curso', related_name='enrollments'
TypeError: __init__() missing 1 required positional argument: 'on_delete'
What can I do?