Django URL problem

62 views
Skip to first unread message

Kacsándi, Zsolt

unread,
Dec 7, 2018, 2:10:13 PM12/7/18
to django...@googlegroups.com
Hi,

I am new in Django and I have a problem.
I want to build an URL structure like this:


The first URL is the list view, the second is the detail view. The first integer (1) in those is the account id, and in the second URL the second integer (2) is the email id for the detail view.

This is the urls.py from my project:

urlpatterns = [
path('<int:account_id>/', include('app.urls')),
path('admin/', admin.site.urls),
]

And from my app:

urlpatterns = [
path('email/', views.EmailIndexView.as_view(), name='email.index'),
path('email/<int:pk>', views.EmailDetailView.as_view(), name='email.detail'),
]

The detail view works well but when I open the list view I have got this message:

NoReverseMatch at /1/emails/

Reverse for 'email.detail' with arguments '(7,)' not found. 1 pattern(s) tried: ['(?P<account_id>[0-9]+)\\/email\\/(?P<pk>[0-9]+)$']
Request Method: GET
Request URL: https://teambox.hu/1/emails/
Django Version: 2.1.3
Exception Type: NoReverseMatch
Exception Value:
Reverse for 'email.detail' with arguments '(7,)' not found. 1 pattern(s) tried: ['(?P<account_id>[0-9]+)\\/email\\/(?P<pk>[0-9]+)$']


Can anyone help me what did I do wrong?

Thank you in advance for your help!

Zsolt

vishal sharma

unread,
Dec 7, 2018, 2:12:40 PM12/7/18
to django...@googlegroups.com
Hello,

I am making multiupload files API in Django please suggest which functions we can use for uploading multiple upload?

Thanks!!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAC8-FuadYzHsoLcq11WvpDSrNX151n3%2BAtNVGVnbdXAZiLiE1Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

thanh.ngu...@gmail.com

unread,
Dec 7, 2018, 10:49:51 PM12/7/18
to Django users
Hello, I think you are missing ('email/<int:pk>') in template. 

thanh.ngu...@gmail.com

unread,
Dec 7, 2018, 10:54:34 PM12/7/18
to Django users
It can be like {% url 'email' %} (incorrect) => {% url 'email' <value> %} (correct) :D


On Saturday, December 8, 2018 at 2:10:13 AM UTC+7, Kacsándi, Zsolt wrote:
Reply all
Reply to author
Forward
0 new messages