Re: Bulk-creating two ForeignKey linked models - id field for relationship isn't set properly?

2016-11-25 Thread Michael Viveros
Victor Hooi, did you ever find a work-around? I'm having the same problem of trying to efficiently create models that have a Many to One relationship (so that they are linked by a Foreign Key). The ticket referenced above is still open and I manually

Re: Bulk-creating two ForeignKey linked models - id field for relationship isn't set properly?

2013-08-20 Thread Victor Hooi
Hi, Cool, thanks for the link to the ticket. Very interesting reading, and I learnt something =). Apparently the ticket says the patch still needs docs/tests - guess it'll be a while before this gets integrated then...hmm. Cheers, Victor On Wed, Aug 21, 2013 at 2:11 AM, Simon Charette wrote:

Re: Bulk-creating two ForeignKey linked models - id field for relationship isn't set properly?

2013-08-20 Thread Victor Hooi
Hi, In the source file (JSON) - I have a list of Products dictionaries. The images are one of the elements in that dictionary - hence, the link between them is that images is a child of Product. Hence, when I loop through to create Product, I can create the images and link it there. At the en

Re: Bulk-creating two ForeignKey linked models - id field for relationship isn't set properly?

2013-08-20 Thread Daniel Roseman
On Tuesday, 20 August 2013 12:10:34 UTC+1, Victor Hooi wrote: > Hi, > > 1. Hmm, in that case, using bulk_create may not work - I'm currently > relying on generating the full lists of Products and ProductImages, then > saving in a batch at the end. > > So I need to loop through and call .save() i

Re: Bulk-creating two ForeignKey linked models - id field for relationship isn't set properly?

2013-08-20 Thread Victor Hooi
Hi, 1. Hmm, in that case, using bulk_create may not work - I'm currently relying on generating the full lists of Products and ProductImages, then saving in a batch at the end. So I need to loop through and call .save() individually on each Product, then the corresponding ProductImages, before

Re: Bulk-creating two ForeignKey linked models - id field for relationship isn't set properly?

2013-08-20 Thread Daniel Roseman
On Tuesday, 20 August 2013 10:57:52 UTC+1, Victor Hooi wrote: > Hi, > > *1. Bulk Creating Products/ProductImages* > > I have a Django custom management command that bulk-loads a list of > products and product images from a JSON file. > > I have a Product model, along with an ProductImage model -

Bulk-creating two ForeignKey linked models - id field for relationship isn't set properly?

2013-08-20 Thread Victor Hooi
Hi, *1. Bulk Creating Products/ProductImages* I have a Django custom management command that bulk-loads a list of products and product images from a JSON file. I have a Product model, along with an ProductImage model - each Product may have many ProductImages. class Product(models.Model): >

Re: Linked-models

2008-09-03 Thread Rajesh Dhawan
Hi Andy, > I'm just starting out with Django, so please bear with me. > > I've got a suppliers database, with a unique REF for each supplier. > I've also got a contracts database, also with a unique contract > number. > > There's another model, which I state below.. the first two fields are > to

Linked-models

2008-09-03 Thread andylockran
Guys, I'm just starting out with Django, so please bear with me. I've got a suppliers database, with a unique REF for each supplier. I've also got a contracts database, also with a unique contract number. There's another model, which I state below.. the first two fields are to store the above t

Re: Creating 2 linked models from one page

2006-08-03 Thread limodou
On 8/4/06, Ian Clelland <[EMAIL PROTECTED]> wrote: > > On 8/3/06, cyberco <[EMAIL PROTECTED]> wrote: > > > > OK, but what to do with the following in case of 2 models: > > > > In the past, I've made a custom manipulator in situations like this. > Something like this (WARNING: Untested code ahead!)

Re: Creating 2 linked models from one page

2006-08-03 Thread Ian Clelland
On 8/3/06, cyberco <[EMAIL PROTECTED]> wrote: > > OK, but what to do with the following in case of 2 models: > In the past, I've made a custom manipulator in situations like this. Something like this (WARNING: Untested code ahead!) might work for you: class CustomManipulator(forms.manipulator):

Re: Creating 2 linked models from one page

2006-08-03 Thread cyberco
OK, but what to do with the following in case of 2 models: === new_data = request.POST.copy() errors = manipulator.get_validation_errors(new_data) if not errors: manipulator.do_html2python(new_data) == The complete method is: === def new(request): manipulato

Re: Creating 2 linked models from one page

2006-08-03 Thread limodou
On 8/3/06, cyberco <[EMAIL PROTECTED]> wrote: > > Yes, but I want only one 'submit' button on the html page. This means > that the POST data goes to one 'view' method. How can I first create an > instance of A and then an instance of B (with A's id) with the same > POST data? > > You can put two m

Re: Creating 2 linked models from one page

2006-08-03 Thread cyberco
Yes, but I want only one 'submit' button on the html page. This means that the POST data goes to one 'view' method. How can I first create an instance of A and then an instance of B (with A's id) with the same POST data? --~--~-~--~~~---~--~~ You received this mes

Re: Creating 2 linked models from one page

2006-08-03 Thread limodou
On 8/3/06, cyberco <[EMAIL PROTECTED]> wrote: > > I want to enable users to fill out two forms (textareas) on one page, > where each form creates a new instance of a model/class. I have the 2 > following models: > > > class A(models.Model): > text = models.TextField()

Creating 2 linked models from one page

2006-08-03 Thread cyberco
I want to enable users to fill out two forms (textareas) on one page, where each form creates a new instance of a model/class. I have the 2 following models: class A(models.Model): text = models.TextField() class B(models.Model): a = models.ForeignKey(A) text