Opened 16 years ago
Last modified 16 years ago
#9558 closed
datetime blank=True — at Version 1
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 (last modified by )
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.session['loggedinas'] 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') ...
Note:
See TracTickets
for help on using tickets.
Reformatted description. Please use preview before posting. Also, it would be ever so much more helpful if you'd specify what exact error you get. Why leave us guessing with the vague "an error"?