0

문제가 발생하며이 문제를 해결할 방법을 찾지 못했습니다. 모두 괜찮아 보이지만 작동하지 않습니다. 난 그냥 장고 양식에 의해 생성 된 개체에 대한 모든 정보와 템플릿이Django CBV 모델로 리디렉션 한 후 흰색 HTML 페이지

:

는 과정이다. object id 계정을 사용하는 다른 템플릿으로 리디렉션해야하는 버튼이 있지만이 템플릿으로 리디렉션 될 때 HTML 흰색 페이지가 표시됩니다. 리디렉션하기 위해이 버튼이 관련 템플릿

class IdentitySocieteResumeView(LoginRequiredMixin, ListView) : 

    template_name = 'Identity_Societe_Resume.html' 
    model = Societe 

    def get_context_data(self, **kwargs) : 

     context_data = super(IdentitySocieteResumeView, self).get_context_data(**kwargs) 

     id = self.kwargs['id'] 
     societe = get_object_or_404(Societe, pk=id) 

     obj = Societe.objects.filter (Nom=societe.Nom, SIRET=societe.SIRET, SIREN=societe.SIREN, Ville=societe.Ville) 

     if obj: 
      sc_obj = obj[0] 

      ... 

     return context_data 

: 내가 구체적으로 생성 된 객체를 표시 할 수 있도록 첫 번째 클래스가

class Societe(models.Model): 

    NumeroIdentification   = models.CharField(max_length=30, null=True, verbose_name='Numero Identification physique', unique=True) 
    Nom        = models.CharField(null= False, max_length=30, verbose_name='Nom de Société') 
    Etat       = models.CharField(max_length = 30, choices = CHOIX_ETAT_SOCIETE, null=False, verbose_name="Etat") 
    ... 

    def get_absolute_url(self): 
     return reverse_lazy('SocieteResume', kwargs={'id': self.id}) 

    def __unicode__(self): 
     return unicode (self.id, self.NumeroIdentification, self.Nom, ...) 

:

내 모델입니다 다음 템플리트 :

<form method='POST' action="{% url 'SocietePDF' societe.id %}">{% csrf_token %} 
{% csrf_token %} 
<button>Générer le PDF de la Fiche d'Identification </button> 
</form> 

이 단추는 다음으로 리디렉션됩니다 (을 가져와야 함). 개인보기/템플릿)를 가지고하기 위해:

내 urls.py 파일은 다음과 같습니다
class IdentitySocietePDFCreatingView(LoginRequiredMixin, TemplateView) : 

    template_name = 'Identity_Societe_PDF.html' 
    model = Societe 

    def get_context_data(self, **kwargs) : 

     context_data = super(IdentitySocietePDFCreatingView, self).get_context_data(**kwargs) 

     id = self.kwargs['id'] 
     societe = get_object_or_404(Societe, pk=id) 

     obj = Societe.objects.filter (Nom=societe.Nom, SIRET=societe.SIRET, SIREN=societe.SIREN, Ville=societe.Ville) 

     ... 

     return context_data 

:

from django.conf.urls import url 
from Identity.views import IdentityIndividuFormView, IdentityHomepageView, IdentityChoiceUpdateView, IdentitySocieteFormView, IdentitySocieteResumeView, IdentitySocietePDFCreatingView 
from . import views 

urlpatterns = [ 
    url(r'^Homepage$', IdentityHomepageView.as_view(), name="Home"), 
    url(r'^Person/ChoiceUpdate/$', IdentityChoiceUpdateView.as_view(), name="IdentityChoice"), 
    url(r'^Person/Form/$', IdentityIndividuFormView.as_view(), name="IndividuFormulaire"), 
    url(r'^Company/Form/$', IdentitySocieteFormView.as_view(), name = "SocieteFormulaire"), 
    url(r'^Person/Form/Resume/(?P<id>\d+)/$', views.IdentityIndividuResume, name="IndividuResume"), 
    url(r'^Company/Form/Resume/(?P<id>\d+)/$', IdentitySocieteResumeView.as_view(), name="SocieteResume"), 
    url(r'^Person/Update/$', views.IdentityIndividuUpdateAll, name="Edition"), 
    url(r'^Company/Update/$', views.IdentitySocieteUpdateAll, name="EditionSociete"), 
    url(r'^Person/Research/$', views.IdentityIndividuResearching, name="IndividuRecherche"), 
    url(r'^Company/Research/$', views.IdentitySocieteResearching, name="SocieteRecherche"), 
    url(r'^Company/Research/Fraud/$', views.IdentitySocieteFraudResearching, name="SocieteRechercheFraude"), 
    url(r'^Company/Research/Employe/$', views.IdentitySocieteEmploye, name="SocieteRechercheEmploye"), 
    url(r'^Person/Read/PDF/$', views.IdentityIndividuPDFReading, name="Consultation"), 
    url(r'^Company/Read/PDF/$', views.IdentitySocietePDFReading, name="SocieteConsultation"), 
    url(r'^Person/Delete/$', views.IdentityIndividuDelete, name="Suppression"), 
    url(r'^Person/Form/PDF/(?P<id>\d+)/$', views.IdentityIndividuPDFCreating, name="IndividuPDF"), 
    url(r'^Company/Form/PDF/(?P<id>\d+)/$', IdentitySocietePDFCreatingView.as_view(), name="SocietePDF"), 
    url(r'^Statistics/$', views.IdentityStatistics, name="Statistiques"), 
    url(r'^Person/Update/Civility/$', views.IdentityIndividuUpdateCivility, name="EditionCivilite"), 
    url(r'^Person/Update/Coordonates/$', views.IdentityIndividuUpdateCoordonates, name="EditionCoordonnees"), 
    url(r'^Person/Update/Contact/$', views.IdentityIndividuUpdateContact, name="EditionContact"), 
] 

이상한 것은입니다 :로 리디렉션 될하기 위해 내가 버튼을 클릭하면 SocietePDF 흰색 HTML 페이지가 나타납니다. 그러나 URL을 잘라내거나 붙여 넣으면 템플릿에 액세스 할 수 있습니다.

내 프로세스에 뭔가가 없습니다.

감사합니다.

+0

"빈"은 "빈"및 "비어 있지 않은"흰색을 의미합니다. –

+0

@DanielRoseman 알았어. 내 HTML 페이지가 모두 흰색이지만 빈칸이 더 적합하다는 것을 의미하는 것은 유감 스럽다. ^^ 나는 너에게 프랑스어 langage를 말한 것을 몰랐다;) – Deadpool

+1

나는 많은 재능을 가지고있다. :) 어쨌든, 나는 한 가지이다. IdentitySocietePDFCreatingView가 POST 요청을 기대하지 않기 때문에 POST에서 GET으로 양식 작업을 변경하는 것이 좋습니다. –

답변

2

IdentitySocietePDFCreatingView가 POST 요청을 기다리지 않습니다. 양식 작업을 GET으로 변경해야합니다.