Hello
I need the last object of model inside it.
for example I have:
class Field(models.Model):
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().c
This really should be in a custom model manager, and not the model itself.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to django-users+unsubscr...@googlegroups.
Im not agree. Managers are created for custom query. But here the query is last.
I think I got the philosophy. The default value should not be a manager,
because the database does not understand it.
Maybe I am wrong!
--
You received this message because you are subscribed to the Google Groups
"
I commented out the default value and then ran the makemigrations again, and
then uncommented again and worked. Of course by lambda.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from i
4 matches
Mail list logo