It works!! Thanks a lot for your help, Adi!
cheers On May 12, 12:25 pm, Adi Jörg Sieker <[EMAIL PROTECTED]> wrote: > On 12.05.2008, at 18:57, RoMo wrote: > > > > > > > Hello guys! > > > First of all I don't know if I'm asking the right question, but i'll > > try to explain myself the best I can: > > > I would like to know if in a view there is a way that after a "try:" > > and evaluate the expression as false, it justs ignores that query and > > display a message error, but keep loading everything else. > > > For example: > > > try: > > posts = Post.objects.get(Author=user) > > except Record.DoesNotExist: > > //Missing code Here// > > > What I would like to do is: check if user has posted something, if he > > hasn't just displays a "you haven't posted anything yet" where the > > Post should be and it keeps loading everything else normally. > > what about: > > try: > posts = Post.objects.get(Author=user) > # btw get will raise an AssertionError if more than record is found. > # i.e. if a user posted more than one post > except Record.DoesNotExist: > posts = None > > return RequestContext(foo,bar, {'posts' : posts}) > > and in your template: > > {%if posts %} > display the posts > {% else %} > No haven't posted anything > {% endif %} > > regards > adi > > -- > Adi J. Sieker mobile: +49 - 178 - 88 5 88 13 > Freelance developer skype: adijsieker > SAP-Consultant web: http://www.sieker.info/profile > openbc:https://www.openbc.com/hp/ > AdiJoerg_Sieker/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---