Skip to content

Admin Panel

Ushka includes a built-in, auto-generated admin panel that allows you to perform basic CRUD (Create, Read, Update, Delete) operations on your database models directly from your web browser.

It's a powerful tool for managing your application's data without needing to write custom views or interact directly with the database.

Enabling the Admin Panel

The admin panel is disabled by default. To enable it, you need to add and configure the [admin] section in your ushka.toml file.

# in ushka.toml

[admin]
enabled = true

That's it! Once you restart your development server, the admin panel will be available at the /admin URL (e.g., http://127.0.0.1:8000/admin).

The Admin Password

For security, the admin panel is protected by a password.

When you enable the admin panel for the first time, Ushka will automatically generate a secure, random password for you. You will see this password printed in the console when you start the server.

INFO: --- Admin Panel ---
INFO:   Admin panel enabled at http://127.0.0.1:8000/admin
INFO:   Password: some-randomly-generated-string

It is highly recommended to set your own password in ushka.toml for production environments.

[admin]
enabled = true
password = "your-own-strong-password-here"

How It Works

The admin panel automatically discovers all the models defined in your project (i.e., any class that inherits from ushka.contrib.db.Model).

For each model discovered, it provides a user interface where you can: * List all records, with pagination and a simple search box. * Create new records via a dynamically generated form. * Edit existing records. * Delete records.

The forms for creating and editing records are generated based on the columns you defined in your model class, with appropriate HTML input types inferred from the column's data type (e.g., db.String becomes <input type="text">, db.Int becomes <input type="number">).