【问题标题】:Error when deploying django app部署 django 应用程序时出错
【发布时间】:2011-09-17 00:12:26
【问题描述】:

我使用 Django 1.3 构建了一个应用程序,现在正在尝试使用 postgresql 在 linode 上部署到 ubuntu 10.10。我在前端和静态媒体上使用 nginx,并将应用程序请求发送到使用 apache/mod_wsgi 服务的应用程序。在我的本地开发机器(也是 Ubuntu 10.10)上一切正常,我可以在我的网络服务器上安装应用程序,但是当我尝试访问主页时出现以下错误:'str' object has no attribute '_default_manager'

根据错误消息,我对字段进行子类化的模型表单出现问题,将其从 FK 字段更改为 URLField 并手动执行验证。这是抛出错误的形式:

class TopicResourceForm(ModelForm):
    resource = URLField(label='Resource URL')
    class Meta:
        model = TopicResource
        fields = ('title', 'rtype', 'note')

这些是模型。

class TopicResource(models.Model):
    added = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)
    title = models.CharField(max_length=140, blank=True)
    note = models.TextField(blank=True)
    resource = models.ForeignKey('aresource.Resource')
    rtype = models.ForeignKey('aresource.ResourceType', verbose_name="Resource Type", blank=True, null=True)
    topic = models.ForeignKey('mystudy.Topic')

    def __unicode__(self):
        return '%s on %s' % (self.resource, self.topic)

    def get_absolute_url(self):
        return '/topics/%s/%s/%s' % (self.topic.slug, self.resource.id,
        self.id)



class Resource(models.Model):
    added = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)
    url = models.URLField(unique=True)
    rtype = models.ForeignKey(ResourceType, verbose_name="Resource Type", blank=True, null=True)

    def __unicode__(self):
        return '%s' % self.url

    def get_absolute_url(self):
        return '/resources/%s' % self.id

任何帮助将不胜感激,谢谢。

【问题讨论】:

    标签: django django-forms mod-wsgi


    【解决方案1】:

    看来您的问题与此问题 Getting the "str" has no property "_default_manager" on a Django app just on startup 中的问题相似。该问题的答案引发了对各种建议修复的讨论。希望有帮助。

    【讨论】:

    猜你喜欢
    • 2018-02-04
    • 2021-04-28
    • 2019-06-25
    • 2017-09-20
    • 2018-02-09
    • 2021-07-23
    • 2018-12-25
    • 2021-05-16
    相关资源
    最近更新 更多