Django-dbindexer 的问题

发布于 2024-10-19 17:49:03 字数 6937 浏览 4 评论 0原文

我在适当的Google群组(http://groups.google.com/group/django-non-relational/browse_thread/thread/a51c1903af175e1c)中提出了我的问题,但开发人员现在似乎有点忙,所以我担心我的问题会仍然没有得到答复。希望我能在这里找到问题的解决方案。

本质是: 我使用 Django 基本应用 中的 Django-nonrel + GAE + 博客应用 从我的应用程序的管理面板,我尝试创建新的博客文章。并得到以下异常:

DatabaseError: Lookup type 'month' isn't supported

我在相关的谷歌组中询问了这一点,并得到回答使用 django-dbindexer< /a>. 关于它的描述,它正是我所需要的,因此我指导了所有说明并将其“附加”到我的应用程序中。索引已完成,但我却遇到了同样的异常。这是完整的跟踪:

Traceback (most recent call last):
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\core\handlers\base.py", line 111, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\contrib\admin\options.py", line 308, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\utils\decorators.py", line 93, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\views\decorators\cache.py", line 79, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\contrib\admin\sites.py", line 190, in inner
    return view(request, *args, **kwargs)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\utils\decorators.py", line 28, in _wrapper
    return bound_func(*args, **kwargs)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\utils\decorators.py", line 93, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\utils\decorators.py", line 24, in bound_func
    return func(self, *args2, **kwargs2)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\db\transaction.py", line 282, in inner
    res = func(*args, **kwargs)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\contrib\admin\options.py", line 852, in add_view
    if form.is_valid():
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\forms\forms.py", line 121, in is_valid
    return self.is_bound and not bool(self.errors)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\forms\forms.py", line 112, in _get_errors
    self.full_clean()
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\forms\forms.py", line 269, in full_clean
    self._post_clean()
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\forms\models.py", line 338, in _post_clean
    self.validate_unique()
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\forms\models.py", line 347, in validate_unique
    self.instance.validate_unique(exclude=exclude)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\db\models\base.py", line 669, in validate_unique
    date_errors = self._perform_date_checks(date_checks)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\db\models\base.py", line 791, in _perform_date_checks
    if qs.exists():
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\db\models\query.py", line 498, in exists
    return self.query.has_results(using=self.db)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\db\models\sql\query.py", line 428, in has_results
    return compiler.has_results()
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\djangotoolbox\db\basecompiler.py", line 222, in has_results
    return self.get_count(check_exists=True)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\djangotoolbox\db\basecompiler.py", line 269, in get_count
    return self.build_query().count(high_mark)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\djangotoolbox\db\basecompiler.py", line 275, in build_query
    query.add_filters(self.query.where)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\djangotoolbox\db\basecompiler.py", line 72, in add_filters
    self.add_filters(child)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\djangotoolbox\db\basecompiler.py", line 76, in add_filters
    self.add_filter(column, lookup_type, self._negated, db_type, value)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\djangoappengine\db\compiler.py", line 57, in _func
    return func(*args, **kwargs)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\djangoappengine\db\compiler.py", line 211, in add_filter
    raise DatabaseError("Lookup type %r isn't supported" % lookup_type)
DatabaseError: Lookup type 'month' isn't supported

这是我的数据模型(来自 basic.blog.models):

class Post(models.Model):
    """Post model."""
    STATUS_CHOICES = (
        (1, _('Draft')),
        (2, _('Public')),
    )
    title = models.CharField(_('title'), max_length=200)
    slug = models.SlugField(_('slug'), unique_for_date='publish')
    author = models.ForeignKey(User, blank=True, null=True)
    body = models.TextField(_('body'), )
    tease = models.TextField(_('tease'), blank=True, help_text=_('Concise text suggested. Does not appear in RSS feed.'))
    status = models.IntegerField(_('status'), choices=STATUS_CHOICES, default=2)
    allow_comments = models.BooleanField(_('allow comments'), default=True)
    publish = models.DateTimeField(_('publish'), default=datetime.datetime.now)
    created = models.DateTimeField(_('created'), auto_now_add=True)
    modified = models.DateTimeField(_('modified'), auto_now=True)
    categories = models.ManyToManyField(Category, blank=True)
    tags = TagField()
    objects = PublicManager()

    class Meta:
        verbose_name = _('post')
        verbose_name_plural = _('posts')
        db_table  = 'blog_posts'
        ordering  = ('-publish',)
        get_latest_by = 'publish'

    def __unicode__(self):
        return u'%s' % self.title

    @permalink
    def get_absolute_url(self):
        return ('blog_detail', None, {
            'year': self.publish.year,
            'month': self.publish.strftime('%b').lower(),
            'day': self.publish.day,
            'slug': self.slug
        })

    def get_previous_post(self):
        return self.get_previous_by_publish(status__gte=2)

    def get_next_post(self):
        return self.get_next_by_publish(status__gte=2)

这是我的应用程序的 dbindexes 模块中的内容(basic.blog.dbindexes):

from basic.blog.models import Post
from dbindexer.api import register_index



register_index(Post, {
    'publish': 'month',
 #   'created': 'month',
 #   'modified': 'month',
})



import logging
logger = logging.getLogger(__name__)
logger.info('Basic.blog dbindexes')    # Logging statement to check if this module is ever executed to be sure indexing is done

提前感谢您的帮助。

I asked my question in appropriate Google Group (http://groups.google.com/group/django-non-relational/browse_thread/thread/a51c1903af175e1c), but developers seems are kinda busy now, so I'm afraid my question will remain unanswered. Hope I'll find solution of my problem here.

Essense is:
I use Django-nonrel + GAE + Blog App from Django Basic apps
From admin panel of my app I tried to create new blog post. And got the following exception:

DatabaseError: Lookup type 'month' isn't supported

I asked about this in related google group and was answered to use django-dbindexer.
Regarding it desription it is exactly what I need, so I guided through all instructions and "attached" it to my app. Indexing is done, but I however get the same exception. Here is the full trace:

Traceback (most recent call last):
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\core\handlers\base.py", line 111, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\contrib\admin\options.py", line 308, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\utils\decorators.py", line 93, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\views\decorators\cache.py", line 79, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\contrib\admin\sites.py", line 190, in inner
    return view(request, *args, **kwargs)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\utils\decorators.py", line 28, in _wrapper
    return bound_func(*args, **kwargs)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\utils\decorators.py", line 93, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\utils\decorators.py", line 24, in bound_func
    return func(self, *args2, **kwargs2)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\db\transaction.py", line 282, in inner
    res = func(*args, **kwargs)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\contrib\admin\options.py", line 852, in add_view
    if form.is_valid():
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\forms\forms.py", line 121, in is_valid
    return self.is_bound and not bool(self.errors)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\forms\forms.py", line 112, in _get_errors
    self.full_clean()
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\forms\forms.py", line 269, in full_clean
    self._post_clean()
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\forms\models.py", line 338, in _post_clean
    self.validate_unique()
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\forms\models.py", line 347, in validate_unique
    self.instance.validate_unique(exclude=exclude)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\db\models\base.py", line 669, in validate_unique
    date_errors = self._perform_date_checks(date_checks)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\db\models\base.py", line 791, in _perform_date_checks
    if qs.exists():
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\db\models\query.py", line 498, in exists
    return self.query.has_results(using=self.db)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\django\db\models\sql\query.py", line 428, in has_results
    return compiler.has_results()
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\djangotoolbox\db\basecompiler.py", line 222, in has_results
    return self.get_count(check_exists=True)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\djangotoolbox\db\basecompiler.py", line 269, in get_count
    return self.build_query().count(high_mark)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\djangotoolbox\db\basecompiler.py", line 275, in build_query
    query.add_filters(self.query.where)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\djangotoolbox\db\basecompiler.py", line 72, in add_filters
    self.add_filters(child)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\djangotoolbox\db\basecompiler.py", line 76, in add_filters
    self.add_filter(column, lookup_type, self._negated, db_type, value)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\djangoappengine\db\compiler.py", line 57, in _func
    return func(*args, **kwargs)
  File "F:\Its_mine19\Programming\Java\pineapplemon\src\djangoappengine\db\compiler.py", line 211, in add_filter
    raise DatabaseError("Lookup type %r isn't supported" % lookup_type)
DatabaseError: Lookup type 'month' isn't supported

Here is my data model (from basic.blog.models):

class Post(models.Model):
    """Post model."""
    STATUS_CHOICES = (
        (1, _('Draft')),
        (2, _('Public')),
    )
    title = models.CharField(_('title'), max_length=200)
    slug = models.SlugField(_('slug'), unique_for_date='publish')
    author = models.ForeignKey(User, blank=True, null=True)
    body = models.TextField(_('body'), )
    tease = models.TextField(_('tease'), blank=True, help_text=_('Concise text suggested. Does not appear in RSS feed.'))
    status = models.IntegerField(_('status'), choices=STATUS_CHOICES, default=2)
    allow_comments = models.BooleanField(_('allow comments'), default=True)
    publish = models.DateTimeField(_('publish'), default=datetime.datetime.now)
    created = models.DateTimeField(_('created'), auto_now_add=True)
    modified = models.DateTimeField(_('modified'), auto_now=True)
    categories = models.ManyToManyField(Category, blank=True)
    tags = TagField()
    objects = PublicManager()

    class Meta:
        verbose_name = _('post')
        verbose_name_plural = _('posts')
        db_table  = 'blog_posts'
        ordering  = ('-publish',)
        get_latest_by = 'publish'

    def __unicode__(self):
        return u'%s' % self.title

    @permalink
    def get_absolute_url(self):
        return ('blog_detail', None, {
            'year': self.publish.year,
            'month': self.publish.strftime('%b').lower(),
            'day': self.publish.day,
            'slug': self.slug
        })

    def get_previous_post(self):
        return self.get_previous_by_publish(status__gte=2)

    def get_next_post(self):
        return self.get_next_by_publish(status__gte=2)

Here is what I have in dbindexes module of my app (basic.blog.dbindexes):

from basic.blog.models import Post
from dbindexer.api import register_index



register_index(Post, {
    'publish': 'month',
 #   'created': 'month',
 #   'modified': 'month',
})



import logging
logger = logging.getLogger(__name__)
logger.info('Basic.blog dbindexes')    # Logging statement to check if this module is ever executed to be sure indexing is done

Thanks in advance for any help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文