1👍
From the docs:
Behind the scenes, Django appends
"_id"
to the field name to create its database column name.
alpha.asampleID_id = self.pk
This is why having a suffix of “ID” is inappropriate.
0👍
From the given error message, it looks like you are trying to save a relationship. You should pass the actual object, not its primary key.
def save(self, *args, **kwargs):
is_new = self.pk is None
super(Sample, self).save(*args, **kwargs)
if is_new:
alpha = AnotherSample()
alpha.asampleID = self
alpha.say = "Lolz"
alpha.save()
👤pram
- [Answer]-How do I use unique_together in django?
- [Answer]-Django DateTimeField User Input
- [Answer]-Possible way to create fixtures in the view with Django?
- [Answer]-Django Template DoesNotExist Error
- [Answer]-Django – ./manage.py defaults to python 2.x
Source:stackexchange.com