I am trying to delete a report from a particular client, so currently in my url.py
i am passing the client id and the report id, hoping to delete report Y from client X. I could have done this using def ReportScheduleDeleteView(request):
, but was hoping to use the Class-Based DeleteView.
I had a look at this example
but wasn't able to blend with my code.
So here is my code.
urls.py
url(r'^jsclient/(?P<pk>\d+)/report/(?P<r_pk>\d+)/delete/$', ReportScheduleDeleteView.as_view(), name="report-delete"),
models.py -
class JSClient(models.Model):
name = models.CharField(max_length=255, unique=True)
clientAccount = models.CharField(max_length=255)
....
class ReportSchedule(models.Model):
client = models.ForeignKey(JSClient)
schedRepName = models.CharField(max_length=255)
reportType = models.CharField(max_length=255, choices=REPORT_TYPE)
....
views.py :
class ReportScheduleDeleteView(DeleteView):
model = ReportSchedule
template_name = "report/report_confirm_delete.html"
success_url = lazy(reverse, str)('jsclient-list')
I am sure there must be a way of doing this using the Class-Based DeleteView, any help on this is appreciated.