Thursday, July 23, 2015

Re: Allow users to submit django form once per day

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBCAAGBQJVsUJlAAoJEC0ft5FqUuEh6A4P/0IZJN9LF4SRtHTGLAuY0miu
AuDncEq852N6V/TglcZtjMBgkWpnIvBzxt6Lx6LWPD88eCxjXk/agppedSSRMauI
ZWm5630qdeamMRZxaVF72wdr1v93ZCNEckp2XxArzwaq33uwHbSDsiEMa+cp1d6s
tPb1D6TxxTfaShG/UlWxWbZs6ejEOA1vpLq+70c5ziqY1azP0SBdxtPocdQkF8CF
PRpMDdyCHS7NA1YxykJ7r7b31NKOnZz4Oc+4VtnkyYTwSTAKi833HGknY9dEyvPu
/We1gbs1CSfG2zzmuF4ASb9DeyXYKSsz31jbf/OpZfMiNtD1ioGMJPhRiJ/9JCU+
oz10UyDGKv1VPE6d5shW7+s65IedAumiRADCFrXrJPeSeCqFrUEglHMAGuLToQwL
5gl/j/OMnfbEoJ6FtHytcCoCHxaS24ePILPp4rviSwGHkAM4X00SGnxfW6vN2vZH
dHF79c1V+NfJn7KKuKZqyH+fZuW//30aW7Ast4Oi60UjL41nss6NF7xx9qdLYQtL
myJb0IZ8PT3aUAGKXXw1mGwoKWVcc40qz2JXIrfNBFV2nKjo914/m2xU47S0vH+/
sgHsfVfxg40SbaU4TA+uW4cd4vPUIb+cUlt5MQA5jOhGTuD5pPZ7c6DEP76zJJ54
mcX0f9ez2Z9zaWFVRvYO
=s2ZG
-----END PGP SIGNATURE-----
On 07/23/2015 01:32 PM, Nkansah Rexford wrote:
> You can save the datetime of the last form submission and check
> whether its oneday or not in the view. If its one day then show pass
> the form or else dont.
>
> Hope this helps.
>
>
> I do know I have to save the date stamp, but the question is Where? On
> the model class, the user class, or in a text file?

The database. Either a new field on a user or profile model, or on the
model the form is for, or a new model specifically for this purpose.
Hard to say with the info you've given so far which of those makes most
sense for your case, any of them could work. (E.g. "on the model the
form is for" only makes sense if that model is "owned" by a single user,
not edited by multiple users.)

Saving persistent data on a Python class (if that's what you meant by
"the model class" or "the user class") doesn't work; you'll lose the
data if the server restarts.

Text file would work, but that's a lot of hassle to no good end when you
have the database available, whose entire purpose is to store persistent
data for you.

Carl

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/55B14265.9000200%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment