Re: Saving data fails because of null constraint when data is not null

2018-12-22 Thread Joel Mathew
I havent defined more than one primary key. If primary key is defined, the automatic field wouldnt be generated, right? Sincerely yours, Joel G Mathew On Sat, 22 Dec 2018 at 16:13, Glen D souza wrote: > if you check the error message > > DETAIL: Failing row contains (3, 1, Consultation OPD,

Re: Saving data fails because of null constraint when data is not null

2018-12-22 Thread Glen D souza
if you check the error message DETAIL: Failing row contains (3, 1, Consultation OPD, 135, 135, null, 1). There are total of 7 values Check your model class CGHSRates(models.Model): rid = models.AutoField(primary_key=True) serial = models.IntegerField(default=0) name = models.CharField(max_lengt

Saving data fails because of null constraint when data is not null

2018-12-22 Thread Joel Mathew
Django - constraint error I have the following python code in django which is deployed on heroku: def newimportdb(request): import xlrd loc = ("./CGHS Rates 2014- Trivandrum.xlsx") wb = xlrd.open_workbook(loc) sheet = wb.sheet_by_index(0) for i in range(sheet.nrows): try: sl = int(sheet.cell_valu