How to run a celery worker with Django app scalable by AWS Elastic Beanstalk?

This is how I set up celery with django on elastic beanstalk with scalability working fine. Please keep in mind that ‘leader_only’ option for container_commands works only on environment rebuild or deployment of the App. If service works long enough, leader node may be removed by Elastic Beanstalk. To deal with that, you may have … Read more

Django model: delete() not triggered

I think you’re probably using the admin’s bulk delete feature, and are running into the fact that the admin’s bulk delete method doesn’t call delete() (see the related ticket). I’ve got round this in the past by writing a custom admin action for deleting models. If you’re not using the admin’s bulk delete method (e.g. … Read more

Django: accessing the model instance from within ModelAdmin?

I think you might need to approach this in a slightly different way – by modifying the ModelForm, rather than the admin class. Something like this: class OrderForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(OrderForm, self).__init__(*args, **kwargs) self.fields[‘parent_order’].queryset = Order.objects.filter( child_orders__ordernumber__exact=self.instance.pk) class OrderAdmin(admin.ModelAdmin): form = OrderForm

CSRF Failed: CSRF token missing or incorrect

When you are using SessionAuthentication, you are using Django’s authentication which usually requires CSRF to be checked. Django REST Framework enforces this, only for SessionAuthentication, so you must pass the CSRF token in the X-CSRFToken header. The Django documentation provides more information on retrieving the CSRF token using jQuery and sending it in requests. The … Read more