我可以在我的数据库中保存模板并从django管理编辑它们吗? 我的想法是为模板创建一个模型:
class DbTemplate(models.Model):
css_class = models.CharField(max_length=200)
name = models.CharField(max_length=200)
content = models.TextField()
class Meta:
verbose_name = "Database Template"
verbose_name_plural = "Database Templates"
def __str__(self):
return self.name
并在django admin中注册:
^{pr2}$在我的网址.py为加载正确模板的r“^page/”设置默认视图,是否可以?在
谢谢!在
您可能需要在视图中手动生成^{} 模板并返回结果^{} 。下面是一个粗略的示例(您应该根据您的用例对其进行修改):
相关问题 更多 >
编程相关推荐