I want to create a custom view in django admin that reflects the change form from another model. I got to creating a custom admin class class and don't know where to go from here. I cannot find good examples for Django 1.8 on how to create a custom view.
Django Version: 1.8
class CustomerProductOrderAdmin(admin.ModelAdmin): review_template = 'admin/onlineordering/order_template.html' def get_urls(self): urls = super(CustomerProductOrderAdmin, self).get_urls() my_urls = patterns('', (r'\d+/customer_template/$', self.admin_site.admin_view(self.customer_template)), ) return my_urls + urls def customer_template(self, request, id): product_orders = CustomerProductOrder.objects.get(pk=id) return render_to_response(self.review_template, { 'quantity': 'Quantity: %s' % product_orders.quantity, }, context_instance=RequestContext(request))
I have a customer table related to this user table.
class Customer(models.Model): customer = models.ForeignKey(settings.AUTH_USER_MODEL, limit_choices_to={'groups__name': "customers"})
/ app / model / 1 #pk = customer.id
Custom form will have this URL
/ app / customform /
When an incoming user goes to / app / customform, they should not see the change form from / app / model / 1. They should not see other users changing forms. In addition, I would like to restrict access to a user form to a specific user group. those. this group cannot see / app / model /, but can see / app / customform.
django-admin
madphp
source share