#django

/

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