Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 自定义django管理添加表单_Python_Django_Django Admin - Fatal编程技术网

Python 自定义django管理添加表单

Python 自定义django管理添加表单,python,django,django-admin,Python,Django,Django Admin,这是我的models.py: # customer table class Pcu(models.Model): cust_id = models.IntegerField('Customer ID', primary_key=True) f_name = models.CharField('First Name', max_length=30) l_name = models.CharField('Last Name', max_length=30) # ... other t

这是我的models.py:

# customer table
class Pcu(models.Model):
  cust_id = models.IntegerField('Customer ID', primary_key=True)
  f_name = models.CharField('First Name', max_length=30)
  l_name = models.CharField('Last Name', max_length=30)
  # ... other typical fields follows

# pawn record
class Pwn(models.Model):
  pwn_no = models.CharField('Pawn No', max_length=13, primary_key=True)
  p_date = models.DateField('Pledge Date')
  amt = models.IntegerField('Amount')
  cust_id = models.ForeignKey(Pcu, db_column='cust_id')
  # ... other fields here...
关系很简单:一个客户(Pcu)将有多个典当记录(Pwn),但一个典当记录只与一个客户关联

使用
django.admin
magic:add Pwn表单具有
cust_id
字段,该字段是一个选择框,它已经添加了客户列表。当列表很短的时候,这没关系,但在我的情况下,它的规模相当大,拥有数千名客户。因此,我想要添加三个自定义字段:名字和姓氏,每个字段都有自己的文本框和一个过滤器按钮,单击该按钮,在
cust\u id
select框中仅显示匹配的客户。第三个字段是显示所选客户地址的标签。如何做到这一点


注意:我是一名新的django学习者,在SmartOS v0.147上使用django v1.6和Python v2.7。数据库是PostgreSQL 9.3

您是否考虑过为此在管理员中创建自定义视图?这将是一个更容易和更干净。你可以点一些链接,帮助我在管理中创建自定义视图?文档:和一篇关于它的博客文章。