Commit 60d00cbb authored by Christophe Siraut's avatar Christophe Siraut

django 1.7: Creating a ModelForm without either the 'fields' attribute or the...

django 1.7: Creating a ModelForm without either the 'fields' attribute or the 'exclude' attribute is deprecated
parent 800107b6
from django import forms from django import forms
from .models import UserProfile, Poll, Choice, Bulletin, Vote from .models import UserProfile, Poll, Choice, Bulletin, Vote
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from datetime import datetime, timedelta from datetime import datetime
from datetimewidget.widgets import DateTimeWidget from datetimewidget.widgets import DateTimeWidget
dateTimeOptions = { dateTimeOptions = {
...@@ -18,6 +18,7 @@ class UserProfileForm(forms.ModelForm): ...@@ -18,6 +18,7 @@ class UserProfileForm(forms.ModelForm):
model = UserProfile model = UserProfile
fields = ('email_notifications',) fields = ('email_notifications',)
class DateTimeWidgetFixed(DateTimeWidget): class DateTimeWidgetFixed(DateTimeWidget):
def __init__(self, **kwargs): def __init__(self, **kwargs):
super(DateTimeWidgetFixed, self).__init__(**kwargs) super(DateTimeWidgetFixed, self).__init__(**kwargs)
...@@ -53,9 +54,12 @@ class ChoiceForm(forms.ModelForm): ...@@ -53,9 +54,12 @@ class ChoiceForm(forms.ModelForm):
# options=dateTimeOptions)} # options=dateTimeOptions)}
exclude = ('poll', 'votecount') exclude = ('poll', 'votecount')
class BulletinForm(forms.ModelForm): class BulletinForm(forms.ModelForm):
class Meta: class Meta:
model = Bulletin model = Bulletin
exclude = []
class VoteForm(forms.ModelForm): class VoteForm(forms.ModelForm):
comment = forms.CharField( comment = forms.CharField(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment