#29706: RenameContentType._rename() doesn't save the content type on the correct
database
-------------------------------------+-------------------------------------
Reporter: Tyler Morgan | Owner: nobody
Type: Bug | Status: new
Component: | Version: master
contrib.contenttypes |
Severity: Normal | Resolution:
Keywords: RenameContentType | Triage Stage: Accepted
transaction atomic content_type |
update_fields using |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Herbert Fortes):
Hi,
First, I shoud went to mentors instead of comment here.
I did not make the test. Back to the ticket: " a default sqlite3
backend which is never actually generated or used. ". If it is
not generated I thought: How get info from there? Then I did
a search.
There is no '.save(using)' in the StackOverflow I linked. If no 'using' is
set
it fails. Then the guy tried two 'transaction.atomic(using='db1')' - and
'db2'
togheter. It worked. First, the decorator (worked). Second, the 'with'
(did
nothing).
{{{
@transaction.atomic(using='db1')
def edit(self, context):
"""Edit
:param dict context: Context
:return: None
"""
# Check if employee exists
try:
result = Passport.objects.get(pk=self.user.employee_id)
except Passport.DoesNotExist:
return False
result.name = context.get('name')
with transaction.atomic(using='db2'):
result.save()
}}}
"In the above example I even made another transaction inside
of the initial transaction but this time using='db2' where the model
doesn't even exist. I figured that would have failed, but it didn't and
the data was written to the proper database."
It is ok to '.save(using=db)'. I used the 'can', probably not the right
term.
Next time I go to mentors. To not make confusion in the ticket.
Regards,
Herbert
--
Ticket URL: <https://code.djangoproject.com/ticket/29706#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" 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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.00bf616a725b7fa80c998fc492515e2c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.