title: How to query for a certain Day (DateField) in django ORM
body: <p>I have an app in which I need to query the database for a certain date, to check if there is an entry already for date x for user y.</p>
  
  <p>I have a model that has the following field:</p>
  
  <pre><code>class MyModel(models.Model):
      user = models.ForeignKey(User)
      day = models.DateField()
      info = models.CharField(max_length=100)
  </code></pre>
  
  <p>In the forms.py I have:</p>
  
  <pre><code>class MyForm(forms.ModelForm):
  
      class Meta:
          model = MyModel
  </code></pre>
  
  <p>and in the views.py code I want to check if this day exists in the database, so I run:</p>
  
  <pre><code>from datetime import date
  from myapp.models import MyModel
  from myapp.forms import MyForm
  ...
  #inside the view function
  form = MyForm(request.POST)
  day = date(form.day)
  if days.objects.filter(user=request.user, day=bookday).exists():
  ... do stuff
  </code></pre>
  
  <p>And it gives me:</p>
  
  <pre><code>Environment:
  
  
  Request Method: POST
  Request URL: http://127.0.0.1:8000/test_url/
  
  Django Version: 1.5
  Python Version: 2.7.3
  Installed Applications:
  ('django.contrib.auth',
   'django.contrib.contenttypes',
   'django.contrib.sessions',
   'django.contrib.sites',
   'django.contrib.messages',
   'django.contrib.staticfiles',
   'django.contrib.admin',
   'south',
   'myapp')
  Installed Middleware:
  ('django.middleware.common.CommonMiddleware',
   'django.contrib.sessions.middleware.SessionMiddleware',
   'django.middleware.csrf.CsrfViewMiddleware',
   'django.contrib.auth.middleware.AuthenticationMiddleware',
   'django.contrib.messages.middleware.MessageMiddleware')
  
  
  Traceback:
  File "/django/env/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
    115.                         response = callback(request, *callback_args, **callback_kwargs)
  File "/django/env/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
    25.                 return view_func(request, *args, **kwargs)
  File "/django/env/myproject/myapp/views.py" in test_url
    26.             bookday = date(form.day)
  
  Exception Type: AttributeError at /test_url/
  Exception Value: 'MyForm' object has no attribute 'day'
  </code></pre>
  
  <p>Although it clearly does have the day form as a DateField. How can I do what is needed in this case?</p>
  
  <p>The POST data:</p>
  
  <pre><code>POST
  Variable    Value
  
  csrfmiddlewaretoken =    u'blahblah'
  
  day =   u'03/27/2013'
  
  user =  u'2'
  </code></pre>
  
  <p>The HTML template form:</p>
  
  <pre><code>&lt;form method="post" action="." &gt;
  {{ form.user }}
  {{ form.day}}
  
  &lt;input type="submit" value="Submit" /&gt;
  {% csrf_token %}
  &lt;/form&gt;
  </code></pre>
  
  <p>EDIT: I clarified the code and put the stacktrace.</p>