From the docs for auto_now_add:
https://docs.djangoproject.com/en/1.11/ref/models/fields/#django.db.models.DateField.auto_now_add
The change to raise FieldError for non-editable fields was meant to prevent bugs, not to block devs from doing what they want. See https://code.djangoproject.com/ticket/26238, and please try to be less antagonistic.
On Monday, May 8, 2017 at 6:30:36 AM UTC-4, marcin....@gmail.com wrote:
-- Automatically set the field to now when the object is first created. Useful for creation of timestamps. Note that the current date is always used; it's not just a default value that you can override. So even if you set a value for this field when creating the object, it will be ignored. If you want to be able to modify this field, set the following instead of
auto_now_add=True:- For
DateField:default=date.today- fromdatetime.date.today() - For
DateTimeField:default=timezone.now- fromdjango.utils.timezone.now()
- For
https://docs.djangoproject.com/en/1.11/ref/models/fields/#django.db.models.DateField.auto_now_add
The change to raise FieldError for non-editable fields was meant to prevent bugs, not to block devs from doing what they want. See https://code.djangoproject.com/ticket/26238, and please try to be less antagonistic.
On Monday, May 8, 2017 at 6:30:36 AM UTC-4, marcin....@gmail.com wrote:
Hi.After upgrading to 1.11 I'm getting this error:FieldError: created_at cannot be specified for <MyModel> model form as it is a non-editable field.First of all, the model contains created_at field declared as DateTimeField(auto_now_add=True). Probably that's why it is non-editable. But I cannot set editable=True - the change has no effect. My application allows overriding "created_at" value, because there are more than one separate input channels, and I have such cases. Other relies on auto_now_add.I want to leave auto_now_add=True as is, and have possibility to override it.How to achieve that?PS. Somebody asked me why I'm considering leaving Django, and this is a real example of worst changes in Django in last years. Breaking compatibility and blocking a dev to do what he want. There is nothing wrong with overriding such value.Marcin
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/41e69d11-e0ab-4b1b-a78d-cf4db968df0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment