Django Reverse with arguments '()' and keyword arguments '{}' not found

前端 未结 4 1744
遥遥无期
遥遥无期 2020-12-02 07:17

Hi I have an infuriating problem.

I have a url pattern like this:

# mproject/myapp.urls.py

url(r\'^project/(?P\\d+)/$\',\'user_pro         


        
4条回答
  •  半阙折子戏
    2020-12-02 07:29

    This problems gave me great headache when i tried to use reverse for generating activation link and send it via email of course. So i think from tests.py it will be same. The correct way to do this is following:

    from django.test import Client
    from django.core.urlresolvers import reverse
    
    #app name - name of the app where the url is defined
    client= Client()
    response = client.get(reverse('app_name:edit_project', project_id=4)) 
    

提交回复
热议问题