[Answered ]-"return self.title</pre>" returns a syntax error django

1👍

Remove the </pre> tag. This tag was (very) likely used to typeset a code fragment, since code fragments are written between <pre> … </pre>, but it is not valid Python code:

class TodoForm(forms.ModelForm):
    class Meta:
        model = Todo
        fields = "__all__"  # ← no </pre>

and for the model:

class Todo(models.Model):
    title = models.CharField(max_length=100)
    details = models.TextField()
    date = models.DateTimeField(default=timezone.now)
    
    def __str__(self):
        return self.title # ← no </pre>

Leave a comment