ForeignKey допускает нулевые значения, если это задано. Ваш код будет выглядеть так:
class Mission(models.Model):
assigned_to = models.ForeignKey('auth.User', related_name='missions_assigned',blank = True,null=True)
Вы должны записать null = True Примечание: после изменения модели вам нужно запустить python manage.py makemigrations yourappname
, а затем python manage.py migrate
[ Вопрос изначально имел perl в качестве тега ]
my $root = "msl";
/
(?<![^\s_]) # At the start of a "word" or after a "_"
\Q$root\E # Match the value of $root literally
(?: \S* s # Non-whitespace characters ending with "s", or
| [^\ss]* # Non-whitespace, non-"s" characters
)
(?!\S) # At the end of a "word"
/x
Оптимизирован:
my $root = "msl";
/
(?<![^\s_]) # At the start of a "word" or after a "_"
\Q$root\E # Match the value of $root literally
[^\ss]*+ # Non-whitespace, non-"s" characters
(?: s (?: [^\ss]*+ s )*+ )?+ # Optionally, non-whitespace characters ending with "s"
(?!\S) # At the end of a "word"
/x
В этом случае, «слово» считается последовательностью непробельных символов, разделенных пробелом, началом строки и / или концом строки.