Django pagination - how to redirect back to a ListView and a page number
<p>In a <code>ListView</code> I render a table using the Paginator with <code>paginate_by = 5</code>.
In each row I have a Button that opens the <code>UpdateView</code>.
After a successful update I'm back on my <code>ListView</code> but always on the first page.
How can I change the <code>success_url</code> so that I'm back on the page number, from where I opened the <code>UpdateView</code>?
Is there a proper way in Django to solve this?</p>

<pre><code>#views.py

class Orders_list(ListView):
    model = Order
    context_object_name = "orders"
    queryset = Order.objects.all()
    paginate_by = 5
    template_name = "orders/orders_list.html"

#http://127.0.0.1:8000/orders/?page=4


class Orders_update(UpdateView):
    model = Order
    form_class = Order_UpdateForm
    template_name = "orders/orders_update.html"
    #success_url = '../../../orders/'
    success_url = reverse_lazy('orders')


#urls.py

urlpatterns = [
    url(r'^orders/$', Orders_list.as_view()),
    url(r'^orders/detail/(?P&lt;pk&gt;\d+)/$', Orders_detail.as_view()),
]


#forms.py

class Order_UpdateForm(forms.ModelForm):
    class Meta:
        model = Order
        fields = ['order_text', 'customer', 'cyclist']

    def __init__(self, *args, **kwargs):
        super(Order_UpdateForm, self).__init__(*args, **kwargs)
        self.fields['cyclist'].queryset = Cyclist.objects.filter(active=True)


#models.py

class Order(models.Model):
    customer = models.ForeignKey('Customer')
    cyclist = models.ForeignKey('Cyclist')
    order_text = models.CharField(max_length=200)
    pick_up = models.CharField(max_length=200)
    destination = models.CharField(max_length=200)
    created_date = models.DateTimeField(default=timezone.now)
    changed_date = models.DateTimeField(blank=True, null=True)

    def created(self):
        self.changed_date = timezone.now()
        self.save()

    def __str__(self):
        return self.order_text


class Customer(models.Model):
    company_name = models.CharField(max_length=200)
    created_date = models.DateTimeField(default=timezone.now)
    changed_date = models.DateTimeField(blank=True, null=True)

    def created(self):
        self.changed_date = timezone.now()
        self.save()

    def __str__(self): return self.company_name


class Cyclist(models.Model):
    lastname = models.CharField(max_length=20)
    firstname = models.CharField(max_length=20)
    created_date = models.DateTimeField(default=timezone.now)
    changed_date = models.DateTimeField(blank=True, null=True)
    active = models.BooleanField(default=True)

    def created(self):
        self.changed_date = timezone.now()
        self.save()

    def __str__(self):
        return self.lastname
</code></pre>

<p><strong>Update</strong></p>

<p>I found a way to solve this (may be). But I still miss something.</p>

<p>What I did so far:</p>

<p>In the <code>ListView</code> template I extended the Url...</p>

<pre><code>window.open("{{ request.path }}update/" + id + "/?page=" + {{ page_obj.number }});
</code></pre>

<p>...then in the view I overwrote the <code>get_context_data</code> method...</p>

<pre><code>#views.py

class Orders_update(UpdateView):
    model = Order
    form_class = Order_UpdateForm
    template_name = "orders/orders_update.html"
    page = "1" # Assigned

    def get_context_data(self, **kwargs):
        context = super(Orders_update, self).get_context_data(**kwargs)
        page = self.request.GET.get('page') # Modified
        return context

    success_url = '../../../orders/?page=' + str(page) # Should be used here to redirect to a specific page on a ListView
</code></pre>

<p>...but now...how can I access the variable <code>page</code> in <code>views.py</code> in the <code>success_url</code>? 
I think this is something very basic (hopefully) and I think I don't understand how scope works in Python.</p>