Ticket #3851: ticket3851.diff

File ticket3851.diff, 630 bytes (added by Christopher Lenz <cmlenz@…>, 8 years ago)

Improved patch

  • django/db/models/manipulators.py

     
    295295            # doesn't have blank=True.
    296296            return
    297297        if isinstance(f.rel, ManyToOneRel):
    298             kwargs['%s__pk' % f.name] = field_val
     298            if field_val == '':
     299                kwargs['%s__isnull' % f.name] = True
     300            else:
     301                kwargs['%s__pk' % f.name] = field_val
    299302        else:
    300303            kwargs['%s__iexact' % f.name] = field_val
    301304    try:
Back to Top