estoy intentando crear un relacion de modelos en django pero me tope con este error.
NOT NULL constraint failed: app_server.client_id
si alguien pudiera ayudarme a comprender el error o a solucionarlo se lo agradeceria mucho.
models.py
class Report_detail(models.Model):
server_id = models.ForeignKey(Server, on_delete=models.CASCADE)
#report = models.ForeignKey(Report, on_delete=models.CASCADE)
key_detail = models.CharField(max_length=40)
value_detail = models.CharField(max_length=40)
detail_date = models.DateField(auto_now_add=True)
class Client(models.Model):
client = models.CharField(max_length=40)
status = models.BooleanField(default=True)
#report_date = models.DateField(auto_now_add=True)
def __str__(self):
return f'{self.client}'
class Server(models.Model):
client = models.ForeignKey(Client, on_delete=models.CASCADE)
ip = models.CharField(max_length=40)
servername = models.CharField(max_length=40)
views.py
#client = get_object_or_404(Client, id=request.POST['client'])
client = Client.objects.filter(pk=request.POST['client']).first()
dbserver_id, created = Db_server.objects.get_or_create(
client= client,
servername=servername,
ip=ip)
saludos.