In any field that is a ForeignKey you now have to add "on_delete = ???" (there are a number of options to replace the ???).

See the last line of the error message as it shows you the file and line number of where the error is.


On Friday, 06 July, 2018 07:13 PM, Umar Kambala wrote:
please this the error i got when i run python manage.py makemigrations

 File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 347, in execute
    django.setup()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\registry.py", line 112, in populate
    app_config.import_models()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\config.py", line 198, in import_models
    self.models_module = import_module(models_module_name)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed   File "C:\Users\Admin\Desktop\Django Web\myproject\boards\models.py", line 10, in <module>
    class Topic (models.Model):
  File "C:\Users\Admin\Desktop\Django Web\myproject\boards\models.py", line 13, in Topic
    board = models.ForeignKey(Board, related_name='topics')
TypeError: __init__() missing 1 required positional argument: 'on_delete'


this are the codes

from django.dbimport models
from django.contrib.auth.modelsimport User


class Board(models.Model):
     name = models.CharField(max_length=30, unique=True)
     description = models.CharField(max_length=100)


class Topic (models.Model):
     subject = models.CharField(max_length=255)
     last_updated = models.DateTimeField()
     board = models.ForeignKey(Board, related_name='topics')
     starter = models.ForeignKey(User, related_name='topics')


class Post(models.Model):
     message = models.TextField(max_length=4000)
     topic = models.ForeignKey(Topic, related_name='posts')
     created_at = models.DateTimeField(auto_now_add=True)
     updated_at = models.DateTimeField(null=True)
     created_by = models.ForeignKey(User, related_name='posts')
     updated_by = models.ForeignKey(User, null=True, related_name='+')

--
You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto:django-users@googlegroups.com>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPkbFbaHq8Mgz_ZLnmC1EWQmT7FodSbEaWnd7buTcRR85aYTSg%40mail.gmail.com <https://groups.google.com/d/msgid/django-users/CAPkbFbaHq8Mgz_ZLnmC1EWQmT7FodSbEaWnd7buTcRR85aYTSg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ec3324f6-1cdf-c892-754c-094a6823ada2%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to