Error
Title
Question
I am getting an error
File "/home/sandeep/my-django/mysite/blog/models.py", line 8
(auto_now_add=True)
^
SyntaxError: invalid syntax
Python-Django Creating-Django-Models 04-05 min 0-10 sec
Answers:
Kindly share the complete code for models.py
Please see following code:
-------------------------------------------------------------
from django.db import models
# Create your models here.
class Blog(models.Model):
<span style="white-space:pre">\t</span>name = models.CharField(max_length=120)
<span style="white-space:pre">\t</span>created_on = models.DateTimeField
(auto_now_add=True)
class Article(models.Model):
<span style="white-space:pre">\t</span>blog = models.ForeignKey(Blog,on_delete=models.CASCADE)
<span style="white-space:pre">\t</span>created_on = models.DateTimeField
(auto_now_add=True)
<span style="white-space:pre">\t</span>title = models.CharField(max_length=120)
<span style="white-space:pre">\t</span>body = models.TextField()
<span style="white-space:pre">\t</span>draft = models.BooleanField(default=False)
--------------------------------------------------------------------------
You'll are starting the line with (auto_now_add=True)
which iserror in Python.
There is an error in line continuation.
Continue to write the above code on the same line ....DateTimeFiled(auto_now_add=True)
which iserror in Python.
There is an error in line continuation.
Continue to write the above code on the same line ....DateTimeFiled(auto_now_add=True)
Login to add comment