我计划实现一个继承模型的类,然后简单地显示它的内容。我发现 Django Form Class 正在实现它。
article = Article.objects.get(pk=1)
form = ArticleForm(instance=article)
我怎样才能实现这种技术?我想做这样的:
article = Article.objects.get(pk=1)
class_var = MyClass(instance=article)
class_var.show_content()
//then all of the Article details will be displayed
book = Books.objects.get(pk=1)
class_var2 = MyClass(instance=book)
class_var2.show_content()
//then all of the Book details will be displayed
请帮忙!谢谢!