#34474 closed Bug (invalid)
Django apps registry returns the wrong models
Reported by: | Dimitris Kougioumtzis | Owned by: | nobody |
---|---|---|---|
Component: | Uncategorized | Version: | 4.2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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
Change History (6)
follow-up: 2 comment:1 by , 21 months ago
comment:2 by , 21 months ago
Replying to 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
follow-up: 4 comment:3 by , 21 months ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
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.
comment:4 by , 21 months ago
Replying to 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 ?
follow-up: 6 comment:5 by , 21 months ago
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.
comment:6 by , 21 months ago
Replying to Tim Graham:
The signature for:
apps.get_models(include_auto_created=False, include_swapped=False)
The
get_models()
function in this ticket's description is incorrectly providingapp
as the first argument.
Thanks Tim i fixed it
Hi, the problem and how to reproduce it isn't clear to me. Can you elaborate?