开发者

Django : NoReverseMatch for HttpResponseRedirect

开发者 https://www.devze.com 2023-04-08 13:28 出处:网络
I am trying to Redirect to the post\'s page soon as it\'s saved , well it\'s saved but the redirection won\'t work , it\'s working very fine on the development server .. not in t开发者_JAVA百科he prod

I am trying to Redirect to the post's page soon as it's saved , well it's saved but the redirection won't work , it's working very fine on the development server .. not in t开发者_JAVA百科he production one .

I tried :

            return HttpResponseRedirect(reverse('emr.main.views.viewprofile', args=(profile.id,)))

Well it's working fine but, in production host i have to change emr.main.view.viewprofile to myproject.main.views.viewprofile ! because viewprofile itself it's not working

then i got template syntax error :

TemplateSyntaxError Exception Value: Caught NoReverseMatch while rendering: Reverse for 'main.views.add_record' with arguments '(47L,)' and keyword arguments '{}' not found.

main.view.add_comment which is a url tag Add record

how to solve this issue ?

url.py

    (r'^add/record/(?P<patient_id>\d+)/?$', add_record),
(r'^add/current/(?P<patient_id>\d+)/?$', add_current),

Edit :

The main issues are :

  1. Naming the APP/views needs to rename all the files to fix this for development instead of emr.main.views.add_records to myproject.main.views.. since function itself is not working
  2. URL tags such as {% url main.views.add_record profile.id %} still returning errors ..


You are passing a tuple to reverse() whereas the function expects a list.

Try args=[profile.id] instead.

However, it's difficult to answer this properly without seeing the function definition (or at least signature) for the viewprofile() function.


I think your best bet is to use named url's, as this sounds like a Python path issue with your views.

See https://docs.djangoproject.com/en/1.3/topics/http/urls/#url

It would also be helpful if you would post your urls.py config.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号