Re: Do I have to send shopping cart data to every template in my app?
No, you don't need to use the same template. You are just filling in some data on every request using the context processor. Its like this: 1) Write a context processor that adds shopping cart info to every context. Now it can be accessed via {{ cart.items }} or however you set it up 2) Write templates to use these. For example, if you only want the shopping cart info in, say, half of your pages, have those pages extend a template that contains {{ cart.items }} in the header. For the others, don't. 3) Alternatively, if you *don't* want shopping cart info in all of your contexts, you can use the additional argument to RequestContext for just those views where it is used. The docs reference an "ip_address_processor" that is added this way. And in answer to your questions: a) I don't know if it is better to send your shopping cart data to every template. That depends on your application. b) Of course there is a way. It is included as request.session in every view, if you have the session middleware activated. If this solves your display questions, it is probably easier than creating a custom processor anyway. HTH, -rob On Aug 6, 6:29 am, Greg <[EMAIL PROTECTED]> wrote: > Oggie, > Thanks for the reply. So you're saying that it would be better to > send my shopping cart data to every template through my all my > view's? If that's the case then I assume there is no way to send > request.session information using a custom template? > > Thanks > > On Aug 3, 4:36 pm, oggie rob <[EMAIL PROTECTED]> wrote: > > > If you really need to use a tag, look > > athttp://www.djangoproject.com/documentation/templates_python/#passing-... > > But I think you probably would find it easier to add an extra context > > processor & avoid the tag altogether. > > > -rob > > > On Aug 3, 6:01 am, Greg <[EMAIL PROTECTED]> wrote: > > > > Thanks for your help...I'm now able to create a custom tag. However, > > > I now seem to have a another problem with custom tags. How do I send > > > session information to each template. I can't use > > > request.session['cart'] in my custom tag function because it doesn't > > > have a request parameter. I always get the error 'global name request > > > is not defined' --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Do I have to send shopping cart data to every template in my app?
Oggie, Thanks for the reply. So you're saying that it would be better to send my shopping cart data to every template through my all my view's? If that's the case then I assume there is no way to send request.session information using a custom template? Thanks On Aug 3, 4:36 pm, oggie rob <[EMAIL PROTECTED]> wrote: > If you really need to use a tag, look > athttp://www.djangoproject.com/documentation/templates_python/#passing-... > But I think you probably would find it easier to add an extra context > processor & avoid the tag altogether. > > -rob > > On Aug 3, 6:01 am, Greg <[EMAIL PROTECTED]> wrote: > > > Thanks for your help...I'm now able to create a custom tag. However, > > I now seem to have a another problem with custom tags. How do I send > > session information to each template. I can't use > > request.session['cart'] in my custom tag function because it doesn't > > have a request parameter. I always get the error 'global name request > > is not defined' --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Do I have to send shopping cart data to every template in my app?
If you really need to use a tag, look at http://www.djangoproject.com/documentation/templates_python/#passing-template-variables-to-the-tag But I think you probably would find it easier to add an extra context processor & avoid the tag altogether. -rob On Aug 3, 6:01 am, Greg <[EMAIL PROTECTED]> wrote: > Thanks for your help...I'm now able to create a custom tag. However, > I now seem to have a another problem with custom tags. How do I send > session information to each template. I can't use > request.session['cart'] in my custom tag function because it doesn't > have a request parameter. I always get the error 'global name request > is not defined' --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Do I have to send shopping cart data to every template in my app?
Thanks for your help...I'm now able to create a custom tag. However, I now seem to have a another problem with custom tags. How do I send session information to each template. I can't use request.session['cart'] in my custom tag function because it doesn't have a request parameter. I always get the error 'global name request is not defined' Thanks for you help On Aug 2, 1:37 am, oggie rob <[EMAIL PROTECTED]> wrote: > On Aug 1, 11:22 pm, oggie rob <[EMAIL PROTECTED]> wrote: > > > This is what middleware is made > > for.http://www.djangoproject.com/documentation/middleware/ > > > -rob > > Sorry, I have recently been working withshoppingcarts and had > redirection onmybrain. Fabien's suggestion is probably what you are > after. > > Thob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Do I have to send shopping cart data to every template in my app?
On Aug 1, 11:22 pm, oggie rob <[EMAIL PROTECTED]> wrote: > This is what middleware is made > for.http://www.djangoproject.com/documentation/middleware/ > > -rob Sorry, I have recently been working with shopping carts and had redirection on my brain. Fabien's suggestion is probably what you are after. -rob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Do I have to send shopping cart data to every template in my app?
This is what middleware is made for. http://www.djangoproject.com/documentation/middleware/ -rob On Aug 1, 9:51 pm, Greg <[EMAIL PROTECTED]> wrote: > I've created a shopping cart. I want to put something on the top of > every page that let's people know how many items they have in their > cart. I have a lot of views that don't send any dictionary key's that > contain shopping cart info. If I want to do this...do I now have to > edit every view return render_to_response line so that they all > contain a key that contains my shopping cart info? > > Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Do I have to send shopping cart data to every template in my app?
On 8/2/07, Greg <[EMAIL PROTECTED]> wrote: > > I've created a shopping cart. I want to put something on the top of > every page that let's people know how many items they have in their > cart. I have a lot of views that don't send any dictionary key's that > contain shopping cart info. If I want to do this...do I now have to > edit every view return render_to_response line so that they all > contain a key that contains my shopping cart info? You could also try to use a context processor to populate the template with the values of your shopping cart : http://www.djangoproject.com/documentation/templates_python/#writing-your-own-context-processors -- Fabien SCHWOB --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Do I have to send shopping cart data to every template in my app?
You can create a custom tag, I've never done it myself, but it's in the docs: http://www.djangoproject.com/documentation/templates_python/#writing-custom-template-tags I am sure you can get more help if you need it, but this should get you started. On Aug 2, 12:51 am, Greg <[EMAIL PROTECTED]> wrote: > I've created a shopping cart. I want to put something on the top of > every page that let's people know how many items they have in their > cart. I have a lot of views that don't send any dictionary key's that > contain shopping cart info. If I want to do this...do I now have to > edit every view return render_to_response line so that they all > contain a key that contains my shopping cart info? > > Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Do I have to send shopping cart data to every template in my app?
I've created a shopping cart. I want to put something on the top of every page that let's people know how many items they have in their cart. I have a lot of views that don't send any dictionary key's that contain shopping cart info. If I want to do this...do I now have to edit every view return render_to_response line so that they all contain a key that contains my shopping cart info? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---