Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to access master database in slave state #395

Open
AhmedSalam22 opened this issue Dec 31, 2023 · 1 comment
Open

Trying to access master database in slave state #395

AhmedSalam22 opened this issue Dec 31, 2023 · 1 comment

Comments

@AhmedSalam22
Copy link

I get this error when I try see payment_details view
Screenshot (428)

`

RuntimeError at /payment/3

Trying to access master database in slave state
Request Method: | GET -- | -- http://127.0.0.1:8000/payment/3 4.2.7 RuntimeError Trying to access master database in slave state C:\Users\admin\wwork\env\lib\site-packages\django_replicated\router.py, line 78, in db_for_write openbook_payments.views.payment_details C:\Users\admin\wwork\env\Scripts\python.exe 3.8.0 ['C:\\Users\\admin\\wwork\\ok-api', 'c:\\users\\admin\\appdata\\local\\programs\\python\\python38\\python38.zip', 'c:\\users\\admin\\appdata\\local\\programs\\python\\python38\\DLLs', 'c:\\users\\admin\\appdata\\local\\programs\\python\\python38\\lib', 'c:\\users\\admin\\appdata\\local\\programs\\python\\python38', 'C:\\Users\\admin\\wwork\\env', 'C:\\Users\\admin\\wwork\\env\\lib\\site-packages'] Sun, 31 Dec 2023 12:24:51 +0100

You’re seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard page generated by the handler for this status code.

DJDT
RuntimeError at /payment/3 Trying to access master database in slave state Request Method: GET Request URL: http://127.0.0.1:8000/payment/3 Django Version: 4.2.7 Exception Type: RuntimeError Exception Value: Trying to access master database in slave state Exception Location: C:\Users\admin\wwork\env\lib\site-packages\django_replicated\router.py, line 78, in db_for_write Raised during: openbook_payments.views.payment_details Python Executable: C:\Users\admin\wwork\env\Scripts\python.exe Python Version: 3.8.0 Python Path: ['C:\\Users\\admin\\wwork\\ok-api', 'c:\\users\\admin\\appdata\\local\\programs\\python\\python38\\python38.zip', 'c:\\users\\admin\\appdata\\local\\programs\\python\\python38\\DLLs', 'c:\\users\\admin\\appdata\\local\\programs\\python\\python38\\lib', 'c:\\users\\admin\\appdata\\local\\programs\\python\\python38', 'C:\\Users\\admin\\wwork\\env', 'C:\\Users\\admin\\wwork\\env\\lib\\site-packages'] Server time: Sun, 31 Dec 2023 12:24:51 +0100 Traceback [Switch to copy-and-paste view](http://127.0.0.1:8000/payment/3#) C:\Users\admin\wwork\env\lib\site-packages\django\core\handlers\exception.py, line 42, in inner response = await get_response(request) … Local vars C:\Users\admin\wwork\env\lib\site-packages\django\core\handlers\base.py, line 253, in _get_response_async response = await wrapped_callback( … Local vars C:\Users\admin\wwork\ok-api\openbook_payments\views.py, line 13, in payment_details form = payment.get_form(data=request.POST or None) … Local vars C:\Users\admin\wwork\env\lib\site-packages\payments\models.py, line 143, in get_form return provider.get_form(self, data=data) … Local vars C:\Users\admin\wwork\env\lib\site-packages\payments\dummy\__init__.py, line 25, in get_form payment.change_status(PaymentStatus.INPUT) … Local vars C:\Users\admin\wwork\env\lib\site-packages\payments\models.py, line 97, in change_status self.save(update_fields=["status", "message"]) … Local vars C:\Users\admin\wwork\env\lib\site-packages\payments\models.py, line 128, in save return super().save(**kwargs) … Local vars C:\Users\admin\wwork\env\lib\site-packages\django\db\models\base.py, line 780, in save using = using or router.db_for_write(self.__class__, instance=self) … Local vars C:\Users\admin\wwork\env\lib\site-packages\django\db\utils.py, line 227, in _route_db chosen_db = method(model, **hints) … Local vars C:\Users\admin\wwork\env\lib\site-packages\django_replicated\router.py, line 78, in db_for_write raise RuntimeError('Trying to access master database in slave state') … Local vars`
@denisSurkov
Copy link

I guess this exception is related to "django_replicated" package and has nothing to do with "django-payments".

I suppose you misconfigured "django_replicated" and wrote url for read only database for "db_for_write".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants