Re: How to Detect Current Page as Homepage?
You can retrieve the url variable that you are interested in with evaluating this variable request.path Use this link for more details http://www.djangobook.com/en/2.0/chapter07/ This is an example from the above source def current_url_view_good(request): return HttpResponse("Welcome to the page at %s" % request.path) On Sunday, March 25, 2012 3:49:33 AM UTC-4, Kev Dwyer wrote: > > easypie wrote: > > > I'm trying to check {% if homepage %} then show {% endif %} > > > > I'm not sure how to go about a test to check the current page if it's my > > homepage. Do I need to mess around with context processors? What's the > > usual way of doing it? And how would the {% if ... %} look like? > > > > Assuming your home is named "home" in your urls.py, you could try: > > {% url home as home %} > > {% if request.path == home %}{% endif %} > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/gXYW34-7QAoJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to Detect Current Page as Homepage?
wow. thank you very much! i didn't know the extra string passed in patterns inside a tuple was used in that way too. Does this have to do with get_absolute_url too? This is what I did: {% url satchmo_shop_home as home %} {% if request.path == home %}{% endif %} urlspatterns += patterns('satchmo_store.shop.views', (r'^$', 'home.home', {}, 'satchmo_shop_home'), ... ) On Sunday, March 25, 2012 12:49:33 AM UTC-7, Kev Dwyer wrote: > > easypie wrote: > > > I'm trying to check {% if homepage %} then show {% endif %} > > > > I'm not sure how to go about a test to check the current page if it's my > > homepage. Do I need to mess around with context processors? What's the > > usual way of doing it? And how would the {% if ... %} look like? > > > > Assuming your home is named "home" in your urls.py, you could try: > > {% url home as home %} > > {% if request.path == home %}{% endif %} > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Hizfo9TSvBIJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to Detect Current Page as Homepage?
easypie wrote: > I'm trying to check {% if homepage %} then show {% endif %} > > I'm not sure how to go about a test to check the current page if it's my > homepage. Do I need to mess around with context processors? What's the > usual way of doing it? And how would the {% if ... %} look like? > Assuming your home is named "home" in your urls.py, you could try: {% url home as home %} {% if request.path == home %}{% endif %} -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
How to Detect Current Page as Homepage?
I'm trying to check {% if homepage %} then show {% endif %} I'm not sure how to go about a test to check the current page if it's my homepage. Do I need to mess around with context processors? What's the usual way of doing it? And how would the {% if ... %} look like? -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/0e6Qif6N9QQJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.