jquery data not inputting to postgresql database (django)

I have a datepicker in my base.html. The UI calendar appears in the page, so I know the libraries, etc. are set up ok, but when I submit, the date is not added into the database. Other data on the form is input.

I don't believe it's a formatting issue either, since I added a new CharField column and still get no results.

forms.py

from django import forms
from widgets import *
import datetime
from django.forms import widgets


class DateTestSaveForm(forms.Form):
    date_nm = forms.CharField(
        label=u'Date Name',
        max_length=30
    )
    fromdate = forms.DateField(label=u'date of birth', input_formats=['%d/%m/%Y', '%m/%d/%Y',], required=False, widget=widgets.DateInput(attrs={
        'class': 'required'
    }))
    testdate = forms.CharField(label=u'test')

base.html

  <script type="text/javascript">



    $(function() {
      // $( "#datepicker" ).datepicker({ dateFormat: 'YYYY-MM-DD' });
    $( "#id_fromdate" ).datepicker();
    });


    $(function() {
      // $( "#datepicker" ).datepicker({ dateFormat: 'YYYY-MM-DD' });
    $( "#id_testdate" ).datepicker();
    });


</script>   

views.py

from django.core.context_processors import csrf
from django.http import HttpResponse
from django.shortcuts import render_to_response
from d2.tt.models import *
from django import forms
from d2.tt.forms import *
from django.http import HttpResponseRedirect
from django.template import RequestContext


def datetest_save_page(request):
    if request.method == 'POST': 
        form = DateTestSaveForm(request.POST)
        if form.is_valid():
            date_nm, dummy = DateTest.objects.get_or_create(
                date_nm=form.cleaned_data['date_nm']
            )
            fromdate = form.cleaned_data['fromdate']
            testdate = form.cleaned_data['testdate']
            return HttpResponseRedirect('main_page.html') 
    else:
        form = DateTestSaveForm()
    return render_to_response('datetest_save.html', {
        'form': form, 
    },RequestContext(request))




def main_page(request):
    return render_to_response(
    'main_page.html',RequestContext(request)
    )    

datetest_save.html

{% extends "base.html" %}
{% block title %}DateTest Title{% endblock %}
{% block head %}DateTest Head{% endblock %}

{% block content %}

<form method="post" action=".">{% csrf_token %}
{{ form.as_p }}
 <input type="submit" value="save it" /> 
</form>

{% endblock %}

Thanks for your help.

EDIT: Changed forms.DateField to forms.CharField in TestDate EDIT: Added views.py, added datetest.html

Answers


Figured it out. Missing the save method.


Need Your Help

What is the Angular way of showing an indicator on a button carrying an http request action?

javascript jquery angularjs

We tend to give class to each form that the controller works with and the button so that we can identify button uniquely, and using jquery we get hold of the button and toggle the spinner gif on an...

How to model coarse grained geolocation to correct market

c# geolocation data-modeling nearest-neighbor

Use case example: Client A comes to request sales information, enters their zip code and are directed to Representative X.