Community Apps
Admin Portal
Admin Models

Admin Models

If you want to create a new model in the SuperApp admin portal, you need to register the model with the admin site. This will allow you to view, add, edit, and delete instances of the model in the admin portal.

Instructions

Register the Model

superapp/apps/<app_name>/admin.py
@admin.register(SampleModel, site=superapp_admin_site)
class SampleModelAdmin(SuperAppModelAdmin):
    pass

Create Migrations

docker-compose exec web python3 manage.py makemigrations

Apply Migrations

docker-compose exec web python3 manage.py migrate

Configure the ModelAdmin

You can display specific fields in the list view of the model by using the list_display attribute in the ModelAdmin class.

superapp/apps/<app_name>/admin.py
@admin.register(SampleModel, site=superapp_admin_site)
class SampleModelAdmin(SuperAppModelAdmin):
    list_display = ('username', 'comment')

Add Sidebar Navigation Link

Please follow the sidebar navigation guide to add a link to the model in the sidebar.

Useful Resources