# Django form validation when creating new records

**URL:** <https://community.forestadmin.com/t/django-form-validation-when-creating-new-records/4704>\
**Category:** Help me!\
**Tags:** howtos\
**Created:** [May 19, 2022, 9:34am UTC](https://community.forestadmin.com/t/django-form-validation-when-creating-new-records/4704 "2022-05-19T09:34:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kimo](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@Kimo](https://community.forestadmin.com/u/Kimo)\
**Post date:** [May 19, 2022, 9:34am UTC](https://community.forestadmin.com/t/django-form-validation-when-creating-new-records/4704/1 "2022-05-19T09:34:38Z")

</div>

Hello,

I’m using Forest Admin on a Django project which has a heavily customised admin panel. I’m trying to figure out how to implement these customisations in Forest Admin instead, especially the validation stage between creating a new record in Forest Admin and saving it in the DB.

For example, I want to be perform additional actions once I have clicked “create”.

I would appreciate it if someone could point me in the right direction here. I’ve looked at the [Developer Guide](https://docs.forestadmin.com/documentation/), but mostly it’s related to smart fields and so on, which is great, but not what I’m searching for this particular issue.

Thank you very much!

---

<div class="post-metadata">

**Author:** ![anon37903635](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@anon37903635](https://community.forestadmin.com/u/anon37903635)\
**Post date:** [May 19, 2022, 9:43am UTC](https://community.forestadmin.com/t/django-form-validation-when-creating-new-records/4704/2 "2022-05-19T09:43:33Z")

</div>

Hello @Kimo 👋

There are several ways to directly bring your customisations to your Forest agent:.  
Indeed there are **[Smart Fields](https://docs.forestadmin.com/documentation/reference-guide/smart-fields)** but there are also **[Smart Actions](https://docs.forestadmin.com/documentation/reference-guide/actions/create-and-manage-smart-actions#what-is-a-smart-action)**.

If you have the Forest **routes/** folder, you can potentially tweak the route that handles the “create” following [this part of our documentation](https://docs.forestadmin.com/documentation/reference-guide/routes).

Tell me if that helps 💪  
Cheers 🙏

---

<div class="post-metadata">

**Author:** ![Kimo](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@Kimo](https://community.forestadmin.com/u/Kimo)\
**Post date:** [May 19, 2022, 3:12pm UTC](https://community.forestadmin.com/t/django-form-validation-when-creating-new-records/4704/3 "2022-05-19T15:12:04Z")

</div>

Thank you very much for your reply, Romain! This is indeed helpful.

I have another question, if I may! 😃

I’m trying to use this example, to protect certain records:

```javascript
from django.http import HttpResponse

from django_forest.resources.utils.resource.views import DetailView

class CompaniesDetailView(DetailView):

    def delete(self, request, pk):
        if (pk == 82):
            return HttpResponse(
            'This record is protected, you cannot remove it.',
             status=403);

        return super(CompaniesDetailView, self).delete(request, pk)

```

My questions are:

1. If I have an app where there are several models, do I need to declare the specific model I’m targeting somewhere in the above code?
2. Do I have to include this view in the urls.py file which I created inside the app/forest/ directory?

Thank you,  
Kimo

---

<div class="post-metadata">

**Author:** ![anon6357957](https://avatars.discourse-cdn.com/v4/letter/a/a698b9/32.png) [@anon6357957](https://community.forestadmin.com/u/anon6357957)\
**Post date:** [May 20, 2022, 12:27pm UTC](https://community.forestadmin.com/t/django-form-validation-when-creating-new-records/4704/5 "2022-05-20T12:27:47Z")

</div>

Hi @Kimo,

You should create an urls.py file as explained [here](https://docs.forestadmin.com/documentation/reference-guide/routes/override-a-route#use-extended-search-by-default).

If you need to protect several models, you need to override all the views and add them in the urls.py.  
ex:  
/companies  
/companies/count  
/customers/  
/customers/count/
