Ни одно из вышеупомянутого. Просто используйте admin.site.unregister (). Вот то, как я недавно добавил Пользователей фильтрации на is_active в администраторе ( n.b. фильтрация is_active находится теперь на модели User по умолчанию в ядре Django; все еще работы здесь как пример), весь DRY, как может быть:
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
class MyUserAdmin(UserAdmin):
list_filter = UserAdmin.list_filter + ('is_active',)
admin.site.unregister(User)
admin.site.register(User, MyUserAdmin)
The problem here is that a lies within the tr. Ergo, when the a click() method is triggered, the event bubbles to the tr containing it, creating the recursive loop you mentioned. Rather than call .find('a').click()
, have both a
and tr
use the same click method.
$('tr, a').click(function(){
//dostuff
return false;
});
$(document).ready(function(){
$('table.products tr').click(function(e){
e.stoPropagation(); // for stop the click action (event)
$(this).find('a').click();
return false;
});
});
First, I would console.log($(this).find('a'))
and make sure it is the appropriate link.
Next, I believe the click event is not what you want on the a
element. I think you just want: var a = $(this).find('a'); if (a) document.location.href = a.attr('href');
My JavaScript is pretty weak though : )