#django

/

      • maks25 has quit
      • CrypticSquared joined the channel
      • royendgel joined the channel
      • samsagaz_ joined the channel
      • royendgel has quit
      • maks25 joined the channel
      • teratoma
        also with postgres you can stick arrays in your data models (dont know if thats a good thing)
      • mcspud
        Codd would cry
      • jessamynsmith joined the channel
      • schinckel
        I use arrays when it makes sense to.
      • Bouris has quit
      • If there will never be more than a known number of choices, it isn't such a bad idea.
      • For instance: to store something that may refer to between 0-7 weekdays, I store the ISO weekday values as an array.
      • thmcmahon joined the channel
      • mcspud
        I used to make that assumption about gender, but apparently I was wrong :)
      • FunkyBob
        Remember: "It's the word of Codd, not the word of God."
      • mcspud
        #controversy
      • schinckel
        Anything that needs to refer to a different set of possibly changeable data can't be stored as an array: at least, not without breaking referential integrity.
      • helical has quit
      • mcspud
        Technically anything that is stored as an array, mutable or not, breaks 4NF
      • But as FunkyBob said...
      • schinckel
        Indeed: but practicality beats purity.
      • mcspud
        Agreed
      • thmcmahon
        hi all, i want to have a model with a field that is based on the primary key, which is just the primary key prepended by a bit of text. i.e. PREFIX99 for the 99th entry in the database. I've tried to override the save method, but the primary key doesn't exist yet, so I think it needs to happen post save but I'm not sure how to do it. Grateful for any assistance.
      • UnknownSoldier has quit
      • Koterpillar
        thmcmahon: make it a property
      • FunkyBob
        mcspud: then again, technically datetime fields break 1nf (or is it 2?)
      • magnusgraviti joined the channel
      • mcspud
        thmcmahon - define it as a property on the model so it is computed when it is inspected
      • thmcmahon
        Koterpillar mcspud thanks guys, wasn't sure what it was called, I'll have a look at properties
      • jessamynsmith has quit
      • mcspud
      • thmcmahon
        mcspud: legend, thanks so much
      • reisio has quit
      • qengho joined the channel
      • mcspud
        FunkyBob - They break 4NF technically
      • Koterpillar
        depends
      • mcspud
        on?
      • Koterpillar
        you can view them as UNIX times
      • thmcmahon
        mcspud: works perfectly, thanks.
      • matsaman has quit
      • mcspud
        That doesn
      • 't mean anything, its just a format
      • 4NF says any shared attribute needs to be split
      • So even "First Name" can technically break it if there are 2 people named "Peter"
      • Koterpillar
        how is that different from an integer field?
      • mcspud
        But again, practicality
      • Koterpillar
        ah, yes, ok, that one
      • mcspud
        Koterpillar - its not
      • helical joined the channel
      • samsagaz_ joined the channel
      • In practice any reasonable finite set of choices that can be changed over time should be split into their own table, but `reasonable` is very subjective
      • Koterpillar
        hmm
      • Technodrome has quit
      • the "set of choices" bit is one I'll pick on
      • schinckel
        Also, if you are going to be _ordering_ by one of these "choices" (i.e., a timestamp, or even a name), then putting that value into a seperate table is probably going to be counter-productive.
      • Yeah, it's not strictly a limited set of choices.
      • Koterpillar
        time is continuous, therefore the set is infinite
      • schinckel
        I mean, there are an unlimited number of ... yeah, that.
      • mcspud
        Koterpillar - any DB system will have the deepest level of granularity it can go do though
      • so at 1ms increments, in the purest sense of it you should do that via FK relationships to a "Time" table
      • Koterpillar
        I feel like building a DB with unbounded precision floats, that has AWS keys, automatically orders itself new hardware and blocks calls until it's fulfilled
      • in fact, scratch that
      • Guest63578 is now known as rgenito
      • mcspud
        dont do that
      • username_ has quit
      • Koterpillar
        let's fork pg to report virtual tables like "datetimes", "floats" and such, and making float fields seem like FKs to that table
      • SELECT * FROM floats; will still work, obviously
      • schinckel
        hahaha
      • mcspud
        We are going down a deep, dark hole here
      • Koterpillar - I feel like Joe Celko has written something about this before :P
      • Koterpillar
        note that this hole is bounded
      • thmcmahon has quit
      • schinckel
        happy to watch, not getting involved in this one, as fun as it sounds.
      • mcspud
        He probably has a valid usecase for it
      • haha
      • FunkyBob hands out the popcorn
      • schinckel munch
      • helical has quit
      • Off the top of anyones head, does anyone know if, when calculating an income stream for an income/expense report to what period you assume it is valid? I'm guessing you annualise it, so 100/month income from child support becomes $1200 etc
      • helical joined the channel
      • Technodrome joined the channel
      • SecondForm_Glenn joined the channel
      • Combined2857 has quit
      • EyePulp joined the channel
      • qengho
        Hi hi hi. I am having trouble with the model interface. Imagine three model tables that together represent an Exam, some Exam Questions, and a student's Exam Question Answer to the exam questions. I see how I can start with exam questions answers and follow related links to Exam and Exam Questions. I want to use the database state to know what exam questions are not yet answered. That is I want to
      • construct a to-do list from db state. So, Exam has a incoming fk from Questions. A Question has incoming fk from Answer. (There are other things on answers that make it unique to a student.) I want to subtract Answers from Questions to know what's unanswered. How can I do this nicely with django models?
      • I can express it in SQL. I want to be django-y.
      • Koterpillar
        .filter(something__something__answer__pk__isnull=True)
      • qengho
        Ooo.
      • I'm trying to think of what has an 'answer'. Answer points to a Question. Question could have a related_name link back to via "answers" (eg).
      • UnknownSoldier joined the channel
      • Koterpillar
        exam.questions.filter(answer__pk__isnull=True)
      • ?
      • maks25 has quit
      • matsaman joined the channel
      • phinxy has quit
      • jennifer joined the channel
      • jennifer
        hello
      • On Mac os
      • I am getting a 404 instead of a welcome screen, yet I see no error in the console, what else could it be?
      • helical has quit
      • jennifer twiddles thumbs.
      • jarshwah_
        can you show the output of the console from the moment you runserver to the 404? https://dpaste.de/
      • matsaman
        jennifer: a 404 where?
      • jennifer
        Yes one second
      • tchalla joined the channel
      • tchalla
        how do i get a @property from a thumbs.values("title”, ‘???’) ?
      • jarshwah_
        jennifer: and you're trying to access http://127.0.0.1:8000/ in your web browser?
      • jennifer
        yes
      • On safari
      • cybo_
        tchalla, you'd need to use .only instead
      • jennifer
        whoa whoa whoa
      • It works on chrome but not safari, why is htis?
      • asadjb joined the channel
      • jarshwah_
        that's weird
      • $ python manage.py runserver 8005
      • try that, then access at port 8005
      • jennifer
        It is weird indeed, I dunno why
      • Why 8005? One sec
      • qengho
        Because it's new.
      • jennifer
        What's new?
      • jarshwah_
        just a different port, just incase something else is interfering
      • qengho
        Getting you to behave differently might lead to the solution.
      • jennifer
        Says can;'t connect to server
      • jarshwah_
        you might want to consider turning off ipv6 in network connections
      • or /etc/hosts
      • qengho
        Wat? No.
      • jennifer
        No
      • I won't do that because I write my own web server using socket and it works
      • Using 8000 and 8080
      • qengho
        Django should emit the address and port to connect to. Even on v6-only systems.
      • jennifer
        So I know it's likely not related to ipv6
      • I'm also on a Mac, I didn't make any major / serious change to the system, it's a new laptop that's supposed to "just work"
      • jarshwah_
        "know" "likely" :P
      • asadjb has quit
      • jennifer
        Well I've been surprised before
      • But then this would be one of those "this is just stupid" surprise
      • Like a game of counterstrike interfering with somebody's ability to open up word
      • I've seen that and it's just dumb, absolutely dumb
      • cybo_
        jennifer, probably best to just disable ipv6, just to be safe. I've seen some absolutely crazy behaviour from osx before
      • jennifer
        :(
      • tchalla
        cybo_: values with .only or just .only?
      • cybo_
        one of our guys' cookies wouldn't stick. all of us tried to crack it
      • jennifer
        Or I can just develop on chrome...
      • Fuck okayu
      • cybo_
        tchalla, just .only