Indeed, as far as I can tell, there is no canonical agreement for Django, but I really like the Rails convention:
created_at for DateTime fieldscreated_on for date fields
created works great for creation dates, but as soon as you have more ambiguous fields like activated , this becomes a problem. Is this a boolean or a date / date? Naming conventions exist to help developers understand code faster and spend less time on unimportant decisions. This is the philosophy behind the configuration convention , which is big in the Rails community, but unfortunately not so much in Django. This confusion that I mentioned, for example, is typical, and therefore I prefer to always be more clear:
- If it is boolean
is_activated - If it is datetime
activated_at - If it's just
activated_on date
I heard people say that “you should not mix field names with data types”, but in my opinion this is pretty empty advice and I never heard any specific arguments. If we want to optimize code readability and decision making, than I really think explicit naming conventions are the way to go.
Ariel source share