Martín Miranda

Arregla TipoOrganismoAdmin

... ... @@ -37,9 +37,14 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# Aplicaciones de tercero
'django_extensions',
# Aplicaciones propias
'persona',
'organismo',
'core',
]
MIDDLEWARE = [
... ...
... ... @@ -3,14 +3,15 @@ from django.db.models import Count
from organismo.models import Organismo, TipoOrganismo
@admin.register(TipoOrganismo)
class TipoOrganismoAdmin(admin.ModelAdmin):
list_display = ('nombre', 'es_activo', 'cantidad_organismo')
search_fields = ('nombre',)
actions = ('desactivar_seleccionados', )
actions = ('desactivar_seleccionados',)
def get_queryset(self, request):
queryset = super().get_queryset(request).values('organismos').annotate(cantidad_organismo=Count('organismos')).all()
queryset = super().get_queryset(request).annotate(cantidad_organismo=Count('organismos'))
if request.user.is_superuser:
return queryset
... ... @@ -23,8 +24,6 @@ class TipoOrganismoAdmin(admin.ModelAdmin):
return tipo.cantidad_organismo
@admin.register(Organismo)
class OrganismoAdmin(admin.ModelAdmin):
list_display = ('nombre', 'tipo')
... ...
# Generated by Django 3.2.7 on 2021-09-29 12:56
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('organismo', '0003_tipoorganismo_es_activo'),
]
operations = [
migrations.AlterField(
model_name='organismo',
name='tipo',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='organismos', to='organismo.tipoorganismo'),
),
]
... ...
-r base.txt
django-extensions==3.1.3
\ No newline at end of file
... ...