Prasanna
Hi, show LogoutView code
any further suggestions ?
Nikita Goncharov
You can go to this view(LogoutView) in django code and you will see that this view is not receiving GET method, only POST.
Prasanna
Actually I am running django server in my local and trying to hit http://127.0.0.1:8000/logout/ URL ...... Then I am getting 405 error
Nikita Goncharov
Nikita Goncharov
Shiva
I want to host mysql workbench in gcp and want to access remotely across systems, is any one know ways to do thsi
Prasanna
Is there error ?
yes same 405 error
Nikita Goncharov
yes same 405 error
You need to press button in form, not paste url in browser
Nikita Goncharov
Назар
I changed logout.html file with this code.... but didn't work
no, you need to add this code in you base.html file where you want to have a button to logout
Nikita Goncharov
Your users will have page where for example in header will be button for profile, logout and etc. When they want to do logout, they just press this button and django will send POST request to your logout view
Фазлиддин
please help me to find a good book about Django and creating Apis with DRF, in general creating a good pet project with django
Фазлиддин
I now about existing a lot of books about django, but i don't know which from them its good
Nikita Goncharov
please help me to find a good book about Django and creating Apis with DRF, in general creating a good pet project with django
To learn django you can look for "django for beginners" and "django for profi". And DRF has really good docs, so you can learn it from official site
Назар
many many practice
Nikita Goncharov
after the reading docs what i need to do?
Do projects and learn django from inside
Prasanna
Thank you so much @Nikita Goncharov and @Ha3ap .....Now logout functionality is working
Светлана
Hi, help please. There is a mistake, but all it’s correct ( ImportError: No module named 'blogicum' pytest-django could not find a Django project (no manage.py file could be found). You must explicitly add your Django project to the Python path to have it picked up.
شهرزاد محمد
I'm facing an issue with setting cookies in Django Rest Framework. Here's the relevant code: response.set_cookie( key='auth_token', value=token, secure=False, # httponly=True, # samesite='None' ) And the relevant settings: CORS_ALLOWED_ORIGINS = ['http://127.0.0.1:4321/'] CSRF_TRUSTED_ORIGINS = ['http://127.0.0.1:4321/'] CORS_ALLOWED_ORIGINS = [ 'http://127.0.0.1:4321', ] CORS_ALLOW_CREDENTIALS = True CORS_ALLOW_METHODS = ['*'] CORS_ALLOW_HEADERS = ['*'] CSRF_COOKIE_SAMESITE = 'None' CSRF_COOKIE_SECURE = False SESSION_COOKIE_SECURE = False CORS_ORIGIN_WHITELIST = [ 'http://127.0.0.1:4321', ] SESSION_COOKIE_SECURE = False The issue is that the cookie appears in the response header as: set-cookie: auth_token=c75e2c18b1f96d770ac919f1ded519a3cc701af2; Path=/account/; SameSite=None But it does not get stored in the browser. Does anyone know what might be causing this issue?
شهرزاد محمد
Charly
in FireFox storage inspector
Are you using a frontend framework or something like that? maybe you don' t see the cookies for the frontend but these may be stored for the backend
Hamzat
Hello I'm try to use the django-ckeditor-5 in my admin panel but it's not working Who can help me out please 🙏?
شهرزاد محمد
Are you using a frontend framework or something like that? maybe you don' t see the cookies for the frontend but these may be stored for the backend
I use frontend but as I said it shows in header response set-cookie: auth_token=c75e2c18b1f96d770ac919f1ded519a3cc701af2; Path=/account/; SameSite=None
Charly
I use frontend but as I said it shows in header response set-cookie: auth_token=c75e2c18b1f96d770ac919f1ded519a3cc701af2; Path=/account/; SameSite=None
yes you see that but if your frontend runs in ither port is like other doiman and cookies will only be in the same domain
شهرزاد محمد
yes you see that but if your frontend runs in ither port is like other doiman and cookies will only be in the same domain
I have set these settings. Is there anything else? CORS_ALLOWED_ORIGINS = ['http://127.0.0.1:4321/'] CSRF_TRUSTED_ORIGINS = ['http://127.0.0.1:4321/'] CORS_ALLOWED_ORIGINS = [ 'http://127.0.0.1:4321', ] CORS_ALLOW_CREDENTIALS = True CORS_ALLOW_METHODS = ['*'] CORS_ALLOW_HEADERS = ['*'] CSRF_COOKIE_SAMESITE = 'None' CSRF_COOKIE_SECURE = False SESSION_COOKIE_SECURE = False CORS_ORIGIN_WHITELIST = [ 'http://127.0.0.1:4321', ] SESSION_COOKIE_SECURE = False
Hamzat
Show what you have done and any error you have
I have installed the package but I only have access to bold and Italics I don't have access to other styling This is my code below
Hamzat
I have installed the package but I only have access to bold and Italics I don't have access to other styling This is my code below
CKEDITOR_5_CONFIGS = { 'default': { 'toolbar': [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote', 'insertTable', 'undo', 'redo' ], 'height': 300, 'width': '100%', 'image': { 'toolbar': [ 'imageTextAlternative', 'imageStyle:full', 'imageStyle:side' ] }, 'blockToolbar': [ 'paragraph', 'heading1', 'heading2', 'heading3', '|', 'bulletedList', 'numberedList', 'blockQuote' ], 'codeBlock': { 'languages': [ { 'language': 'plaintext', 'label': 'Plain text' }, { 'language': 'python', 'label': 'Python' }, { 'language': 'javascript', 'label': 'JavaScript' }, { 'language': 'html', 'label': 'HTML' }, { 'language': 'css', 'label': 'CSS' } ] } } }
شهرزاد محمد
Is not about settings is about how cookies work
Ok I use the same domain with another port how can I store cookies
Charly
And you don' t need it, if you keep the cookies for the backend these will be used automatically
Charly
and for APIs is not common to use cookies better to use localstorage
شهرزاد محمد
and for APIs is not common to use cookies better to use localstorage
but auth token is not secure to save in localstorage?
شهرزاد محمد
why you say that?
XSS and token leak
Charly
XSS and token leak
it has nothing to do with XSS
Charly
so listen, you want to have the cookie with the token accesible for your js code, isn't the same thing for localstorage?
Hamzat
Please 🙏 can someone share any resources for django-ckeditor-5 specifically I can't seem to find any recent or good resources
Hamzat
The official documentation of course
There's no information on how to set it up in django
Charly
There's no information on how to set it up in django
https://pypi.org/project/django-ckeditor-5/
Hamzat
https://pypi.org/project/django-ckeditor-5/
Thank you so much Will check this out
Priyanshu Pratap
Ok i get you, thanks 🙏🏻
You can store it in cookie with httponly set to true it won't be accessible by javascript and protects from xss
Priyanshu Pratap
No try to set cookie from backend
شهرزاد محمد
Charly
but cookies are not crossdomain
Charly
Means?
cookies can't be shared on different domains (it can but that way)
Priyanshu Pratap
Yep
Varun
Is raw in django support lazy loading
Varun
Or Orm is good option
Charly
Or Orm is good option
Why would you use django with no ORM?
Varun
sql query is complex
Charly
sql query is complex
Like impossible to make with the ORM?
Varun
I tried to make orm of it,but it lead to complex orm and large code
Varun
def get_voucher_list(voucher_type): qry = """ SELECT t2.id, t2.vch_id AS entity_id, t2.vch_date AS date, t2.vch_no, (SELECT name FROM masters_master1 AS m1 WHERE m1.id = t2.cm1) AS account_name, t2.c1, (SELECT name FROM masters_master1 AS m1 WHERE m1.id = t2.master_id1) AS item_name, t2.c2, t2.d1 FROM transactions_tran2 AS t2 WHERE t2.vch_type = %s AND t2.rectype = %s """ rst = Tran2.objects.raw(qry, [voucher_type, const.T2_ITEM_DATA]) return rst
Charly
I tried to make orm of it,but it lead to complex orm and large code
ok so then how exactly you want to use lazy loading for that query?
Varun
Raw also return queryset as I am not using connection.cursor approach
Varun
And second I want to display the data on html page,I don't want to modified object
Varun
I want to ask from you,I.e. when I use raw,does it fetch data from database,or when I iterate over queryset then it interact with database.