Hi there, I'm kind of a novice in django and like to call rfm_update before the get request in the RFM Viewset will executed, but no surprise the migrate doesn't work for a new deployment.
What is the best practice to do something like rfm_update so that migrate works. Thanks in advance, Christian def rfm_update(): rfms = RFM.objects.all() rfms.delete() df_rfm = pd.DataFrame(list(Order.objects.all().values())) rfm_data = processing(df_rfm, datetime_col='order_datetime', customer_id_col='customer_id').reset_index() RFM.objects.bulk_create([RFM(customer_id=rec[0], frequency=rec[1], recency=rec[2], T=rec[3]) for rec in rfm_data.values]) class RFMViewSet(viewsets.ModelViewSet): rfm_update() # Not good! queryset = RFM.objects.all() serializer_class = RFMSerializer lookup_field = 'customer_id' http_method_names = ['get'] -- 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+unsubscr...@googlegroups.com. To post to this group, send email to django-users@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/ff23886d-a5e6-4fc2-bade-e9716c1a91c5%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.