For a django model, how can I get the django admin URL to add another, or list objects, etc.?

前端 未结 3 2164
攒了一身酷
攒了一身酷 2020-12-24 12:43

As much as I love the django documentation, the section on bookmarklets in the admin is strangely vague.

My question is this: If I\'m in a view and I have a django

3条回答
  •  旧时难觅i
    2020-12-24 13:38

    http://docs.djangoproject.com/en/dev/ref/contrib/admin/#reversing-admin-urls

    obj = coconut_transportation.swallow.objects.all()[34]
    
    # list url
    url = reverse("admin:coconut_transportation_swallow_changelist")
    
    # change url
    url = reverse("admin:coconut_transportation_swallow_change", args=[obj.id])
    
    # add url
    url = reverse("admin:coconut_transportation_swallow_add")
    

提交回复
热议问题