Q:

one to one field django


from django.db import models 
  
class Vehicle(models.Model): 
    reg_no = models.IntegerField() 
    owner = models.CharField(max_length = 100) 
  
class Car(models.Model): 
    vehicle = models.OneToOneField(Vehicle,  
          on_delete = models.CASCADE, primary_key = True) 
    car_model = models.CharField(max_length = 100) 
Here,it is good practice to name the one-to-one fiels with same name as that of related model,lowercase
0

New to Communities?

Join the community