Best way to modified third party app database restrictions?

42 views
Skip to first unread message

Yongky Tria Putra

unread,
Apr 11, 2019, 7:46:32 AM4/11/19
to Django users
Hello everyone,

What is the best way to modified database field restrictions in third party app (pretix)? Currently, i want to change max_digits=7  to max_digits=9  in database below.

default_price = models.DecimalField(
decimal_places=2, max_digits=7,
null=True, blank=True,
verbose_name=_("Default price"),
)
Is it possible without modified the third party source code?
Thanks

Vinicius Assef

unread,
Apr 11, 2019, 7:49:41 AM4/11/19
to django...@googlegroups.com
Try to set default_price.max_digits=9

Or you can create your own class extending DecimalField setting your defaults.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c3646848-03f9-459a-99ad-7b71e7348799%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yongky Tria Putra

unread,
Apr 12, 2019, 7:16:04 AM4/12/19
to Django users

I solve it with this two lines code in my models:

from thirdparty.models import ParentModelClass
ParentModelClass._meta.get_field('default_price').max_digits = 9

then makemigrations && migrate

voila it work, but i don't know any downside using this tricks.

Hope it will help others with similar situation as well.

Yongky Tria Putra

unread,
Apr 12, 2019, 7:28:39 AM4/12/19
to Django users
Almost forget. It thanks to Peterino comments on this https://stackoverflow.com/a/2357942/2579404
Reply all
Reply to author
Forward
0 new messages