how to format a a url to return something like this “product/4/improved-led-lamp” in the templateDjango blows up with 1.1, Can't find urls moduleHaving trouble with getting URL config to work% url % not work in DjangoDjango 1.8.3 urlsHow to link my css, js and image file link in djangoextends not working in Django 1.9NoReverseMatch error: Split URL and Views into multiple files to link and reverse them from a single REST Api RootDjango - Slug field for model object not being applied to URLWhy is Django template pattern matching with wrong view and causing a NoReverseMatch error?urls.py django 2.0.2 need parameters
A quine of sorts
Installed software from source, how to say yum not to install it from package?
Why wasn't ASCII designed with a contiguous alphanumeric character order?
What is the meaning of 'shout over' in a sentence exactly?
Where to connect the fuse and why?
Correct use of the the idiom 'Гнать/Катить бочку'
ESTA Elegible after Qatar?
Listen to my Story...Let us find the Unique Invisible Pan Digital Pair
Does "boire un jus" tend to mean "coffee" or "juice of fruit"?
What does 'in attendance' mean on a death certificate - England?
Is my guitar action too high or is the bridge too high?
How does mmorpg store data?
How do I keep a running total of data in a column in Excel?
Can I take Amul cottage cheese from India to Netherlands?
Why is exile often an intermediate step?
What verb for taking advantage fits in "I don't want to ________ on the friendship"?
Does it make sense to (partially) create a conlang that you don't intend to actually use in the story?
How to track mail undetectably?
The alcoholic village festival
Automorphisms and epimorphisms of finite groups
How can an inexperienced GM keep a game fun for experienced players?
Why will we fail creating a self sustaining off world colony?
Fully submerged water bath for stove top baking?
I agreed to cancel a long-planned vacation (with travel costs) due to project deadlines, but now the timeline has all changed again
how to format a a url to return something like this “product/4/improved-led-lamp” in the template
Django blows up with 1.1, Can't find urls moduleHaving trouble with getting URL config to work% url % not work in DjangoDjango 1.8.3 urlsHow to link my css, js and image file link in djangoextends not working in Django 1.9NoReverseMatch error: Split URL and Views into multiple files to link and reverse them from a single REST Api RootDjango - Slug field for model object not being applied to URLWhy is Django template pattern matching with wrong view and causing a NoReverseMatch error?urls.py django 2.0.2 need parameters
I'm trying to return a formatted url that will look like this "edit-book/4/improved-led-lamp" using the % url % tag
I've tried % url 'dashboard:editbook' 4 slug %
here is the root url.py
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('', include('home.urls')),
path('dashboard/', include('dashboard.urls')),
path('admin/', admin.site.urls),
]
here is my dashboard app's urls,py
from django.urls import path
from . import views
app_name = 'dashboard'
urlpatterns = [
path('edit-book/<int:id>/<slug:title>', views.BookView.as_view(), name='editbook'),
]
if I visit "edit-book/4/improved-led-lamp" in my browser, it resolves, but when I try to reproduce this in the view using % url % tag, it throws noReverseMatch error
this is the error
screenshot of error
python django django-templates
add a comment |
I'm trying to return a formatted url that will look like this "edit-book/4/improved-led-lamp" using the % url % tag
I've tried % url 'dashboard:editbook' 4 slug %
here is the root url.py
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('', include('home.urls')),
path('dashboard/', include('dashboard.urls')),
path('admin/', admin.site.urls),
]
here is my dashboard app's urls,py
from django.urls import path
from . import views
app_name = 'dashboard'
urlpatterns = [
path('edit-book/<int:id>/<slug:title>', views.BookView.as_view(), name='editbook'),
]
if I visit "edit-book/4/improved-led-lamp" in my browser, it resolves, but when I try to reproduce this in the view using % url % tag, it throws noReverseMatch error
this is the error
screenshot of error
python django django-templates
Please show the full error.
– Daniel Roseman
Mar 25 at 15:57
@DanielRoseman, I just uploaded a screenshot of the error, plus i've edited the code to provide more details
– dmoxy
Mar 25 at 16:11
add a comment |
I'm trying to return a formatted url that will look like this "edit-book/4/improved-led-lamp" using the % url % tag
I've tried % url 'dashboard:editbook' 4 slug %
here is the root url.py
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('', include('home.urls')),
path('dashboard/', include('dashboard.urls')),
path('admin/', admin.site.urls),
]
here is my dashboard app's urls,py
from django.urls import path
from . import views
app_name = 'dashboard'
urlpatterns = [
path('edit-book/<int:id>/<slug:title>', views.BookView.as_view(), name='editbook'),
]
if I visit "edit-book/4/improved-led-lamp" in my browser, it resolves, but when I try to reproduce this in the view using % url % tag, it throws noReverseMatch error
this is the error
screenshot of error
python django django-templates
I'm trying to return a formatted url that will look like this "edit-book/4/improved-led-lamp" using the % url % tag
I've tried % url 'dashboard:editbook' 4 slug %
here is the root url.py
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('', include('home.urls')),
path('dashboard/', include('dashboard.urls')),
path('admin/', admin.site.urls),
]
here is my dashboard app's urls,py
from django.urls import path
from . import views
app_name = 'dashboard'
urlpatterns = [
path('edit-book/<int:id>/<slug:title>', views.BookView.as_view(), name='editbook'),
]
if I visit "edit-book/4/improved-led-lamp" in my browser, it resolves, but when I try to reproduce this in the view using % url % tag, it throws noReverseMatch error
this is the error
screenshot of error
python django django-templates
python django django-templates
edited Mar 25 at 16:13
dmoxy
asked Mar 25 at 15:47
dmoxydmoxy
185 bronze badges
185 bronze badges
Please show the full error.
– Daniel Roseman
Mar 25 at 15:57
@DanielRoseman, I just uploaded a screenshot of the error, plus i've edited the code to provide more details
– dmoxy
Mar 25 at 16:11
add a comment |
Please show the full error.
– Daniel Roseman
Mar 25 at 15:57
@DanielRoseman, I just uploaded a screenshot of the error, plus i've edited the code to provide more details
– dmoxy
Mar 25 at 16:11
Please show the full error.
– Daniel Roseman
Mar 25 at 15:57
Please show the full error.
– Daniel Roseman
Mar 25 at 15:57
@DanielRoseman, I just uploaded a screenshot of the error, plus i've edited the code to provide more details
– dmoxy
Mar 25 at 16:11
@DanielRoseman, I just uploaded a screenshot of the error, plus i've edited the code to provide more details
– dmoxy
Mar 25 at 16:11
add a comment |
1 Answer
1
active
oldest
votes
Your syntax looks correct and if slug
variable consists of slug ([-a-zA-Z0-9_]+
) it should be working.
Look into contents of slug
. Error screenshot shows that it's an empty string.
I've updated the question
– dmoxy
Mar 25 at 16:12
1
screenshot shows thatslug
variable is empty string. You need an actual slug there.
– Kyryl Havrylenko
Mar 25 at 16:14
thanks mate, you were right
– dmoxy
Mar 25 at 16:17
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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%2f55341601%2fhow-to-format-a-a-url-to-return-something-like-this-product-4-improved-led-lamp%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your syntax looks correct and if slug
variable consists of slug ([-a-zA-Z0-9_]+
) it should be working.
Look into contents of slug
. Error screenshot shows that it's an empty string.
I've updated the question
– dmoxy
Mar 25 at 16:12
1
screenshot shows thatslug
variable is empty string. You need an actual slug there.
– Kyryl Havrylenko
Mar 25 at 16:14
thanks mate, you were right
– dmoxy
Mar 25 at 16:17
add a comment |
Your syntax looks correct and if slug
variable consists of slug ([-a-zA-Z0-9_]+
) it should be working.
Look into contents of slug
. Error screenshot shows that it's an empty string.
I've updated the question
– dmoxy
Mar 25 at 16:12
1
screenshot shows thatslug
variable is empty string. You need an actual slug there.
– Kyryl Havrylenko
Mar 25 at 16:14
thanks mate, you were right
– dmoxy
Mar 25 at 16:17
add a comment |
Your syntax looks correct and if slug
variable consists of slug ([-a-zA-Z0-9_]+
) it should be working.
Look into contents of slug
. Error screenshot shows that it's an empty string.
Your syntax looks correct and if slug
variable consists of slug ([-a-zA-Z0-9_]+
) it should be working.
Look into contents of slug
. Error screenshot shows that it's an empty string.
edited Mar 25 at 16:13
answered Mar 25 at 16:03
Kyryl HavrylenkoKyryl Havrylenko
4592 silver badges9 bronze badges
4592 silver badges9 bronze badges
I've updated the question
– dmoxy
Mar 25 at 16:12
1
screenshot shows thatslug
variable is empty string. You need an actual slug there.
– Kyryl Havrylenko
Mar 25 at 16:14
thanks mate, you were right
– dmoxy
Mar 25 at 16:17
add a comment |
I've updated the question
– dmoxy
Mar 25 at 16:12
1
screenshot shows thatslug
variable is empty string. You need an actual slug there.
– Kyryl Havrylenko
Mar 25 at 16:14
thanks mate, you were right
– dmoxy
Mar 25 at 16:17
I've updated the question
– dmoxy
Mar 25 at 16:12
I've updated the question
– dmoxy
Mar 25 at 16:12
1
1
screenshot shows that
slug
variable is empty string. You need an actual slug there.– Kyryl Havrylenko
Mar 25 at 16:14
screenshot shows that
slug
variable is empty string. You need an actual slug there.– Kyryl Havrylenko
Mar 25 at 16:14
thanks mate, you were right
– dmoxy
Mar 25 at 16:17
thanks mate, you were right
– dmoxy
Mar 25 at 16:17
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2f55341601%2fhow-to-format-a-a-url-to-return-something-like-this-product-4-improved-led-lamp%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
Please show the full error.
– Daniel Roseman
Mar 25 at 15:57
@DanielRoseman, I just uploaded a screenshot of the error, plus i've edited the code to provide more details
– dmoxy
Mar 25 at 16:11