#django

/

      • archdori joined the channel
      • hell_razer joined the channel
      • RoboHak
        They aren't bad, but they could be a little more verbose
      • FunkyBob
        yeah
      • only wrote the app last week... c'mon! :P
      • v0lksman
        he says to the guy in the $6000 suit ... C'MON!
      • RoboHak
        Does it work for views that are not forms?
      • FunkyBob
        RoboHak: well, for that I'd normally use sniplates...
      • RoboHak
        My original problem was that django-crispy-forms does not work for detail views
      • FunkyBob: What are those?
      • FunkyBob
        same idea, but not form specific
      • I took the work I did in sniplates [which has a different form tags approach] and came up with formulation last week
      • phildini joined the channel
      • RoboHak
        I'm surprised there isn't something built into django to handle this
      • Is the standard way either custom templates or custom widgets?
      • FunkyBob
        standard way to control form rendering?
      • widgets in code
      • AIUI, the core devs agree it's not good enough, but so far all the alternatives were too slow
      • I haven't tested yet, but I believe formulation should be quite fast
      • gbel joined the channel
      • ustunozgur joined the channel
      • sayd joined the channel
      • sayd
        what would be a good name for this function that took n as a parameter? return "abcdefghijklmnopqrstuv"[int(n)]
      • domino14 has left the channel
      • with wxyz added obviously..
      • FunkyBob
        huh?
      • sayd
        plucking the letter of the alphabet by numerical index
      • FunkyBob
        ah
      • so it's like chr(ord('a') + int(n)) ?
      • Raisins has left the channel
      • volk_ joined the channel
      • sayd
        yeah looks to be
      • def letter_from_int(n):
      • ?
      • FunkyBob
        get_letter()?
      • hypolin joined the channel
      • theneb
        On using a RadioSelect it returns the __str__ value for a given Model. Whats the best path with a custom widget based on RadioSelect to choose a different field from the input QuerySet?
      • KristianDK joined the channel
      • sayd
        that code is good FunkyBob . it does what i need quite nicely
      • FunkyBob
        theneb: actually ,as the docs and the tutorial say, it uses __unicode__
      • theneb: but if that's not present, Python will fall back to __str__
      • byoung joined the channel
      • theneb
        FunkyBob: Okay, if that's within the model I'd like to leave that value alone. It's just for one widget that I wish to return one of the other fields.
      • mattmcc
        theneb: RadioSelect takes a renderer object, check out how RadioFieldRenderer works.
      • theneb
        Yes, have been going through that mattmcc. The Renderer seems to have the __str__ field value and not the direct access to the queryset row
      • Oddstr13 has left the channel
      • Adys joined the channel
      • Brent joined the channel
      • mattmcc
        Oh, it's a ModelChoiceField? That class has a label_from_instance method.
      • Cromulent joined the channel
      • byoung joined the channel
      • gbel joined the channel
      • ojh joined the channel
      • samuel_ joined the channel
      • rideh joined the channel
      • seanbrant joined the channel
      • altipard joined the channel
      • v0lksman
        I have a self referencing foreign key. Is there a way to find the related object that doesn't have a self reference?
      • not sure how to say that properly
      • mattmcc
        Is it nullable?
      • v0lksman
        yes
      • mattmcc
        So filter on thatfield__isnull
      • rideh joined the channel
      • jammons joined the channel
      • anth0ny joined the channel
      • v0lksman
        Agian with examples! http://dpaste.org/GvkOc/
      • filtering on null returns all the top level subnets so thats a no go
      • tdrizzy joined the channel
      • I need the top level in relation to the subnet I'm looking at
      • mattmcc
        If this is a tree structure, I highly recommend django-mptt or django-treebeard.
      • Otherwise you're working way too hard.
      • v0lksman
        I guess it could be seen as a tree but I really only need to know the top level parent of a subnet..I never really need to traverse a tree per say
      • but maybe I am working too hard and should go get a drink... :)
      • mattmcc
        What you're describing _is_ tree traversal. Finding the root given an arbitrary branch. Without storing tree data, you'll have to recursively query every node.
      • katsh joined the channel
      • v0lksman
        crap. ok...either of the two suggestions easier than the other for this simple traversal type?
      • volk_
        v0lksman tree data structure in a database = nested set model
      • look into it
      • mattmcc
        It's a single step operation in both apps.
      • FunkyBob
        mmm... nested sets :)
      • mattmcc
        Any given node will have a get_root method.
      • volk_
        :)
      • ls3 joined the channel
      • v0lksman
        yeah..just realized I can't modify these tables
      • mattmcc
        Well, then you're stuck looping through all the ancestors of your node until you find the root one.
      • Milossh joined the channel
      • v0lksman
        http://dpaste.org/7E4KP/ any reason obj would return blank? does it get destroyed if the attr doesn't exist?
      • anth0ny joined the channel
      • mattmcc
        Missing return statement?
      • BTW, bare excepts are bad.
      • v0lksman
        it should only return if masterSubnetId DoesNotExist
      • yeah I was going to qualify it once I proved the concept to myself... ;)
      • FunkyBob
        "should" does not mean "will"
      • mattmcc
        But it needs to keep that return value all the way back out your recursion chainn.
      • v0lksman
        how does one do that?
      • FunkyBob
      • mattmcc
        With the return statement you're missing.
      • FunkyBob
        wow... what a way to spot a bug
      • mattmcc
        Say you're five levels deep. The innermost invocation returns the value. But then the one that called it doesn't return anything.
      • So the fourth, third, second, and first invocations don't receive anything, and you get None.
      • It might be more clear if you used a while loop instead.
      • jdunck joined the channel
      • ls3 joined the channel
      • scruz joined the channel
      • donspaulding joined the channel
      • scruz
        hi. if i need to test a view that should force file download as an attachment, how would i go about it?
      • mattmcc
        Check the response headers?
      • scruz
        hmm. i was actually hoping i could use Client to download and parse the file
      • mattmcc
        Oh, then the fact that it's an attachment isn't relevant. Just look at the response body like you normally would.
      • scruz
        thanks
      • mattmcc
        The Content-Disposition handler is just a hint to browsers, it doesn't affect how the rest of the response is structured.
      • s/handler/header/
      • Cromulent joined the channel
      • sayan joined the channel
      • v0lksman
        thanks guys...got my recursion working...!
      • mindlogger joined the channel
      • hansy joined the channel
      • andrewaclt joined the channel
      • robmorrissey joined the channel
      • FSCV joined the channel
      • atula joined the channel
      • anth0ny joined the channel
      • gremly joined the channel
      • arrty joined the channel
      • b3free joined the channel
      • nedbat joined the channel
      • Raisins joined the channel
      • wenzhixue joined the channel
      • TodPunk joined the channel
      • tWoolie joined the channel
      • racycle joined the channel
      • majlos joined the channel
      • hoot joined the channel
      • ls3 joined the channel
      • jammons joined the channel
      • wstearns joined the channel
      • altipard joined the channel
      • faldridge joined the channel
      • craigkerstiens joined the channel
      • ls3_ joined the channel
      • andredieb joined the channel
      • methoddk joined the channel
      • TraceEv joined the channel
      • Back2Basics joined the channel
      • home joined the channel
      • craigkerstiens joined the channel
      • hyperair joined the channel
      • joshfinnie joined the channel
      • yoxyue joined the channel
      • wenzhixue joined the channel