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