2
我做了遷移之後,當我嘗試遷移時出現此錯誤。 mathfield安裝在INSTALLED_APPS中。AttributeError:'模塊'對象沒有屬性'MathField'
from django.db import models
from django.utils import timezone
import mathfield
class Post(models.Model):
author = models.ForeignKey('auth.User')
title = models.CharField(max_length=200)
text = models.TextField()
latex = mathfield.MathField(default=timezone.now)
created_date = models.DateTimeField(default=timezone.now)
published_date = models.DateTimeField(
blank=True, null=True)
def publish(self):
self.published_date = timezone.now()
self.save()
def __str__(self):
return self.title
Django的mathfield安裝在我的virtualenv django-mathfield usage 使用默認情況的錯誤,或者如果我允許makemigrations期間一次性默認。
我是在Django 1.8,但降級後,我仍然得到同樣的導入錯誤。我會嘗試別的,看看它是否有效。我使用Python 2.7和Django 1.7。 – Rider