Hello,

how to fetch the DoesNotExist exception generated by get_object_for_this_type? 
Being generic i can't use the actual model.

I tried something like that, but i doesn't seem to work, the original 
exception is still raised.

from django.contrib.contenttypes.models import ContentType
from django.http import Http404
from django.shortcuts import get_object_or_404

ctype = get_object_or_404(ContentType,
                          app_label=obj_app,
                          model=obj_model)
try:
    obj = ctype.get_object_for_this_type(id=obj_id)
except ctype.DoesNotExist:
    raise Http404


Best Regards,
Dirk Eschler

-- 
Dirk Eschler <esch...@gmail.com>

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