title: Refeencing a parameter from a related model object inside a DeleteView to pass to my get_success_url?
body: <p>I have this model, related with my User schema model:</p>
  
  <pre><code>class EntrepreneurshipOffer(models.Model):
  
      created_by = models.ForeignKey(
          settings.AUTH_USER_MODEL,
          on_delete=models.CASCADE
      )
  ...
  </code></pre>
  
  <p>In addition, I have a view named <code>EntrepreneurshipOffersByUser</code> which let me list all offers that I've created</p>
  
  <pre><code>class EntrepreneurshipOffersByUser(LoginRequiredMixin, UserProfileDataMixin, ListView):
      template_name = 'entrepreneurship/my_entrepreneurship_offer_list.html'
  
      def get_queryset(self, *args, **kwargs):
          user = self.request.user
          queryset_list = EntrepreneurshipOffer.objects.filter(created_by__username=user.username)
          return queryset_list
  
      def get_context_data(self, **kwargs):
          context = super(EntrepreneurshipOffersByUser, self).get_context_data(**kwargs)
          user = self.request.user
          entrepreneurship_offers = EntrepreneurshipOffer.objects.filter(created_by__username=user.username)
          context['offers_by_user'] = entrepreneurship_offers
          return context
  </code></pre>
  
  <p>The URLs to view my <code>EntrepreneurshipOffer</code> objects are:</p>
  
  <pre><code># Main URL which call to Entrepreneurship Offer URLs
  url(r'^offer/entrepreneurship/', include('entrepreneurship.urls', namespace='offer')),
  
  # List Entrepreneurship Offer's user
      url(r'^by/u/(?P&lt;username&gt;[-\w]+)/$',
          EntrepreneurshipOffersByUser.as_view(),
          name='list'),
      ]
  </code></pre>
  
  <p>My question is related to the goal of delete <code>EntrepreneurshipOffer</code> and after, redirect the workflow to my <code>EntrepreneurshipOffer</code> list objects mentioned above.</p>
  
  <p>I have the <code>EntrepreneurshipOfferDeleteView</code> class-based view with the <code>get_success_url</code> method, in which I call the url to list my objects passing the namespace and the URL name mentioned above, adding the <code>username</code> parameter required by the URL </p>
  
  <pre><code>class EntrepreneurshipOfferDeleteView(SuccessMessageMixin, UserProfileDataMixin, LoginRequiredMixin, DeleteView):
      model = EntrepreneurshipOffer
      #success_url = reverse_lazy("offer:list")
      success_message = "Oferta de emprendimiento eliminada con éxito"
  
      def get_success_url(self):
          entrepreneurship_offer = self.get_object()
          #print(entrepreneurship_offer)
          return reverse_lazy("offer:list", kwargs={'created_by': entrepreneurship_offer.created_by.username})
  </code></pre>
  
  <p>I need to pass the <code>username</code> parameter, but it seems I am not doing of a suited way, because, despite that the <code>username</code> parameter it's added to the workflow, via <code>self.get_object()</code> I get this error:</p>
  
  <pre><code>NoReverseMatch at /offer/entrepreneurship/modelo-de-negocio/delete/
  Reverse for 'list' with arguments '()' and keyword arguments '{'created_by': 'bgarcial'}' not found. 1 pattern(s) tried: ['offer/entrepreneurship/by/u/(?P&lt;username&gt;[-\\w]+)/$']
  </code></pre>
  
  <p>I'm new to class-based views so I'm sure there is an obvious fix for this, but I haven't found it yet. </p>
  
  <p>Any help is much appreciated. Thanks.</p>