I am building a survey website using Django 1.7.7 and Python 3.4.4, where a user enters say his "name" and "id". I have a sql table called "list" that stores all the users names and id's. I would like my Django website to check if when a user enters his/her name and id, if the id already exists in the table for the past 30 days. Basically if the user's id exists in the past 30 days, he/she will not be prompted to take the survey, else they would have to take the survey.
I know I have to build a view function that checks this condition but I am unable to figure out what the query/logic should be. Any help on the view function would help me out in my development immensely! Thank you.