In my previous post I was contemplating moving the forms back in with the model, I have now completed that transition. The form now lives in the same file as the model itself, which has made maintaining the two much easier since they are practically tied together. Also, since Google AppEngine does not allow one to set the choices field of a model property to something along the lines of: (("item", "user friendly item"), ("item2", "User friendly item 2")) in its choices initialiser; to have a form give the user the choices with the user friendly items but have the backend store "item", this is a work-around that solves the problem.
REDIRECT_CHOICES = ( (301, "301 - Permanent Redirect"), (302, "302 - Temporary Redirect"), (403, "403 - Access Denied"), (404, "404 - File Not Found"), (500, "500 - Internal Server Error") ) class Shorturl(db.Model): uripath = db.StringProperty(verbose_name="Path", required=True) httpcode = db.IntegerProperty(verbose_name="HTTP code", required=True, default=301, choices=[x[0] for x in REDIRECT_CHOICES]) location = db.StringProperty(verbose_name="Location") class ShorturlForm(djangoforms.ModelForm): httpcode = forms.IntegerField(widget=forms.Select(choices=REDIRECT_CHOICES), required=True, label='HTTP code') class Meta: model = Shorturl
Given the above tuple it will set the choices in the model for Google AppEngine and pass it to the field on the Django form allowing user friendly output. This will allow the user to pick the right redirect choice without having to know that various different redirect codes.