Quick start
Let's get you up and running on Forest Admin in minutes!
For the purpose of this tutorial, we have used this database. Feel free to use it if you don't have one.
At the end of your onboarding, you will out-of-the-box be able to:
- Access all your data (1)
- Export your data (2)
- Add a record (3)
- View and edit a record (4)
- Edit your UI (5)
- Search and filter (6)

However, your business logic likely requires more features. What if you need to...
- refund an order
- upload new documents, accept or reject them, or ask customers to update their documents,
- contact a customer or ask a team member to perform an action,
- and much more?
It's possible with smart actions
👇
Let's say you want to let your customer support team to easily refund orders, you can quickly create a smart action.
SQL
MongoDB
Rails
Django
Laravel
Declare it in your
/forest/orders.js
file:/forest/orders.js
const { collection } = require('forest-express-sequelize');
collection('orders', {
actions: [{
name: 'Refund order'
}],
});
Then implement it according to your business logic:
...
router.post('/actions/refund-order', permissionMiddlewareCreator.smartAction(), (req, res) => {
// Add your own logic, like calling a Stripe API for instance
res.send({ success: 'Order refunded!' });
});
...
module.exports = router;
Declare it in your
/forest/orders.js
file:/forest/orders.js
const { collection } = require('forest-express-mongoose');
collection('orders', {
actions: [{
name: 'Refund order'
}],
});
Then implement it according to your business logic:
...
router.post('/actions/refund-order', permissionMiddlewareCreator.smartAction(), (req, res) => {
// Add your own logic, like calling a Stripe API for instance
res.send({ success: 'Order refunded!' });
});
...
module.exports = router;
Declare it in your
/lib/forest_liana/collections/order.rb
file:/lib/forest_liana/collections/order.rb
class Forest::Order
include ForestLiana::Collection
collection :Order
action 'Refund order'
end
Then declare the corresponding route:
/app/controllers/forest/orders_controller.rb
Rails.application.routes.draw do
# MUST be declared before the mount ForestLiana::Engine.
namespace :forest do
post '/actions/refund-order' => 'orders#refund_order'
end
mount ForestLiana::Engine => '/forest'
end
Lastly, implement the action according to your business logic:
class Forest::OrdersController < ForestLiana::SmartActionsController
def refund_order
# Add your own logic, like calling a Stripe API for instance
render json: { success: 'Order refunded!' }
end
end
Note that Forest Admin takes care of the authentication thanks to the
ForestLiana::SmartActionsController
parent class controller.You may have to add CORS headers to enable the domain
app.forestadmin.com
to trigger API call on your Application URL, which is on a different domain name (e.g. localhost:8000).Declare it in your
app/forest/orders.py
file:app/forest/orders.py
from django_forest.utils.collection import Collection
from app.models import Order
class OrderForest(Collection):
def load(self):
self.actions = [{
'name': 'Refund order'
}]
Collection.register(OrderForest, Order)
Ensure the file app/forest/__init__.py exists and contains the import of the previous defined class :
app/forest/__init__.py
from app.forest.orders import OrderForest
Make sure your project
urls.py
file include you app urls with the forest
prefix.urls.py
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('forest', include('app.urls')),
path('forest', include('django_forest.urls')),
path('admin/', admin.site.urls),
]
Then declare the corresponding route:
app/urls.py
from django.urls import path
from django.views.decorators.csrf import csrf_exempt
from . import views
app_name = 'app'
urlpatterns = [
path('/actions/refund-order', csrf_exempt(views.RefundOrderView.as_view()), name='refund-order'),
]
Lastly, implement the action according to your business logic:
app/views.py
from django.http import JsonResponse
from django_forest.utils.views.action import ActionView
class RefundOrderView(ActionView):
def post(self, request, *args, **kwargs):
# Add your own logic, like calling a Stripe API for instance
return JsonResponse({'success': 'Order refunded!'})
Note that Forest Admin takes care of the authentication thanks to the
ActionView
parent class view.You may have to add CORS headers to enable the domain
app.forestadmin.com
to trigger API call on your Application URL, which is on a different domain name (e.g. localhost:8000).Declare it in your
app/Models/Order.php
file:app/Models/Order.php
/**
* @return SmartAction
*/
public function refundOrder(): SmartAction
{
return $this->smartAction('single', 'refund order');
}
Then declare the corresponding route:
routes/web.php
Route::post('forest/smart-actions/order_refund-order', [OrdersController::class, 'refundOrder']);
Lastly, implement the action according to your business logic:
app/Http/Controllers/OrdersController.php
<?php
namespace App\Http\Controllers;
use ForestAdmin\LaravelForestAdmin\Http\Controllers\ForestController;
use Illuminate\Http\JsonResponse;
/**
* Class OrdersController
*/
class OrdersController extends ForestController
{
/**
* @return JsonResponse
*/
public function refundOrder(): JsonResponse
{
return response()->json(
['success' => 'Order refunded!']
);
}
}
Congrats! Now it's possible to refund an order!

Now that you have a fully functional admin panel, the next logical step is to make it live, with your live (production) data. Click on Deploy to Production and follow the flow.

That's it! You are now fully operational on Forest Admin.
Last modified 5mo ago