【发布时间】:2018-03-25 12:36:53
【问题描述】:
在我的 createview URL 中,我希望有一个“?”,我可以从中将参数传递给 nect 页面。我正在使用基于类的视图。例如:
www.site.com/appname/appointment/add/?Name=1
我的 HTML 将是:
href={% url 'People:appointment-create' Patient.id %}
目前我的网址是这样的:
re_path(r'appointment/add/$', views.appointmentCreate.as_view(), name='appointment-create'),
我的观点是:
class appointmentCreate(LoginRequiredMixin, CreateView):
model = appointment
form_class = AppointmentForm
def get_initial(self):
patient = self.request.GET.get('patient')
return {
'Patient': patient,
}
我该怎么做呢?
【问题讨论】:
标签: django django-templates django-views