Code

Opened 7 years ago

Closed 7 years ago

#4433 closed (invalid)

typo in django/db/models/fields/__init__.py

Reported by: Krzysztof Sitarski <sit0@…> Owned by: adrian
Component: Database layer (models, ORM) Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

in line 500 (DateTime.get_db_prep_save) there should be:

value = time.strptime(value, '%Y-%m-%d')

instead of:

value = value.strftime('%Y-%m-%d')

Attachments (1)

4433.patch (571 bytes) - added by Krzysztof Sitarski <sit0@…> 7 years ago.

Download all attachments as: .zip

Change History (7)

Changed 7 years ago by Krzysztof Sitarski <sit0@…>

comment:1 Changed 7 years ago by adrian

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Are you sure this is a typo? It's been working thus far...

Could you explain what the problem is?

comment:2 Changed 7 years ago by patrys@…

Exception Type:  	AttributeError
Exception Value: 	'str' object has no attribute 'strftime'

comment:3 Changed 7 years ago by patrys@…

BTW, I believe this was caused by using raw request.POST instead of Form.cleaned_data. This is not my code and I just fixed a similar "error" that was caused by using wrong data source

comment:4 Changed 7 years ago by mtredinnick

We are still no closer to establishing if this is a problem in Django or not. What do you have to do to replicate this problem. Merely posting the exception does not give steps to reproducing.

As Adrian mentioned, there is already a lot of code using that code path, so it must be something unusual that is being done to trigger this. A small example that demonstrates the problem would be ideal here.

comment:5 Changed 7 years ago by patrys@…

Please notice that I am not the one who filed the bug. I just saw a production code hitting the same line that the patch changes and after going through the code I found out the reason was a call to a model constructor that used request.POST instead of form.cleaned_data

comment:6 Changed 7 years ago by Simon G. <dev@…>

  • Resolution set to invalid
  • Status changed from new to closed

Marked as invalid unless someone can please give some more information?

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.