Re: extending a shopping cart

2011-04-24 Thread razafy
The model vs name issue has to do with lower case vs capitalized letters . To get the model attribute look up info in_meta.fields On Apr 23, 9:52 am, shofty wrote: > ok, answering my own question here, kind of. > > attempt 1. > # get the objects for this content type, then choose the objec

Re: extending a shopping cart

2011-04-24 Thread shofty
yeah, think i've found it. .model_class() worked, but game a strange result, so needs more investigation. thanks for the pointer mate. On Apr 23, 4:33 pm, Shawn Milochik wrote: > Did you check out the docs for adding a generic foreign key to your > model itself? -- You received this mess

Re: extending a shopping cart

2011-04-23 Thread Shawn Milochik
Did you check out the docs for adding a generic foreign key to your model itself? -- 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

Re: extending a shopping cart

2011-04-23 Thread shofty
ok, answering my own question here, kind of. attempt 1. # get the objects for this content type, then choose the object by id ct = ContentType.objects.get_for_model(app_label=app, name=content_type) p = ct.get_object_for_this_type(pk=object_id) the above code works to get the object and a

Re: extending a shopping cart

2011-04-23 Thread shofty
so the problem is definitely this line. ct = ContentType.objects.get_for_model(SuspFitment) this works and adds an item to the cart. am i totally misunderstanding what i can do with ContentTypes? is there a way to grab a contenttype when its passed as a string? off to see if i can find some

Re: extending a shopping cart

2011-04-23 Thread shofty
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.g

Re: extending a shopping cart

2011-04-22 Thread Shawn Milochik
I think you just re-invented generic foreign keys: http://docs.djangoproject.com/en/1.3/ref/contrib/contenttypes/#generic-relations -- 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.c

extending a shopping cart

2011-04-22 Thread shofty
say for instance you had a CartItem that was laid out pretty much as follows class CartItem(models.Model): cart_id = models.CharField(max_length=50) date_added = models.DateTimeField(auto_now_add=True) quantity = models.IntegerField(default=1) size = models.CharField(max_length=20