Есть
URL вида:
/
dashboard/shop/a2078636-6952-447d-bec4-e2306f69c03c/department/create
При создании department надо получить uuid shop'а, определить по нему shop_id(ForeignKey) и автоматически назначить его при создании Departament.
class DepartmentCreate(generic.CreateView):
model = Department
fields = ['shop_id','name', 'body']
UPD:
class DepartmentCreate(generic.CreateView):
model = Department
fields = ['shop_id','name', 'body']
def form_valid(self, form):
url_parts = self.request.path.split('/')
form.instance.shop_id = Shop.objects.get(unique_id=url_parts[3])