category = models.ForeignKey(Category, related_name='fields', on_delete=models.CASCADE,
default = get_last_factory_field_category())
def get_last_factory_field_category():
return Field.objects.last().category
In this definition, will get not defined error. because the function is defined after model.
preivously, I used lambda to get access to the last category. But makemigrations did not work while using lambda.
The clear problem is getting access to the last object of model inside of it.