Missing code to include staticfiles

If you are reading Writing your first Django app, part 6, the code won’t work until you put in the following code from https://docs.djangoproject.com/en/1.8/howto/static-files/ (in the section named Serving static files during development) to the urls.py file. from django.conf import settings from django.conf.urls.static import static urlpatterns = [ # ... the rest of your URLconf goes here ... ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) Basically your urls.py needs to know where to route the static file requests. =) ...

June 1, 2015 · 1 min · birdchan

Django using TIME_ZONE to display local time

It took me a while to figure out how to do this correctly. There is too much noise from google search… Here are my settings for everything to display correctly in my admin site w/ Django 1.8. settings.py USE_TZ = True TIME_ZONE = 'US/Pacific' HUMAN_TIME_FMT = '%Y-%m-%d %H:%M:%S %p' HUMAN_TIME_FMT is optional, I put it there for my own usage. models.py from django.conf import settings from django.db import models from django.utils import timezone class Sync(models.Model): sync_start = models.DateTimeField('sync starts') sync_end = models.DateTimeField('sync ends') def __str__(self): fmt = settings.HUMAN_TIME_FMT my_dt1 = timezone.localtime(self.sync_start).strftime(fmt) my_dt2 = timezone.localtime(self.sync_end).strftime(fmt) return 'From ' + my_dt1 + ' => ' + my_dt2 More to read: # https://docs.djangoproject.com/en/1.8/ref/settings/#std:setting-TIME_ZONE # http://en.wikipedia.org/wiki/List_of_tz_database_time_zones # http://strftime.org/ ...

May 29, 2015 · 1 min · birdchan