2:29 AM
abara
delizin: remove the $ from the dash
2:29 AM
Ariel_Calzada joined the channel
2:30 AM
$ means the end of the regex.
2:30 AM
delizin
abara: Aha! That is what I was missing
2:30 AM
abara
delizin: when using "include" the $ only needs to be putted on the urls.py inside the app
2:30 AM
delizin: ;)
2:31 AM
delizin: try to organize the URL on a grown order down-to-top
2:31 AM
this can avoid some possible problems on the resolution.
2:32 AM
surfnturf
2:33 AM
FunkyBob
why are you doing that work in dispatch ,surfnturf ?
2:33 AM
surfnturf
um because i thought thats where it should be done?
2:34 AM
isn't dispatch the first thing that happens?
2:34 AM
i want to stop unauthorized access at the beginning
2:34 AM
FunkyBob
(a) why not a DetailView ?
2:34 AM
surfnturf
Sure I could. But I'm just rendering a template so I thought templateview easy
2:34 AM
which it wasnt
2:34 AM
FunkyBob
(b) why not filter in the get_object_or_404?
2:34 AM
DetailView renders a template
2:35 AM
dray3 has quit
2:35 AM
surfnturf
how do i filter in the get_obj_or404
2:35 AM
actually i want to later move this into the base views
2:35 AM
so i can protect all of them
2:35 AM
all views that is
2:36 AM
ok detailview works
2:37 AM
i'm not sure what the diff is but i guess i can read the docs
2:37 AM
FunkyBob
2:38 AM
surfnturf
ok i have to read all the docs about those. thx
2:38 AM
could i put that get_object in the base view?
2:39 AM
FunkyBob
if it's shared, sure
2:39 AM
surfnturf
but it wouldn't work for TemplateView it seems
2:39 AM
FunkyBob
that PermittedViewMixin seems pointless
2:39 AM
why not just use LoginRequiredMixin directly?
2:39 AM
surfnturf
yeah I don't know why the other guy did that
2:39 AM
maybe he's putting in permissions later?
2:39 AM
FunkyBob
well, no, TemplateView doesn't know you want it to get an object
2:40 AM
surfnturf
ok thats what i figure
2:40 AM
FunkyBob
he? this isn't your code?
2:40 AM
surfnturf
thats the exception
2:40 AM
no not all my code
2:40 AM
i'm working with a few other guys and there also legacy code
2:40 AM
FunkyBob
ok
2:40 AM
abara
surfnturf: did someone say legacy?
2:41 AM
surfnturf
abara: yes
2:41 AM
abara
are you guys on cobol?
2:41 AM
surfnturf
no
2:41 AM
abara
ah
2:41 AM
FunkyBob
heh
2:41 AM
surfnturf
lol
2:41 AM
FunkyBob
I'm sure you all heard of my client who wrote a web site in cobol?
2:41 AM
surfnturf
thank god for that
2:41 AM
abara
aw man. i almost smelled a job
2:41 AM
FunkyBob: fastes site ever?
2:42 AM
FunkyBob
well... it was hampered by their lack of underestanding HTML, HTTP, and refusal to use cookies
2:42 AM
but what they'd done was impressive
2:42 AM
abara
.-.
2:42 AM
pyjacker
Should the save method of a model ever throw a validation error?
2:43 AM
FunkyBob
pyjacker: no
2:43 AM
abara
can't even imagine the whole code. too much to my brain
2:43 AM
FunkyBob
pyjacker: unless your whole codebase accepts that contract
2:44 AM
BabySuperman has quit
2:45 AM
pydave6367 joined the channel
2:49 AM
pembo13 joined the channel
2:54 AM
surfnturf
2:55 AM
FunkyBob
typo... remove the extra comma
2:55 AM
Morroque has quit
2:57 AM
kushal joined the channel
2:57 AM
mribeirodantas joined the channel
2:58 AM
abara has quit
2:58 AM
ccmonster has quit
2:59 AM
basix joined the channel
2:59 AM
ccmonster joined the channel
3:02 AM
solomonix has quit
3:05 AM
geezhawk joined the channel
3:05 AM
EduardoMartins joined the channel
3:06 AM
domino14 joined the channel
3:06 AM
xpen joined the channel
3:10 AM
saywat has quit
3:10 AM
Welington joined the channel
3:13 AM
Welington has quit
3:13 AM
dheerajchand joined the channel
3:24 AM
jtiai_ joined the channel
3:27 AM
pembo13
it's pretty quiet
3:27 AM
frog3r joined the channel
3:27 AM
ybathia joined the channel
3:27 AM
cssko has quit
3:28 AM
shangxiao
\o/
3:28 AM
limbera
i'm trying to sum the number of times a particular CharField[choices] appears in my model
3:29 AM
e.g. i have a User model, and each user has a location (which is a CountryField - so they look like this: {'location': u'AU'})
3:29 AM
i thought this would do it, players.values_list('location', flat=True).annotate(the_count=Count('location'))
3:29 AM
but it's just listing all of the values (rather than Count-ing them)
3:30 AM
frog3r
So I've been doing research for a couple of hours and can't find a way to do the following: I just want to override the save method for a model and everytime one ImageField is updated, I want to create a thumbnail and save it in another ImageField
3:30 AM
Right now I can detect when the field has changed, that's no issue
3:31 AM
shangxiao
frog3r: you've pretty much described the solution in your question :)
3:31 AM
frog3r
shangxiao: I know I'm almost there haha, thing is, I'm using a remote storage solution
3:32 AM
shangxiao: so most of the code I find doesn't work because it looks for local os.path's for the files
3:33 AM
shangxiao: what I wanted to know is, how can I pass the reference to the file so that I can create a smaller one, and if I'm lucky, you guys know specific library that could help me
3:33 AM
3:33 AM
JZA
hi where do I declare my static files path? I know on settings.py but how do I show them on the DTL?
3:34 AM
delizin
limbera: players.objects.values('location').annotate(the_count=Count('location'))
3:34 AM
limbera: Maybe
3:35 AM
frog3r
JZA: you have two options: one is to use the {% static %} tag documented here:
3:35 AM
limbera
delizin: i had tried that, it just gives me a lot of repeating 1 values for the_count
3:35 AM
xpen has quit
3:35 AM
e.g. {'the_count': 1, 'location': u'AU'}
3:35 AM
ad infinitum
3:35 AM
frog3r
3:35 AM
delizin
limbera: Well that isn'
3:35 AM
limbera: isn't very helpful
3:35 AM
limbera
yeh :-(
3:36 AM
frog3r
the other not much recommended way is to type: <img src="{{ STATIC_URL }}folder/file.extension"
3:36 AM
JZA
frog3r: ok
3:36 AM
althought I do have my images on MEDIA folder
3:36 AM
MEDIA_URL
3:36 AM
akaariai_ joined the channel
3:37 AM
frog3r
if its on the media its easier: if you have object.image
3:37 AM
you can just write
3:37 AM
{{object.image.url}}
3:37 AM
or {{object.file.url}}
3:37 AM
JZA
btw are those names arbitrary? or can I just namethem IMAGES and HTML?
3:37 AM
frog3r
you mean STATIC_URL and MEDIA_URL ?
3:37 AM
JZA
yeah
3:38 AM
Ig uess the folders can be whatever, I woner if the variables can be too.
3:38 AM
frog3r
they are django settings, so the DTL is importing them for you
3:38 AM
EduardoMartins has quit
3:38 AM
JZA
ok
3:38 AM
frog3r
if you create another name, you'll have to create a custom tag, as the new names won't be in the context
3:39 AM
JZA
is there a difference also between static/ and static-only/?
3:39 AM
frog3r
I've honestly never seen the second
3:39 AM
Chester1212 joined the channel
3:40 AM
xpen joined the channel
3:40 AM
akaariai has quit
3:40 AM
JZA
frog3r: usually when doing collectstatic it will send everything to static-only
3:40 AM
maybe is the guy's setup
3:42 AM
frog3r
JZA: yes, collectstatic destination folder is set with the STATIC_ROOT django setting
3:42 AM
JZA
ok
3:42 AM
frog3r
he might have STATIC_ROOT set to /static-only/
3:42 AM
and add the /static/ folder in STATICFILES_DIRS
3:46 AM
EduardoMartins joined the channel
3:46 AM
robvdl has quit
3:47 AM
akaariai_ has quit
3:48 AM
akaariai joined the channel
3:48 AM
f3lp joined the channel
3:48 AM
EduardoMartins has quit
3:53 AM
PiresFelix has quit
3:53 AM
ojii|work has quit
3:55 AM
BabySuperman joined the channel
3:59 AM
sagaragarwal94 joined the channel
4:00 AM
jtiai_ has quit
4:02 AM
any recommendations on the thumbs thing?
4:02 AM
FunkyBob
what thumbs thing?