Questions tagged [django-url-reverse]
77 questions
0
votes
0 answers
Django - two different urls calling same method which throws error
project urls.py
urlpatterns = [
path('', include('products.urls')),
]
application urls.py
path('p/a/s/',views.get_product_store_data,name='get_product_store_data'),
# store by url
path('/',views.store_from_url,…

sandeepnegi
- 123
- 13
0
votes
2 answers
Django - Testing a view name retrieved from a url parameter ie. ref=home
Simply put, I am trying to test a view name, captured from a URL parameter, within one of my view functions to see if it is valid. If not, to redirect to another page.
For example, take this url...
www.site.com/users/?ref=view_name
Then in my view
…

VIDesignz
- 4,703
- 3
- 25
- 37
0
votes
2 answers
getting error while fetching urls in templates- Django
I'm trying to replicate an ecommerce website and show separate products when they click at different links of the category. But I'm having trouble with fetching the urls in the template.
Here's my views.py :
from django.shortcuts import render,…

Dhiman
- 103
- 1
- 8
0
votes
2 answers
Django: Reverse for ‘topic_posts’ with arguments ‘(3, ”)’ not found
The reverse of '‘topic_posts’ works fine in other places. But it doesn’t work here.
HTML file
{% with post=board.get_last_post %}
ValueError at /

Wei Wong
- 65
- 1
- 7
0
votes
0 answers
Django Encrypt the URL (PK and ID)
I am trying to find best solution for encrypting my URL, I have found some old versions, for python 2.2.
I need to set my URLs, not to display like this:
.com/AddPost/1/ and .com/PostDetail/40.
But something like…

Davor_Python
- 15
- 9
0
votes
1 answer
Django Rest Framework: Second parameter in url being constructed with a dot (.) instead of /
I've got the following method in my View:
@action(detail=True, methods=['delete'])
def remove(self, request, *args,**kwargs):
print("here")
I've created a test for this endpoint. But haven't been able to get the correct url.
When I do
url =…
0
votes
1 answer
When I try to add some data in database from admin, Iam getting NoReverseMatch error
Here I am not using any admin template. I am using the default admin template. How can I reverse this url?
The error which I get:
NoReverseMatch at /admin/machine/module/add/
Reverse for 'machine_module_change' with arguments '('',)' not found. 1…

Ravesh Naik
- 43
- 8
0
votes
1 answer
Django Rest Framework URL for custom action not working
I've got the following custom action in my view:
class OrderAPIViewSet(viewsets.ViewSet):
def create(self, request):
print("Here: working")
@action(detail=True, methods=['post'])
def add(self, request, *arg, **kwargs):
…

Bond Jerome
- 95
- 2
- 12
0
votes
1 answer
How do I reverse the URL of a Django admin template in a view?
I have a custom Django admin form registered, how do I programmatically find the URL for the template in a view?
I know my form is at /admin/custom_app/horse/ but how do I programmatically look that up, incase the from URL is changed in the…

Amin Shah Gilani
- 8,675
- 5
- 37
- 79
0
votes
1 answer
trouble converting Python regex to path with django
I am working on a project which uses regex urls. The way it is currently designed is you have to manually type the url as a model field which then gets passed to the urls/views as an argument? (I don't fully understand this part yes, still…

fkay
- 184
- 1
- 10
0
votes
1 answer
Reverse for 'xyz' not found. 'chat' is not a valid view function or pattern name. At redirect('xyz')
I am getting an error while using the path in Django.
this is the code where the redirect function is called in views.py
def addmsg(request):
c = request.POST['content']
new_item = messageItem(content = c)
new_item.save()
bot_msg(c)
…

Puneeth Reddy
- 137
- 2
- 11
0
votes
1 answer
how to make sub pages url in django
In my online store django project, I want to create a sub-page which shows the details of a product that is listed in a page.
in urls.py I created the urls for both pages like bellow:
path('wwqm', views.water_quality_sensor ,…

Shahriar.M
- 818
- 1
- 11
- 24
0
votes
2 answers
Django url passing as many parameters as you want delimited by /
How can I define the URL pattern so that I can pass to an URL as many parameters as I want? I really researched the documentation and other stackoverflow questions but I didn't found something similar to that. I need this to work as a filter for an…

B. Victor
- 94
- 1
- 8
0
votes
0 answers
django: how to include parent category URL in child category URL (Category is a nested model)
The thing is, I have a model named ProductCategory, this model may or may not have another model as a parent category.
consider I have three Categories : grandParent -> parent -> child
Currently when I click on child category the URL is…

ArMot
- 148
- 7
0
votes
1 answer
ValueError at // Field 'id' expected a number but got '' in django
right now I am working on a blog application which is made without using django admin site and I have added blog post feature to that.I have used two foreign keys to a single User model which is customized with Custom User Model.
Now, the problem is…

Pravin Pandya
- 35
- 1
- 5