代码之家  ›  专栏  ›  技术社区  ›  Arbazz Hussain

使用模型类创建的对象之间的Django选择列表表单

  •  0
  • Arbazz Hussain  · 技术社区  · 7 年前

    models.py

       class Project(models.Model):
            project_name = models.CharField(max_length=100,unique=True)
            project_headers = models.TextField(unique=True) 
            projects_urls = models.TextField()
            project_timestamp = models.DateTimeField(auto_now_add=True)
            project_results = models.TextField(blank=True,null=True)
    
            def __str__(self):
                return self.project_name
    

    假设我已经创建了一个2个Projects对象,上面有一个类,下面是 project_name

    1. 谷歌网站
    2. facebook.com

    Django Choices list 作为 项目名称 对象更新其字段,例如 project_urls 等等,基于

    1 回复  |  直到 7 年前
        1
  •  1
  •   Walucas    7 年前

    请看这篇文章: https://simpleisbetterthancomplex.com/tutorial/2018/01/29/how-to-implement-dependent-or-chained-dropdown-list-with-django.html

    它向您展示了如何使用javascript实现这一点。我已经这样做了,效果很好。