Erlich Bachman
Erlich Bachman

Reputation: 142

How can i confirm a database entry in django admin?

I have been working around this problem. I have a user submitting a HTML form lets say to list their hotel on my website. I need to review this form before i add it into my hotels model to be published. One approach i have worked on is to use a requests model where this form can be stored and later using django admin action write a custom action to add/remove the request. In case of acceptance i copy the details to my hotels model else it sends an email or a notification back to user.

Second approach is simply using django action on hotels model where the request is sent to approve it or reject it. In this case i want to know if thats possible where a data point doesn't get written to database until it's been accepted by admin. If yes how can i do that?

Finally, these details are displayed on my main page and search page for users to book these places.

If there is a better and effective way to do it. Please share that.

Thanks in advance. If something isn't clear i can answer your specific questions in the comments below 😊. Have a nice day.

Upvotes: 0

Views: 215

Answers (1)

Arpit Svt
Arpit Svt

Reputation: 1203

You can have is_published Boolean field in your hotel model and you can default it to false initially. After you inspect the hotel details you can set the is_published field to True from django admin.

So now whenever you are querying for hotels to show on your website. You can query Hotel.objects.filter(is_published=True)

Upvotes: 2

Related Questions