diff --git a/hosting/templates/hosting/bill_error.html b/hosting/templates/hosting/bill_error.html new file mode 100644 index 00000000..5374ecb5 --- /dev/null +++ b/hosting/templates/hosting/bill_error.html @@ -0,0 +1,14 @@ +{% extends "hosting/base_short.html" %} +{% load staticfiles bootstrap3 %} +{% load i18n %} +{% block content %} + +
+
+

Error

+

Could not get HostingBill object for client.

+

Please create a HostingBill object via the admin page

+
+
+{% endblock %} + diff --git a/hosting/views.py b/hosting/views.py index b552063a..b5a18597 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -424,10 +424,14 @@ class HostingBillDetailView(PermissionRequiredMixin, LoginRequiredMixin, DetailV return HostingBill.objects.filter(customer__id=pk).first() def get_context_data(self, **kwargs): - # Get User - user_email = self.object.customer.user.email # Get context context = super(DetailView, self).get_context_data(**kwargs) + # Get User + try: + user_email = self.object.customer.user.email + except AttributeError: + self.template_name = 'hosting/bill_error.html' + return context # Add VMs to context context['vms'] = []