Stuart,

This is great, thank you.

I've grown familiar with the template {% syntax %}{{ yay|howcool }}{%
endsyntax %}, I've just been in the dark from where the API (or more
commonly called "templatetags") come from.  This is great insight, and I'll
have a swing at it this evening.  I'm sure others will benefit from this
small feature so I'll post some snippets of success (or failure). : )

Is there a way to know if I have python syntax errors?  I understand it's
"kind of" compiled, but when I made modifications to other python items, it
wouldn't update immediately, and in some cases break the entire site without
much insight into the errors.  For this, I backed up files before modifying
them, but I'm a bit more accustomed to a "^---- Here's your error"
debugging.

_Tres

On Tue, Feb 8, 2011 at 11:03 AM, Stuart Laughlin <[email protected]>wrote:

> On Tue, Feb 8, 2011 at 8:20 AM, Tres Finocchiaro
> <[email protected]> wrote:
> >
> > Ok this seems fairly simple.  Essentially I'll be adding a
> > one-function-python templatetags file and importing it into my template?
> (or
> > modifying an already existing templatetags file to have this new feature,
> > correct?
> >
>
> This is correct. When customizing / extending satchmo as you describe,
> it is best to do so in a way that doesn't change the satchmo codebase
> (by making use of template directories, signals, context processors,
> etc.). This makes future upgrades easier, among other advantages.
>
> So anyway, I think the optimal way to implement your custom template
> filter would be to create a new django app and include it in your
> installed apps. In that app you would create the templatetags file
> with the custom filter. Otherwise, if you don't care about keeping the
> satchmo codebase pristine, the easiest way to create your feature
> would be to simply create a total_qty property on the Order class.
>
> > Since "order" is a built in object for Satchmo  (i believe), and since
> I've
> > never made my own template file before does anyone have a sample template
> > file that uses "orders"?  If there's one built-in, I'd be happy to use
> that
> > too.
>
> I think your templatetags directory would contain a myfilters.py with
> something like this...
>
> from django import template
> register = template.Library()
>
> @register.filter
> def total_qty(order):
>   total = 0
>   for line_item in order.orderitem_set.all():
>      total += line_item.quantity
>   return total
>
> -------------------------------------
>
> Sorry about the clunky python; I have C brain-damage.
>
> Then in your template -- have a look at
> apps/satchmo_store/shop/templates/shop/_order_details.html for
> example. You would copy this file into your templates directory and
> update it as you wish. At the top you would add something like {% load
> myfilters %} and then right above Contact Information (circa line 16)
> you could add something like...
>
> Total Quantity: {{ order|total_qty }} <br/>
>
> I think that's about all there is to it.
>
>
> --Stuart
>
> > Reading an existing file will likely help bridge the knowledge-gap, since
> > the language is still relatively new to me!!  Thanks again!!!
> > -Tres
> > --
> > - [email protected]
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Satchmo users" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> > http://groups.google.com/group/satchmo-users?hl=en.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Satchmo users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/satchmo-users?hl=en.
>
>


-- 
- [email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"Satchmo users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/satchmo-users?hl=en.

Reply via email to