Re: If logged in show X, if not Y
I there any way to name a template? For example my subtempaltes/ loginform.html - I want to name it loginform. In group work it'll be a very useful feature. I knto that {% include %} tag allows passing name - but how? On 29 Lis, 04:09, Venkatraman Swrote: > On Mon, Nov 29, 2010 at 7:44 AM, Andre Terra wrote: > > I think a more elegant approach would be to have a main template with {% > > block some_name_for_the_part_that_changes %}, and have two different > > template (logged_in.html and not_logged_in.html) that both extend said block > > in 'main.html'. > > The conditional logic in View or Template depends on what you want to > show/not-show in the template -- if its just a small section that you want > to conditionally show, then prefer the auth check in the template, else move > it to the view. > > -V-http://twitter.com/venkasub -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: If logged in show X, if not Y
On Mon, Nov 29, 2010 at 7:44 AM, Andre Terrawrote: > I think a more elegant approach would be to have a main template with {% > block some_name_for_the_part_that_changes %}, and have two different > template (logged_in.html and not_logged_in.html) that both extend said block > in 'main.html'. > The conditional logic in View or Template depends on what you want to show/not-show in the template -- if its just a small section that you want to conditionally show, then prefer the auth check in the template, else move it to the view. -V- http://twitter.com/venkasub -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: If logged in show X, if not Y
On 11/28/2010 6:50 PM, robos85 wrote: > Hi, > I've read about {% if user.is_authenticated %} and m template is going > to have the same structure, but some block will have different content > for logged users. Additionally there will by some more buttons. > I wondered if there's some other way to divide it. > By no I have that plan: > define 1 mainframe template. In it I'll include some sub-templates. In > that sub-templates I'll make {% if user.is_authenticated %} and > include the destination template or do the stuff. > > Is this plan ok? It seems like a perfectly sensible plan to me. You will probably find that you can define a hierarchy of templates, with the basic look and feel provided by the top-level templates. Sub-templates aren't always necessary. regards Steve -- DjangoCon US 2011 Portland, OR: September 6-8 http://djangocon.us/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: If logged in show X, if not Y
I think a more elegant approach would be to have a main template with {% block some_name_for_the_part_that_changes %}, and have two different template (logged_in.html and not_logged_in.html) that both extend said block in 'main.html'. Then, as Xavier suggested, move the "if user is authenticated" part to the view: if is authenticated: render logged_in.html else: render not_logged_in.html Regards, Andre Terra On Sun, Nov 28, 2010 at 22:50, robos85wrote: > Hi, > I've read about {% if user.is_authenticated %} and m template is going > to have the same structure, but some block will have different content > for logged users. Additionally there will by some more buttons. > I wondered if there's some other way to divide it. > By no I have that plan: > define 1 mainframe template. In it I'll include some sub-templates. In > that sub-templates I'll make {% if user.is_authenticated %} and > include the destination template or do the stuff. > > Is this plan ok? > > On 29 Lis, 01:27, Xavier Ordoquy wrote: > > Hi, > > > > You may want to look at the authentication contrib application that comes > with Django. > > Esp here:http://docs.djangoproject.com/en/1.2/topics/auth/#id7 > > > > Another solution if you intend to have totally different templates would > be to check within the view the user state and render a different template. > > > > Regards, > > Xavier. > > > > Le 29 nov. 2010 à 00:53, robos85 a écrit : > > > > > > > > > > > > > > > > > I managed to make register and login on my site. Now I want to divide > > > my template to parts for loggen and not logged user. > > > What is the best way to check and display template parts for this? For > > > example if user is not logged in: show login form but if he is logged > > > in - in the same place show him his avatar. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@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. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: If logged in show X, if not Y
Hi, I've read about {% if user.is_authenticated %} and m template is going to have the same structure, but some block will have different content for logged users. Additionally there will by some more buttons. I wondered if there's some other way to divide it. By no I have that plan: define 1 mainframe template. In it I'll include some sub-templates. In that sub-templates I'll make {% if user.is_authenticated %} and include the destination template or do the stuff. Is this plan ok? On 29 Lis, 01:27, Xavier Ordoquywrote: > Hi, > > You may want to look at the authentication contrib application that comes > with Django. > Esp here:http://docs.djangoproject.com/en/1.2/topics/auth/#id7 > > Another solution if you intend to have totally different templates would be > to check within the view the user state and render a different template. > > Regards, > Xavier. > > Le 29 nov. 2010 à 00:53, robos85 a écrit : > > > > > > > > > I managed to make register and login on my site. Now I want to divide > > my template to parts for loggen and not logged user. > > What is the best way to check and display template parts for this? For > > example if user is not logged in: show login form but if he is logged > > in - in the same place show him his avatar. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: If logged in show X, if not Y
Hi, You may want to look at the authentication contrib application that comes with Django. Esp here: http://docs.djangoproject.com/en/1.2/topics/auth/#id7 Another solution if you intend to have totally different templates would be to check within the view the user state and render a different template. Regards, Xavier. Le 29 nov. 2010 à 00:53, robos85 a écrit : > I managed to make register and login on my site. Now I want to divide > my template to parts for loggen and not logged user. > What is the best way to check and display template parts for this? For > example if user is not logged in: show login form but if he is logged > in - in the same place show him his avatar. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
If logged in show X, if not Y
I managed to make register and login on my site. Now I want to divide my template to parts for loggen and not logged user. What is the best way to check and display template parts for this? For example if user is not logged in: show login form but if he is logged in - in the same place show him his avatar. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.