When I’m deleting a company using my Django web-interface on the production-server as a superadministrator, I’m receive a Internal server error 500 as response which is displayed on the screen.
Here is the possible additional error log I received only once
Deleting a company does work locally on my PC and on the test-server.
Delete code backend:
class CompanyDeleteView(GroupRequiredMixin, LoginRequiredMixin, View):
#login_url=‘/accounts/login/’
group_required = [u"SuperAdministrator"]
def delete(self, request, **kwargs):
company_id = kwargs.get('pk')
if company_id:
company = shortcuts.get_object_or_404(models.CompanyModel, id=company_id)
users = []
admins = []
for user in company.users.all():
if helpers.get_user_level(user) in ['SuperAdministrator', 'TechnicalService']:
admins.append(user)
else:
users.append(user)
company.delete()
for user in users:
user.delete()
perfotec = models.CompanyModel.objects.get(name='Perfotec')
for user in admins:
user.companies.set([perfotec])
return http.HttpResponse(json.dumps("success"), content_type="application/json")
return http.HttpResponseBadRequest()
Javascript code in HTML file: