Celery-Progress-Bar Not Working in Django - python

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.

Related

No reversematch error eventhough pk is imported

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

The Django test client: polls app part 5 NoReverseMatch

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/

Cannot have any URLs with slugs. NoReverseMatch

I'm a begginer grasping at straws with difficulty dealing with the django slug url system and these NoReverseMatch errors that make no sense to me even after reading the docs.
I have a django project. In one of the views, I pass a list of geoJSON features into a template, and show them on a map. I want to have each feature act as a clickable 'link' to a view that will show stuff about it. The following is part of the template that has those features that I want to click on:
//part of the template:
<script type="text/javascript">
...
function onEachFeature(feature, layer) {
layer.on('click', function (e) {
window.location.href = "{% url 'polls:areadetail' feature.properties.myslug%}";
});
}
(I have confirmed that feature.properties.myslug does in fact contain the slug I want).
The url pattern I want to go to:
urlpatterns = [...
url(r'^areadetail/(?P<areaslug>[-\w]+)/$', views.AreaDetail, name='areadetail'),]
And the view it relates to:
def AreaDetail(request, areaslug):
area = get_object_or_404(Area, nameslug=areaslug)
return render(request, 'polls/areadetail.html', {'area':area})
The issue I get is, by doing what I show and placing that url reference inside that template I show above, that I want to be able click on, that template won't even work at all, giving me a 'Error during template rendering' full page error info that starts with:
NoReverseMatch at /polls/areas/
Reverse for 'areadetail' with arguments '('',)' and keyword arguments '{}' not found. 1 pattern(s) tried: [u'polls/areadetail/(?P[-\w]+)/$']
Any help would be immensely appreciated
EDIT part1: As I've said in response to falsetru, I'm sure feature.properties.myslug has in fact got a slug expression in it.
EDIT2: Based on something I found in a django ticket, I've made a slight change in the url regex at urls.py, from (?P<areaslug>[-\w]+)/$ to (?P<areaslug>[-\w]+)?/$ and now the error is:
Page not found (404)
Request Method: GET Request URL: http://127.0.0.1:8000/polls/areadetail// Raised by: polls.views.AreaDetail
Is it possible that because the "{% url 'polls:areadetail' feature.properties.myslug%}" bit is inside javascript, that feature.properties.myslug is not being inserted there correctly? Like some sort of brackets are needed here?
According to the error message, feature.properties.myslug is empty or has no value.
Make sure the feature.properties.myslug is passed correctly from view.
Comment out {% url .. %} temporarily.
Print {{ feature }}, {{ feature.properties }}, {{ feature.properties.myslug }} to see if which part is missing.
Fix view accordingly.
Uncomment {% url .. %}.
After some more digging around I've found the answer to why doesn't this work in another question at:
How to pass javascript variable to django custom filter
The answer to it by Ludwik Trammer says:
Django templates are build on the server side, while JavaScript is executed on the client side.
That means that template code is always executed before JavaScript (as
it is executed by the server, before the page is sent to the client).
As a consequence it is absolutely impossible to mix JavaScript and
Django code the way you want to.
Which clearly applies here. I was focused on problems with the URL template, regex on the urls.py file etc. when the problem was that no matter what I did, because it's in a javascript section, run client-side, that URL template will always be incomplete no matter what I do, therefore being an impossible solution to what I want.

Named url with kwargs issue

Can anyone explain to me what is happening here? In the same template I have the following:
Group
Group
The top url works fine while the bottom errors out the entire page with:
Reverse for 'triage' with arguments '()' and keyword arguments '{u'group_id': 7}' not found. 0 pattern(s) tried: []
Any ideas?
The documentation mentions that:
This {% url ... as var %} syntax will not cause an error if the view is missing.
That is why the 1st view errors out the page while the second one works.
In any case, probably there is an error in your url pattern - can you show us your urls.py ?

NoReverseMatch error with socialauth in Django

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' %}

Categories

Resources