Hi Guys, I'm attempting to replace the django.contrib comment app's "post_comment" using a view in views.py.
I have it working but I would like to check that I am doing it in an ok django friendly way. The content_type that the request.POST['content_type'] returns is: `myapp.mymodel` When I try to use this as a content_type using: `"ContentType.objects.get_for_model(request.POST['content_type']).pk` I get an error: 'unicode' object has no attribute '_meta' Obviously it needs to be an object model - I need it to return an instance of *mymodel* so that I can add it to the Comment object and save it. To get this to work I have used : myappStr = string.split(myapp.mymodel,'.')[0] mymodelStr = string.split(myapp.mymodel,'.')[-1] contentType = ContentType.objects.get_by_natural_key(myappStr, mymodelStr) This works, but I think I shouldn't need to split a string. Perhaps at some moment the content_type will actually return a model and this string split hack is going to fall apart. Any ideas? Many thanks! Adam -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6f9bc42d-1a01-4b2b-9afc-7157cd1b1f0a%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.