-5
我似乎無法發現這段代碼有什麼問題。Python語法錯誤
from django.db import models
from django.utils import timezone
from django.contrib.auth.models import user
# Create your models here.
class post(models.Model):
STATUS_CHOICES = (
('draft','Draft'),
('published','Published'),
)
title = models.CharField(max_length=250)
slug = models.SlugField(max_length=250,unique_for_date='publish')
author = models.ForeignKey(User,related_name='blog_posts')
body= models.TextField()
publish = models.DateTimeField(default=timezone.now)
created= models.DatetimeField(auto_now_add=True)
updated= models.DateTimeField(auto_now=True)
status = models.CharField(max_length=10,
choices=STATUS_CHOICES,
default='draft')
class Meta:
ordering = ('-publish',)
def__str__(self):
return self.title
運行時我得到錯誤信息線34
「def__str __(個體經營):」 無效的語法。
冒號似乎是問題,但我不知道爲什麼。
非常感謝。我不相信我沒有看到。 – user331692