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,
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
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
'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
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
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
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
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
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
9 matches
Mail list logo