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().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.

-- 
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.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7de3335f-4afe-4f4b-ac1d-067e326cad1b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to