In that case, is there something in a template that is possibly calling the delete view based on some user trigger, i.e. some Javascript function?
From: [email protected] [mailto:[email protected]] On Behalf Of RyanW Sent: Wednesday, October 24, 2018 10:11 AM To: Django users Subject: Re: Django auto-deletes field related to MySQL Transactions I've tried two separate MySQL db's on two separate servers. They both have given me deletes. What's strange is that I've set up a local copy on my laptop with both a local Postgres DB and MySQL connection, and I don't get the same deletes. I've narrowed it down that it must be something the users are doing to trigger these deletes, based on logs that would've put them active during a time of a delete. On Wednesday, October 24, 2018 at 10:03:00 AM UTC-5, Matthew Pava wrote: I can’t see anything wrong with what you’ve presented. Try generating a new database and using that. See if you still get random deletes on that database. From: [email protected]<javascript:> [mailto:[email protected]<javascript:>] On Behalf Of RyanW Sent: Wednesday, October 24, 2018 9:51 AM To: Django users Subject: Re: Django auto-deletes field related to MySQL Transactions Hi Matthew and Joel. Thanks for your help. I'm attaching the models.py, views.py and templates for your reference. I'm drawing a blank on the implementation that could trigger a delete. Thanks again On Tuesday, October 23, 2018 at 11:54:17 AM UTC-5, Matthew Pava wrote: And make sure your form is posting to the save view and not the delete view. Maybe show us your template. From: [email protected] [mailto:[email protected]] On Behalf Of Joel Sent: Tuesday, October 23, 2018 11:32 AM To: [email protected] Subject: Re: Django auto-deletes field related to MySQL Transactions You could have a signal which captures all these and logs its origin. On Tue, 23 Oct, 2018, 9:35 PM RyanW, <[email protected]> wrote: Yes, I honestly don't see how Django could be doing this either. The only I could think of was user deletion, but no one has claimed to have done so. No other apps are connected. Thanks for the tip!! On Tuesday, October 23, 2018 at 10:05:51 AM UTC-5, Matthew Pava wrote: It doesn’t seem like Django would be doing this. Do you have any other apps connected to the database? You’ll probably want to surround your URL in quotation marks. <a href=”{% url ‘epedelete’ epe.id<http://epe.id> %}”> From: [email protected] [mailto:[email protected]] On Behalf Of RyanW Sent: Tuesday, October 23, 2018 9:33 AM To: Django users Subject: Re: Django auto-deletes field related to MySQL Transactions I have a button to delete a record by the user, displayed inside a template as: <td><a href={% url 'epedelete' epe.id %}><input class="btn btn-danger" type="button" value="Delete" /></a></td> and the function in views.py def delete(request, part_id=None): obj = epe.objects.get(id=part_id) obj.delete() return HttpResponseRedirect(reverse('epe_home')) Other than that, I have some ForeignKey restraints on_delete to preserve integrity, like so: epe_ani2 = models.ForeignKey( Subjects, on_delete=models.PROTECT, null=True, blank=True ) As for the authentication backend, I'm using the default provided by Django: ['django.contrib.auth.backends.ModelBackend'] Thank you for the help! On Tuesday, October 23, 2018 at 9:16:24 AM UTC-5, Matthew Pava wrote: Check your source code for any delete commands. This might also be your authentication backend. Which one are you using? From: [email protected] [mailto:[email protected]] On Behalf Of RyanW Sent: Monday, October 22, 2018 7:55 PM To: Django users Subject: Django auto-deletes field related to MySQL Transactions I have a Django site I'm developing, which I've connected to a MySQL db. I haven't deployed into production yet, as I'm still working on a couple of things, however I leave the server running in development for initial data entry. I've noticed that some of the records already inputted gets deleted, seemingly randomly. I enabled logging on MySQL and found logs like the following: 6798 Connect [email protected] on downswebdb2 6798 Query SET NAMES utf8 6798 Query set autocommit=0 6798 Query set autocommit=1 6798 Query SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED 6798 Query SELECT `Epe_epe`.`id`, `Epe_epe`.`epe_type`, `Epe_epe`.`epe_type2_id`, `Epe_epe`.`epe_date`, `Epe_epe`.`epe_ani`, `Epe_epe`.`epe_ani2_id`, `Epe_epe`.`epe_apn`, `Epe_epe`.`epe_apn2_id`, `Epe_epe`.`epe_weight`, `Epe_epe`.`epe_drug_type1`, `Epe_epe`.`epe_drug1`, `Epe_epe`.`epe_dose1`, `Epe_epe`.`epe_amount1`, `Epe_epe`.`epe_route1`, `Epe_epe`.`epe_time1`, `Epe_epe`.`epe_drug_type2`, `Epe_epe`.`epe_drug2`, `Epe_epe`.`epe_dose2`, `Epe_epe`.`epe_amount2`, `Epe_epe`.`epe_route2`, `Epe_epe`.`epe_time2`, `Epe_epe`.`epe_drug_type3`, `Epe_epe`.`epe_drug3`, `Epe_epe`.`epe_dose3`, `Epe_epe`.`epe_amount3`, `Epe_epe`.`epe_route3`, `Epe_epe`.`epe_time3`, `Epe_epe`.`epe_drug_type4`, `Epe_epe`.`epe_drug4`, `Epe_epe`.`epe_dose4`, `Epe_epe`.`epe_amount4`, `Epe_epe`.`epe_route4`, `Epe_epe`.`epe_time4`, `Epe_epe`.`epe_drug_type5`, `Epe_epe`.`epe_drug5`, `Epe_epe`.`epe_dose5`, `Epe_epe`.`epe_amount5`, `Epe_epe`.`epe_route5`, `Epe_epe`.`epe_time5`, `Epe_epe`.`epe_drug_type6`, `Epe_epe`.`epe_drug6`, `Epe_epe`.`epe_dose6`, `Epe_epe`.`epe_amount6`, `Epe_epe`.`epe_route6`, `Epe_epe`.`epe_time6`, `Epe_epe`.`epe_iso_start`, `Epe_epe`.`epe_iso_end`, `Epe_epe`.`epe_o2_end`, `Epe_epe`.`epe_start1`, `Epe_epe`.`epe_start2`, `Epe_epe`.`epe_start3`, `Epe_epe`.`epe_start4`, `Epe_epe`.`epe_start5`, `Epe_epe`.`epe_start6`, `Epe_epe`.`epe_start7`, `Epe_epe`.`epe_start8`, `Epe_epe`.`epe_hr1`, `Epe_epe`.`epe_hr2`, `Epe_epe`.`epe_hr3`, `Epe_epe`.`epe_hr4`, `Epe_epe`.`epe_hr5`, `Epe_epe`.`epe_hr6`, `Epe_epe`.`epe_hr7`, `Epe_epe`.`epe_hr8`, `Epe_epe`.`epe_spo2_1`, `Epe_epe`.`epe_spo2_2`, `Epe_epe`.`epe_spo2_3`, `Epe_epe`.`epe_spo2_4`, `Epe_epe`.`epe_spo2_5`, `Epe_epe`.`epe_spo2_6`, `Epe_epe`.`epe_spo2_7`, `Epe_epe`.`epe_spo2_8`, `Epe_epe`.`epe_temp1`, `Epe_epe`.`epe_temp2`, `Epe_epe`.`epe_temp3`, `Epe_epe`.`epe_temp4`, `Epe_epe`.`epe_temp5`, `Epe_epe`.`epe_temp6`, `Epe_epe`.`epe_temp7`, `Epe_epe`.`epe_temp8`, `Epe_epe`.`epe_etco2_1`, `Epe_epe`.`epe_etco2_2`, `Epe_epe`.`epe_etco2_3`, `Epe_epe`.`epe_etco2_4`, `Epe_epe`.`epe_etco2_5`, `Epe_epe`.`epe_etco2_6`, `Epe_epe`.`epe_etco2_7`, `Epe_epe`.`epe_etco2_8`, `Epe_epe`.`epe_rr1`, `Epe_epe`.`epe_rr2`, `Epe_epe`.`epe_rr3`, `Epe_epe`.`epe_rr4`, `Epe_epe`.`epe_rr5`, `Epe_epe`.`epe_rr6`, `Epe_epe`.`epe_rr7`, `Epe_epe`.`epe_rr8`, `Epe_epe`.`epe_comment` FROM `Epe_epe` WHERE `Epe_epe`.`id` = 1508 6798 Query set autocommit=0 6798 Query DELETE FROM `Epe_epe` WHERE `Epe_epe`.`id` IN (1508) 6798 Query commit 6798 Query set autocommit=1 6798 Quit Where Epe_epe is from a model called Epe in my Django app. As far as I know, no user is performing delete commands on these records, so can I assume Django is performing these deletes in the background? What would a trigger possibly be for these deletes? Thank you -- 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 [email protected]. To post to this group, send email to [email protected]. 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/91c6af18-cdf0-45f4-9f1c-e865c7128334%40googlegroups.com<https://groups.google.com/d/msgid/django-users/91c6af18-cdf0-45f4-9f1c-e865c7128334%40googlegroups.com?utm_medium=email&utm_source=footer>. For more options, visit https://groups.google.com/d/optout. -- 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 [email protected]. To post to this group, send email to [email protected]. 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/0be635cb-6f54-451c-ae92-07b38841e6c6%40googlegroups.com<https://groups.google.com/d/msgid/django-users/0be635cb-6f54-451c-ae92-07b38841e6c6%40googlegroups.com?utm_medium=email&utm_source=footer>. For more options, visit https://groups.google.com/d/optout. -- 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 [email protected]. To post to this group, send email to [email protected]. 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/59a2ed67-2e8a-4864-9495-7d8e1810c4ad%40googlegroups.com<https://groups.google.com/d/msgid/django-users/59a2ed67-2e8a-4864-9495-7d8e1810c4ad%40googlegroups.com?utm_medium=email&utm_source=footer>. For more options, visit https://groups.google.com/d/optout. -- 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 [email protected]. To post to this group, send email to [email protected]. 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/CAA%3Diw__WFtVJ6-zT793z8y-ZOf%2BcmLjAbJ%2B-9NaOT9mHtq6R0A%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAA%3Diw__WFtVJ6-zT793z8y-ZOf%2BcmLjAbJ%2B-9NaOT9mHtq6R0A%40mail.gmail.com?utm_medium=email&utm_source=footer>. For more options, visit https://groups.google.com/d/optout. -- 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 [email protected]<javascript:>. To post to this group, send email to [email protected]<javascript:>. 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/1ae1ce38-8148-46bc-8a65-99569aeef9bc%40googlegroups.com<https://groups.google.com/d/msgid/django-users/1ae1ce38-8148-46bc-8a65-99569aeef9bc%40googlegroups.com?utm_medium=email&utm_source=footer>. For more options, visit https://groups.google.com/d/optout. -- 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 [email protected]<mailto:[email protected]>. To post to this group, send email to [email protected]<mailto:[email protected]>. 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/6995836e-5d91-43e5-8587-5af38f52fdcc%40googlegroups.com<https://groups.google.com/d/msgid/django-users/6995836e-5d91-43e5-8587-5af38f52fdcc%40googlegroups.com?utm_medium=email&utm_source=footer>. For more options, visit https://groups.google.com/d/optout. -- 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 [email protected]. To post to this group, send email to [email protected]. 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/04fcfe06ead24a1f902d0f14b82038a6%40ISS1.ISS.LOCAL. For more options, visit https://groups.google.com/d/optout.

