Opened 16 years ago
Last modified 16 years ago
#9558 closed
datetime blank=True — at Initial Version
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Uncategorized | Version: | 1.0 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In a model, having a DateTimeField with blank = True, I get an error when leaving the value blank on saving.
My model is, simplified:
class Place(models.Model):
name = models.CharField(max_length=100)
class Event(models.Model):
user = models.ForeignKey(User)
place = models.ForeignKey(Place, blank=True)
starttime = models.DateTimeField(blank=True)
class EventForm(forms.ModelForm):
class Meta:
model = Event
exclude = owner
def edit_event(request, event_id=False):
userid = request.sessionloggedinas
if request.POST:
event = EventForm(request.POST)
if event.is_valid():
cleaned_data = event.cleaned_data
event = Event( user_id = userid )
fields = ['name', 'description', 'starttime', 'endtime', 'photo', 'file']
for fieldname in fields:
setattr( event, fieldname, cleaned_data[fieldname])
return HttpResponseRedirect('/success')
...