#django

/

      • biker
        the error says: Related Field has invalid lookup: icontains
      • does anyone knows why is this wrong? =/ thanks (:
      • Y3K
        biker: If I'm right tags is a FK, so you need to lookup for a field, not a model.
      • mike007 joined the channel
      • biker: Change it to filter(tags__name__icontains='linux')
      • biker
        Y3K: thanks (: let me do it
      • Y3K
        With name being a tag model's field (the one you're looking into)
      • colinbits has quit
      • biker
        Y3K: yes! that worked! (: thanks a lot
      • Y3K
        biker: You're welcome.
      • biker
        i knew tags was a table,., but i didnt know that i coulnt look up for it just by using the post model
      • thanks (:
      • derek_c has quit
      • oal joined the channel
      • txsl has quit
      • freannrak has quit
      • Laybunz joined the channel
      • M4r10 joined the channel
      • M4r10
        Hello Everyone, what the name of web service of Django?
      • Y3K
        M4r10: Web service? You mean the server? Well, it can be run with many of them so I don't know which one you want.
      • M4r10
        Yes, serve !
      • hwrd|work has quit
      • you can pass me some names?
      • tWoolie has quit
      • Y3K
      • Y3K
      • josuebrunel has quit
      • M4r10
        youo like Ruby?
      • Ruby have someone, e.g : Rack
      • ToApolytoXaos has quit
      • webservice Ruby,
      • Y3K
        M4r10: What? Well, the last time I checked Django was written with Python.
      • dirn joined the channel
      • M4r10: Hmm did you read what I told you?
      • colinbits joined the channel
      • M4r10
        yes, but not answered what I asked
      • Thanks, do not need you anymore
      • M4r10 has quit
      • Y3K
        You're welcome.
      • EyePulp joined the channel
      • joshfinnie joined the channel
      • colinbits has quit
      • joshfinnie has quit
      • joshfinnie joined the channel
      • FunkyBob
        Y3K: odd, I thought you'd answered him
      • le4fy joined the channel
      • Y3K
        FunkyBob: AFAIK I did, but he just thanked me, haha.
      • FunkyBob: Good morning.
      • zeograd has quit
      • FunkyBob
        how's things?
      • tWoolie joined the channel
      • yay... sounds like the baby has decided to sleep
      • Y3K
        FunkyBob: Going fine, it stills being sunday here, hehehe. In *kind of* a hurry to finifh everything before the chat with Daryl :)
      • *finish
      • rolleiflex joined the channel
      • kenbolton_ joined the channel
      • zoumpis joined the channel
      • FunkyBob
        finish?
      • what's he got you doing?
      • Laybunz has quit
      • Y3K
        FunkyBob: Oh no, it's a project for a client of mine.
      • FunkyBob
        ah
      • need a hand?
      • kenbolton has quit
      • Y3K
        FunkyBob: Hmm not really, just cleaning up templates and running a fast check, but thank you.
      • FunkyBob: May I help you with something?
      • FunkyBob
        hrm
      • picard276 joined the channel
      • picard276
        hey guys i had a question about sort_by in the django framework
      • i want to do Model.object.sort_by(some_field)
      • FunkyBob
        ok
      • Y3K
        picard276: Just ask :)
      • picard276
        but if when it sorts... there is another field... i want to sort by another criteria for the matching fields
      • Unifox has quit
      • so if i want to sort by rating.. and two entries have the same rating.. for those two entries i want to sort by another criteria as well
      • mattmcc
        picard276: I think you mean order_by, and it can take any number of fields.
      • picard276
        but in order_by.. will it always sort on the first thing in the command first?
      • (hence... if i wanted to sort by rating, then age
      • FunkyBob
        yes
      • Y3K
        FunkyBob: What was that?
      • FunkyBob
        it's all in the docs, picard276
      • kenbolton_ is now known as kenbolton
      • Y3K: well, you could help me test django-rated :)
      • ionelmc has quit
      • Mathuin joined the channel
      • Y3K
        FunkyBob: Sure, is it on GH?
      • FunkyBob
        yep
      • picard276
      • ticketbot
      • Y3K
        Checking it...
      • FunkyBob
        picard276: stop using the dev docs
      • picard276: let me guess, you use google to find stuff in the django docs?
      • picard276
        Entry.objects.order_by('blog__name', 'headline')
      • i use the django docs to find stuff i the django docs?
      • tanaydin joined the channel
      • FunkyBob
        why don't people use their brains any more?
      • Mathuin
        My crate model has two methods: capacity and jars. I would like to order by the crate utilization -- the "least full" crate to the "most full" crate. Unfortunately, .order_by() doesn't do math. Any suggestions on the best way to do this?
      • tanaydin
        anybody knows that, djang-allauth broken ?
      • i'm gettingTypeError at /accounts/facebook/login/callback/
      • 'dict' object is not callable
      • Y3K
        FunkyBob: Hey, that sounds like a really interesting app, I just thought about a pair of project that could use it.
      • Mathuin
        The SQL statement I wrote to do this has "order by (100*count(invj.id)/capacity) asc" if that helps.
      • colinbits joined the channel
      • tanaydin
        after succesbull login
      • sucessfull i mean
      • sedeki joined the channel
      • Mathuin
        I was thinking about making a property 'utilization' on my crate model and sorting in that, but it seemed a little excessive.
      • nkryptic
        Mathuin: you might try the order_by of 'extra': https://docs.djangoproject.com/en/1.5/ref/model...
      • Y3K
        FunkyBob: Any "special" testing required?
      • colinbits has quit
      • Mathuin
        nkryptic: that looks like it has potential!
      • gazumps has quit
      • BlueDreams has quit
      • If I read it correctly, .extra() lets me fake a column and then sort on it. That's pretty much what I do in my ugly SQL statement.
      • Y3K
        Mathuin: I don't have to much experience with .extra(), but AFAIK it's better to use .raw() - Don't ask me exactly why, it's an Jacob's advice :P
      • Mathuin
        .raw() always seemed a little too close to the bone, though, as if it bypassed all the optimization and laziness.
      • vbabiy joined the channel
      • BlueDreams joined the channel
      • Hmm. .extra() doesn't like the definition for jars() that I'm using, which is somewhat magic.
      • Y3K has quit
      • LewisZ joined the channel
      • colinbits joined the channel
      • Yeah, order_by is not property friendly.
      • colinbits has quit
      • gazumps joined the channel
      • sedeki_ joined the channel
      • For the curious: [(crate.id, crate.capacity, crate.jars) for crate in sorted(Crate.objects.filter(bin__in=Bin.objects.filter(shelf__in=Shelf.objects.filter(row__in=Row.objects.filter(warehouse=2)))), key=lambda c: c.jars*1.0/c.capacity)]
      • I had to do the sorting outside Django but I get the right results.
      • donkdonk has left the channel
      • heptal joined the channel
      • elky
        I'm looking at using https://pypi.python.org/pypi/django-object-perm... -- is there something better or is this the only way to get permissions for model instances?
      • LewisZ has quit
      • sedeki has quit
      • sedeki_ is now known as sedeki
      • picard276
        is there something in order_by that allows you to sort on another field if two fields have the same value?
      • i just read the documentation nothing seemed like that was available?
      • PleaseWork joined the channel
      • basically another sort aspect if a tie exists for the tied items?
      • PleaseWork
        I am using a custom ErrorList in a form, in which I output specific html (div, etc.) However, when an error gets rendered using {{ form.errors }} I still see the normal django error formatting (class=errorlist, etc.)
      • elky
        picard276, do you mean like: .order_by('name', 'created_date') ?
      • PleaseWork
        Any ideas on what is going on?
      • picard276
        elky but will that only order on created_date if name is the same
      • luyikei__ joined the channel
      • what i tried to do elky was order_by('rating', Count('categories'))
      • elky
        picard276, afaik
      • picard276
        so that i only basically if a rating is tied
      • Mathuin
        picard276: I don't know if it'll like Count() there. You could try .annotate(numcat=Count('categories')).order_by('rating', 'numcat')
      • picard276
        let me give that a whirl Mathuin
      • Mathuin
        I got the idea from the help for .annotate(), which is right above the help for .order_by() on the QuerySet API reference page.
      • dmclain has quit