[Django] #34474: Django apps registry returns the wrong models

2 views
Skip to first unread message

Django

unread,
Apr 7, 2023, 10:12:21 AM4/7/23
to django-...@googlegroups.com
#34474: Django apps registry returns the wrong models
-------------------------------------------------+------------------------
Reporter: Dimitris Kougioumtzis | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 4.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------------+------------------------
When i want to get the models for the app sites it returns the wrong
models


{{{
def get_models(request):
app = request.GET.get('app')
models = []
amodels = apps.get_models(app)
for model in amodels:
models.append(model.__name__)
return JsonResponse({"models":models})
}}}

when i call the function with request parameters sites it returns
models from the admin app

--
Ticket URL: <https://code.djangoproject.com/ticket/34474>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 7, 2023, 10:41:09 AM4/7/23
to django-...@googlegroups.com
#34474: Django apps registry returns the wrong models
-------------------------------------+-------------------------------------
Reporter: Dimitris | Owner: nobody
Kougioumtzis |

Type: Bug | Status: new
Component: Uncategorized | Version: 4.2
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

Hi, the problem and how to reproduce it isn't clear to me. Can you
elaborate?

--
Ticket URL: <https://code.djangoproject.com/ticket/34474#comment:1>

Django

unread,
Apr 7, 2023, 1:17:22 PM4/7/23
to django-...@googlegroups.com
#34474: Django apps registry returns the wrong models
-------------------------------------+-------------------------------------
Reporter: Dimitris | Owner: nobody
Kougioumtzis |
Type: Bug | Status: new
Component: Uncategorized | Version: 4.2
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Dimitris Kougioumtzis):

Replying to [comment:1 Tim Graham]:


> Hi, the problem and how to reproduce it isn't clear to me. Can you
elaborate?


Hello Tim

In the above function i pass a request get parameter called (app) and i
want to return the models for the specific app,

For example when i pass the app name sites i want to return the Site
model

but the function returns models from auth app

--
Ticket URL: <https://code.djangoproject.com/ticket/34474#comment:2>

Django

unread,
Apr 7, 2023, 1:55:10 PM4/7/23
to django-...@googlegroups.com
#34474: Django apps registry returns the wrong models
-------------------------------------+-------------------------------------
Reporter: Dimitris | Owner: nobody
Kougioumtzis |
Type: Bug | Status: closed
Component: Uncategorized | Version: 4.2
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => invalid


Comment:

This function doesn't seem to be part of Django. Please see
TicketClosingReasons/UseSupportChannels if you need help debugging your
code. Use this ticket tracker to report a bug in Django, explaining why
Django is at fault and providing sufficient code to reproduce the problem.

--
Ticket URL: <https://code.djangoproject.com/ticket/34474#comment:3>

Django

unread,
Apr 8, 2023, 2:37:49 AM4/8/23
to django-...@googlegroups.com
#34474: Django apps registry returns the wrong models
-------------------------------------+-------------------------------------
Reporter: Dimitris | Owner: nobody
Kougioumtzis |
Type: Bug | Status: closed
Component: Uncategorized | Version: 4.2
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Dimitris Kougioumtzis):

Replying to [comment:3 Tim Graham]:


> This function doesn't seem to be part of Django. Please see
TicketClosingReasons/UseSupportChannels if you need help debugging your
code. Use this ticket tracker to report a bug in Django, explaining why
Django is at fault and providing sufficient code to reproduce the problem.

the result of the above function for the app django.contrib.messages

django.contrib.messages [<class 'django.contrib.admin.models.LogEntry'>,
<class 'django.contrib.sites.models.Site'>, <class
'django.contrib.flatpages.models.FlatPage_sites'>, <class
'django.contrib.flatpages.models.FlatPage'>, <class
'django.contrib.auth.models.Permission'>, <class
'django.contrib.auth.models.Group_permissions'>, <class
'django.contrib.auth.models.Group'>, <class
'django.contrib.auth.models.User_groups'>, <class
'django.contrib.auth.models.User_user_permissions'>, <class
'django.contrib.auth.models.User'>, <class
'django.contrib.contenttypes.models.ContentType'>, <class
'django.contrib.sessions.models.Session'>, <class
'rest_framework.authtoken.models.Token'>, <class
'rest_framework.authtoken.models.TokenProxy'>]

so is it correct for the app django.contrib.messages it return that
models ?

--
Ticket URL: <https://code.djangoproject.com/ticket/34474#comment:4>

Django

unread,
Apr 8, 2023, 8:24:30 AM4/8/23
to django-...@googlegroups.com
#34474: Django apps registry returns the wrong models
-------------------------------------+-------------------------------------
Reporter: Dimitris | Owner: nobody
Kougioumtzis |
Type: Bug | Status: closed
Component: Uncategorized | Version: 4.2
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

[https://docs.djangoproject.com/en/dev/ref/applications/#django.apps.AppConfig.get_models
The signature] for: `apps.get_models(include_auto_created=False,
include_swapped=False)`

The `get_models()` function in this ticket's description is incorrectly
providing `app` as the first argument.

--
Ticket URL: <https://code.djangoproject.com/ticket/34474#comment:5>

Django

unread,
Apr 8, 2023, 8:38:09 AM4/8/23
to django-...@googlegroups.com
#34474: Django apps registry returns the wrong models
-------------------------------------+-------------------------------------
Reporter: Dimitris | Owner: nobody
Kougioumtzis |
Type: Bug | Status: closed
Component: Uncategorized | Version: 4.2
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Dimitris Kougioumtzis):

Replying to [comment:5 Tim Graham]:


>
[https://docs.djangoproject.com/en/dev/ref/applications/#django.apps.AppConfig.get_models
The signature] for: `apps.get_models(include_auto_created=False,
include_swapped=False)`
>
> The `get_models()` function in this ticket's description is incorrectly
providing `app` as the first argument.


Thanks Tim i fixed it

--
Ticket URL: <https://code.djangoproject.com/ticket/34474#comment:6>

Reply all
Reply to author
Forward
0 new messages