#django

/

      • bwillielv joined the channel
      • hexsprite joined the channel
      • FunkyBob
        so... Location.objects.filter(project__pk__in=data['id_list']) ?
      • foist
        Yes, that is my queryset
      • JesperHansen has quit
      • phix
        ok
      • foist
        JSON will look something like this: http://pastebin.com/j1yhh2d4
      • phix: thanks, I'm looking at the docs there to see if it can help.
      • phix
        it helped me :)
      • invalid post id, can you paste thr link again?
      • foist
      • noireailes joined the channel
      • csotelo has quit
      • hyperair has quit
      • I've managed to get all the right Locations - which is obvious - but then my nested serializer returns ALL projects of those Locations, rather than just the set that I need http://dpaste.com/1204350/
      • Siecje joined the channel
      • foundatron has quit
      • phix: I don't really see how I can use django-filter to achieve my needs.
      • duckx0r joined the channel
      • Left_Turn
        __love__ apart from the hardcoding on line 8 which im about to change. im still don't understand how lines 1-4 doesnt match line 20:(
      • noireailes
        Hello all. I have quick question. Currently, I have a model manager that I use to basically do a SQL GROUP BY statement. ie. (self.model.objects.values(u'asin').annotate(asin_count=Count('asin')).order_by('asin_count') ). However, i'd like to move that line into my views.py which seems to make django throw a fit. 1) Is it even possible to do that group by / addition of another column on the fly in views.py and 2) if so, how do i go about doing it? Sorr
      • duckx0r
        I've been trying to install pootle after a server upgrade (debian 6 to 7) with apache and mod_wsgi and this is the error I'm getting http://paste.ubuntu.com/5714825/ can anyone help me debug this?
      • adamsilver joined the channel
      • schinckel
        noireailes: That's what model managers are for. Views should contain as little of that type of logic as possible.
      • Ariel_Calzada joined the channel
      • foist
        I could start by making my queryset on the Project model instead, but I don't know how I would group results by Location in that case.
      • noireailes
        schinckel: gah. haha... i was afraid that would be the anwser.
      • jankowiak joined the channel
      • zerick has quit
      • velcrow
        I keep getting this error when running syncdb ... what does this mean?
      • forms.Form
      • oops not that
      • TypeError: __init__() got an unexpected keyword argument 'blank'
      • adamsilver
        Hey guys, I am wondering if I am designing my database correctly. I have a "Credit" table "TransferRequest" table. Users can request Credit to be transferred. I want to track with which transfer the credit went. So I added this field my Credit table: transfer_request = models.ForeignKey(TransferRequest, null=True, blank=True, default=None) to be able to assign the transfer ID to the credit field when a transfer is initiated. Is
      • jarshwah joined the channel
      • noireailes
        schinckel: would you mind taking a moment to look over my views and help me, on a very high level, implement this model manager? The way I need to access my data, i've tried very hard to implement as a model manager but couldn't seem to find a good way to do it without seeming incredibly "hacky". I've even tried implementing a RESTful API to try and fit what I need to do but imho, views.py is probably where I can implement it best.... http://pastebin.c
      • sohail joined the channel
      • schinckel: I am new to both python and django and while I love the elegence of both the language and the framework, I can't help but feel like the way that i'm used to programming is all very wrong for the way django is setup.
      • FunkyBob
        noireailes: are you used to using PHP? if so, yes, it's probably all very wrong :P
      • crazydiamond has quit
      • noireailes
        funkyBob: haha, actually i haven't messed much with php at all. quite frankly, i haven't done a lot of web programming at all. A lot of what i've done involves java and databases. I have some familiarity with the MVC "framework" as well.
      • justhamade has quit
      • FunkyBob
        noireailes: don't see how MVC has relevance here
      • zxq9 joined the channel
      • noireailes: but your prior experience with DBs should help
      • noireailes
        FunkyBob: It took me a long time to figure out that MVC != MTV. haha... -_-;;
      • FunkyBob
        noireailes: and MTV is so misleading, it's a mistake to not clearly state in the FAQ it's a JOKE
      • because neither models nor templates are required... only views and url patterns
      • mrap has quit
      • foist
        FunkyBob: any idea how I would filter down my nested serializer results?
      • noireailes
        FunkyBob: now i'm slightly confused, and feeling like I am at the butt end of running joke on all the "help" blogs?
      • FunkyBob
        foist: not really, sorry.. I don't know DRF well enough
      • foist: I could find you a solution using django-nap esaily enough :)
      • noireailes: confused about what?
      • foist
        FunkyBob: just checked it out :) I'm afraid I'm too far in now.
      • Kedgen has quit
      • FunkyBob
        foist: I could only help you with nap because, well, nobody knwos it like i do :P
      • mrap joined the channel
      • noireailes: Django is simple. A request comes in. It's matched against the url patterns, which selects a view. The request is passed to the view, which returns a response. Done.
      • noireailes
        FunkyBob: you said that neither models nor templates are required. I figured if I was to use django, i'd try to do it right so I spent the better half of a week converting my preexisting tables of data into the django model... lol.
      • FunkyBob
        noireailes: the definition of a "view" in Django is: a function that accepts a request as its first argument, and returns a response.
      • aznblur joined the channel
      • noireailes: sure, templates and models are powerful tools... but they're not _required_ in Django.
      • justhamade joined the channel
      • knightshade has quit
      • MentalPower joined the channel
      • schinckel
        I would say that forms (again, optional) are the next most important part of django, after views.
      • (In terms of ensuring data validation)
      • I wish I'd understood that earlier.
      • FunkyBob
        yeah
      • noireailes
        FunkyBob schinckel: In my very limited experience so far, I'm loving both templates and forms.
      • FunkyBob
        noireailes: as do we :)
      • Raisins has quit
      • schinckel
        Really, for most things, django is enough.
      • SpoutBE has quit
      • I'm sometimes hitting the boundaries: usually the ORM is the first place.
      • passy has quit
      • Although, templates can be slow, too.
      • chrisjones has quit
      • (But that's if you abuse them: as with models/ORM)
      • melinath has quit
      • noireailes
        schinckel: I could not agree with you more. I would just rather prefer to use raw SQL... haha.
      • melinath joined the channel
      • RDove joined the channel
      • hwrd|work joined the channel
      • although, I have found querysets to be immensely useful
      • hwrd|work has quit
      • schinckel
        I'd describe myself as an SQL journeyman, but at times I've had django generate better SQL than I did by hand.
      • And, if you really need to, you can drop down to raw sql.
      • hwrd|work joined the channel
      • (I actually quite enjoy writing SQL, but it can be quite time consuming)
      • sohail has quit
      • RDove
        This is kind of a newb question... I am working on an httpd server that has django enabled. The root dir is /var/www/html/ for html/php in the httpd.conf but if I put anything in the directory, I am not able to visit the url/whatever.php without getting a 404 django thing. Is there a way to let me do normal php stuff in a sub directory without disabling the django stuff?
      • schinckel
        And something like .prefetch_related() is like secret-sauce.
      • noireailes
        I find SQL very soothing. It's like solving a math problem.
      • schinckel
        noireailes: Have you ever coded in prolog?
      • FunkyBob
        I find SQL disgusting
      • noireailes
        schinkel: no, i haven't. i'll be sure to take a look at it
      • FunkyBob
      • noireailes
        funkybob: lol.
      • schinckel
        noireailes: Although, erlang is more popular now.
      • O'Reilly has a special at the moment on a book by Bank, IIRC.
      • About relational theory.
      • (Just wrote theocracy by mistake...)
      • aznblur
        How does one create a form whereby the user can choose to add more text fields?
      • bwillielv has quit
      • FunkyBob
        aznblur: sounds like a formset to me
      • schinckel
        You will need javascript to add the fields without a page load, though.
      • aznblur
        hmm.. cheers, I'll look into that then
      • melinath has quit
      • noireailes
        So, sorry to bring this back full circle but... is there NO way for me do a GROUP BY within views.py and I would HAVE to use a model manager?
      • mattmcc
        noireailes: Well, nothing stops you from running raw SQL anywhere.
      • melinath joined the channel
      • hwrd|work has quit
      • schinckel
        noireailes: Doing stuff in model manager/queryset methods is much better: you can then re-use it in multiple places.
      • FunkyBob
        noireailes: well, annotate does group by
      • schinckel
        If you need request.user, just pass that into the method.
      • adamsilver has left the channel
      • noireailes
        records = records.values(u'asin').annotate(asin_count=Count('asin')).order_by('asin_count').reverse()
      • alp82 has quit
      • this statement works perfectly in the model manager, and I love how I can chain queryset functions
      • jayfk has quit
      • on top of each other. I think it's probably the most beautiful thing i've seen when it comes to SQL lol.
      • sweetgrass joined the channel
      • schinckel
        noireailes: There is some sweet stuff in https://pypi.python.org/pypi/django-model-utils
      • FunkyBob
        ooh... Duro has a new release... really must write a Python binding for that
      • schinckel
        noireailes: I use PassThroughManager on almost every model class I write.
      • hyperair joined the channel
      • neoice joined the channel
      • tsurantino joined the channel
      • duckx0r has quit
      • noireailes: Based on Jamie Matthews' post: http://dabapps.com/blog/higher-level-query-api-...
      • Which I wish I'd read about 3 years before he wrote it.
      • noireailes
        schinckel: I don't want you to think that I just went afk. Please give me a few minutes to read through the links on both the PassThroughManager and this blog.
      • schinckel
        No worries.
      • gp has quit
      • neoice
        here's something I've been thinking about today: how come there aren't more Django things that can be installed as a "standalone application"? everyone seems to distribute their Django code at the "app" level to be included into another "project". no one seems to distribute Django code as a full "project". you can't `git clone foo && vim settings_foo.py` and run it.
      • aleray has quit
      • schinckel
        I'm idling while my pg_restore command completes for testing a data migration script, so I've nothing better to do other than type into IRC.
      • codeme has quit
      • neoice: Because that's how we make our money: integrating all of those bits and selling them to clients.
      • :)
      • noireailes
        schinckel: ^^;; haha.
      • schinckel
        There are a few: sentry comes to mind.
      • (I think there are also crms that do that, but I'm not sure)
      • FunkyBob
        wasn't there that social site ? pinax, wasn't it?
      • kristallpirat has quit
      • sohail joined the channel
      • neoice
        schinckel: I've been setting up a lot of Rails apps and even though I'm not a fan of Ruby/Rails, the fact that I can `git clone` and point my http server at the rack file... pretty powerful.
      • Siecje has quit