Questions tagged [django-url-reverse]

77 questions
0
votes
1 answer

Django passing dynamic URL parameter into reverse function

I have just stated to learn Django. So far I pass dynamic URL parameters into reverse function inside the get_absolute_url() method in the following ways: # By using kwargs: def get_absolute_url(self): return reverse('book-detail',…
0
votes
0 answers

Not getting the expected result from Django reverse

hope anyone here will be able to help me out. I am trying to get the reverse url for a viewset but somehow it's not working. I will quickly go through what I have done from the moment everything was working fine to the moment the reverse stopped…
0
votes
0 answers

django NoReverseMatch not a valid view function or pattern name

I am having problems with an old project that was running on a deprecated django version. I updated django to 4.1.5 and made a few edits to the urls.py files that they were using python from django.conf.urls. I changed this to use re_path but now am…
0
votes
0 answers

django.urls.exceptions.NoReverseMatch: Reverse for 'watchlist' not found. 'watchlist' is not a valid view function or pattern name

I am building a django (v3.2.5) project called commerce which has an app called auctions. urls.py for commerce: from django.contrib import admin from django.urls import include, path urlpatterns = [ path("admin/", admin.site.urls), path("",…
0
votes
0 answers

Django - Sitemap Reverse URL with parameters from list

I'm looking at creating a sitemap based on a list of parameters, but seem to be running into issues. I can get it to work with a single parameter, but not iterate over a list of parameters. Here is the working code, for a single parameter: class…
LBJ33
  • 425
  • 11
  • 29
0
votes
1 answer

reversing admin "change" url

I´m trying to find some example of how to use change url of modelAdmin and what exactly result it gives. Sincerly I do not understand the part from docs: "This will find the first registered instance of the admin application (whatever the instance…
kubaSpolsky
  • 357
  • 2
  • 10
0
votes
1 answer

URL to redirect related model instance django

I have a 2 models with ForeignKey linked to each other class Moc(models.Model): title = models.CharField(max_length=128, blank=False) scope = models.TextField(max_length=128, blank=False) .... def __str__(self): return self.title class…
SS_SS
  • 63
  • 7
0
votes
1 answer

Reverse for 'AddCart' not found. 'AddCart' is not a valid view function or pattern name

I am Working on my project and I don't know how this error I got Can anybody see what I'm missing? This is my root project urls.py from django.contrib import admin from django.urls import path, include from .import views from django.conf import…
0
votes
1 answer

How to use return redirect as a callback function in Django

I have been trying to get my code working through out the whole day. I have a view function but its too verbose plus i am trying to use its implementation on another view so i am trying to refactor the code for the function to be able to run in…
Xcode
  • 11
  • 2
0
votes
0 answers

Django urls configuration

I have an example website using django. I have 2 link "about" and "blog". When I click "blog" it become localhost/blog and nothing problem, but when I click "blog" once more it become localhost/blog/blog and error happen. What's the solution?
0
votes
1 answer

Using Django,I want my user when he Register ,He directly go to to create page, But when I do it ,It never go to create page .Here is my code

Views.py #For Cystomer Registration class CustomerRegistrationView(View): def get(self,request): form = CustomerRegistrationForm() return render(request,'mp/register.html',{'form':form}) def post(self,request): form =…
0
votes
1 answer

Django: Problem with passing parameters from a template {% url %} to a view

I have this urlpath: path('download//', views.download, name='download'), And this is the view: def download(request, fpath, fname): # some code In template, I have this href tag and I want to pass those strings as…
0
votes
3 answers

ImportError: cannot import name 'url' from 'django.conf.urls'

ImportError: cannot import name 'url' from 'django.conf.urls' (/home/chams/pfe_project/CarApp/venv/lib/python3.8/site-packages/django/conf/urls/_init_.py) I can't find any mistakes in my code !
0
votes
1 answer

Django - NoReverseMatch Error even with correct parameters (no namespacing)

I'm trying to create an app that stores problems (specifically math problems), and displays them to the user. I haven't add much of the functionality that I want to yet, and as I'm fairly new to Django, I have been following along with the Django…
0
votes
1 answer

send request to the url if matches otherwise send it to parameterised url in django

urls.py urlpatterns = [ re_path(r'^([-\w]{3,})/$', shop_from_url, name='shop_from_url'), path('ckeditor/', include('ckeditor_uploader.urls')), path('', include('products.urls')), path('authenticate/',…
sandeepnegi
  • 123
  • 13