首页 > python > django对象被保存在数据库中,在django admin中显示,但它没有在django模板中呈现

django对象被保存在数据库中,在django admin中显示,但它没有在django模板中呈现 (django object is getting saved in database, getting showed in django admin, but its not getting rend)

问题

我面临着问题。我正在尝试保存django模型对象。对象被保存在数据库中,在django admin中显示,但它没有在django模板中呈现。

解决方法

要调试此问题,请尝试使用string_if_invalid。(例如:如果show.eventNone__str__可能会崩溃并且不会返回任何值。)

而且:而不是TicketType.objects.create(..)尝试o = TicketType(...)随后o.full_clean()检测更多与您的模型相关的问题。

问题

I am facing problem. I am trying to save django model object. Object is getting saved in database, getting showed in django admin, but its not getting rendered in django template.

解决方法

To debug this problem, try using string_if_invalid. (For example: If show.event is None, __str__ might crash and won't return any value.)

And also: Instead of TicketType.objects.create(..) try o = TicketType(...) followed by o.full_clean() to detect more problems related to your model.

相似信息