简体   繁体   English

在Django管理控制台中仅显示一个字段?

[英]Show only one field in Django Admin panel?

I have the following two classes declared in admin Django files. 我在管理Django文件中声明了以下两个类。 On the admin panel 3 inline inputs are shown, I only want to show 1 input. 在管理面板上显示了3个内联输入,我只想显示1个输入。 Any guesses on why 3 inline inputs are shown instead of just one? 关于为何显示3个内联输入而不是仅显示一个的任何猜测?

class OriginURLInline(ViewPermissionMixin, admin.StackedInline):
model=IncentiveReferrerURL
verbose_name = 'Promotion URL'
verbose_name_plural = 'Promotion link'
fields = ('origin_url',)

class IncentiveReferrerURL(TimeStampedModel):
# The TimeStampedModel will provide self-updating 'created' and 'modified' fields on the inherited model

incentive = models.ForeignKey(
    Incentive,
    on_delete=models.PROTECT,
    null=True,
    blank=True,
)
origin_url = models.CharField(
    max_length = 100,
    verbose_name = 'Promotion Name:',
    help_text='Please e'
)

On your admin add: 在您的管理员上添加:

extra=0

that will fix this behavior 这将解决此问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM