objects.get_or_create() managed to create a duplicate? >_>
zencore joined the channel
stridebird joined the channel
mrgrj is now known as mrgrj|afk
Crovax31_ joined the channel
Crovax31_ has quit
jhfisc has quit
jhfisc joined the channel
Crovax31_ joined the channel
loa joined the channel
loa
Hello! How i can check if object will be updated before save?
jrabbit
Oh I think the other programmer made an assumption about it
loa
I need this because i need update one field with timestamp if it will be updated, for exmaple one of it field was changed.
jrabbit
loa: use an auto date-time thing
jtiai^
loa: Well django doesn't track dirty fields. So it uses much simpler algorithm.
Marethyu has left the channel
jrabbit
you're overcomplicating it in that case
loa
it is not i am, i just use another human db schema.
felixx has quit
i need compare fields and if there got changed, i need update timestamp and model.
jtiai^
loa: if you .save() first django checks value of pk. If it's None django does insert. if it's set, django tries to update, if that fails django tries to insert.
loa
so it will always update record right if even nothing got changed?
Tadassssss: Also I suggest that you do official tutorial. Or, Django Girls do have very excellent tutorial as well.
Tadassssss
jtiai^, I did these and they suggest only the very basics
jtiai^, with your suggested formula I'm getting AttributeError: 'QuerySet' object has no attribute 'date'
jhfisc has quit
jtiai^
Tadassssss: So you do have queryset - you then need to loop over queryset and do the math over individual objects. (which now suggests that your obj is not really object but queryset - problem with naming)
Tadassssss
jtiai^, so I need to loop in my views and not in my template right?
jtiai^
You need to do it in both. But it's for different reasons.
in a view you do data manipulation and such, in a template it's for representational purposes.
Tadassssss
jtiai^, aah, okay, then I think I will give up on this for now and move on something easier
thanks
jtiai^
Actually what you're trying to do is very fudamental :D
and basic stuff that you do almost every time.
Tadassssss
jtiai^, the thing is that i have over 100 users and increasing every time, I need to make it as a function so it would do this for me automatically
newb in python, 2months experience only
programming 6 months in total
so yeah
jtiai^
Tadassssss: If you do that math "often", you may want to write it as a property in your model.
jhfisc joined the channel
bullicon has quit
Tadassssss
okay, so as I said I will leave this for a bit later because I dont feel I have enough experience to write this yet