Kacsándi, Zsolt
2018-12-07 18:53:38 UTC
Hi,
I am new in Django and I have a problem.
I want to build an URL structure like this:
https://example.com/1/email
https://example.com/1/email/2
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
I am new in Django and I have a problem.
I want to build an URL structure like this:
https://example.com/1/email
https://example.com/1/email/2
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
--
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.
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.