Zaryab
It's really urgent
AJ
Martín
@pyflare, @batman071 I did plenty of research yesterday. I read a lot about deployment and a lot of things I coud make with swgi and static resources, but I think I saw very few things about URLs
I'm using the SERVER_URL variable in two places in the views, but I'm starting to think @saveychauhan was right and I should use the request.
There is a request._current_scheme_host attribute that contains exactly what I want
Also I could get it by f'{request.scheme}://{request.get_host()}'
Mirco
Martín
well, I can show my code
Mirco
Martín
this is my views.py: https://hastebin.com/sawahoniku.py
Martín
the important points are the HERE comments
Martín
I'm building the paths by using the SERVER_URL
Martín
this works like charm locally
Mirco
Perfect, and I'm more confident about what I told u
If u set up the settings related to https for production settings, you will get automatically HTTPS
Locally u will still use local settings without secure settings and so you will have HTTP
Mirco
without playing with request meta attributes about scheme
Martín
so what I should do is....
Martín
use the request?
Martín
then I just set SERVER_URL as it is, but in local.py and production.py
and set https in production
Mirco
Martín
I tried like this in local.py:
HOST = env.url("DJANGO_HOST_URL", default='http://corelli.sytes.net')
SERVER_URL = f'{HOST.scheme}://{HOST.netloc}:{HOST.port}'
Martín
but maybe I can save one call to the environment variable to get the URL, idk
Mirco
Martín
ok
Mirco
But I don't know what's needed for your sftp connection or some edge cases
Martín
I think the sftp connection thing is fully covered, thanks 😊
Martín
I'm not concerned with that
Mirco
Related to the server url I mean
Martín
I'm fiddling now with the thing, this env.url() function seems weird, I'm about to use just env.str()
Sumit
What is the best way to create social authentication endpoints, or some library that can manage social authentication with DRF.
Mirco
Martín
let me see
Martín
import environ
Martín
Django-environ allows you to utilize 12factor inspired environment
variables to configure your Django application.
Martín
it seems like it is django-environ
Mirco
Yup, exactly
Another suggestion is don't use cookiecutter before a strong acknowledgement of Django
You will miss lots of pieces
Mirco
Martín
But I don't know how should I set the value in the environment variable
Martín
With or without the port
Martín
And the default
Mirco
Mirco
If you look at django-environ source code, you can understand much better
Mirco
https://www.tutorialspoint.com/urllib-parse-parse-urls-into-components-in-python
Mirco
This library can understand scheme, port and so on
Martín
Martín
Mirco
Anonymous
hey guys!!!......iam using rest framework and and i want to add an extra boolean to a ModelViewSet create action response
here is a code sample https://pastebin.com/tLLYtyAq 😃
Anonymous
Shubham
Shubham:
Hey so I need to extract the numbers from files it's like a text file
And also need to find the smallest one out of them
Mirco
Batman
Bhupesh
Hello Guys,
I am using the following code in multiple views
authentication_classes = [SessionAuthentication, BasicAuthentication]
permission_classes = [IsAuthenticated]
is there any way to prevent this code duplicacy ?
Bhupesh
DEFAUTL_PERMISSION_CLASSES, got it 😅
Mirco
Bhupesh
looks like searching in this group is better than googling 😂
Mirco
Philip
Hello guys , what a will be problem. I want parse datetime with input field , but after post i get api in which date field is empty. For input type used datetime-local
enansi
Hi all. How do I write a tests against my Django DRF API for actions that need actual objects in the database? For example I need to write a test for a function that takes a list of IDs, those IDs are primary keys of objects in the database.
Muslim
Anonymous
hii everyone , could anyone help me?
Anonymous
i have confusion that i was a part of project which involved django ,angular , node js
Anonymous
so for frontend when we have angular , why we node js
Anonymous
i didnt understood that..it was being used for loading client files?????????
professor
Muhammed Enes
How can i get the all urls path my django app?
Philip
from name_app.urls import urlpatterns)
Shubham
So I am gonna work on a erp system what are steps that I should consider to built it
Shubham
cj
Anonymous
Is anyone looking for helping hand in project? I m really interested for that
Prajwal
How to solve sqlite3 operational error 'no such table'
Mirco
Anonymous
https://youtu.be/qCxvOqB3l3U
Anonymous
https://youtu.be/xocy7YU9Qik
Anonymous
Great to start with Django
Вадим
Hello, Guys. I have a question. Django has humanize template module. When i load it in my template, it humanizez all number variables in this template. But this default behaviour is undesirable. I want humanize to affect only those vars a postpone with |intcomma filter. How can I solve it (besides making my own templatetag) ?
Вадим
And besides |stringformat:'d' filter ))
Вадим
Can I change this default behaviour ?
Anonymous
How to generate token for custom user