【问题标题】:Getting attributes in django在 django 中获取属性
【发布时间】:2015-10-20 13:54:09
【问题描述】:

这可能是一个愚蠢的问题,但是如何在 Django 中提取属性?

我正在尝试编写一个从 AboutBio 中提取“body”属性的视图

from django.db import models

class AboutBio(models.Model):
    body = models.TextField()
    title = models.CharField(max_length=144)

    def __str__(self):
        return self.title

# Create your models here.

【问题讨论】:

标签: python django


【解决方案1】:

从AboutBio 模型中获取body:

AboutBio._meta.get_field('body')

来自docs.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-05-27
    • 1970-01-01
    • 2020-02-02
    • 2014-03-13
    • 2023-03-22
    • 2014-05-12
    • 2018-05-23
    • 2021-12-16
    相关资源
    最近更新 更多