Cleanup of the Reddit app, now uses Class views

This commit is contained in:
2011-09-09 14:20:13 +01:00
parent 0b6d97e2f6
commit 8f914a98ac
7 changed files with 102 additions and 56 deletions

View File

@@ -1,14 +1,11 @@
from django import forms
from django.contrib.auth.models import User
from reddit.models import RedditAccount
class RedditAccountForm(forms.Form):
class RedditAccountForm(forms.ModelForm):
""" Basic Reddit account input form """
username = forms.CharField(label = u'Reddit Username', max_length=64)
def clean(self):
try:
eaccount = RedditAccount.objects.get(username=self.cleaned_data['username'])
@@ -16,3 +13,8 @@ class RedditAccountForm(forms.Form):
return self.cleaned_data
else:
raise forms.ValidationError("This User ID is already registered")
class Meta:
model = RedditAccount
fields = ('username', 'user')
widgets = {'user': forms.HiddenInput()}