These are chat archives for django/django

12th
Oct 2017
Anish Shrestha
@annshress
Oct 12 2017 01:39
@patient nncron only has windows installers :laughing: I am on linux.
djangoReactGuy
@SanskarSans
Oct 12 2017 02:33
Hello can anyone help me on google autocomplete places ?
Anish Shrestha
@annshress
Oct 12 2017 05:16
CAME TO LEARN THERE'S at command that can easily schedule task to run at a particular time.
One f-ing day on celery and cron, and there was this life saver.
djangoReactGuy
@SanskarSans
Oct 12 2017 05:24
Pierre Sigwalt
@pierresigwalt
Oct 12 2017 05:42
Hi guys I got a question, I am using django with cassandra, how can I use the COPY function from cassandra? thank you
LordXyTh
@LordXyTh
Oct 12 2017 06:27
hi everyone, im trying to add a foreign key to an existing model but I can't seem to. Any ideas?
Anish Shrestha
@annshress
Oct 12 2017 06:29
Errolog
? please
LordXyTh
@LordXyTh
Oct 12 2017 06:35
psycopg2.IntegrityError: insert or update on table "indents_indent" violates foreign key constraint "indents_indent_buyingParty_id_ccadad97_fk_indents_b"

DETAIL:  Key (buyingParty_id)=(0) is not present in table "indents_buyingparty".


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "./manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/rizwan/anaconda/envs/indentify/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/Users/rizwan/anaconda/envs/indentify/lib/python3.6/site-packages/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/rizwan/anaconda/envs/indentify/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/rizwan/anaconda/envs/indentify/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/Users/rizwan/anaconda/envs/indentify/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 204, in handle
    fake_initial=fake_initial,
  File "/Users/rizwan/anaconda/envs/indentify/lib/python3.6/site-packages/django/db/migrations/executor.py", line 115, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/Users/rizwan/anaconda/envs/indentify/lib/python3.6/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/Users/rizwan/anaconda/envs/indentify/lib/python3.6/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/Users/rizwan/anaconda/envs/indentify/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 93, in __exit__
    self.execute(sql)
  File "/Users/rizwan/anaconda/envs/indentify/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 120, in execute
    cursor.execute(sql, params)
  File "/Users/rizwan/anaconda/envs/indentify/lib/python3.6/site-packages/django/db/backends/utils.py", line 80, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/Users/rizwan/anaconda/envs/indentify/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/Users/rizwan/anaconda/envs/indentify/lib/python3.6/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/Users/rizwan/anaconda/envs/indentify/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/Users/rizwan/anaconda/envs/indentify/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
django.db.utils.IntegrityError: insert or update on table "indents_indent" violates foreign key constraint "indents_indent_buyingParty_id_ccadad97_fk_inden
ts_b"
DETAIL:  Key (buyingParty_id)=(0) is not present in table "indents_buyingparty".
Anish Shrestha
@annshress
Oct 12 2017 06:39
And your related tables?
dont post entire table
just tables and error-causing fields
Key (buyingParty_id)=(0) is not present in table
are you providing default value to the foreignkey?
LordXyTh
@LordXyTh
Oct 12 2017 06:40
yep
Anish Shrestha
@annshress
Oct 12 2017 06:40
And it is looking for 0, which can't be.
id starts from 1
LordXyTh
@LordXyTh
Oct 12 2017 06:41
ah.
let me try default =1
Anish Shrestha
@annshress
Oct 12 2017 06:41
make that foreignkey null=True
or add defaults during migrations.
LordXyTh
@LordXyTh
Oct 12 2017 06:41
nope. doesn't work
yeah i have null=True
and default=1
and blanl=True
blank*
Here's the truncated model
class SellingParty(models.Model):
    name = models.CharField(max_length=255)


class BuyingParty(models.Model):
    name = models.CharField(max_length=255)


class Indent(models.Model):
    sellingParty = models.ForeignKey(SellingParty, null=True, blank=True, default=1, on_delete=models.CASCADE)
    buyingParty = models.ForeignKey(BuyingParty, null=True, blank=True, default=1, on_delete=models.CASCADE)
Anish Shrestha
@annshress
Oct 12 2017 06:48
remove default, you either want null or default, NOT BOTH
LordXyTh
@LordXyTh
Oct 12 2017 06:49
awesome! thanks @annshress !
Raymond Joseph Usher Roche
@rjusher
Oct 12 2017 15:28
@annshress are you still looking for a solution for the celery beat, celery worker thing?