postgres module

Signed-off-by: Nico Schottelius <nico@wurzel.schottelius.org>
This commit is contained in:
Nico Schottelius 2015-05-14 01:24:40 +02:00
parent c3f24179fc
commit 2b9ebdf96c
2 changed files with 5 additions and 3 deletions

View file

@ -27,15 +27,16 @@ def index(request):
return render(request, 'digital_glarus/index.html') return render(request, 'digital_glarus/index.html')
def contact(request): def contact(request):
message = Message(received_date=datetime.datetime.now())
form = MessageForm(request.POST, instance=message)
if request.method == 'POST': if request.method == 'POST':
message = Message(received_date=datetime.datetime.now())
form = MessageForm(request.POST, instance=message)
if form.is_valid(): if form.is_valid():
form.save() form.save()
return HttpResponseRedirect(reverse("digital_glarus:contact")) return HttpResponseRedirect(reverse("digital_glarus:contact"))
form = MessageForm() # form = MessageForm()
context = { context = {
'form': form, 'form': form,

View file

@ -12,6 +12,7 @@ https://docs.djangoproject.com/en/1.8/ref/settings/
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os import os
import django.db.backends.postgresql_psycopg2
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))