Re: Django foreign-key cannot assign must be a instance

2020-05-20 Thread saqlain abbas
try to pass -1.0 On Tue, May 19, 2020 at 1:08 PM Aldian Fazrihady wrote: > replace > ``` > Report.objects.create(param=test_name,comp=compon,value=test_value) > ``` > with > ``` > Report.objects.create(param=test_name,comp_id=compon,value=test_value) > ``` > > On Tue, May 19, 2020 at 2:39 PM

Re: Django foreign-key cannot assign must be a instance

2020-05-19 Thread Aldian Fazrihady
replace ``` Report.objects.create(param=test_name,comp=compon,value=test_value) ``` with ``` Report.objects.create(param=test_name,comp_id=compon,value=test_value) ``` On Tue, May 19, 2020 at 2:39 PM ratnadeep ray wrote: > Can you please say in which line we should make that change because in

Re: Django foreign-key cannot assign must be a instance

2020-05-19 Thread ratnadeep ray
Can you please say in which line we should make that change because in so many places I am using comp. So in all the places should I change that ? On Tuesday, 19 May 2020 12:36:19 UTC+5:30, Aldian Fazrihady wrote: > > Use comp_id= instead of comp= > > Regards, > > Aldian Fazrihady >

Re: Django foreign-key cannot assign must be a instance

2020-05-19 Thread Aldian Fazrihady
Use comp_id= instead of comp= Regards, Aldian Fazrihady http://aldianfazrihady.com Pada tanggal Sel, 19 Mei 2020 13.49, ratnadeep ray menulis: > Hi all, > > I am trying to add a row in the DB using the following views.py: > > # Create your views here. >> from django.shortcuts import render >>

Django foreign-key cannot assign must be a instance

2020-05-19 Thread ratnadeep ray
Hi all, I am trying to add a row in the DB using the following views.py: # Create your views here. > from django.shortcuts import render > from fusioncharts.models import Component,Report > import xlrd > def pie_chart(request): > labels = [] > data = [] > loc =

RE: Django foreign-key cannot assign must be a instance

2018-07-18 Thread Matthew Pava
imary-key-fields From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Gerald Brown Sent: Wednesday, July 18, 2018 4:51 AM To: django-users@googlegroups.com Subject: Re: Django foreign-key cannot assign must be a instance Also when creating my models I use "

Re: Django foreign-key cannot assign must be a instance

2018-07-18 Thread Gerald Brown
Also when creating my models I use "id = models.AutoField(primary_key=True)" for my ID field.  This way Django will Auto generate an ID for each record. On Tuesday, 17 July, 2018 08:03 PM, Sainath Bavugi wrote: I am developing a web app using Django. I have created the table in MySQL

Re: Django foreign-key cannot assign must be a instance

2018-07-17 Thread Sainath Bavugi
Thanks a lot. that worked On Tuesday, 17 July 2018 13:29:49 UTC+1, Sainath Bavugi wrote: > > I am developing a web app using Django. I have created the table in MySQL > database and then generated the models.py using inspectdb. I am able to > fetch details and connect to the database

Re: Django foreign-key cannot assign must be a instance

2018-07-17 Thread Glen D souza
I would suggest you to try this code sav_list = List(id=4, item_name ='name1', item_desc='desc1', location='location', reason='rfp', pid=Order.objects.get(poid = 3)) Instead of passing integer 3 to pid, try to the pass the order Object which has the poid = 3 On 17 July 2018 at 17:33, Sainath

Re: Django foreign-key cannot assign must be a instance

2018-07-17 Thread Gerald Brown
The way I do it is backwards from what you are doing.  I.E. I make the models first and then use ./manage.py makemigrations & ./manage.py migrate.  This way Django creates the tables AND the FK Indexes, which I think may be missing on your setup.  Now that you have the models try running the

Django foreign-key cannot assign must be a instance

2018-07-17 Thread Sainath Bavugi
I am developing a web app using Django. I have created the table in MySQL database and then generated the models.py using inspectdb. I am able to fetch details and connect to the database without any issues. But while saving the values to the particular table, below error is shown *Cannot