Как получить uid объекта с предыдущей страницы в веб-приложении Django?

<

Здесь я получил DetailView модели Plan:

class PlanDetailView(IsStaffPermissionMixin, DetailView):
model = Plan
template_name = "backoffice/plans/plan_detail.html"
context_object_name = 'plan'

def get_object(self):
    uid = self.kwargs.get("uid")
    return get_object_or_404(Plan, uid=uid)

def get_context_data(self, **kwargs):
    # Call the base implementation first to get a context
    context = super().get_context_data(**kwargs)
    practice_sessions = PracticeSession.objects.all().filter(plan__uid=self.kwargs.get("uid"))
    context['practice_sessions'] = practice_sessions
    return context

Здесь я получил PracticeSession CreateView:

class PracticeSessionCreateView(IsStaffPermissionMixin, CreateView):
model = PracticeSession
template_name = "backoffice/practice_session/practice_session_create.html"
fields = ['uid', 'title', 'plan', 'snippet', 'welcome_content', 'done_content', 'order_index', ]
success_url = reverse_lazy('practice-sessions')
<

enter image description here enter image description here

Моя форма:

class PracticeSessionCreateForm(ModelForm):
class Meta:
    model = PracticeSession
    fields = '__all__'

Большое СПАСИБО заранее!!!

Вернуться на верх