thanks, it looks like i have.

i can't get it working though.

so the idea is to get the app name, model and id of the object before
submission to the cart.

    form.fields['object_id'].widget.attrs['value'] = product.id
    form.fields['content_type'].widget.attrs['value'] =
ContentType.objects.get_for_model(SuspFitment)
    form.fields['app'].widget.attrs['value'] =
ContentType.objects.get_for_model(SuspFitment).app_label

then in the cart i need to retrieve the particular item, check its not
already in the cart and add it / update it etc...

the following lines don't work, both found from googling this issue,
since i can't work out what to do from the documentation. I've
included my suspicion on whats happening, please tell me what i've
misunderstood about these lines.

attempt 1.
# get the objects for this content type, then choose the object by id
    ct = ContentType.objects.get_for_model(content_type)
    p = ct.get_object_for_this_type(pk=object_id)

attempt 2.
# get the object by supplying app, model and id
    p = ContentType.objects.get(app_label=app, model=content_type,
id=object_id)

not sure what im doing wrong, i need to get an object, i know its app/
model/id.


On Apr 22, 5:48 pm, Shawn Milochik <sh...@milochik.com> wrote:
> I think you just re-invented generic foreign keys:
>
> http://docs.djangoproject.com/en/1.3/ref/contrib/contenttypes/#generi...

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