what's args parameter in reverse()

17 views
Skip to first unread message

Gear Crew

unread,
Sep 26, 2018, 8:53:54 AM9/26/18
to Django users

what's the useful form args=''1" here and why use 1 not anything else 
def test_post_update_view(self):
        response = self.client.post(reverse('post_edit',args='1'),{
        'title':'Updated title',
        'body':'Updated text',
        })Enter code here...


luca bocchi

unread,
Sep 26, 2018, 7:35:47 PM9/26/18
to Django users
args should be a list or a tuple, although is not specified clearly in the docs:
https://docs.djangoproject.com/en/1.11/ref/urlresolvers/#reverse


def test_post_update_view(self):
        response = self.client.post(reverse('post_edit',args=['1']),{
        'title':'Updated title',
        'body':'Updated text',
        })

L
Reply all
Reply to author
Forward
0 new messages