I am following the polls app and I am copying everything making sure I have 100% the same code they have but when I use
response = client.get(reverse('polls:index'));
I get a huge error and none of the notes are making sense to me. I was told by someone it has to do with my views.py but I looked and the Django site and it is 100% the same as mine. This was the error I got:
django.urls.exceptions.NoReverseMatch: Reverse for 'vote' with arguments '('',)' not found. 1 pattern(s) tried: ['pools/(?P<question_id>[0-9]+)/vote/$']
Looks like you have to specify the GET parameter named question_id on your URL.
The NoReverseMatch exception is raised by django.urls when a matching
URL in your URLconf cannot be identified based on the parameters
supplied.
The error said you have to provide a question id. I used 1 as an example.
http://localhost:8000/pools/1/vote/
Related
I got a No reverseMatch Error evnthough pk has been imported.
Traceback:
Reverse for 'profile_page' with no arguments not found. 1 pattern(s) tried: ['profile_page/(?P<pro>[^/]+)$']
urls.py:
path('profile_page/<str:pro>', UserProfileView, name='profile_page'),
Reverse for 'profile_page' with no arguments not found. 1 pattern(s) tried: ['profile_page/(?P<pro>[^/]+)$']
Your Error Traceback clearly says that no arguments are found for profile_page route.
Since your url route for profile_page accepts a string, you need to pass one
urls.py
path('profile_page/<str:pro>', UserProfileView, name='profile_page'),
Wherever you are navigating to profile_page in your HTML code. you have to pass a string along with it.
I suppose you are using this route to display the profile page of a user, then use this - {% url 'profile_page' <some_user_name> %}
Eg: User
I am trying to use celery-progress module to show the user the progress of the task, since it takes lot of time to complete the task. However, after following the instructions on https://github.com/czue/celery-progress,I am seeing the following error on the front-end:-
NoReverseMatch at /netadc/arista/views/getFabListArista/TRCW/
Reverse for 'task_status' with arguments '('',)' not found. 1 pattern(s) tried: [u'celery_progress/(?P<task_id>[\\w-]+)/$']
Request Method: GET
Request URL: http://x.x.x.x/netadc/arista/views/getFabListArista/TRCW/
Django Version: 1.11
Exception Type: NoReverseMatch
Exception Value:
Reverse for 'task_status' with arguments '('',)' not found. 1 pattern(s) tried: [u'celery_progress/(?P<task_id>[\\w-]+)/$']
The URL pattern on the front-end var progressUrl = "{% url 'celery_progress:task_status' task_id %}"; does not work.
When I change it to var progressUrl = "{% url 'celery_progress:task_status' 'task_id' %}"; i do not get the error, but no tasks are running.
Any experts on django/python, please help.
You have to add the url mapping of celery_progress to your main urls.py. It's described in the Prerequisites section of the project's README.
Check here: https://github.com/czue/celery-progress/issues/27
this implies the task ID is blank. The best way to troubleshoot it is to try and figure out why it's blank. It can be because your backend isn't properly configured so the ID is not assigned/returned from the async call, because you're not passing it properly from the view to the template, because you're referencing the wrong variable in the template, etc.
I'd recommend you get to the bottom of why the ID is blank and that should hopefully lead you to the appropriate solution.
I use django-grappelli to create orderable inlines on the admin site. Occasionally (not reproducibly - about 50% of the time, which is particularly weird), Django throws the following exception when I try to save the ordering from the inline:
Exception Type: NoReverseMatch
Exception Value: Reverse for 'grp_related_lookup' with arguments '()' and keyword arguments '{}' not found.
Exception Location: /usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py in render, line 424
The offending line is this:
$("#id_" + this).grp_related_fk({lookup_url:"{% url 'grp_related_lookup' %}"});
As per the advice given in this related thread, I've tried quickly testing it in the shell, but it seems to work fine:
>>> from django.core.urlresolvers import reverse
>>> print reverse('grp_related_lookup')
/grappelli/lookup/related/
I'm at a loss. Has anyone made a similar experience?
Django version is 1.5.1.
You probably forgot to add grappelli urls into your urls.py (at least it was the case for me)
url(r'^grappelli/', include('grappelli.urls')),
I have been struggling to implement facebook authentication with socialauth on a Django project. I keep getting this error:
NoReverseMatch at /mysite/test
Reverse for 'socialauth_begin' with arguments '(u'facebook',)' and keyword arguments '{}' not found.
Request Method: GET
Request URL: http://127.0.0.1:8000/mysite/test
Django Version: 1.5.1
Exception Type: NoReverseMatch
Exception Value:
Reverse for 'socialauth_begin' with arguments '(u'facebook',)' and keyword arguments '{}' not found.
I believe I have configured socialauth correctly (this guide helped), but I do not know where the error could be coming from.
This line in my template test.html is giving me issues:
Login with Facebook
I have looked many places online and could not find a reasonable solution.
To save someone using the new python-social-auth and django > 1.4
Use this :
{% url 'social:begin' 'facebook' %}
error message:
ExceptionType: NoReverseMatch
Exception Value: Reverse for 'darts.teams.views.expanded_details' with arguments '(u'RightFlights',)' and keyword arguments '{}' not found.
in the template:
Expanded Details
in urls.py
urlpatterns = patterns('darts.teams.views',
url(r'^(?P<teamname>.*?)/expanded_details/$', 'team_details', {'expanded': True}, "expanded_details"),
url(r'^(?P<teamname>.*?)/details/$', 'team_details', name="team_details"),
url(r'^(?P<teamname>.*?)/add_player/$', 'team_add_player', name="team_add_player"),
url(r'^(?P<teamname>.*?)/add_player/confirm/$', 'team_add_player',"team_add_player_confirm"),
)
The additional URLs in urls.py all render fine, but the 'expanded_details' one is throwing the error.
Why is this one different than the others? Am I missing something blatant?
update
The error says "Reverse for 'darts.teams.views.expanded_details' failed", but it should be 'darts.teams.views.team_details' or 'expanded_details'. The first form is the path to view, the latter is the name of the named URL.
You could check the value of expanded_details inside the templatetag to ensure it is resolved to one of the correct values above, or follow slackjake's suggestion: use 'expanded_details' (note the single quote) directly.
(?P<teamname>.*? is invalid, maybe you mean (?P<teamname>.*?)?
Also, what does lib.url do?