how to create, read, update and delete other dependent tables in detail view Django

24 views
Skip to first unread message

django_learner

unread,
Oct 10, 2018, 9:32:52 AM10/10/18
to Django users
Hi everyone
I have three tables 
class Employee(models.Model):
  name = models.CharField()

class Dependent(models.Model):
  employee_id = models.Foreignkey(Employee , on_delete= models.CASCADE)
  dependent_name = models.CharField()

class Document(models.Model):
  employee_id = models.Foreignkey(Employee , on_delete= models.CASCADE)
   document_name= models.CharField()

So, in the employee Detailview I want to perform CRUD operations on Dependent and Document table

Pls can anyone provide th solution

Thankyou






Michal Petrucha

unread,
Oct 10, 2018, 9:48:19 AM10/10/18
to Django users
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
I suggest that you start here:
https://docs.djangoproject.com/en/2.1/topics/forms/modelforms/#inline-formsets

Michal
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBCgAGBQJbvgL/AAoJEHA7T/IPM/klGbMP/An0WiaasGjW15c37OdYbh2X
2Lf3slT4Au24CuTD0XAD4bGcYoCBQP69tdwTbxNt50Tld1e0KEuJQ5OTrcjM4njr
y+U/OpktVbkstHDcVMrYOhFpnK8Rm53jKfbJykH2Wgfnb74RsaKZ1a75R62EucQJ
UZmag03Rps6DIaqKP+ctLcXZh0JqfHGsQ0vzO/EgZyye+F4Z2EtD8fyvzB0uSBgN
YIKxw7+j8PmbSgVrOVEMrHtoFhDp/98Y5TPven7K+RK0+ZfuZHnHsZ7XRCV8S9vp
p0dfS3+xo3pbtSceQwi8kl6emynyw3FpjgEHv0szNbu2OUY5wRk4xpVUFuKEDmI4
Fd2GtFKKF+sneCY0qxirSiyEJF84cQnLOYssdp9pVaJTtQxkNhal8QrWlWiZW0TG
s3jdio9IJDh95orsyApxgkhNNcPOzEVCH7GK9voVgkzwL0sTOhQfOazOnXJ/4Mw5
qgGJcyiEQwuJO50UJwtxb4ZSF+CGn3DH/9DMu8e9aaxPgTB7vg4dBpEuoPsy/IUU
HMZtpVXP3gRIxLCUJTe/RZIjIjC4sDS4GcX+AL+x+Vvnp9LVlhNYoNhe7XbQkLVl
Q0k/0GdiJT58evMEKX57wf/6j/cAL1shl3YybDhEbpfsqSHwctjdDb5l/XB2dhml
naDJ+rv9kE4lliiZMiFi
=Mu2J
-----END PGP SIGNATURE-----
Reply all
Reply to author
Forward
0 new messages