passing the correct urls.py pattern
up vote
0
down vote
favorite
I have a button which allows me to add a new botany record, I can click on a 'details' button and to gets the correct record by the botany_id. e.g:
http://localhost:8000/botany/1/
http://localhost:8000/botany/2/
http://localhost:8000/botany/3/
In that view/html I have another button which adds a composition to a related table. It should resolve using http://localhost:8000/botany/1/addcomposition/3/
but it tries http://localhost:8000/botany/addcomposition/3/
. This suggests there is an issue in the urls.py which looks like this, I suspect its missing a pattern to account for the botany_id
url(r'^addcomposition/(?P<pk>d+)/$', views.addcomposition, name='addcomposition'),
For clarity I also include the html
<a href="% url 'addcomposition' pk=fraction.fraction_id %" class="btn btn-primary" role="button">+ Composition +</a>
django
add a comment |
up vote
0
down vote
favorite
I have a button which allows me to add a new botany record, I can click on a 'details' button and to gets the correct record by the botany_id. e.g:
http://localhost:8000/botany/1/
http://localhost:8000/botany/2/
http://localhost:8000/botany/3/
In that view/html I have another button which adds a composition to a related table. It should resolve using http://localhost:8000/botany/1/addcomposition/3/
but it tries http://localhost:8000/botany/addcomposition/3/
. This suggests there is an issue in the urls.py which looks like this, I suspect its missing a pattern to account for the botany_id
url(r'^addcomposition/(?P<pk>d+)/$', views.addcomposition, name='addcomposition'),
For clarity I also include the html
<a href="% url 'addcomposition' pk=fraction.fraction_id %" class="btn btn-primary" role="button">+ Composition +</a>
django
It is hard to guess without knowing your application structure (for example, the answer may be different depending on where you are including that url). That said, I would expect your URL to be something like^botany/<botany_id>/addcomposition/<pk>/
– Paulo Scardine
Nov 9 at 16:57
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a button which allows me to add a new botany record, I can click on a 'details' button and to gets the correct record by the botany_id. e.g:
http://localhost:8000/botany/1/
http://localhost:8000/botany/2/
http://localhost:8000/botany/3/
In that view/html I have another button which adds a composition to a related table. It should resolve using http://localhost:8000/botany/1/addcomposition/3/
but it tries http://localhost:8000/botany/addcomposition/3/
. This suggests there is an issue in the urls.py which looks like this, I suspect its missing a pattern to account for the botany_id
url(r'^addcomposition/(?P<pk>d+)/$', views.addcomposition, name='addcomposition'),
For clarity I also include the html
<a href="% url 'addcomposition' pk=fraction.fraction_id %" class="btn btn-primary" role="button">+ Composition +</a>
django
I have a button which allows me to add a new botany record, I can click on a 'details' button and to gets the correct record by the botany_id. e.g:
http://localhost:8000/botany/1/
http://localhost:8000/botany/2/
http://localhost:8000/botany/3/
In that view/html I have another button which adds a composition to a related table. It should resolve using http://localhost:8000/botany/1/addcomposition/3/
but it tries http://localhost:8000/botany/addcomposition/3/
. This suggests there is an issue in the urls.py which looks like this, I suspect its missing a pattern to account for the botany_id
url(r'^addcomposition/(?P<pk>d+)/$', views.addcomposition, name='addcomposition'),
For clarity I also include the html
<a href="% url 'addcomposition' pk=fraction.fraction_id %" class="btn btn-primary" role="button">+ Composition +</a>
django
django
asked Nov 9 at 16:52
Gary Nobles
18413
18413
It is hard to guess without knowing your application structure (for example, the answer may be different depending on where you are including that url). That said, I would expect your URL to be something like^botany/<botany_id>/addcomposition/<pk>/
– Paulo Scardine
Nov 9 at 16:57
add a comment |
It is hard to guess without knowing your application structure (for example, the answer may be different depending on where you are including that url). That said, I would expect your URL to be something like^botany/<botany_id>/addcomposition/<pk>/
– Paulo Scardine
Nov 9 at 16:57
It is hard to guess without knowing your application structure (for example, the answer may be different depending on where you are including that url). That said, I would expect your URL to be something like
^botany/<botany_id>/addcomposition/<pk>/
– Paulo Scardine
Nov 9 at 16:57
It is hard to guess without knowing your application structure (for example, the answer may be different depending on where you are including that url). That said, I would expect your URL to be something like
^botany/<botany_id>/addcomposition/<pk>/
– Paulo Scardine
Nov 9 at 16:57
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
if I pas a second variable through the html, e.g. fk=botany.botany_id
, add (?P<pk>d+)/
after r'^
then the expected http://localhost:8000/botany/1/addcomposition/3/
is displayed.
Solution, html:
<a href="% url 'addcomposition' fk=botany.botany_id pk=fraction.fraction_id %" class="btn btn-primary" role="button">+ Composition +</a>
urls.py:
url(r'^(?P<fk>d+)addcomposition/(?P<pk>d+)/$', views.addcomposition, name='addcomposition'),
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
if I pas a second variable through the html, e.g. fk=botany.botany_id
, add (?P<pk>d+)/
after r'^
then the expected http://localhost:8000/botany/1/addcomposition/3/
is displayed.
Solution, html:
<a href="% url 'addcomposition' fk=botany.botany_id pk=fraction.fraction_id %" class="btn btn-primary" role="button">+ Composition +</a>
urls.py:
url(r'^(?P<fk>d+)addcomposition/(?P<pk>d+)/$', views.addcomposition, name='addcomposition'),
add a comment |
up vote
1
down vote
if I pas a second variable through the html, e.g. fk=botany.botany_id
, add (?P<pk>d+)/
after r'^
then the expected http://localhost:8000/botany/1/addcomposition/3/
is displayed.
Solution, html:
<a href="% url 'addcomposition' fk=botany.botany_id pk=fraction.fraction_id %" class="btn btn-primary" role="button">+ Composition +</a>
urls.py:
url(r'^(?P<fk>d+)addcomposition/(?P<pk>d+)/$', views.addcomposition, name='addcomposition'),
add a comment |
up vote
1
down vote
up vote
1
down vote
if I pas a second variable through the html, e.g. fk=botany.botany_id
, add (?P<pk>d+)/
after r'^
then the expected http://localhost:8000/botany/1/addcomposition/3/
is displayed.
Solution, html:
<a href="% url 'addcomposition' fk=botany.botany_id pk=fraction.fraction_id %" class="btn btn-primary" role="button">+ Composition +</a>
urls.py:
url(r'^(?P<fk>d+)addcomposition/(?P<pk>d+)/$', views.addcomposition, name='addcomposition'),
if I pas a second variable through the html, e.g. fk=botany.botany_id
, add (?P<pk>d+)/
after r'^
then the expected http://localhost:8000/botany/1/addcomposition/3/
is displayed.
Solution, html:
<a href="% url 'addcomposition' fk=botany.botany_id pk=fraction.fraction_id %" class="btn btn-primary" role="button">+ Composition +</a>
urls.py:
url(r'^(?P<fk>d+)addcomposition/(?P<pk>d+)/$', views.addcomposition, name='addcomposition'),
edited Nov 9 at 17:29
Alasdair
174k25294303
174k25294303
answered Nov 9 at 16:57
Gary Nobles
18413
18413
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53230100%2fpassing-the-correct-urls-py-pattern%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It is hard to guess without knowing your application structure (for example, the answer may be different depending on where you are including that url). That said, I would expect your URL to be something like
^botany/<botany_id>/addcomposition/<pk>/
– Paulo Scardine
Nov 9 at 16:57