Re: newbie confused about urls

2013-01-31 Thread Mike Doroshenko II
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+unsubscr...@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.


--
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+unsubscr...@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.




Re: newbie confused about urls

2013-01-31 Thread frocco
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
> .
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
> --
> 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+unsubscr...@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.




Re: newbie confused about urls

2013-01-31 Thread yati sagade
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  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.
>>
>> Visit this group at 
>> http://groups.google.com/**group/django-users?hl=en
>> .
>> For more options, visit 
>> https://groups.google.com/**groups/opt_out
>> .
>>
>> --
>> Mike Doroshenko, Junior Sys Admin
>> TecKnoQuest Inc.
>> mi...@tecknoquest.comwww.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+unsubscr...@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+unsubscr...@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.




Re: newbie confused about urls

2013-01-31 Thread frocco
I am getting this error:
TypeError at /order_details/17/

'str' object is not callable


urls.py
 (r'^order_details/(?P[-\w]+)/$', 'order_details',
 {'template_name': 'registration/order_details.html'}, 'order_details'),
   
template
Order #{{ order.id }} - {{ 
order.date|date }}  (view)

views.py
def order_details(request, order_id, 
template_name="registration/order_details.html"):
""" displays the details of a past customer order; order details can 
only be loaded by the same 
user to whom the order instance belongs.

"""
order = get_object_or_404(Order, id=order_id, user=request.user)
page_title = 'Order Details for Order #' + order_id
order_items = OrderItem.objects.filter(order=order)
return render_to_response(template_name, locals(), 
context_instance=RequestContext(request))


On Thursday, January 31, 2013 2:17:24 PM UTC-5, yati sagade wrote:
>
> 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  >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.
>>>
>>> Visit this group at 
>>> http://groups.google.com/**group/django-users?hl=en
>>> .
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out
>>> .
>>>
>>> --
>>> Mike Doroshenko, Junior Sys Admin
>>> TecKnoQuest Inc.
>>> mi...@tecknoquest.comwww.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...@googlegroups.com .
>> To post to this group, send email to django...@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+unsubscr...@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.




Re: newbie confused about urls

2013-01-31 Thread yati sagade
Okay, please paste the full error page contents at http://dpaste.org
Also, show us your models.py which contains the Order model


On Fri, Feb 1, 2013 at 6:25 AM, frocco  wrote:

> I am getting this error:
> TypeError at /order_details/17/
>
> 'str' object is not callable
>
>
> urls.py
>  (r'^order_details/(?P[-\w]+)/$', 'order_details',
>  {'template_name': 'registration/order_details.html'},
> 'order_details'),
>
> template
> Order #{{ order.id }} - {{
> order.date|date }}  (view)
>
> views.py
> def order_details(request, order_id,
> template_name="registration/order_details.html"):
> """ displays the details of a past customer order; order details can
> only be loaded by the same
> user to whom the order instance belongs.
>
> """
> order = get_object_or_404(Order, id=order_id, user=request.user)
> page_title = 'Order Details for Order #' + order_id
> order_items = OrderItem.objects.filter(order=order)
> return render_to_response(template_name, locals(),
> context_instance=RequestContext(request))
>
>
> On Thursday, January 31, 2013 2:17:24 PM UTC-5, yati sagade wrote:
>
>> 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  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_urlis 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.

 Visit this group at http://groups.google.com/**group**
 /django-users?hl=en 
 .
 For more options, visit 
 https://groups.google.com/**grou**ps/opt_out
 .

 --
 Mike Doroshenko, Junior Sys Admin
 TecKnoQuest Inc.
 mi...@tecknoquest.comwww.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...@**googlegroups.com.
>>> To post to this group, send email to django...@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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com

RE: newbie confused about urls

2013-01-31 Thread Babatunde Akinyanmi
You need to change the view argument you supplied - 'order_details' either
to a string with the full path to the 'order_details' function like:

(r'^order_details/(?P[-\w]+)/$', 'path.to.my.view.order_details',
 {'template_name': 'registration/order_details.html'}, 'order_details'),

or import 'order_details' into your namespace then remove the quote marks
from the view argument so that you will be passing the actual order_detail
object like:

from path.to.my.view import order_details
(r'^order_details/(?P[-\w]+)/$', order_details,
 {'template_name': 'registration/order_details.html'}, 'order_details'),

Sent from my Windows Phone
------
From: frocco
Sent: 2/1/2013 1:55 AM
To: django-users@googlegroups.com
Subject: Re: newbie confused about urls

I am getting this error:
TypeError at /order_details/17/

'str' object is not callable


urls.py
 (r'^order_details/(?P[-\w]+)/$', 'order_details',
 {'template_name': 'registration/order_details.html'}, 'order_details'),

template
Order #{{ order.id }} - {{
order.date|date }}  (view)

views.py
def order_details(request, order_id,
template_name="registration/order_details.html"):
""" displays the details of a past customer order; order details can
only be loaded by the same
user to whom the order instance belongs.

"""
order = get_object_or_404(Order, id=order_id, user=request.user)
page_title = 'Order Details for Order #' + order_id
order_items = OrderItem.objects.filter(order=order)
return render_to_response(template_name, locals(),
context_instance=RequestContext(request))


On Thursday, January 31, 2013 2:17:24 PM UTC-5, yati sagade wrote:
>
> 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<https://docs.djangoproject.com/en/dev/ref/models/instances/?from=olddocs#get-absolute-url>.
> 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  >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.
>>>
>>> Visit this group at 
>>> http://groups.google.com/**group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
>>> .
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>> .
>>>
>>> --
>>> Mike Doroshenko, Junior Sys Admin
>>> TecKnoQuest Inc.
>>> mi...@tecknoquest.comwww.tecknoquest.com
>>>
>>>   --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and s