详细信息未显示 - 有人可以告诉我我的代码有什么问题吗?

伊莎·贾加迪

我正在创建一个系统,用户可以在其中查看其他投诉并查看投诉详细信息,但不能对其进行编辑。视图.py:

class ViewParticularComplaint(TemplateView):
   model = Complaint
   form_class = ComplaintForm
   template_name = 'viewusercompaint.html'
   def get_queryset(self, *args, **kwargs):
       context = super().get_context_data(*args, **kwargs)
       context["complaints"] = self.model.objects.exclude(user = self.request.user)
       return context

模板:

<form class="" action="" method="POST" enctype="multipart/form-data">
            {% csrf_token %}
            <p class="sub-typ-wr">Submit Type</p>
            <a href="/Login/Add-Complaint/Document-Style/"><button type="button" class="btn btn-secondary document-btn">Document</button></a>

            <div class="rep-num">
                <label class="written-label" for="">Report Number</label>
                <div class="written-txt-field">{{complaints.reportnumber}}</div>
            </div>

            <div class="eve-dte">
                <label class="written-label" for="">Event Date</label>
                <div class="written-txt-field">{{form.eventdate}}</div>
            </div>

            <div class="eve-typ">
                <label class="written-label" for="">Event Type</label>
                <div class="written-txt-field">{{form.event_type}}</div>
            </div>

            <div class="dev-pro">
                <label class="written-label" for="">Device Problem</label>
                <div class="written-txt-field">{{form.device_problem}}</div>
            </div>

            <label class="written-label eve-txt" for="">Event Text</label>

            <div class="Manufacturer">
                <label class="written-label" for="">Manufacturer</label>
                <div class="written-txt-field">{{form.manufacturer}}</div>
            </div>

            <div class="pro-code">
                <label class="written-label" for="">Product Code</label>
                <div class="written-txt-field">{{form.product_code}}</div>
            </div>

            <div class="brand-name">
                <label class="written-label" for="">Brand Name</label>
                <div class="written-txt-field">{{form.brand_name}}</div>
            </div>

            <div class="exem">
                <label class="written-label" for="">Exemption</label>
                <div class="written-txt-field">{{form.exemption}}</div>
            </div>

            <div class="pat-pro">
                <label class="written-label" for="">Patient Problem</label>
                <div class="written-txt-field">{{form.patient_problem}}</div>
            </div>



            <div class="comp-textarea">{{form.event_text}}</div>
            <button type="button" class="btn btn-secondary attach-btn-1"><div class="fas fa-file-upload">{{form.document}}</div></button>
        </form>

应该看到的是:

在此处输入图片说明

没有保存按钮之类的东西。但我实际看到的是:

在此处输入图片说明

这是什么问题,我该如何解决??

贾米尔·哈姆丹

你需要使用的是 DetailView

class ViewParticularComplaint(DetailView):
   model = Complaint
   template_name = 'viewusercompaint.html'
   context_object_name = 'complaint'

   def get_queryset(self, *args, **kwargs):
       return Complaint.objects.all()

在模板中,您可以像这样访问投诉对象:

<div class="dev-pro">
    <label class="written-label" for="">Device Problem</label>
    <div class="written-txt-field">{{complaint.device_problem}}</div>
</div>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

TextGeometry没有显示,有人可以告诉我为什么吗?

有人可以告诉我我的代码有什么问题吗?[Python 2.7.1]

有人可以告诉我我的代码有什么问题吗?

有人可以告诉我如何在游戏结束后显示按钮吗?

有人可以告诉我这段代码有什么问题吗

有人可以告诉我此python代码有什么问题吗?

spring-boot运行状况未显示详细信息(带有详细信息)

有人能告诉我我的代码有什么问题吗

有人能告诉我我的代码有什么问题吗?

你能告诉我我用来检索客户上次下订单信息的查询有什么问题吗?

有人可以告诉我我的代码有什么问题并尝试对其进行解释吗?

python中的变量不起作用,有人可以告诉我我的代码有什么问题吗?

它仅显示列表的第一个元素。有人可以告诉我错误是什么吗?

有人可以告诉我我的Type或linq查询出了什么问题吗

有人能告诉我这段代码有什么问题吗?

有人可以告诉我这张图片有什么问题吗?

当有人搜索我的网站时,如何显示Google像我的详细信息?

有人可以告诉我出了什么问题吗?

有人能告诉我为什么它在控制台中不显示任何内容吗??我想获得输入值。我必须使用表格吗?

Xamarin AppCenter Crashes.TrackError未显示我在AppCenter中期望的详细信息

pprof(用于golang)未显示我的软件包的详细信息

Tomcat服务器状态页面未显示所有详细信息

有人可以告诉我为什么我的“姓名”课程会在我的手机导航菜单上显示

我已经使用JOptionPane.showOptionDialog显示了一个JDialog,有人可以告诉我如何将其设置为inVisible或Dispose吗?

有人可以告诉我这有什么问题吗?是的,我刚开始学习 c#

有人可以告诉我我的package.json文件出了什么问题吗?

有人能告诉我 emu8086 中的这段代码有什么问题吗?

为什么我的列表的详细信息没有显示在外部系统的“详细信息”屏幕中

Ionic / Angular:使用“主要”详细信息图案时,没有显示详细信息页面?