0

問題が発生しており、この問題を解決する方法が見つかりません。 すべて問題はないようですが、動作しません。Django CBVモデルのリダイレクト後の白いHTMLページ

これはプロセスです:

私はDjangoのフォームで作成されたオブジェクトに関するすべての情報を持つテンプレートを持っています。 私は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> 

このボタンは(私はを取得する必要があります)ビュー/テンプレートをカスタマイズ有するために:

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 

私urls.pyファイルには、次のようになります。

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ページはすべて白ですが、空白はより適合しています^^私はあなたがフランス語を話すのを知らなかった;) – Deadpool

+1

私は多くの才能を持っています... :)とにかく、あなたのIdentitySocietePDFCreatingViewはPOSTリクエストを期待していないので、フォームアクションをPOSTからGETに変更しようとします。 –

答えて

2

あなたのIdentitySocietePDFCreatingViewはPOSTリクエストを期待していません。フォームアクションをGETに変更する必要があります。

関連する問題