Displaying DynamoDB data in Django admin panel
I want to show data from DynamoDB on the Django admin panel page. I have tried PynamoDB to create the model and register it with the admin panel.
I am facing the following two issues:
Getting only attribute 'id' instead of all attributes from the DynamoDB table. I have confirmed this issue while fetching attribute_definitions from the DynamoDB table using boto3.
attribute_definitions = table_name.attribute_definitions
The second issue I am facing is that I get errors while registering the created Model(by using PynamoDB) with the admin panel. I get the issue
"TypeError: 'MetaModel' object is not iterable"
you can pass this data to admin template using this method
changelist_view
Ex:
class DynmoDbAdmin(admin.ModelAdmin):
def changelist_view(self, request, extra_context=None):
get data from dynamodb
add this data to extra_context
return super().changelist_view(request, extra_context=extra_context)
after that you need to extend admin template follow this pattern
- add
'APP_DIRS': True,
to your settings file. - go to your app and create this folders
templates/admin/model_name
- in this folder create file
change_list.html
this links will help you.