Try to instead limit the QuerySet:

try:
    post = Post.objects.filter(thread = self.pk).order_by('created')[:
1].get()
except DoesNotExist:
    post = NULL

return post # or do something else

http://docs.djangoproject.com/en/1.3/topics/db/queries/#limiting-querysets

On Apr 4, 1:35 am, Adam Tonks <a...@adam-tonks.co.uk> wrote:
> At the suggestion of someone on IRC, I tried accessing the first result from
> within my template, using {{ thread.original_author.0 }} (where
> original_author is the name of the function with the return statement), and
> that works fine.
>
> It's a workaround, but not ideal, as I'll be using it in various places
> throughout the project, and if I need to change it, that'd mean going
> through each bit of code manually (defeating the point of me writing the
> function in the first place).
>
> Exactly the same problem applies when I access the posts using
> self.post_set.order_by('created)[0]

-- 
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.

Reply via email to