Skip to content

Commit

Permalink
Use variable for csv date format.
Browse files Browse the repository at this point in the history
  • Loading branch information
yesimon committed Apr 11, 2014
1 parent 6abb860 commit 6674bb8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions hunger/admin.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import csv
from datetime import datetime

from django.contrib import admin
from django.http import HttpResponse

from hunger.models import InvitationCode, Invitation
from hunger.utils import now
from hunger.forms import InvitationCodeAdminForm

CSV_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"


def export_email(modeladmin, request, queryset):
response = HttpResponse(mimetype='text/csv')
Expand All @@ -21,13 +21,13 @@ def export_email(modeladmin, request, queryset):
email = obj.user.email
used = obj.used
invited = obj.invited
created = datetime.strftime(code.created, "%Y-%m-%d %H:%M:%S")
created = datetime.strftime(code.created, CSV_DATE_FORMAT)
try:
invited = datetime.strftime(obj.invited, "%Y-%m-%d %H:%M:%S")
invited = datetime.strftime(obj.invited, CSV_DATE_FORMAT)
except TypeError:
invited = ''
try:
used = datetime.strftime(obj.used, "%Y-%m-%d %H:%M:%S")
used = datetime.strftime(obj.used, CSV_DATE_FORMAT)
except TypeError:
used = ''

Expand Down

0 comments on commit 6674bb8

Please sign in to comment.