The queryset returns zero or more instances of your model. So if
there's only one result, you can just get the first item in the
queryset by its index.

For example:

some_queryset = YourModel.objects.filter(**kwargs)

if some_queryset.count() == 1:
    x = some_queryset[0]
    #x is now an instance of your model.
else:
    raise ValueError("%d results -- expected one!" % (some_queryset.count(),)


Shawn

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

Reply via email to