Django: IndexError at /admin/auth/user/ list index out of range
<p>I have 2 models: customers(which contain user = m.ForeignKey(User, related_name="customers")) and UserAdmin (class UserAdmin(NestedModelAdmin, DjangoUserAdmin)). I want add to users field, which generate link to orders for every user: in app/models.py i wrote this code:</p>

<pre><code>def orders_url(self):
return format_html(u"&lt;a href='/admin/order/order/?q={0}'&gt;Orders&lt;/a&gt;", self.user.first_name)
</code></pre>

<p>And in app/admin/user_admin.py i have this code:</p>

<pre><code>from myproject.customer.models import Customer
def orders_url(self, user):
    customer = user.customers.all()[0]
    return customer.orders_url()
</code></pre>

<p>When I trying to search some user(for example /admin/auth/user/?q=Nick), all goes good,and it generate link to Nick's orders, but when I go in /admin/auth/user/, i see this error: IndexError at /admin/auth/user/
list index out of range. 
Traceback link to next code:</p>

<pre><code>path_to_project/customer/admin/user_admin.py in orders_url
                customer = user.customers.all()[0] 
▼ Local vars
Variable    Value
self       &lt;myproject.customer.admin.user_admin.UserAdmin object at 0xa7e788c&gt;
user       &lt;User: &gt;
</code></pre>

<p>Forgot about that message:</p>

<pre><code>Error during template rendering
In template /home/vagrant/venv/local/lib/python2.7/site-packages/django/contrib/admin/templates/admin/change_list.html, error at line 91
list index out of range
91 {% result_list cl %}
</code></pre>

<p>How can I change it?</p>