RE: DRY violation using get_or_create with defaults

2012-06-12 Thread Sells, Fred
] On Behalf Of Jonathan French Sent: Tuesday, June 12, 2012 7:52 AM To: django-users@googlegroups.com Subject: Re: DRY violation using get_or_create with defaults On 12 June 2012 04:44, Jerome Baum wrote: Drop the "defaults" kwarg to get_or_create as apparently you're not usin

Re: DRY violation using get_or_create with defaults

2012-06-12 Thread Jonathan French
On 12 June 2012 04:44, Jerome Baum wrote: > Drop the "defaults" kwarg to get_or_create as apparently you're not using > it. Also drop the conditional on those set/save statements. Ah, I should have made clear that some of the fields in defaults are NOT NULL, so it's necessary to pass them in de

Re: DRY violation using get_or_create with defaults

2012-06-12 Thread Jerome Baum
On 12 Jun 2012, at 10:44, Gelonida N wrote: > On 06/12/2012 05:44 AM, Jerome Baum wrote: >> Drop the "defaults" kwarg to get_or_create as apparently you're not >> using it. Also drop the conditional on those set/save statements. >> >> > > Wouldn't this create more db accesses than the original

Re: DRY violation using get_or_create with defaults

2012-06-12 Thread Gelonida N
On 06/12/2012 05:44 AM, Jerome Baum wrote: Drop the "defaults" kwarg to get_or_create as apparently you're not using it. Also drop the conditional on those set/save statements. Wouldn't this create more db accesses than the original code? On Monday, June 11, 2012 3:44:47 PM UTC+2, ojno wrot

Re: DRY violation using get_or_create with defaults

2012-06-11 Thread Jerome Baum
Drop the "defaults" kwarg to get_or_create as apparently you're not using it. Also drop the conditional on those set/save statements. On Monday, June 11, 2012 3:44:47 PM UTC+2, ojno wrote: > > Hi all, > > In my app, which involves doing background tasks and possibly rerunning > them a number of

Re: DRY violation using get_or_create with defaults

2012-06-11 Thread Kurtis Mullins
hmm, have you considered creating a custom Model Manager with a custom method for this purpose? I don't really have any ideas at the moment, sorry! On Mon, Jun 11, 2012 at 9:44 AM, ojno wrote: > Hi all, > > In my app, which involves doing background tasks and possibly rerunning > them a number o