#django

/

      • kyheo has quit
      • mekhami
        blackcross ▸ hahah sorry that was a stupid crud app i did for a 'job interview'
      • blackcross ▸ my 'studychess' app is django channels though
      • kyheo joined the channel
      • hylje joined the channel
      • ekkelett joined the channel
      • surfnturf_
        nkuttler: looks like the problem is with django-bootstrap3. Doesn't mark message as safe. so i wrote my own display and added it. thx
      • kyheo has quit
      • kyheo joined the channel
      • hutch34_ has quit
      • Biwaa joined the channel
      • Nizumzen has quit
      • fletom has quit
      • fletom joined the channel
      • gaunledream has quit
      • rpkilby has quit
      • lucasxu has quit
      • Biwaa has quit
      • archangelic joined the channel
      • nincha
      • for templates
      • jessamynsmith joined the channel
      • jonez
        I am using |date in my template, but that only gives me the seconds offset when I use Z instead of the timezone name
      • nincha,
      • Koterpillar joined the channel
      • ozcanesen joined the channel
      • jeanba joined the channel
      • jessamynsmith has quit
      • jessamynsmith joined the channel
      • nincha
        show your code? for what you're trying to do
      • jonez
        ok hold on. ty for your help
      • casuallancelot has quit
      • aossama has quit
      • FinalAngel has quit
      • ellmetha joined the channel
      • my goal is to display "EDT" instead of "-14400". I can prolly modify the event somehow and make the format I want with a proper tzname using strftime() or such...
      • brunch875 has quit
      • nincha
        yeah are you trying to show the time in the user's timezone?
      • lacrymology joined the channel
      • papna has quit
      • Y04NN has quit
      • because you said you want it to show "EDT or PDT"
      • jonez
        nincha, eventually, yes. at the moment it's ok if I see "EDT" which is the server's timezone
      • nincha
        pl
      • ok
      • jonez
        I would like the ability to add an event in whatever timezone I want.. might be pacific time, or central, or whatever.
      • nincha
        yeah you have to explicitly ask the user what zone they want it displayed in
      • no way for it to detect their timezone that I know of
      • but yeah I don't know if there's a way to do that through the filter
      • jonez
        I'll prolly make a field in the user profile for that
      • nincha
        I'd do it in a strftime
      • jonez
        can I call strftime from the tmpl?
      • nincha
      • set the TIME_FORMAT variable I think
      • ellmetha has quit
      • or DATETIME_FORMAT would be more applicable
      • revpj joined the channel
      • aossama joined the channel
      • leetrout has quit
      • phenicie joined the channel
      • tourdownunder joined the channel
      • ellmetha joined the channel
      • kyheo has quit
      • sorry I can't help much more than that other than doing some trial and error
      • djosh has quit
      • milardovich joined the channel
      • dardevelin joined the channel
      • ellmetha1 joined the channel
      • ellmetha has quit
      • fission6
        anyone have a go to tempalte tag / filter for dict access
      • FunkyBob
        been done many times
      • but really, stop passing dicts to your context :)
      • Biwaa joined the channel
      • nincha
        ok here's what I concluded, the "date" and "time" filters in a template use the PHP style format strings, so if you wanted to do it all in the template you would do:
      • {{event.startdate|date:"D d M Y" }} {{ event.startdate|time:"H:i T" }}
      • MarkusH
        FunkyBob: double checking on my djangocon talk: I use GIN indexes on JSONB fields, GIST on spacial fields and with a unique constraint to e.g. prevent time-range overlaps (room booking and such), right?
      • sjdines joined the channel
      • ellmetha1 has quit
      • fission6
        FunkyBob: OH BOY, i don't want to but essentially i need to do some looks up as a result of the ORM not letting me do an annotate query effiecently which leads to me having to do a few queries and then map items in to each other to get some extra info
      • FunkyBob
        MarkusH: erk.. ask mattmcc or schinckel :)
      • MarkusH
        mattmcc: schinckel: consider yourself asked --^ :)
      • FunkyBob hands fission6 a fresh new yak shaving kit
      • fission6
        what does that mean
      • FunkyBob
        fission6: pull the work out of the template... either do it in the view, make a smarter data type, or move it into a filter/tag
      • fission6
        i did move the look up into a template tag
      • but i need to pass the dict in
      • Biwaa has quit
      • Koterpillar
        why don't you know the _key_ ahead of time?
      • milardovich has quit
      • fission6
        i mean i could, if i did some data restructing inside the view
      • FunkyBob
        fission6: but I also applaud you explaining the path that lead you to this point
      • Koterpillar
        FunkyBob: "stop passing dicts to your contexts" should be "stop messing around with dynamic keys"
      • fission6
        FunkyBob: its been a damn painful 24 hours
      • i have everything working i want to deploy but the annotate query was just not performant, i then made it raw SQL which is nasty and got it working and it performed a bit better, now I just threw in the towel and did seperate queries for what I need which are VERY fast but i need to associate it to "Brands" which is what I am listing in my template
      • nincha
        jonez: {{event.startdate|date:"D d M Y" }} {{ event.startdate|time:"H:i T" }} worked for me
      • FunkyBob
        fission6: well, for some background please provide the query and how it's poorly executed
      • jonez
        nincha, does that display the timezone?
      • nincha
        yes the "T" on the "time" filter
      • jonez
        ah cool
      • fission6
        FunkyBob: http://dpaste.com/2901ZQ0 been in here discussing and #postgres for the last 24 hours ;(
      • jonez
        I am going to make a custom filter to make things easier
      • FunkyBob
        fission6: I mean ,a dict lookup filter is _trivial_ .. so go with that for the short time
      • but know that you are accruing technical debt
      • fission6
        right
      • how woud you approach this
      • FunkyBob:
      • Koterpillar
        you know the problem is hard when your dpaste times out
      • jwhitmore has quit
      • fission6
        lol
      • FunkyBob
        fission6: sorry, I really need to focus on my paid work right now...
      • sounds like Koterpillar is on the case, though
      • MarkusH
        nighty-night
      • ellmetha joined the channel
      • FunkyBob
        (client dumped a list of fixes/changes on me 3 days before end of contract)
      • fission6
        totally understood
      • FunkyBob
        MarkusH: see you soon :)
      • Koterpillar
        fission6: I know little about queries though
      • so I'll just attack the map problem
      • imagine you have your filter as {{ dict|key:mykey }}, what will you write then?
      • fission6
        what do you mean
      • Koterpillar
        that's your filter for dict access
      • that results in dict[mykey]
      • what do you want to do with it?
      • hutch34_ joined the channel
      • iamhssingh has quit
      • FunkyBob
        win 4
      • tourdownunder has quit
      • fission6
        use it
      • {% with |get_item as value %} …
      • jonez
        how do I make sure my 'templatetags' module is imported? I made a 'datestamp' filter, and I consistently get an error about how 'datestamp' is not a defined tag library
      • Koterpillar
        fission6: which key did you want for this? Can you paste the structure of the data?
      • FunkyBob
        jonez: use {% load mylib %}
      • jonez: why aren't you reading the actual django docs?
      • jonez
        oh.. the 'load' is for the 'templatetags' name, not the individual filter?
      • FunkyBob
        jonez: it's for whatever you called the file
      • jonez
        that link says I'm supposed to put my filters in this custom folder.. I'll change it
      • FunkyBob
        you put them in a folder in your app called templatetags/
      • fission6
        Koterpillar: what do you mean which key did i want for this?
      • FunkyBob
      • jonez
        FunkyBob, ah. ok.
      • fixed it. prob was I needed to restart the server
      • FunkyBob
        yes, that does happen... because the reload watcher didn't know about the file
      • tourdownunder joined the channel
      • ozcanesen joined the channel
      • jonez
        ok
      • Debnet has quit
      • Biwaa joined the channel