Re: Modify get_or_create() to use field lookups parameters for values

2014-07-26 Thread Gavin Wahl
That is how it works now. On Sat, Jul 26, 2014 at 6:38 AM, Mattias Linnap wrote: > One way to make it work in presence of field lookups would be to demand > that the full values of mandatory fields must be present in the defaults > dictionary. > > For example: > Model.objects.get_or_create(name

Re: Modify get_or_create() to use field lookups parameters for values

2014-07-26 Thread Mattias Linnap
One way to make it work in presence of field lookups would be to demand that the full values of mandatory fields must be present in the defaults dictionary. For example: Model.objects.get_or_create(name_iexact='hello', defaults={'name': 'Hello', 'slug': 'foo'}) or Model.objects.get_or_create(p

Re: Modify get_or_create() to use field lookups parameters for values

2014-06-09 Thread gavinwahl
I don't think this is possible to do generally. What would count__gt=1 or pub_date__month=12 do? On Friday, June 6, 2014 3:50:08 PM UTC-6, Patrick Bregman wrote: > > Hi all, > > First of, I'm new to this list so please tell me if there's something that > can be done better. It's the best way to

Modify get_or_create() to use field lookups parameters for values

2014-06-09 Thread Patrick Bregman
Hi all, First of, I'm new to this list so please tell me if there's something that can be done better. It's the best way to learn for me ;) Recently I've been doing some reworking of an old (think Django 1.1 or 1.2) webapp of mine into the latest and greatest of Django. In the process I modifi