#django

/

      • FunkyBob
        ICheeseYou: ?
      • the_rat has quit
      • d3m0n_ is now known as d3m0ff
      • sashah has quit
      • d3m0ff is now known as d3m0n_
      • ICheeseYou
        you wrote "ICheeseYou: !" after I said " morning all (in this side of the world)"
      • hence Im a bit confused
      • FunkyBob
        consider it a positive greeting
      • mike007 joined the channel
      • aberrant
        HOLY SHIT IT WORKS
      • mykul joined the channel
      • omg. I can't believe it.
      • FunkyBob
        heh
      • aberrant
        gaze upon that beautiful code
      • ICheeseYou
        consider it considered
      • aberrant
        I should snippets this.
      • It's that friggin' elegant
      • dross joined the channel
      • hansy has quit
      • FunkyBob
        heh
      • aberrant
        please to critique, FunkyBob
      • hwrd|work joined the channel
      • aleray has quit
      • sonmi joined the channel
      • robbyoconnor joined the channel
      • picoguy
        Can I not do this with templates? http://pastebin.com/qhq5JYBy
      • Reddog[0] joined the channel
      • FunkyBob
        picoguy: you can't conditionally define blocks, no
      • blocks are defined at template parse time
      • Reddog[0]
        Evening all, was wondering if someone could help me with a best practice type question. I've seen about 3-4 approaches to what I'm trying to do and just need some second opinions
      • picoguy
        FunkyBob: alright :( thanks
      • sonmi has quit
      • sonmi joined the channel
      • FunkyBob
        Reddog[0]: shoot
      • Reddog[0]
        I have some user form pages I'm trying to make friendly, and I've got a main model with some just ordinary CharFields on it. This Model can also have images associated with it, and so I'm wanting to create an ajax view that allows me to upload the images on the fly
      • That's all working fine
      • My question is how I then can associate the images that have been uploaded with the main model on that form
      • My first thought was maybe a modelformset, get ids back from the ajax call, and stuff them in hidden input boxes
      • bluepnume has quit
      • picoguy
        FunkyBob: is there an easy way to restrict a page to specific users?
      • Reddog[0]
        but that seems maybe like overkill
      • FunkyBob
        picoguy: user_passes_test decorator?
      • k_sze has quit
      • Reddog[0]: hrm... tricky
      • sonmi
        hcalves: me again regarding multiple model managers. the problem I have now is that i have to inherit from both manager Models, which seem impossible. i'm trying to combine django-fts with a model that already uses geodjango ( https://github.com/ryszard/django-fts/blob/mast... and https://docs.djangoproject.com/en/dev/ref/contr... )
      • picoguy
        FunkyBob: ok ill look into it
      • leetrout has quit
      • Reddog[0]
        Yeah... For the sake of clarity let's say the main form / page is an "Event" and the ajax-y upload things would be photos for that event
      • FSCV has quit
      • robbyoconnor has quit
      • To skip the model formset I could use like a hidden input box with a comma delimted list, or json-encoded array, but that seems awfully hacky
      • bluepnume joined the channel
      • hcalves
        sonmi: it certainly isn't, because I already did something similar
      • Keeyai joined the channel
      • sonmi: you just need to find the Manager class GeoDjango appends to the model class, and inherit from it
      • seagreen has quit
      • sonmi
        hcalves: multiple inheritance of bother the geodjango and fts manager into a new manager class? okay, but what about my model itself having to derive from both fts.SearchableModel and the geodjango Model?
      • hcalves
        sonmi: MyModel(GeoDjangoModel, SearchableModel)?
      • [1]ChrisHC joined the channel
      • sonmi: there's nothing too magical going on. just inherit a new Model and Manager base class
      • sonmi
        hcalves: doing that leads to "TypeError: Error when calling the metaclass bases | Cannot create a consistent method resolution | order (MRO) for bases Model, SearchableModel"
      • bpmj has quit
      • XofP has quit
      • JJMalina has quit
      • feedbackflow has quit
      • Reddog[0]
        FunkyBob: Any ideas or general direction you can think of? Or, almost as good, any "definitely don't do that" advice?
      • JJMalina joined the channel
      • hcalves
        sonmi: SearchableModel is just this: https://github.com/ryszard/django-fts/blob/mast...
      • you can just inherit the managers if you want
      • FunkyBob
        Reddog[0]: you sound like you're on the right path... assuming you must "ajax" upload the images before you submit the form...
      • hcalves
        you'll might have to tweak some stuff though, I remember trying to use this django-fts library and found a bunch of problems with custom querysets
      • sonmi
        hmm, good point, although I wonder what the module private _VectorField() will do - would that be missing hten?
      • FunkyBob
        or you could just have them uploaded to the right spot, and stuff those paths into a formset
      • Reddog[0]
        FunkyBob: I don't necessarily *have* to, but I think it makes the user experience considerably nicer
      • hmm
      • hcalves
        sonmi: if you only need to support full text search in postgres, I would recommend taking a look at this library: https://github.com/hcarvalhoalves/django-tsearch2
      • nvandijk has quit
      • sonmi: django-fts only provides a search() method on the manager, you can't search on querysets
      • riley526 has quit
      • sonmi
        hcalves: taking a look at your library, thanks. is there a usage example?
      • juanriaza has quit
      • hcalves
        I should probably update it and add documentation
      • will do that no
      • *now
      • axolx joined the channel
      • sonmi
        hcalves: haha, thanks!
      • juanriaza joined the channel
      • hcalves
        the options are very similar django-fts though
      • racycle joined the channel
      • there's a sample project you can look for usage, under tsearch2_dev
      • sonmi
        hcalves: okay. will mixing SearchableModel and geodjango Model go smoothly though? i might have to find out the hard way
      • axolx
        hi -- is it possible to define a group with certain permissions in code, rather than in the DB? this group doesnt need to admin access, so i rather it be stored in code and available to all instances of the site (staging, production, testing)
      • hcalves
        sonmi: I remember I wrote this library specifically because I had trouble inherint from GeoDjango and using full text search fields from other libraries
      • sonmi: I'll add documentation then it might help you
      • sonmi
        hcalves: cool, thanks
      • redfive-c2g has quit
      • __love__
        anyone know a good way for me to override `upload_to` on this line (https://github.com/stephenmcd/cartridge/blob/ma...) without forking Cartridge?
      • dailylinux has quit
      • JJMalina has quit
      • d0c0nnor has quit
      • d0c0nnor joined the channel
      • rend has quit
      • thelodger has quit
      • ah the joys of bringing an IRC channel to its knees
      • rend joined the channel
      • hyperair has quit
      • gerard0 has quit
      • FunkyBob
        __love__: the real question is.... why?
      • __love__
        because i don't want file name conflicts and i don't want to maintain a fork of cartridge?
      • FunkyBob
        I reckon stephenmcd might accept a patch that let you set the valeu for that in settings...
      • stephenmcd: what say you?
      • stephenmcd
        I actually rejected it a while back
      • XofP joined the channel
      • __love__
        lol
      • FunkyBob
        stephenmcd: why's that?
      • JJMalina joined the channel
      • lcastro has quit
      • stephenmcd
        it was a while ago so I don't recall it well, but I believe the rationale was that they wanted to use a different location entirely which I said should be handled by a storages backend
      • and that there's probably a dozen or so file upload fields across the project, should every single one have a different configurable setting?
      • dstufft
        CARTAGE_STORAGE_DIRECTORIES = {}
      • bluepnume has quit
      • that or namespace your upload_to's ;)
      • stephenmcd
        it just seems like solving it at the wrong level
      • bluepnume joined the channel
      • the notion is that "product" conflicts with some other app's upload directory
      • should every single third-party app in a project have a configurable upload directory?
      • JJMalina has quit
      • __love__
        ideally, yes
      • your hardcoded idea will never be right in 100% of cases. probably not even in 50%
      • phildini has quit
      • as soon as you introduce the idea of multiple users creating products, anonymously to each other, your hardcoded path has become nothing but a giant naming conflict waiting to happen
      • aberrant
        hey FunkyBob - if you define get_query_set in a Manager, can you pass a parameter to it for use in a queryset filter?
      • jpadilla has quit
      • fly9 has quit
      • stephenmcd
        what do multiple users have to do with it, doesn't Django handle duplicate filenames?
      • __love__
        stephenmcd: it can (and does by default, yes). but it also gives me one giant directory of images
      • __love__ wants control, damnit
      • phildini joined the channel
      • stephenmcd
        how would changing the value of "product" change having a single directory for all of the images for that field?
      • __love__
        stephenmcd: if it's a function, i can pass in the user's id/username, the product name, whatever, to help namespace things
      • stephenmcd
        right that's a good argument, I didn't know you could pass a function in
      • dstufft
        yea passing a function into upload_to is awesome
      • fly9 joined the channel
      • __love__
        dstufft: i never do anything else
      • stephenmcd
        personally I don't see a problem with a single directory, but that's just me
      • byoung has quit
      • dstufft
        that doesn't work so well whne you have a ton of people uploading the same thing :)
      • __love__
        you know linux does have a limit on # of files in one directory, right? (at least AFAIK)