Showing
5 changed files
with
30 additions
and
4 deletions
@@ -37,9 +37,14 @@ INSTALLED_APPS = [ | @@ -37,9 +37,14 @@ INSTALLED_APPS = [ | ||
37 | 'django.contrib.sessions', | 37 | 'django.contrib.sessions', |
38 | 'django.contrib.messages', | 38 | 'django.contrib.messages', |
39 | 'django.contrib.staticfiles', | 39 | 'django.contrib.staticfiles', |
40 | + # Aplicaciones de tercero | ||
41 | + 'django_extensions', | ||
42 | + | ||
43 | + # Aplicaciones propias | ||
40 | 'persona', | 44 | 'persona', |
41 | 'organismo', | 45 | 'organismo', |
42 | 'core', | 46 | 'core', |
47 | + | ||
43 | ] | 48 | ] |
44 | 49 | ||
45 | MIDDLEWARE = [ | 50 | MIDDLEWARE = [ |
@@ -3,14 +3,15 @@ from django.db.models import Count | @@ -3,14 +3,15 @@ from django.db.models import Count | ||
3 | 3 | ||
4 | from organismo.models import Organismo, TipoOrganismo | 4 | from organismo.models import Organismo, TipoOrganismo |
5 | 5 | ||
6 | + | ||
6 | @admin.register(TipoOrganismo) | 7 | @admin.register(TipoOrganismo) |
7 | class TipoOrganismoAdmin(admin.ModelAdmin): | 8 | class TipoOrganismoAdmin(admin.ModelAdmin): |
8 | list_display = ('nombre', 'es_activo', 'cantidad_organismo') | 9 | list_display = ('nombre', 'es_activo', 'cantidad_organismo') |
9 | search_fields = ('nombre',) | 10 | search_fields = ('nombre',) |
10 | - actions = ('desactivar_seleccionados', ) | 11 | + actions = ('desactivar_seleccionados',) |
11 | 12 | ||
12 | def get_queryset(self, request): | 13 | def get_queryset(self, request): |
13 | - queryset = super().get_queryset(request).values('organismos').annotate(cantidad_organismo=Count('organismos')).all() | 14 | + queryset = super().get_queryset(request).annotate(cantidad_organismo=Count('organismos')) |
14 | if request.user.is_superuser: | 15 | if request.user.is_superuser: |
15 | return queryset | 16 | return queryset |
16 | 17 | ||
@@ -23,8 +24,6 @@ class TipoOrganismoAdmin(admin.ModelAdmin): | @@ -23,8 +24,6 @@ class TipoOrganismoAdmin(admin.ModelAdmin): | ||
23 | return tipo.cantidad_organismo | 24 | return tipo.cantidad_organismo |
24 | 25 | ||
25 | 26 | ||
26 | - | ||
27 | - | ||
28 | @admin.register(Organismo) | 27 | @admin.register(Organismo) |
29 | class OrganismoAdmin(admin.ModelAdmin): | 28 | class OrganismoAdmin(admin.ModelAdmin): |
30 | list_display = ('nombre', 'tipo') | 29 | list_display = ('nombre', 'tipo') |
1 | +# Generated by Django 3.2.7 on 2021-09-29 12:56 | ||
2 | + | ||
3 | +from django.db import migrations, models | ||
4 | +import django.db.models.deletion | ||
5 | + | ||
6 | + | ||
7 | +class Migration(migrations.Migration): | ||
8 | + | ||
9 | + dependencies = [ | ||
10 | + ('organismo', '0003_tipoorganismo_es_activo'), | ||
11 | + ] | ||
12 | + | ||
13 | + operations = [ | ||
14 | + migrations.AlterField( | ||
15 | + model_name='organismo', | ||
16 | + name='tipo', | ||
17 | + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='organismos', to='organismo.tipoorganismo'), | ||
18 | + ), | ||
19 | + ] |
requirements/development.txt
0 → 100644
-
Please register or login to post a comment