#django

/

      • wldcordeiro__ has quit
      • foist has quit
      • skeuomor1 is now known as skeuomorf
      • elestud joined the channel
      • dblado joined the channel
      • dblado has quit
      • rpkilby has quit
      • aidan
        should datetimes coming out of my postgres database be in the local timzone? they seem to be in UTC
      • rideh^ joined the channel
      • anth_x joined the channel
      • kanja has quit
      • rideh^ joined the channel
      • ubuntu_aze joined the channel
      • dang`r`us
        aidan, that depends on how your django project is configured.
      • TIME_ZONE = '...'
      • USE_TZ = True
      • if you want local time.
      • also, make sure you're not feeding django raw datetime objects
      • anyway: "Time zone support is disabled by default. "
      • mihow has quit
      • aidan
        dang`r`us: yeah I have a TIME_ZONE and USE_TZ set
      • busla has quit
      • mrhanky has quit
      • MarkusH
        aidan: pytz installed?
      • And yes, PG should have the UTC time stamps, iirc
      • mrhanky joined the channel
      • dang`r`us
        aidan, 02:28:08 dang`r`us also, make sure you're not feeding django raw datetime objects
      • mrhanky has left the channel
      • busla joined the channel
      • mrhanky joined the channel
      • aidan
        dang`r`us: created = models.DateTimeField(default=timezone.now, editable=False) ...
      • dang`r`us: def save(self, *args, **kwargs): self.updated = timezone.now()
      • dang`r`us
        aidan, looks a-ok
      • jessamynsmith has quit
      • aidan
        yeah :|
      • SteenJobs joined the channel
      • dang`r`us
        aidan, apparently the dates get normalized to UTC when saving, I'm observing the same thing here
      • aidan
        In [13]: pytz.VERSION
      • Out[13]: '2015.4'
      • I just noticed our tests fail before 10am heh
      • dang`r`us
        ouch
      • FunkyBob
        heh... I remember a test that used to fail on weekends
      • mattmcc
        Saving everything in UTC is about the only way to preserve your sanity.
      • busla joined the channel
      • dang`r`us
        yeah, after I thought a bit about it it totally makes sense
      • jmelloy
        word
      • rideh joined the channel
      • especially databases and users in different time zones
      • aidan
        yeah, so saving in UTC makes sense ... I just thought they were meant to come out in the right timezone?
      • FunkyBob
        technically, you're losing detail by discarding the timezone of the original value entered... but it's not worth thinking about for 99.9999% of cases :)
      • aidan
        What's the pattern to compare dates in tests then? timezone.make_aware(task.updated, timezone.get_current_timezone()).date() == date .. yuck
      • surely django does a SET TIMEZONE = settings.get('TIME_ZONE')
      • domino14 joined the channel
      • kanja joined the channel
      • busla has quit
      • djapo joined the channel
      • maybe Task.objects.get(pk=1).updated.astimezone(get_current_timezone()).date()
      • jiang42 joined the channel
      • shannonlucas has quit
      • raj` joined the channel
      • jiang42 has quit
      • raj` is now known as raj
      • Hairy joined the channel
      • dray3 joined the channel
      • kanja has quit
      • darylantony joined the channel
      • kanja joined the channel
      • dheerajchand joined the channel
      • or we think in UTC in the backend until it's presentation time but that's yucky too with just dates.
      • dang`r`us
        why do you need non-utc dates anyway?
      • I mean
      • you can always convert them to your preferred time zone
      • citizen-stig joined the channel
      • aidan
        dang`r`us: to eliminate ambiguity
      • dang`r`us
        aidan, ... say what now?
      • aidan
        dang`r`us: our tests break at midnight because there's ambiguit
      • y
      • slackorama has quit
      • dang`r`us
        aidan, what kind of ambiguity are you talking about?
      • and how does that test case look
      • aidan
      • citizen-stig has quit
      • dang`r`us
        well, don't use timezone.now and instead get an UTC date
      • also, this test will always be a race condition around midnight
      • aidan
        dang`r`us: we need some sort of internal policy on how we write code, at the moment it's obviously ambiguous.
      • dang`r`us
        it's not ambiguous, the test case is just dumb
      • let's say 'ambiguous' is a bad word. I'd choose 'brittle'.
      • why do you even test for date inequality like this?
      • aidan
        The test makes sure rows get their updated value changed, to pick up on a bug caused by foo.otherobjects.all().update(x=y)
      • micah_chatt joined the channel
      • sargas has quit
      • I could test for the exact datetime but also race conditions.
      • mehola joined the channel
      • toothe joined the channel
      • toothe
        I'm debatig between postgresql vs mysql for django
      • MarkusH
        aidan, get the objects, update them, get them again, test the updated time varies
      • or even "is larger"
      • darylantony has quit
      • toothe: pg
      • toothe
        why?
      • mattmcc
        Because postgres. :P
      • MarkusH
        bc 1) mysql doesn't have transactions around ddl
      • 2) because pg is smarter regarding indexing and query evaluation
      • 3) ... (I'm too lazy to find the link(s) right now)
      • jrrickerson joined the channel
      • mattmcc
        Heh. You can do a "?mysql" in #postgresql for some liks.
      • *links
      • But, unless you really want to get into the details, just save yourself the time and use Postgres.
      • lefteris has left the channel
      • Everything works better.
      • dray3 has quit
      • MarkusH
        toothe: Coming from MySQL, PG feels a bit weird to administrate in the beginning but you get used to it pretty easily
      • aidan
        MarkusH: yeah > seems reasonable
      • toothe
        MarkusH: In what sense is it weird to administrate?
      • i've never admin'd a DB
      • jmelloy has quit
      • aidan
        yeah I learned all the tooling around mysql so pg was weird, but it's so much better
      • MarkusH
        toothe: things like database templates
      • bmac joined the channel
      • only one storage backend (who the f*** though MyISAM was a good idea in the first place??)
      • rje joined the channel
      • PiresFelix joined the channel
      • bwreilly has quit
      • toothe
        i think at some point I'm gonna have to dive into the differences between databases.
      • natea joined the channel
      • pembo13 joined the channel
      • theslow1 joined the channel
      • theslow1
        hey everyone, I am using django's send_email functionality
      • is it possible that when the SMTP server goes down it takes out the entire site?
      • mattmcc
        No, it'd just raise an error.
      • theslow1
        got it, thanks matt
      • frog3r joined the channel
      • frog3r
        I've been browsing looking for an explanation, but is there some scenario where request.is_secure always returns True?
      • can it be related to the fact that I'm using nginx as a proxy?
      • FunkyBob
        when you tell django it's secure
      • frog3r
        where could I be doing that? if I'm using http only
      • FunkyBob
        well
      • it'
      • return self.scheme == 'https'
      • do you have SECURE_PROXY_SSL_HEADER set?
      • toothe
        igh...it bothers me so much that my IPv6 address isn't automatically assigned...
      • yargh....
      • frog3r
        SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
      • FunkyBob
        and did you tell nginx to set that header?
      • if you're not using https... why did you set that setting?
      • IIRC there are big fuck-off warnings around using that
      • frog3r
        I think I left it when testing changing the site to https only
      • I am planning to change the whole site to https