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?
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?
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
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)