maxtepkeev / architect

A set of tools which enhances ORMs written in Python with more features
Other
391 stars 57 forks source link

when I want to updated partitioning field occurs error #83

Open lidyum opened 3 years ago

lidyum commented 3 years ago

partitioning field = created_time when it has ben been first created no problem, everything is ok but when trying to change month of created_time, error occurs

"app_accounting_payment_y2021m05_create_time_check" allows check restriction....

@architect.install('partition', type='range', subtype='date', constraint='month', column='created_time')
class Payment(models.Model):
    created_time = models.DateTimeField(auto_now_add=True, verbose_name=_('Created Time'))
    payment_no = models.UUIDField(default=uuid.uuid4, unique=True, editable=False, verbose_name=_('Payment No'))
    amount = models.DecimalField(decimal_places=2, max_digits=17, verbose_name=_('Amount'))
    tax_payer_register_no = models.PositiveIntegerField(verbose_name=_('Tax Payer Register No'))
import datetime

#create payment model
payment_instance = Payment.objects.create(amount=500, tax_payer_register_no=1)

#update, payment model's created_time
new_created_date=datetime.datetime.strptime(2001-01-01 12:00:00", "%Y-%m-%d %H:%M:%S")
payment_instance.created_time=new_created_date
payment_instance.save()