Answers for "how to refer to foreign key inside foreign key django"

0

django foreign key to same

class Task(models.Model):
    title = models.CharField()
    relates_to = models.ForeignKey('self')
Posted by: Guest on May-25-2021
0

django create foreignkey from id

### Specify `fk_id` ###

# Create
employee = Employee.objects.create(
  first_name='first',
  last_name='last',
  type_id=4,
)

# Edit
employee = Employee(first_name="Name", last_name="Name")
employee.type_id = 4
employee.save()
Posted by: Guest on August-25-2021

Python Answers by Framework

Browse Popular Code Answers by Language