#10244: FileFields can't be set to NULL in the db
-------------------------------------+-------------------------------------
Reporter: oyvind | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.0
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: filefield NULL | Needs documentation: 1
empty | Patch needs improvement: 0
Has patch: 1 | UI/UX: 0
Needs tests: 1 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Comment (by siroky@…):
I bumped into a problem. If `instance.null_file_field` is None then
methods like `save()` will not work (AttributeError: 'NoneType' object has
no attribute 'save'). I'm thinking about 2 solutions:
1) Make the descriptor return value comparable to None (via `__eq__`).
This is not very clean because the best practise is to use operator `is`
(`is_none = x is None`).
2) Keep the empty string ("") on the Python side as a representation of
file's database NULL. Not very consistent but it has better backward
compatibility if someone already uses the string comparison (`has_no_file
= filefield.name == ""`).
Any suggestions?
--
Ticket URL: <https://code.djangoproject.com/ticket/10244#comment:14>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.f759c7f6c751ddb7041701c594733bb6%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.