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













1















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










share|improve this question
























  • 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















1















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










share|improve this question
























  • 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













1












1








1








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










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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










1 Answer
1






active

oldest

votes


















2














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.






share|improve this answer

























  • I've updated the question

    – dmoxy
    Mar 25 at 16:12






  • 1





    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










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
);



);













draft saved

draft discarded


















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









2














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.






share|improve this answer

























  • I've updated the question

    – dmoxy
    Mar 25 at 16:12






  • 1





    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















2














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.






share|improve this answer

























  • I've updated the question

    – dmoxy
    Mar 25 at 16:12






  • 1





    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













2












2








2







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.






share|improve this answer















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.







share|improve this answer














share|improve this answer



share|improve this answer








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 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

















  • I've updated the question

    – dmoxy
    Mar 25 at 16:12






  • 1





    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
















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






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.



















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript