Same problem:
----
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/
site-packages/django/core/handlers/base.py" in get_response
77. response = callback(request, *callback_args, **callback_kwargs)
File "/Users/dahl/Code/telecom/confmngr/views.py" in detail
205. conf.save()
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/
site-packages/django/db/models/base.py" in save
217. db_values = [f.get_db_prep_save(f.pre_save(self, False)) for f
in non_pks]
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/
site-packages/django/db/models/fields/__init__.py" in get_db_prep_save
494. value = value.strftime('%Y-%m-%d')
AttributeError at /telecom/conference/detail/9/
'tuple' object has no attribute 'strftime'
----
This happens on update of newform. What am I doing wrong?
view code:
-----------------
conf = Conference.objects.get(id=conf_id)
if request.POST:
#validate input:
if conf.caller == os.environ['REMOTE_USER']:
p = request.POST.copy()
form = ConferenceForm(p)
print "before is valid"
if form.is_valid():
print dir(form.clean_data['conference_date'])
#try:
conf.caller=form.clean_data['caller'],
conf.extension=form.clean_data['extension'],
conf.day_of_week=form.clean_data['day_of_week'],
conf.conference_date=form.clean_data['conference_date'],
conf.conference_time=form.clean_data['conference_time'],
conf.time_zone=form.clean_data['time_zone'],
conf.group_leader=form.clean_data['group_leader'],
conf.leader_extension=form.clean_data['leader_extension'],
conf.number_of_lines=form.clean_data['number_of_lines'],
conf.domestic_lines=form.clean_data['domestic_lines'],
conf.international_lines=form.clean_data['international_lines'],
conf.duration_of_call=form.clean_data['duration_of_call'],
conf.recurring_call=form.clean_data['recurring_call'],
conf.end_date=form.clean_data['end_date'],
conf.cost_code=form.clean_data['cost_code'],
conf.unattended_tone_in=form.clean_data['unattended_tone_in']
conf.save()
msg = "Conference #%s Updated" % conf_id
-----
conferenceForm:
-----
class ConferenceForm(forms.Form):
caller = forms.CharField(max_length=256,label="Caller/Requester",
initial=os.environ['REMOTE_USER'])
extension = forms.CharField(max_length=11,label="Extension")
day_of_week = forms.ChoiceField(label="Day of
Week",choices=dow_choices)
conference_date = forms.DateField(label="Conference Date")
conference_time = forms.TimeField(label="Conference Time")
time_zone = forms.CharField(max_length=4,label="Time Zone")
group_leader = forms.CharField(max_length=32,label="Group Leader")
leader_extension = forms.CharField(max_length=11,label="Leader
Extension")
number_of_lines = forms.CharField(max_length=11,label="Number of
Lines")
domestic_lines = forms.CharField(max_length=11,label="Domestic
Lines")
international_lines =
forms.CharField(max_length=11,label="International Lines")
duration_of_call = forms.TimeField(label="Call Duration")
recurring_call = forms.CharField(label="Recurring
Call",required=False,
widget=CheckboxInput())
end_date = forms.CharField(label="End Date",required=False)
cost_code = forms.CharField(max_length=32,label="Cost Code")
unattended_tone_in = forms.CharField(label="Unattended Tone-in",
widget=CheckboxInput(),
initial=True)
On Apr 30, 11:39 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Would you mind posting your code snippet here. I have the same issue.
> I thought the widget dealt with the creation of the datetime.date obj?
>
> best regards,
>
> David
>
> On Apr 20, 4:56 am, Henrik Lied <[EMAIL PROTECTED]> wrote:
>
> > Hi Malcolm,
>
> > I just figured it out - with some help in the IRC-channel.
>
> > I passed the form variables through datetime.date. That did the trick.
>
> > Thanks for your reply!
>
> > On 20 Apr, 11:44, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
> > > On Fri, 2007-04-20 at 09:09 +0000, Henrik Lied wrote:
> > > > Hi there,
>
> > > > I'm creating a user registration system for a project.
> > > > The system uses the SelectDateWidget for user input of birthdate.
>
> > > > When I try to register a new user, the system spits back this error:
> > > > 'str' object has no attribute 'strftime'
>
> > > > This is the relevant code:
> > > > bd_month = frm.data['birthdate_month']
> > > > bd_day = frm.data['birthdate_day']
> > > > if len(bd_month) == 1:
> > > > bd_month = '0'+bd_month
> > > > if len(bd_day) == 1:
> > > > bd_day = '0'+bd_day
>
> > > > temp_date = frm.data['birthdate_year']+'-'+bd_month+'-'+bd_day
>
> > > > The error occurs in django/db/models/fields/__init__.py in
> > > > get_db_prep_save
>
> > > A few more clues might be helpful. The error message is telling you that
> > > you're passing a string where a datetime object is expected, but you
> > > don't explain how you are passing data to a model field anywhere. Note
> > > that get_db_prep_save() is used to convert Python objects back to
> > > strings for putting into the database, so if your field data has not
> > > been already converted to a Python object by that point, a mistake has
> > > been made somewhere.
>
> > > What line in the above code fragment throughs the exception? If none of
> > > those lines do it, how are you passing your data to the code that does
> > > throw the exception? Can you write a short example that shows the
> > > problem?
>
> > > Regards,
> > > Malcolm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---