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:

  1. 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

  2. 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

  1. add 'APP_DIRS': True, to your settings file.
  2. go to your app and create this folders templates/admin/model_name
  3. in this folder create file change_list.html

this links will help you.

  1. https://docs.djangoproject.com/en/3.2/howto/overriding-templates/
  2. How to override and extend basic Django admin templates?
Back to Top