Django App to pull a weather forecast from WeatherUnderground

views.py 381B

1234567891011
  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. from django.shortcuts import render
  4. from .models import Forecast
  5. from prettyprint import pp
  6. def WeatherWidget(request):
  7. today = Forecast.objects.get(pk=1)
  8. week = Forecast.objects.order_by('pk').exclude(pk=1)[:3]
  9. return render(request, 'dash/weather.tpl.html', {'today': today, 'week':week, })