Reputation: 67
I have bootstrap design to bind my django crud like operation. which has Modal to insert data and table to show that data on same page. in insert Modal there is 2, 3 dropdown which i want to populate with my mysql db records . thats why i want to combine two modals in single def.
views.py
def deptlist(request):
department = Department.objects.all()
return render(request, 'manageemp.html', {'department': department})
def managemp(request):
employees = Employee.objects.all()
return render(request, "manageemp.html", {'employees': employees})
forms.py
class EmpForm(ModelForm):
class Meta:
model = Employee
fields = ["employee_id", "Name", "designation", "department_id", "manager_id",
"date_of_joining","date_of_birth", "location_id", "email","contact_number",
"password", "created_by", "modified_by", "status", "user_type"]
class dept(ModelForm):
class Meta:
model = Department
fields = ["department_id", "department_name", "created_by", "modified_by", "status"]
Upvotes: 2
Views: 149
Reputation: 3890
You can return multiple context within render:
def form_view(request):
department = Department.objects.all()
employees = Employee.objects.all()
return render(request, "manageemp.html", {'department': department, 'employees': employees})
Upvotes: 1