Thursday, January 31, 2013

Re: newbie confused about urls

Hi
You usually define get_absolute_urls() on a model to let Django know how to derive a URL for that object. The docs for get_absolute_url can be found  here. I advise you to understand how URL routing works in Django thoroughly, especially how not to hardcode stuff into your models. In the linked page, you'll also see how you can use `reverse` to reference formatted URLs from the urlconf in question.

Regards


On Thu, Jan 31, 2013 at 11:26 PM, frocco <farocco@gmail.com> wrote:
I am following the "Beginning Django e-commerce" book and he uses the get_absolute_url method in his models.
The book is dated (2009) and being new, I am not sure what applies.
He also creates urls.py in each module directory, but when I run it, it never finds it.
it defaults to the main urls.py that was created when I created the project.


On Thursday, January 31, 2013 11:54:37 AM UTC-5, Mike Doroshenko II wrote:
You mean mappings urls to views(pages?). Because if get_absolue_url is like request.get_full_path() then you would use that in the view itself and use urls.py to map urls to pages/views. And templates are are called from in views.

frocco wrote:
Hi All,

I am trouble understanding how to use urls.
I see tutorials that have get_absolue_url, url  mysite, ect.

I need to do:

1. load a page with no parameters
2. load a page with 1 parameter
3. load a page with more than 1 parameter

What should my templates look like?

Thank you



--
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.
-- Mike Doroshenko, Junior Sys Admin TecKnoQuest Inc.
mi...@tecknoquest.com www.tecknoquest.com

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Yati Sagade

Software Engineer at mquotient

Twitter: @yati_itay | Github: yati-sagade

Organizing member of TEDx EasternMetropolitanBypass
http://www.ted.com/tedx/events/4933
https://www.facebook.com/pages/TEDx-EasternMetropolitanBypass/337763226244869

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment