#django

/

      • romich joined the channel
      • FunkyBob
      • oh, I should finish reading the backlog before reacting
      • compow: depends
      • telex joined the channel
      • compow: you might want to filter the queryset and distinct it before passing it to get_object_or_404
      • compow
        so i would do models.Question.objects.filter(pk=question_id, pub_date__lte=timezone.now())
      • toothe
        12 commits today...
      • wonder how to check how many lines i did in a day...
      • compow
        FunkyBob, i dont quite get it
      • FunkyBob
        compow: get_object_or_404 will accept a model or a queryset as first argument
      • aerioux has quit
      • get_object_or_404(Question.objects.filter(choice_set__isnull=False).distinct(), ....
      • compow
        okay makes sense
      • thanks
      • FunkyBob
        because when you join the m2m you end up causing multiples of the records that _do_ have choices
      • one for each choise
      • choice
      • compow
        but isnt that relation o2m?
      • one question has multiple choices but one choice doesnt belong to multiple questions
      • FunkyBob
        yes, but when you join the tables, you get one table of NxM rows
      • compow
        qs = models.Question.objects.filter(choice_set__isnull=False).distinct()
      • says its unable to resolve the keyword
      • choice__isnull=False?
      • FunkyBob
        choice__isnull perhaps?
      • nirakara joined the channel
      • compow
        okay worked
      • thanks
      • FunkyBob
        cool
      • StvnW has quit
      • nikhil_ has quit
      • the other way is Question.objects.annotate(choice_count=Count('choice')).filter(choice_count=0)
      • blackfry joined the channel
      • foxmask
        bonjello
      • AzMoo joined the channel
      • AzMoo has quit
      • FunkyBob
        foxo
      • mastizada has quit
      • mastizada joined the channel
      • bradfordli123 joined the channel
      • marlinc has quit
      • deltaskelta joined the channel
      • kmodo joined the channel
      • kmodo
        hi, really noob question: doing a query as a listview, and returns as object_list, how can i rename that so I can use {% for project in projects %} instead of in object_list?
      • FunkyBob
        quite sure the docs cover how you can set that name
      • context_object_name ?
      • deltaskelta
        I'm having some trouble understanding what the docs mean about validating formsets (MAX_FORMS), example here: https://dpaste.de/mhQK
      • FunkyBob
        I believe by default you will have object_list and {model}_list
      • kmodo
      • JoeTann has quit
      • marlinc joined the channel
      • wowww... thanks that was pretty easy
      • FunkyBob
        as it ought be, really
      • kmodo
        true, i was doing a couple other views this way return render(request, 'search.html', { 'query_string': query_string, 'posts': posts }) and didn't realize all I needed to do was set a variable
      • greg_f has quit
      • mattste joined the channel
      • FunkyBob
        careful passing raw query strings to templates...
      • mattste has left the channel
      • not_a_web_devbot has quit
      • jessamynsmith joined the channel
      • kmodo
        I believe I'm just doing it as a "you searched for..." thing, is it dangerous that way without being sanitized?
      • mattste joined the channel
      • FunkyBob
        yes
      • Rune joined the channel
      • SamSagaZ has quit
      • ekkelett has quit
      • pyface has quit
      • jessamynsmith has quit
      • kmodo
        from an injection standpoint?
      • mattste has quit
      • iron_houzi joined the channel
      • ekkelett joined the channel
      • skeuomorf joined the channel
      • FunkyBob
        yes
      • kmodo
        I didn't know that, thought django sanitized everything
      • greg_f joined the channel
      • pyface joined the channel
      • Biwaa joined the channel
      • pedro_ joined the channel
      • not_a_web_devbot joined the channel
      • Lokefar joined the channel
      • not_a_web_devbot has quit
      • pedro_
        hi all, is it possible to only change the hostname to something else than localhost in StaticLiveServerTestCase?
      • FunkyBob
        kmodo: well, it depends
      • mattmcc
        You can put an entry in your /etc/hosts that points to localhost..
      • pedro_
        mattmcc: already have that, I would like to make tests use that domain...
      • Biwaa
        that point to 127.0.0.1 (as you can't put an other name but only an ip) :)
      • kuter joined the channel
      • StvnW joined the channel
      • madboxs joined the channel
      • pedro_
        it's set here https://github.com/django/django/blob/master/dj..., but I don't see a clean to change it
      • mattmcc
        Subclass?
      • If it's just a class attribute.. Set it in your test.
      • pedro_
        it's dynamic and only gets created later, changing it at that point won't affect the localhost part
      • the hackish `self.live_server_url = self.live_server_url.replace('localhost', self.tenant1.domain_url)` does work but quite ugly :)
      • compow has quit
      • rokups joined the channel
      • Leeds has quit
      • pupil has quit
      • badet0s joined the channel
      • tulioz has quit
      • samj1912 joined the channel
      • mastizada joined the channel
      • zamro_ has quit
      • flobin joined the channel
      • zamro joined the channel
      • dlam has quit
      • moerin joined the channel
      • zamro has quit
      • SimpleName has quit
      • Biwaa has quit
      • Biwaa joined the channel
      • SimpleName joined the channel
      • mar77i
        hmm, I'm wondering. how far I should write this cache thing myself. This is kind of a gateway proxy whateverthing which is supposed to cache external resources after some post-processing.
      • Ahuj joined the channel
      • one thing I wonder especially is whether I should store the data in the database or as files, which can be text and binary, images I don't think past a few mibs...
      • SimpleName
        who can convert it to use decorator https://dpaste.de/d8Da
      • mar77i
        I think cleaning up is simpler when I only have database rows to clear...
      • mattmcc
        If it's a few mb, it'd fit in memory just fine.
      • madboxs has quit
      • mar77i
        yes. the piece.
      • but there will be quite a few requests to quite a few pieces, dunno, some 3-figure per day
      • mattmcc
        Oh, you mean a few mb per image?
      • mar77i
        yup.
      • oh, let me check anyway
      • nah, it's not even mibs. it's usually not even hundreds of kilobytes. but having thousands of ~100 kib-heavy entries in a database doesn't seem right to me...
      • StvnW has quit
      • mattmcc
        Yeah, I was thinking more like redis.
      • brxs joined the channel
      • Ahuj has quit
      • mar77i
        the entries expire after a few weeks.
      • not_a_web_devbot joined the channel
      • mattmcc
        You can set ttls on redis keys.
      • mar77i
        some at least. I don't know whether I want to add another dependency, as I have a dedicated media directory an a django app on postgres already
      • *that depends on
      • mattmcc
        It's not exactly a difficult thing to set up.
      • It also makes a good option for Django's cache system anyway.
      • mar77i
        I imagine it could be added to requirements.txt, right?
      • mattmcc
        No, it's not Python.
      • You'd install it from distro packages, like Postgres.
      • mar77i
        ugh.
      • EyePulp joined the channel
      • not_a_web_devbot has quit
      • mattmcc
        apt-get install redis-server, done.
      • foxmask
        Does someone (try to) use VueJS with Django ?
      • I search some tips / advices on how to make them work altogether
      • not sure if I can mix django template and vue template or make 2 things completly seperated
      • bradfordli123 joined the channel
      • EyePulp has quit
      • Ergo joined the channel