Re: Clarification on Foreign Keys requested

2018-03-06 Thread Bill Freeman
When all is as usual, you don't play with pk in your code. You put the foreign object in the field of the referring object. (In python that's just a reference, so don't worry about copies, etc.) When the referring object is saved, django saves the pk of the object in the field in the db in a fie

Re: Clarification on Foreign Keys requested

2018-03-05 Thread Malik Rumi
I tried the to_field argument, that was a mistake, and I put it back. I was just inserting the pk of the foreign object. However, as things are moving through the pipeline, I used uuid.uuid4() to create additional pks as needed at it went along. Example: def process_item(self, item, spiders)

Re: Clarification on Foreign Keys requested

2018-03-05 Thread Bill Freeman
Are you specifying the to_field argument, or are you letting it default? And is the pk of the other model made by Django by default, or are you explicitly specifying a foreign key constraint on some field of your own. Things might be better in 2.0, but I've had my troubles with pk that isn't an A