jazzband / django-payments

Universal payment handling for Django.
https://django-payments.readthedocs.io
Other
1.07k stars 282 forks source link

Trying to access master database in slave state #395

Closed AhmedSalam22 closed 1 month ago

AhmedSalam22 commented 11 months ago

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 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 commented 10 months ago

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".