# duplicated data

**URL:** <https://forum.djangoproject.com/t/duplicated-data/5563>\
**Category:** Using Django\
**Created:** [December 4, 2020, 7:15pm UTC](https://forum.djangoproject.com/t/duplicated-data/5563 "2020-12-04T19:15:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahmed3122](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ahmed3122/32/2713_2.png) [@ahmed3122](https://forum.djangoproject.com/u/ahmed3122)\
**Post date:** [December 4, 2020, 7:15pm UTC](https://forum.djangoproject.com/t/duplicated-data/5563/1 "2020-12-04T19:15:52Z")

</div>

how can I prevent user to save the same data twice in from from models!

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [December 4, 2020, 7:19pm UTC](https://forum.djangoproject.com/t/duplicated-data/5563/2 "2020-12-04T19:19:22Z")

</div>

Write a custom save method on your model to check to see if an existing model already has the data being submitted. If it’s just one or two fields that need to be unique, you could apply a unique constraint in the model.

---

<div class="post-metadata">

**Author:** ![ahmed3122](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ahmed3122/32/2713_2.png) [@ahmed3122](https://forum.djangoproject.com/u/ahmed3122)\
**Post date:** [December 4, 2020, 9:52pm UTC](https://forum.djangoproject.com/t/duplicated-data/5563/3 "2020-12-04T21:52:13Z")

</div>

thank you so much  
I use “from django.core.exceptions import ObjectDoesNotExist”  
but your suggestion looks more useful  
thank you so much
