Re: weird "must be an intance" error
haha Thanks for that... i never would have figured it out On Apr 18, 4:59 pm, akaariaiwrote: > On Apr 18, 11:38 pm, Bobby Roberts wrote: > > > oops... forgot to clarify that Item.tid is a FK to printLocation > > Then you would want to assign to tid_id. For foreign keys the tid > wants an instance, the tid_id can be assigned the "db value" for that > foreign key. I am not sure if the tid_id can be named something else. > If it can be, you can find out the right field name to assign to by > checking out ItemTracking._meta.get_field_by_name('tid')[0].attname in > the django shell. > > - Anssi -- 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.
Re: weird "must be an intance" error
On Apr 18, 11:38 pm, Bobby Robertswrote: > oops... forgot to clarify that Item.tid is a FK to printLocation Then you would want to assign to tid_id. For foreign keys the tid wants an instance, the tid_id can be assigned the "db value" for that foreign key. I am not sure if the tid_id can be named something else. If it can be, you can find out the right field name to assign to by checking out ItemTracking._meta.get_field_by_name('tid')[0].attname in the django shell. - Anssi -- 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.
Re: weird "must be an intance" error
oops... forgot to clarify that Item.tid is a FK to printLocation -- 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.
Re: weird "must be an intance" error
On Apr 18, 11:03 pm, Bobby Robertswrote: > considering this snippet: > > valPrintlocation=int(request.POST.get('printlocation')) > if valPrintlocation==-1: > needsprinting=0 > else: > needsprinting=1 > > Item = ItemTracking.objects.get(Barcode = > barcode) > Item.tid=valPrintlocation > Item.NeedsPrinting=needsprinting > ... > > can you see any reason i'm getting this error: > > Cannot assign "-1": "ItemTracking.tid" must be a "printLocation" > instance. > > I get the same error regardless of the value of valPrintlocation It would help if you would include the definition of ItemTracking at least. Based on that snippet I would guess the problem is that ItemTracking.tid must be a printLocation instance... :) - Anssi -- 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.
weird "must be an intance" error
considering this snippet: valPrintlocation=int(request.POST.get('printlocation')) if valPrintlocation==-1: needsprinting=0 else: needsprinting=1 Item = ItemTracking.objects.get(Barcode = barcode) Item.tid=valPrintlocation Item.NeedsPrinting=needsprinting ... can you see any reason i'm getting this error: Cannot assign "-1": "ItemTracking.tid" must be a "printLocation" instance. I get the same error regardless of the value of valPrintlocation -- 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.