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:
When I try to use this as a content_type using:
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,'.')
mymodelStr = string.split(myapp.mymodel,'.')[-1]
contentType = ContentType.objects.get_by_natural_key(myappStr,
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.
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 email@example.com.
To post to this group, send email to firstname.lastname@example.org.
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.