Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

null value in column "price" violates not-null constraint #5

Closed
jyr opened this Issue · 2 comments

3 participants

@jyr

My model:

class Product(models.Model):
name = models.CharField(max_length=100)
description = models.TextField()
cost = models.FloatField(blank=True, null=True)
price = models.FloatField()

I try with:

(venv)vagrant@lucid32:~/project$ ./manage.py loadtestdata app.Product:3
Traceback (most recent call last):
File "./manage.py", line 14, in
execute_manager(settings)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/init.py", line 438, in execute_manager
utility.execute()
File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/init.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(args, *options.dict)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(args, *options)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/db/transaction.py", line 217, in inner
res = func(args, *kwargs)
File "/usr/local/venv/local/lib/python2.7/site-packages/autofixture/management/commands/loadtestdata.py", line 208, in handle
autofixture.create(model, count, *kwargs)
File "/usr/local/venv/local/lib/python2.7/site-packages/autofixture/init.py", line 92, in create
return autofixture.create(count)
File "/usr/local/venv/local/lib/python2.7/site-packages/autofixture/base.py", line 478, in create
instance = self.create_one(commit=commit)
File "/usr/local/venv/local/lib/python2.7/site-packages/autofixture/base.py", line 456, in create_one
instance.save()
File "/usr/local/venv/local/lib/python2.7/site-packages/django/db/models/base.py", line 460, in save
self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/db/models/base.py", line 553, in save_base
result = manager._insert(values, return_id=update_pk, using=using)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/db/models/manager.py", line 195, in _insert
return insert_query(self.model, values, *
kwargs)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/db/models/query.py", line 1436, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 791, in execute_sql
cursor = super(SQLInsertCompiler, self).execute_sql(None)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 735, in execute_sql
cursor.execute(sql, params)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/db/backends/util.py", line 34, in execute
return self.cursor.execute(sql, params)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 44, in execute
return self.cursor.execute(query, args)
django.db.utils.IntegrityError: null value in column "price" violates not-null constraint

Any tip?

@romankrv

maybe, default attar?

@romankrv

maybe, default attar?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.