{{{
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.
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>
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>
* 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>
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>
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>
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>