Suggestion:
```python
try:
  category_object = Category.objects.get(name=category)
except Category.DoesNotExist:
  category_object = Category.objects.create(name=category, prefix=category[:1])
  warning.append(_('Category unknown. New category created.'))
motion.category = category_object
```