def sighting_add(request): if request.method == 'POST': form = SightingForm(request.POST, request.FILES) if form.is_valid(): sighting = form.save(commit=False) photo_obj = save_photo(request.FILES['image']) sighting.photo = photo_obj sighting.datetime = form.cleaned_data['date_time'] sighting.save() return HttpResponseRedirect(reverse( 'ias-sighting-detail', args=[sighting.pk]) ) else: form = SightingForm() return render_to_response( 'ias/sighting.html', { 'form': form, # action="." does not work with jQuery mobile as it does not # call the URL with a slash on the end which then causes a # Django error 'action': reverse('ias-sighting-add') }, context_instance=RequestContext(request) )
def sighting(request): if request.method == 'POST': form = SightingForm(request.POST, request.FILES) if form.is_valid(): sighting = form.save(commit=False) photo_obj = save_photo(request.FILES['image']) sighting.photo = photo_obj sighting.datetime = datetime.datetime.now() sighting.save() url = [ "http://", Site.objects.all()[0].domain, reverse("ias-sighting-detail", args=[sighting.pk, IN_APP]), "#Questionnaire" ] return HttpResponse("".join(url)) else: logging.error("POST: %s, ERROR: %s" % (request.POST, form.errors)) else: logging.debug(request) return HttpResponse("OK")