Django auto-deletes field related to MySQL Transactions

2018-10-22 Thread RyanW
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
rya...@cobb.eyes.uab.edu 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 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/91c6af18-cdf0-45f4-9f1c-e865c7128334%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django auto-deletes field related to MySQL Transactions

2018-10-23 Thread RyanW
I have a button to delete a record by the user, displayed inside a template 
as:



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:* django...@googlegroups.com  [mailto:
> django...@googlegroups.com ] *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
> rya...@cobb.eyes.uab.edu 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?
>
>  
>
> Tha

Re: Django auto-deletes field related to MySQL Transactions

2018-10-23 Thread RyanW
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.   url ‘epedelete’ epe.id %}”>
>
>  
>
>  
>
> *From:* django...@googlegroups.com  [mailto:
> django...@googlegroups.com ] *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:
>
>  
>
>  type="button" value="Delete" />
>
>
> 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:* django...@googlegroups.com [mailto:django...@googlegroups.com] *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
> rya...@cobb.eyes.uab.edu 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

Re: Django auto-deletes field related to MySQL Transactions

2018-10-24 Thread RyanW
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:* django...@googlegroups.com  [mailto:
> django...@googlegroups.com ] *On Behalf Of *Joel
> *Sent:* Tuesday, October 23, 2018 11:32 AM
> *To:* django...@googlegroups.com 
> *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, > 
> 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.   url ‘epedelete’ epe.id %}”>
>
>  
>
>  
>
> *From:* django...@googlegroups.com [mailto:django...@googlegroups.com] *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:
>
>  
>
>  type="button" value="Delete" />
>
>
> 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:* django...@googlegroups.com [mailto:django...@googlegroups.com] *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
> rya...@cobb.eyes.uab.edu 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

Re: Django auto-deletes field related to MySQL Transactions

2018-10-24 Thread RyanW
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:* django...@googlegroups.com  [mailto:
> django...@googlegroups.com ] *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:* django...@googlegroups.com [mailto:django...@googlegroups.com] *On 
> Behalf Of *Joel
> *Sent:* Tuesday, October 23, 2018 11:32 AM
> *To:* django...@googlegroups.com
> *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,  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.   url ‘epedelete’ epe.id %}”>
>
>  
>
>  
>
> *From:* django...@googlegroups.com [mailto:django...@googlegroups.com] *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:
>
>  
>
>  type="button" value="Delete" />
>
>
> 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:* django...@googlegroups.com [mailto:django...@googlegroups.com] *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
> rya...@cobb.eyes.uab.edu 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
>
> 679

Re: Django auto-deletes field related to MySQL Transactions

2018-10-24 Thread RyanW
Yes, it is. Are you referring to 'delete' method in my views?

On Wednesday, October 24, 2018 at 1:24:12 PM UTC-5, C. Kirby wrote:
>
> Is this happening to production users? It is probably because their 
> browser is doing pre-fetch of links to speed up their UX. GET request are 
> considered by the browser to be safe (non-destructive) and ideally 
> idempotent. YOu should _never_ put a destructive action behind a GET, it 
> should always be behind a POST or (even better if you are going the full 
> REST route) DELETE. 
>
> On Wednesday, October 24, 2018 at 11:10:33 AM UTC-4, RyanW wrote:
>>
>> 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:* django...@googlegroups.com [mailto:django...@googlegroups.com] *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:* django...@googlegroups.com [mailto:django...@googlegroups.com] *On 
>>> Behalf Of *Joel
>>> *Sent:* Tuesday, October 23, 2018 11:32 AM
>>> *To:* django...@googlegroups.com
>>> *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,  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.  >> href=”{% url ‘epedelete’ epe.id %}”>
>>>
>>>  
>>>
>>>  
>>>
>>> *From:* django...@googlegroups.com [mailto:django...@googlegroups.com] *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:
>>>
>>>  
>>>
>>> >> type="button" value="Delete" />
>>>
>>>
>>> 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(
>>>
>>>   

Re: Django auto-deletes field related to MySQL Transactions

2018-10-24 Thread RyanW
Hi Mark,

I did at one point, but I don't any longer ( I use RESTRICT now). 

Would you guys mind if I attached a copy of the app for review?

Thank you!

On Wednesday, October 24, 2018 at 6:36:12 PM UTC-5, mark wrote:
>
> Just a wild guess - do you have a cascade delete in your models that is 
> causing the deletion? Is a user deleting another object, and that is 
> triggering a cascade delete on a different model?
>
> Mark
>
> On Wed, Oct 24, 2018 at 4:22 PM RyanW > 
> wrote:
>
>> Yes, it is. Are you referring to 'delete' method in my views?
>>
>> On Wednesday, October 24, 2018 at 1:24:12 PM UTC-5, C. Kirby wrote:
>>>
>>> Is this happening to production users? It is probably because their 
>>> browser is doing pre-fetch of links to speed up their UX. GET request are 
>>> considered by the browser to be safe (non-destructive) and ideally 
>>> idempotent. YOu should _never_ put a destructive action behind a GET, it 
>>> should always be behind a POST or (even better if you are going the full 
>>> REST route) DELETE. 
>>>
>>> On Wednesday, October 24, 2018 at 11:10:33 AM UTC-4, RyanW wrote:
>>>>
>>>> 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:* django...@googlegroups.com [mailto:django...@googlegroups.com] 
>>>>> *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:* django...@googlegroups.com [mailto:django...@googlegroups.com] 
>>>>> *On Behalf Of *Joel
>>>>> *Sent:* Tuesday, October 23, 2018 11:32 AM
>>>>> *To:* django...@googlegroups.com
>>>>> *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,  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?
>>>>>
>>>>

Re: Django auto-deletes field related to MySQL Transactions

2018-10-27 Thread RyanW
Thanks for the info. Do you know of a way that I can confirm this is 
happening?

Best,
- Ryan

On Thursday, October 25, 2018 at 8:37:35 AM UTC-5, C. Kirby wrote:
>
> The delete method in your views, yes, but also how you build the button. 
> You should use a form with a hidden field (the id to delete), and the 
> button ("Delete") should be the form submit. Then on the view side you 
> should use a standard form handler (if request.POSTetc) to handle 
> things. What is probably happening is the browser is automatically 
> following the  tag to do prefetching, and causing the record to delete. 
> Browsers will not prefetch "POST" verbs (so, a form post)
>

-- 
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/aa944f18-69b0-4734-9833-0ec88dd9acee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.