'Need to link my existing view to the admin using admin plus module in a table type view
admin.py
def my_view(request):
pass
admin.site.register_view('timelogreport', view=my_view, name='TimeLog Report')
views.py
def dictfetchall(cursor):
"Return all rows from a cursor as a dict"
columns = [col[0] for col in cursor.description]
return [
dict(zip(columns, row))
for row in cursor.fetchall()
]
@api_view(['GET'])
def job(self):
cursor = connection.cursor()
with open('C:\\Users\\gobs4\\stage\\Project-Management-Tools\\query.sql','r') as inserts:
query = inserts.read()
cursor.execute(query)
return Response(dictfetchall(cursor))
I have used the django admin plus module for creating a view in admin page, But i dont know how to link the above views.py to the admin register view. Can you please help me to do that and i need to show it as table view and not as a json view in the admin, is that possible?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
