Re: How to hide/disable ModelAdmin

2021-03-05 Thread zvo...@seznam.cz
Seems I know the answer:

class HiddenAdmin(admin.ModelAdmin):
has_module_permission = lambda self, req: False

https://stackoverflow.com/questions/2431727/django-admin-hide-a-model
https://stackoverflow.com/questions/49293901/hide-model-from-main-admin-list-but-allow-creation-in-inline-editor
Dne čtvrtek 4. března 2021 v 21:22:41 UTC+1 uživatel zvo...@seznam.cz 
napsal:

> I want use Django 2+ autocomplete_fields.
> Adding them into (source) ModelAdmin will give lot of errors (see bellow).
> So I must add a (target) ModelAdmin with search_fields=...
>
> After that everything works.
> However I don't want to have such new ModelAdmin's visible/accessible.
> I have data of their models already much better accessible in Inlines.
>
> Is there a way how to give search_fields=.. and not show the new 
> ModelAdmin?
>
> Thank you.
>
> ```
> ERRORS: 
> : (admin.E039) An admin for model 
> "PartVariant" has to be registered to be referenced by 
> PartCodeInline.autocomplete_fields. 
> : (admin.E040) PartCodeTypeAdmin 
> must define "search_fields", because it's referenced by 
> PartCodeInline.autocomplete_fields. 
> : (admin.E039) An admin for model 
> "Size" has to be registered to be referenced by 
> PartSizeInline.autocomplete_fields. 
> : (admin.E039) An admin for 
> model "Size" has to be registered to be referenced by 
> PartSubGroupInline.autocomplete_fields.
> ```
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/98a443b2-15f7-4172-bd8e-1635dc98f30an%40googlegroups.com.


How to hide/disable ModelAdmin

2021-03-04 Thread zvo...@seznam.cz
I want use Django 2+ autocomplete_fields.
Adding them into (source) ModelAdmin will give lot of errors (see bellow).
So I must add a (target) ModelAdmin with search_fields=...

After that everything works.
However I don't want to have such new ModelAdmin's visible/accessible.
I have data of their models already much better accessible in Inlines.

Is there a way how to give search_fields=.. and not show the new ModelAdmin?

Thank you.

```
ERRORS: 
: (admin.E039) An admin for model 
"PartVariant" has to be registered to be referenced by 
PartCodeInline.autocomplete_fields. 
: (admin.E040) PartCodeTypeAdmin 
must define "search_fields", because it's referenced by 
PartCodeInline.autocomplete_fields. 
: (admin.E039) An admin for model 
"Size" has to be registered to be referenced by 
PartSizeInline.autocomplete_fields. 
: (admin.E039) An admin for 
model "Size" has to be registered to be referenced by 
PartSubGroupInline.autocomplete_fields.
```

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2d5c4536-9e1f-49f6-93a9-31802a80e12cn%40googlegroups.com.