-1
from django.db import models

class Topic(models.Model):
    text = models.CharField(max_length=200)
    date_added = models.DateTimeField(auto_now_add=True)


    def _str_(self):
        return self.text
class Entry(models.Model):
    topic = models.ForeignKey(Topic)
    text = models.TextField
    date_added = models.DateTimeField(auto_now_add=True)

    class Meta:
        verbose_name_plural= 'entries'

    def _str_(self):
        return self.text[:50]+"..."

This is my code,When i run:

python3 manage.py makemigrations learning_logs

The answer is :

 TypeError: __init__() missing 1 required positional argument: 'on_delete'

why this warning ? I read the documentation too, but no help.

I_love_python
  • 67
  • 1
  • 2
  • 7
  • Please see this question - https://stackoverflow.com/questions/44026548/getting-typeerror-init-missing-1-required-positional-argument-on-delete – Srinivas Reddy Thatiparthy Dec 21 '17 at 12:57
  • 1
    What's unclear? Both the error message and [the docs](https://docs.djangoproject.com/en/2.0/ref/models/fields/#arguments) are explicit: you need to add the on_delete argument. – Daniel Roseman Dec 21 '17 at 13:04

1 Answers1

2

Yes! Thanks for documention . Now I solved this wranging.

My way is :

on_delete=models.DO_NOTHING
I_love_python
  • 67
  • 1
  • 2
  • 7