1
所以我試圖創建一個自定義管理器來擴展默認的管理器,並且我得到一個錯誤,對於我來說我無法修復。我讀過所有的django文檔,看不到我做錯了什麼!/name'article_finish_date'處的名稱錯誤未定義
錯誤:
NameError at/
name 'article_finish_date' is not defined
這裏是我的models.py
import datetime
from django.conf import settings
from django.db import models
from django.utils import timezone
from django.contrib.auth.models import User
class ArticleManager(models.Manager):
def get_queryset(self):
return super(ArticleManager, self).get_queryset().filter(article_finish_date==None)
class Article(models.Model):
article_name_text = models.CharField(max_length=200)
article_creation_date = models.DateTimeField('date created')
article_publish_date = models.DateTimeField('date published', null=True, blank=True)
article_finish_date = models.DateTimeField('date finished', null=True, blank=True)
def __str__(self):
return self.article_name_text
actives = ArticleManager()
我已經在文章模型的所有不同的值試過的過濾,但是出現了同樣的問題。我嘗試了遷移和遷移,但是沒有取得任何進展。
非常感謝提前,問你是否需要更多的細節!
它適用於我。確保你沒有其他問題。也許刪除* .pyc文件並重新啓動環境。 – Selcuk