I found a tutorial for putting forms in modals that works but its not using 
CBVs and I'd rather use CBVs. Here is the function that works...

def gaas_create(request):
    form = GaasWaferDesignForm()
    context = {'form': form}
    html_form = 
render_to_string('engineering/gaas_wafer_designs/gaas_wafer_design_form_inner.html',
        context,
        request=request,
    )
    return JsonResponse({'html_form': html_form})

so far this is what I've tried but it doesnt work...

class GaasWaferDesignCreateView(LoginRequiredMixin, CreateView):
    fields = ("design_ui", "emitting", "contact_location", "optical_power", 
"design_date", "designer", "design_document", "designer_ui", "in_trash", 
"inactive_date", "notes")
    model = GaasWaferDesign
    template_name = 
'engineering/gaas_wafer_designs/gaas_wafer_design_form_inner.html'
    form = GaasWaferDesignForm()
    context = {'form': form}
    html_form = 
render_to_string('engineering/gaas_wafer_designs/gaas_wafer_design_form_inner.html')

    def options(self, request, *args, **kwargs):
        response = JsonResponse({'html_form': html_form})
        return response

    def form_valid(self, form):
        object = form.save(commit=False)
        object.created_by = self.request.user
        object.save()
        return super(GaasWaferDesignCreateView, self).form_valid(form)


I'm just guessing but i think the part thats causing it not to work might 
be 

html_form = 
render_to_string('engineering/gaas_wafer_designs/gaas_wafer_design_form_inner.html',
        context,
        request=request,
    )



Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fbe33122-a132-46a9-9281-1e02d52838af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to