Connect singlr Custom Product to specific template/view

27 views
Skip to first unread message

vitsin

unread,
Jun 10, 2012, 10:33:39 PM6/10/12
to satchm...@googlegroups.com
hi,
what would be the way(and example please) to connect specific Custom Product to its unique template(HTML page) and view(functionality behind HTML)?
Once I've defined Custom Product in Satchmo, shop refers to it by unique URL,
so probably it could be done ...

appreciate the help,
--vs

alkatron

unread,
Jun 11, 2012, 8:46:13 AM6/11/12
to satchm...@googlegroups.com
> --
> You received this message because you are subscribed to the Google
> Groups "Satchmo users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/satchmo-users/-/Sb4FGJ0dLWMJ.
> To post to this group, send email to satchm...@googlegroups.com.
> To unsubscribe from this group, send email to
> satchmo-user...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/satchmo-users?hl=en.

You have to make a custom view...something like this

def myget_product(request, product_slug=None, selected_options=(),
default_view_tax=None):
"""Basic product view"""

if product_slug == <specific Custom Product slug>: # any condition
that unique identify you product
template = <its unique template(HTML page)>
...
...

else:
template = <default template>
...
...
...
...
return response




May be there is better way, but this works.... I'm learning too

vitsin

unread,
Jun 11, 2012, 6:14:15 PM6/11/12
to satchm...@googlegroups.com
Ah! views yes! Thanks, its so simple and obvious once some one show an example ...


On Monday, June 11, 2012 8:46:13 AM UTC-4, Alkatron wrote:
On 06/11/2012 04:33 AM, vitsin wrote:
> hi,
> what would be the way(and example please) to connect specific Custom
> Product to its unique template(HTML page) and view(functionality
> behind HTML)?
> Once I've defined Custom Product in Satchmo, shop refers to it by
> unique URL,
> so probably it could be done ...
>
> appreciate the help,
> --vs
> --
> You received this message because you are subscribed to the Google
> Groups "Satchmo users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/satchmo-users/-/Sb4FGJ0dLWMJ.
> To post to this group, send email to satchm...@googlegroups.com.
> To unsubscribe from this group, send email to
> satchmo-users+unsubscribe@googlegroups.com.

Tomas Neme

unread,
Jun 11, 2012, 7:14:35 PM6/11/12
to satchm...@googlegroups.com
You want to do this for a single product?

If not, you can also get the template from the product slug, for example:

template_dirs = [s.format(product_slug) for s in ("product/{}/", "product/")]
template, origin =
django.template.loader.find_template("product.html",
dirs=template_dirs)

that way, you'll use the template in
templates/product/<product-slug>/product.html if it exists, and
fallback to templates/product/product.html if it doesn't.

This way you can have as many "specific templates" as you want without
having to write any extra code (just the templates)

On Mon, Jun 11, 2012 at 7:14 PM, vitsin <vitaly....@gmail.com> wrote:
> Ah! views yes! Thanks, its so simple and obvious once some one show an
> example ...
>
>
> On Monday, June 11, 2012 8:46:13 AM UTC-4, Alkatron wrote:
>>
>> On 06/11/2012 04:33 AM, vitsin wrote:
>> > hi,
>> > what would be the way(and example please) to connect specific Custom
>> > Product to its unique template(HTML page) and view(functionality
>> > behind HTML)?
>> > Once I've defined Custom Product in Satchmo, shop refers to it by
>> > unique URL,
>> > so probably it could be done ...
>> >
>> > appreciate the help,
>> > --vs
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "Satchmo users" group.
>> > To view this discussion on the web visit
>> > https://groups.google.com/d/msg/satchmo-users/-/Sb4FGJ0dLWMJ.
>> > To post to this group, send email to satchm...@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > satchmo-user...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/satchmo-users?hl=en.
>>
>> You have to make a custom view...something like this
>>
>> def myget_product(request, product_slug=None, selected_options=(),
>>      default_view_tax=None):
>>      """Basic product view"""
>>
>>      if product_slug == <specific Custom Product slug>: # any condition
>> that unique identify you product
>>          template = <its unique template(HTML page)>
>>          ...
>>          ...
>>
>>      else:
>>          template = <default template>
>>      ...
>>      ...
>>      ...
>>      ...
>>      return response
>>
>>
>>
>>
>> May be there is better way, but this works.... I'm learning too
>
> --
> You received this message because you are subscribed to the Google Groups
> "Satchmo users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/satchmo-users/-/-NgPJIkEEGYJ.
>
> To post to this group, send email to satchm...@googlegroups.com.
> To unsubscribe from this group, send email to
> satchmo-user...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/satchmo-users?hl=en.



--
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

vitsin

unread,
Jun 13, 2012, 3:51:03 PM6/13/12
to satchm...@googlegroups.com

myCustomProduct extends Satchmo Custom Product.
What I'm looking for is how to render very particular myCustomProduct template when http://localhost:8000/product/mycustomproduct/ URL called.
So other Custom Products will not be affected by myCustomProduct template and fall back to default product/detail_customproduct.html.

mycustomproduct - slug name of myCustomProduct

regards,
--vs
>> > satchmo-users+unsubscribe@googlegroups.com.
> satchmo-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages