Mirco
There's an entire topic about deploying
Martín
https://docs.djangoproject.com/en/2.2/howto/deployment/ this, right?
m0nte cr1st0
Hello. Help, pls https://stackoverflow.com/q/59694061/11214129
Martín
you can get current scheme by request.scheme
that's great to know, but I was looking to save work for later by getting it at the settings and not waiting for detect it at the views
Martín
right now I'm reading the docs
Martín
If you run manage.py check --deploy you will see the list of them
I tried this, but I have a problem because of missing environment variables, which I will fix later reading the docs first of all 😁
Batman
setting SECURE_SSL_REDIRECT to True in your settings file would be the one precisely
if you set this to true, you can be certain that it will be https forever
Batman
Hello. Help, pls https://stackoverflow.com/q/59694061/11214129
create a statistic serializer first which returns your desired fields, then set statistics field on user serializer to the statistic serializer and pass the argument many = True in it
Martín
did you take a look at this? @madtyn
I wrote down the URL and read, but didn't do nothing yet
Martín
I will probably try, because I will test locally with some people I know, but I don't want any warning like "This web is not secure" showing up
Martín
But I'm with deployment issues first
Mirco
I will probably try, because I will test locally with some people I know, but I don't want any warning like "This web is not secure" showing up
It doesn't matter locally That's why a better idea is to have different settings file per stage by following 12factors pattern
Anonymous
Write a Django based web server to parse a user request (POST), and write it to a CSV file.
Anonymous
Please help
Mirco
That I do. I have local.py, production.py and test.py
Great, so set Django settings related to https into production.py only
Martín
But that's already taken care of with cookiecutter-django The thing is that in some views I'm building paths over my URL all the time. There I need the scheme, and I would prefer not to inspect the request all the time
Martín
Mmmmh, I feel like I will end putting the https in production.py
Martín
Hardcoding the scheme there
Martín
Can I omit the scheme?
Mirco
Mmmmh, I feel like I will end putting the https in production.py
The right way is to use the settings Django offers u
Mirco
Can I omit the scheme?
Yup because for example the secure redirect will do the job on prod
Martín
Maybe I'm doing stupid stuff just because I'm ignorant
Mirco
Maybe I'm doing stupid stuff just because I'm ignorant
No worries, u just need to study a bit more and understand best way to manage stuff without reinventing the wheel
Anonymous
Hello. Help, pls https://stackoverflow.com/q/59694061/11214129
i just posted an answer, it's not tested please check
Martín
Oh, I also forgot I'm using the same SERVER_URL variable for tests, that's another reason when using TDD
Martín
But I could use different variables in tests
m0nte cr1st0
thnx
Anonymous
welcome
Yash
I am working with openpyxl lib to edit excel file in django. I am using this method to save the file. But how can I convert this to pdf and export it back to user?
Anonymous
Hello) For example, I need to take after authorization on another site to take the name of his products that he has in the basket of goods on his authorization account) How to do this? Well, or other information
Aditya
Hello from my Django page it's not going to admin page it's showing error what need to be done
Aditya
If you don't share the error and the code, we cannot help ya
Operational error at/admin/ No such table:Django _session
Aditya
Did u run migrations ?
I am getting this error from going from main Django page to admin page
Anonymous
Hi I had a error in my project, as I am a beginner with dev Django, I went to read the manual. But I remained a little confused. In my case I have the models called Clients and Hosts. Every Host belongs to a Client, so I added the id_client field as a foreign key, in the Host table, in the templates when I have to access the client name through the Host table do so for example: {{host.id_client.name}}. But when I was learning and trying to implement CRUD + AJAX on my project, when trying to create a new Hosts model record, I had to use id_client_id, for function "create ()" ... In the Models documentation, I found the paragraph "Database Representation" that says Django adds "_id", but would you like to understand if this is editable? Or should you rename the column FK? My models: class Clients(models.Model): id_client = models.BigIntegerField(primary_key=True, blank=True) ... class Hosts(models.Model): id_host = models.BigIntegerField(primary_key=True) id_client = models.ForeignKey('Clients', models.DO_NOTHING, db_column='id_client', related_name='host_client_id') ... obj = Hosts.objects.create( id_client_id=id_client, <others fields> )
مــا
Hello everyone. I'm considering Django as the backend of my Vue.js application, because I need to do some text processing on file uploads and python can be good for that. I am starting to learn Django but I thought perhaps somebody in this group could give me some guidance so that I don't beat about the bush too much.
مــا
I think I can write all the frontend in Vue.js, then what I need to do in the backend is just to process the files the user uploads and as a result to insert some data in a database. My concrete question is: Would I need to use Django for that, or just Django Rest Framework is enough?
Anonymous
A tip, Django assigns a field ID automatically to the models
I read this in the documentation, but the database already existed. I had to declare the PK's in the models. What I haven't really learned yet is how to make django stop waiting for this "_id" for FK. This is possible?
PV
form.save(commit=false) process data here then form.save
PV
For example if form.is_valid(): data = form.save(commit=False) data.creator = request.user data.updater = request.user data.auto_id = get_auto_id(Customer) data.save()
PV
If anyone doesn't got solution after 24 hour of posting questions, ping me, i will help you
Anonymous
can anyone tell me how to render pdf files in templates
Yash
There are many python packages available for that, you can even use jQuery also
I can't use jquery since I'm working on backend and I can't get a library which suits my need for required conversion.
Sweetie
Any django template available to build something like this website: https://shoppy.gg/
Yash
i have too much data with same value in database and i want to show only one time that who have a exact same value so how i do that like same name shows only one time when i retrieve data
Damron
Hi guys! Can someone give advise about working in team between backender and frontender? We don't know how to frontender to make render of site without waiting for backend end their work? I mean we are going to make site, and it's a big problem to communicate frontenders and backenders. My question may be not so understandable)
Anonymous
Hi. The task is this. Suppose I want to add subheadings to the chapter from the admin panel. Initially, I do not know how many of them. And with each addition to the admin panel, a new field should appear. That is, initially one thing, if I fill it out, the following will appear, etc.
Sweetie
How to make django restframework to work with api keys so users can consume service like: /endpoint?token=xxxxxxxxxxx&foo=bar
Sweetie
Token passed via get parameters ?! Use headers! See TokenAuthentication class
I don't want to use Authorisation headers that makes it complex for user to consume api. I want them to easily consume api from anywhere. example.com/endpoint?token=xxxxxxx&foo=bar The header auth make it hard to consume api for non programmers. My api should be callable from browsers directly
Sweetie
If your user can't figure out a authorization header they won't figure out an API either
I am asking this simple way to consume api: https://app.scrapingbee.com/api/v1?api_key=YOUR_APIKEY&url=YOUR_URL
Mirco
I am asking this simple way to consume api: https://app.scrapingbee.com/api/v1?api_key=YOUR_APIKEY&url=YOUR_URL
And we are trying to tell u a better practice is to send the API key into headers
Sweetie
And we are trying to tell u a better practice is to send the API key into headers
I said I don't want to do that. Is it not possible with django inbuilt? I know security risks but I still want to use api key in url.
Sweetie
I just want to know if django restframework allows to do that or I have to create a token model and generate token for users and authenticate them by comparing the received token all in my code.
Mirco