Mercurial > public > sg101
view bandmap/views.py @ 820:9a0df7bd2409
Bandmap application work in progress.
Model defined.
Map is displaying.
Initial display of add form.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 21 Sep 2014 18:20:29 -0500 |
parents | |
children | 71db8076dc3d |
line wrap: on
line source
"""Views for the bandmap application. """ from django.contrib.auth.decorators import login_required from django.shortcuts import redirect, render from bandmap.forms import BandForm def map_view(request): return render(request, 'bandmap/map.html') @login_required def add_band(request): """ Provides the ability for a user to submit a new band to the map. """ if request.method == 'POST': form = BandForm(request.POST) if form.is_valid(): band = form.save(commit=False) band.user = request.user band.save() redirect('bandmap-thanks') else: form = BandForm() return render(request, 'bandmap/add.html', { 'form': form, })