从 wagtail 1.13 升级到 2.0 后的片段标题问题
Snippet title problem after upgrade from wagtail 1.13 to 2.0
我正在网站上从版本 1.13.4 升级 wagtail。主要关注这个 post https://wagtail.org/blog/upgrading-wagtail/ 。然而,由于第一次更新 wagtail 2.0 片段标题是错误的。我可以在模板化的前端页面上解决它,但它们在管理面板上仍然显示错误。
How titles are displayed on the admin panel
And this same issue is with fields that link to those snippets
我已经将 wagtail 更新到 2.4,因为博客 post 说它应该支持 python 3.7,但问题仍然存在。据我所知,终端输出中没有错误消息,迁移 运行 没有任何问题。我应该从哪里开始寻找任何线索?
这应该是项目中的相关艺术家片段声明
@register_snippet
class Artist(index.Indexed, models.Model):
class Meta:
ordering = ['name']
def __unicode__(self):
return unicode(self.name)
objects = ArtistQuerySet.as_manager()
name = models.CharField(max_length=512)
name_encoded = models.CharField(max_length=512)
image_url = models.URLField(blank=True, max_length=512)
image = models.ForeignKey(
'wagtailimages.Image',
blank=True,
null=True,
on_delete=models.SET_NULL,
related_name='+',
)
@property
def status(self):
# If there are no events currently attached to this artist
if not self.artistatevent_set.all():
return NO_CURRENT_DATES
# This artist does have some events, next see if there's any tickets
if self.total_ticket_count is not 0:
# Are they all the same type?
if self.available_ticket_count == self.total_ticket_count:
return AVAILABLE
if self.sold_out_ticket_count == self.total_ticket_count:
return SOLD_OUT
if self.cancelled_ticket_count == self.total_ticket_count:
return CANCELLED
if self.unavailable_ticket_count == self.total_ticket_count:
return UNAVAILABLE
# See if we have ANY of the following
if self.available_ticket_count:
return AVAILABLE
if self.coming_soon_ticket_count:
return COMING_SOON
if self.sold_out_ticket_count:
return SOLD_OUT
# Nothing matched, so default
return UNAVAILABLE
panels = [
FieldPanel('name'),
ImageChooserPanel('image'),
]
search_fields = [
index.SearchField('name', partial_match=True),
]
编辑:
这是admin.py声明
的片段
...
class NameIDAdmin(admin.ModelAdmin):
list_display = ('name', 'id')
...
admin.site.register(Artist, NameIDAdmin)
从Python 2升级到3时,您应该将__unicode__
方法替换为__str__
:https://docs.djangoproject.com/en/1.10/topics/python3/#str-and-unicode-methods
我正在网站上从版本 1.13.4 升级 wagtail。主要关注这个 post https://wagtail.org/blog/upgrading-wagtail/ 。然而,由于第一次更新 wagtail 2.0 片段标题是错误的。我可以在模板化的前端页面上解决它,但它们在管理面板上仍然显示错误。
How titles are displayed on the admin panel And this same issue is with fields that link to those snippets
我已经将 wagtail 更新到 2.4,因为博客 post 说它应该支持 python 3.7,但问题仍然存在。据我所知,终端输出中没有错误消息,迁移 运行 没有任何问题。我应该从哪里开始寻找任何线索?
这应该是项目中的相关艺术家片段声明
@register_snippet
class Artist(index.Indexed, models.Model):
class Meta:
ordering = ['name']
def __unicode__(self):
return unicode(self.name)
objects = ArtistQuerySet.as_manager()
name = models.CharField(max_length=512)
name_encoded = models.CharField(max_length=512)
image_url = models.URLField(blank=True, max_length=512)
image = models.ForeignKey(
'wagtailimages.Image',
blank=True,
null=True,
on_delete=models.SET_NULL,
related_name='+',
)
@property
def status(self):
# If there are no events currently attached to this artist
if not self.artistatevent_set.all():
return NO_CURRENT_DATES
# This artist does have some events, next see if there's any tickets
if self.total_ticket_count is not 0:
# Are they all the same type?
if self.available_ticket_count == self.total_ticket_count:
return AVAILABLE
if self.sold_out_ticket_count == self.total_ticket_count:
return SOLD_OUT
if self.cancelled_ticket_count == self.total_ticket_count:
return CANCELLED
if self.unavailable_ticket_count == self.total_ticket_count:
return UNAVAILABLE
# See if we have ANY of the following
if self.available_ticket_count:
return AVAILABLE
if self.coming_soon_ticket_count:
return COMING_SOON
if self.sold_out_ticket_count:
return SOLD_OUT
# Nothing matched, so default
return UNAVAILABLE
panels = [
FieldPanel('name'),
ImageChooserPanel('image'),
]
search_fields = [
index.SearchField('name', partial_match=True),
]
编辑:
这是admin.py声明
的片段...
class NameIDAdmin(admin.ModelAdmin):
list_display = ('name', 'id')
...
admin.site.register(Artist, NameIDAdmin)
从Python 2升级到3时,您应该将__unicode__
方法替换为__str__
:https://docs.djangoproject.com/en/1.10/topics/python3/#str-and-unicode-methods