#django

/

      • jrabbit joined the channel
      • jhfisc joined the channel
      • jrabbit
        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?
      • jtiai^
        Yes.
      • jhfisc has quit
      • roomcayz joined the channel
      • jhfisc joined the channel
      • bullicon joined the channel
      • plfiorini joined the channel
      • loa: Is jsut one or two fields that should update timestamp if changed? Or any fields on your model?
      • loa
        Few
      • busla joined the channel
      • jhfisc has quit
      • Title, description, price
      • FunkyBob
        the form will know
      • hamub has quit
      • jonez has quit
      • busla has quit
      • madil joined the channel
      • xliiv joined the channel
      • jhfisc joined the channel
      • Itkovian joined the channel
      • andyhoang2 has quit
      • jhfisc has quit
      • mrgrj|afk is now known as mrgrj
      • Itkovian has quit
      • xall_ joined the channel
      • jhfisc joined the channel
      • xall has quit
      • jhfisc has quit
      • phinxy joined the channel
      • busla joined the channel
      • goldfish joined the channel
      • andyhoang2 joined the channel
      • Tadassssss
        how do I subtract current date with date from sql orm timestamp?
      • in django template
      • is it even possible?
      • Biwaa has quit
      • pyface joined the channel
      • Biwaa joined the channel
      • jtiai^
        Tadassssss: Should be possible.
      • Biwaa has quit
      • Itkovian joined the channel
      • lolidunno has quit
      • Tadassssss: something like .annotate(ExpressionWrappere(datetime.now() - F('myfield'), output_field=DateTimeField())) should work.
      • bullicon has quit
      • chaosk joined the channel
      • bkxd joined the channel
      • roomcayz joined the channel
      • bullicon joined the channel
      • exaroth joined the channel
      • ISC has quit
      • doismellburning
        jtiai^: that's some funny looking DTL ;P
      • jtiai^
        doismellburning: where? :o
      • FunkyBob
        Tadassssss: avoid doing work in your template :)
      • jtiai^
        or.. :D my reading skills sucks :D
      • jwhitmore joined the channel
      • plfiorini has quit
      • jhfisc joined the channel
      • plfiorini joined the channel
      • fleetfox
      • date - date is dateinterval, what are you gonna do with that in template
      • Tadassssss
        jtiai^, could you check, I have this https://paste.pound-python.org/show/4YISXGGIRWr...
      • I have no idea how to subtract that >.>
      • second day working in django
      • jhfisc has quit
      • hamub joined the channel
      • scruz has quit
      • jtiai^
        Tadassssss: Do that math in a view code.
      • Tadassssss
        yes, but how could I retrieve only date column, jtiai^?
      • jtiai^
        Um... you can do something like: obj.date_difference = datetime.date.today() - obj.date
      • jhfisc joined the channel
      • Tadassssss
        jtiai^, I think I tried something similiar but received obj has no attribute date, I will try again
      • jtiai^
        also your view code is bit strange by doing manual template loading..
      • Tadassssss
        jtiai^, Yes I would like to know how to do that dinamically, because that is the goal of this app, just total newb and dont know anything
      • fleetfox
        offical tutorial?
      • jtiai^
        Tadassssss: https://docs.djangoproject.com/en/1.11/intro/tu... that's a bit better way.
      • Tadassssss
        jtiai^, aa like this, ok thanks!
      • jhfisc has quit
      • jhfisc joined the channel
      • jtiai^
        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
      • jtiai^
      • And after that you can do in your tempalte: {{ obj.date_diff }}
      • Tadassssss
        jtiai^, okay thanks I will try to work on this!
      • jhfisc has quit
      • Tadassssss has quit
      • DrYockel has quit
      • FunkyBob
        so here I find myself again... craving a project to occupy my mind
      • jhfisc joined the channel
      • iraj joined the channel
      • nobody?
      • jtiai^
        Write direct SDO_GEOMETRY using gis backend for oracle, instead of current WKT based...
      • Cyph0n joined the channel
      • FunkyBob
        jtiai^: I understand "gis" and "oracle" .... in that sentence.
      • jtiai^
        Well latest cx_Oracle bough ability to access oracle user types directly - including SDO_GEOMETRY object.
      • Compared to WKT format, it's almost 200 times faster to read and 20 times faster to write.
      • __marco has quit
      • But it needs quite a bunch of code to convert between Django geom types and SDO_GEOMETRY object.
      • Fun stuff.
      • FunkyBob
        "fun"... yes... quite
      • I might just make that fork of uwsgi, instead :)
      • jtiai^
        Actually i've done it once...
      • jhfisc has quit
      • FunkyBob
        but?
      • jtiai^
        cx_oracle had some bugs so it crashed from time to time - and I didn't put my source anywhere safe place. And then I lost... :D
      • jhfisc joined the channel
      • csotelo joined the channel
      • FunkyBob
        oracle? bugs? surely you jest!
      • finster joined the channel