#django

/

      • NomadJim joined the channel
      • SkyCaptain
        do I even need a separate view for the form?
      • gv1222 has quit
      • FunkyBob
        that depends on the functionality you want... but from the looks... no
      • garrypolley has quit
      • SkyCaptain
        ah, great!
      • OK
      • perfect, I have it working
      • NomadJim has quit
      • thanks for the help
      • FunkyBob
        you probably also want to set post.user before saving it
      • SkyCaptain
        the app is sort of predicated on one user, so I am just going to have the form only be visible when one is logged in
      • NomadJim joined the channel
      • which brings me to another question: every time I make an entry, it logs me out
      • FunkyBob
        well, your form excludes the user field...
      • SkyCaptain
        hrm
      • even after removing that directive, it still logs me out after I submit the form
      • natea joined the channel
      • NomadJim has quit
      • NomadJim joined the channel
      • pyCasso joined the channel
      • veduardo has quit
      • pyCasso
        how can i use datetime methods on strings in django?
      • FunkyBob
        use in what way?
      • pyCasso
        events.date.strftime('%A')
      • elyezer joined the channel
      • i want to take the events.date string 2015-02-14 and manipulate it using either jinja or DTL
      • krietx joined the channel
      • limbera has quit
      • ybathia joined the channel
      • FunkyBob
        again... "manipulate" is rather vague...
      • but what you get back from strfime is not a datetime object any more
      • pyCasso
        or perhaps the function that returns the date should be a method object and not a string?? like date = strftime_(self,string)
      • FunkyBob
        just
      • stop all this guff about how you're doing things
      • and tell me what you want to happen
      • ybathia_ joined the channel
      • mcspud joined the channel
      • krietx
        http://dpaste.de/tGvw — Hi, I am trying to combine two forms (a CustomerCreateForm and CustomerUpdateForm) into one form which will accept an argument (create=True/False), but I’m having issues getting this value (form __init__) usable in the class. Can anyone suggest any pointers? Thanks!
      • pyCasso
        I want to take a date string in the template {{ event.date }}
      • FunkyBob
        date string? or a datetime object?
      • pyCasso
        next I want to get values using datetime
      • FunkyBob
        ...
      • pyCasso
        {{ events.date.strftime(...) }}
      • stealthii joined the channel
      • FunkyBob
        why can't you just tell me what you want?
      • instead of t elling me how you think you want to do it?
      • WeiJunLi has quit
      • pyface joined the channel
      • brandan`
        lol
      • ybathia has quit
      • ybathia_ is now known as ybathia
      • ybathia has quit
      • FunkyBob
        DTL has a date filter for formatting datetime objects
      • pyCasso
        I want to format a date string
      • FunkyBob
        why?
      • doing that is a means to an end... what's the end?
      • brandan`
        yeah, what are your philosophical motivations, pyCasso?
      • let's get to the bottom of what makes you you
      • pilva has quit
      • pyCasso
        no motivations, Im porting an app over from another project into django
      • FunkyBob
        brandan`: you're not helping
      • pyCasso
        i am still in my learning phase with django
      • spent months building something with flask, but I really should have began with django
      • brandan`
        was i supposed to be helping?
      • FunkyBob
        brandan`: you weren't supposed to be trolling.
      • brandan`
        i wasn't trolling
      • FunkyBob
        that's a matter of perspective.
      • brandan`
        whatever you need to tell yourself
      • FunkyBob
        pyCasso: if you want to format a datetime object in a template, use the date filter
      • pyCasso: but that is not "using datetime methods on a string"
      • pyCasso
        i tried using {{ events.date|date('%A')}}
      • got an error saying no filter named date
      • solomonix joined the channel
      • FunkyBob
        pyCasso: that is not valid DTL syntax
      • look at the examples in the docs
      • pyCasso
        o i see
      • FunkyBob
        templates are not python
      • krietx
        {{ events.date|date:”D d M Y” }} {# Fri 01 Jan 2015 #}
      • pyCasso
        i tried { events.date|date:"D d M Y" }}
      • but got an error ("expected token 'end of print statement', got ':'",)
      • krietx
        Two “{“s ?
      • FunkyBob
        end of print? are you using DTL? or Jinja2?
      • pyCasso
        Jinja2
      • FunkyBob
        ah, well... I've not used that
      • can I ask why you picked jinja2?
      • brandan`
        so now we get to the philosophical motivations
      • pyCasso
        I thought by importing the jinja2 lib it simply extends the DTL
      • FunkyBob
        no
      • pyCasso
        brandan: majority of my templates are using jinja2
      • FunkyBob
        it uses jinja2 instead of DTL
      • pyCasso
        shit fire!...
      • FunkyBob
        if that's what you're into...
      • krietx
        {{ car.date_of_manufacture.strftime('%Y-%m-%d') }} from http://stackoverflow.com/questions/4830535/pyth...
      • FunkyBob
        brandan`: well, I was hoping more for technical motivations... but sure, it could be philosophical
      • pyCasso
        when i use DTL, i would need to create extensions for DTL
      • FunkyBob
        such as?
      • pyCasso
        krietx: thanks, Im well aware of how jinja2 date works
      • no "set" methods
      • rubemlrm has quit
      • no strftime methods
      • FunkyBob
        set as in "set a variable on context"?
      • no, it has the date filter for date formatting
      • pyCasso
        set as in set variable in a template
      • FunkyBob
        and {% with %} for defining stuff ad-hoc
      • pyCasso
        {% set foo = "my string" %}
      • FunkyBob
        why would you do that in oyur template?
      • minot1 joined the channel
      • {% with foo="mystring" %} .....
      • pyCasso
        query filters
      • FunkyBob
        you're affecting filters in your template?
      • no wonder you don't like DTL... you're trying to treat it like PHP
      • rubemlrm joined the channel
      • pyCasso
        haha!
      • I never said i didn't like DTL
      • FunkyBob
        DTL is written with the view of keeping "work" out of the presentation layer
      • schinckel
        If you have statements in your template that result in DB hits, you are *probably* doing it wrong.
      • pyCasso
        to be honest I thought DTL was Jinja
      • FunkyBob
        pyCasso: DTL pre-dates Jinja
      • schinckel
        That makes me think: I wonder if it would be possible to get warnings if db rendering code caused a db hit. That would be neat.
      • Could even make it errors if DEBUG.
      • pyCasso
        im pursuing Jinja for future use, doesn't seem to far off
      • FunkyBob
        wonder if anyone else has written a template engine adapter for Django...
      • solomonix has quit
      • I know of 3... DTL, Jinja2, and Knights-Templater
      • pyCasso
        Im searching for one now...Jinja2 should play nice with django
      • FunkyBob
        pyCasso: django 1.8 provides an adapter so you can use jinja2
      • schinckel
        It does, with 1.8. Otherwise you need to do more work to get it to work.
      • FunkyBob
        pluggable template engines was a major feature of 1.8
      • pyCasso
        also, other js libraries and php libraries have been adopting the Jinja approach
      • schinckel
        Just because everyone does something doesn't make it right ;)
      • brandan`
        what does?
      • pyCasso
        using jinja2?? i think
      • schinckel
        Me saying so!
      • ;)
      • FunkyBob
        "because PHP does it" is usually a reason _not_ to do something...
      • brandan`
        why?
      • pyCasso
        I love jinja, the first time i used it
      • AirSwimmer has quit
      • I thought python language was jinja
      • hahah
      • sonofdirt joined the channel
      • brandan`
      • pyCasso
        thats my personal opinion
      • brandan`
        rasmus lerdorf has a lot of great insight
      • dting has quit
      • mattmcc
        Heh. That'd be relevant only if he'd been involved in PHP's development for the last ten years.
      • pyCasso
        jinja2 made me switch to python.
      • luisalonsocn joined the channel