Re: update_or_create() always creates (or recreates)

2015-11-06 Thread Yunti
could compare it to the attributes of your instance and set the flag to > True if they have changed and then not bother saving if you get to the end > of processing your scraped data and the modified flag has not been set to > True. > > Dan > > On 6 November 2015 at 16:12,

Re: update_or_create() always creates (or recreates)

2015-11-06 Thread Yunti
thing else is more appropriate/best practice? On Friday, 6 November 2015 14:40:59 UTC, Dan Tagg wrote: > > Hi Yunti, > > > You could go up a level in the structure of your application and apply the > logic there, where there is more support. > > Are you using Django form

Re: update_or_create() always creates (or recreates)

2015-11-06 Thread Yunti
ults: > if getattr(obj, k) != v: > changed = True > setattr(obj, k, v) > if changed: > obj.save() > return obj, False # Updated object > else: > # Multiple objects... > > return

Re: update_or_create() always creates (or recreates)

2015-11-06 Thread Yunti
'rating': product_detail['supplierRating']}) On Thursday, 5 November 2015 20:05:39 UTC, Carsten Fuchs wrote: > > Hi Yunti, > > Am 05.11.2015 um 18:19 schrieb Yunti: > > I have tried to use the update_or_create() method assuming that it would > eith

Re: update_or_create() always creates (or recreates)

2015-11-06 Thread Yunti
n the database was updated everytime. (I suppose the issue could be with how that field gets reset to the next time it's run- I didnt) On Thursday, 5 November 2015 20:05:39 UTC, Carsten Fuchs wrote: > > Hi Yunti, > > Am 05.11.2015 um 18:19 schrieb Yunti: > > I have tried

update_or_create() always creates (or recreates)

2015-11-05 Thread Yunti
I have tried to use the update_or_create() method assuming that it would either, create a new entry in the db if it found none or update an existing one if it found one and had differences to the defaults passed in - or wouldn't update if there was no difference. However it just seemed to rec

Re: Validating data for use directly in a model (not via forms)

2015-10-21 Thread Yunti
an() after get_or_create() ? I think you may be right regarding just setting up forms for the models. I don't need a form but do need the validation. Thanks for your help. On Wednesday, 21 October 2015 19:09:01 UTC+1, Simon Charette wrote: > > Hi Yunti, > > Did you read about model

Validating data for use directly in a model (not via forms)

2015-10-21 Thread Yunti
I have a django project where I want to save web scraped data to the database via the django ORM- which will be used in the django app. The data is currently in the form of JSON -> converted to python dict via json.loads I setup my model with the narrowest/ most constrained field type possible

Django Models Joining and Normalising

2015-10-14 Thread Yunti
I'm still relatively new to Django and now working on a project that has much more complex models than I've used before. The question is about when is it best to separate out large models into separate models (and the impact caused by joining the smaller models together and also keeping data