Sweetie
DRF has a beautiful TokenAuthentication to implement what you wanna do but in the best way
Suppose my user want to access a web site which is blocked for him he can just do this https://app.scrapingbee.com/api/v1?api_key=YOUR_APIKEY&url=YOUR_URL And view the website in browser easily. While he cannot consume my api at all if I make it header authentication. I am trying to find a easy way for user to consume api and also track his number of api calls
Sweetie
Ok thanks
Mirco
☺️
Sweetie
I did already read drf docs before asling here and in TokenAuthentication it askes me to send header Authentication: Api-key xxxxxxxxxxx While I am asking for token in Url. I will read again itp see if I missed some part.
⟨ Simon |
instead of asking them to use URL parameters
Damron
Frontend devs can use fake data to go ahead with their job without waiting real data service to be built by backend team
Can you please describe how it will be look like? At the moment we want to make as follows: In idea front makes own context in views.py and work with them in template(front can get simple data from DB by own, such as is_autherised, post_list and so on, using some filters to hide and show necessary html code in one page) And next the back just need to get more complex information and maybe make some changes in templates But the main idea is that front uses named fields from context and later backenders can understand what fields were used and for what
Mirco
I did already read drf docs before asling here and in TokenAuthentication it askes me to send header Authentication: Api-key xxxxxxxxxxx While I am asking for token in Url. I will read again itp see if I missed some part.
Think a bit more.on it What's the difference between receive the token by get parameter , check if exists and so on and get the token via the header and Django will do the job by itself
professor
does anyone have an example of group permisions in django?
Mirco
Not reinventing the wheel is one of Django's goal
Sweetie
There are 1000's of web apps that use api key in URL. I know it's a security risk. My api is not serving any sensitive info it's there just to track number of api call each user is making. I don't understand why no one is answering how I can do that and instead suggest me better ways that I already know. I want token in url just like many other apps, only question is if there is already a way or I have to code the logics myself.
Mirco
But you will spend useless time by following one of the worst strategy we have nowadays
⟨ Simon |
and your users won't understand how to use URL parameters
Sweetie
also chances are you'll have to do the logic yourself
Thanks that was the answer I was in need of
Damron
That's why nowadays frontend and backend are fully decoupled So frontend devs can work without knowing Django / python If you still are at first stage , think a bit more if there's the skills for using modern frontend frameworks
Hmm I don't quite understand you) You said front to use fake data - but what's the data? where he should take them? Will it be easy backenders to insert dynamical data from views? And what frameworks can you suggest?)
Mirco
And so it's easy to create fake data
Damron
Backend team must know what data is building up so it's easy to tell frontend devs you will receive data in this format
Yes, that make the sense So we need to discuss what the data receives each template and then fronts and back work separately, right? But how frontender to make fake data? can you please give some examples?
Mirco
Yes, that make the sense So we need to discuss what the data receives each template and then fronts and back work separately, right? But how frontender to make fake data? can you please give some examples?
Let's say they will use javascript fetch API ( or Ajax ) And your backend will send as response a json like { "name" : "A real name" } They can use a fake json like { "name" : "Foo" } And keep working on UI/UX
Egor
Hi! I have django + drf on backend and react on frontend. The architecture of the app implies that we serve frontend and backend as two independent entities. For authentication we chose to use session basaed authentication. I have a couple of questions regarding login+logout process and csrf. DRF docs mention that for logging in we must use default django login view (because of security concerns). I though that we could redirect all login requests to django(via webserver like nginx or caddy) and then redirect back to frontend. Is it a fine solution, or maybe react can make POST requests to some simple api endpoint where we would manualy authenticate and login users. Also, http methods such as POST,PUT,PATCH require csrf token. Do we need another endpoint for obtaining csrf tokens, or can we simply set csrf in login view and that would be enough? Thanks in advance)
Doragonsureiyā
I think I got it, thank you!!)
You're welcome! 😊
Mirco
Please buy it
Tony
What is the best model field for storing comments
Rainur
I think I got it, thank you!!)
Thanks, i had the same question
Yash
https://docs.djangoproject.com/en/3.0/ref/models/querysets/#django.db.models.query.QuerySet.distinct
its shows error - DISTINCT ON fields is not supported by this database backend
professor
hey guys , what is the best and less painful to create content based group permission?
Anonymous
please any one tell me how to render any pdf files in templates because whenever i click on that pdf link it only shows me the download link of pdf but not open my pdf which reside in my local directory
Anonymous
https://stackoverflow.com/questions/39919012/django-python-show-pdf-in-a-template
Anonymous
i have found this link but not satisfy with the solution can anyone have any idea about this
Anonymous
all pdf files are placed in my static folder
professor
https://stackoverflow.com/questions/59701165/permission-using-decorator-django-class-based-view
Yash
How do you save a NamedTemporaryFile into a model FileField in Django?
AJ
A python question, suppose I have list a = [1,2,3] and a var = 5, I want to keep looping over the list 5 times and get 2, what's the most pythonic way to achive this.
Raudin
AJ
Thanks
Jimmies San
its shows error - DISTINCT ON fields is not supported by this database backend
https://stackoverflow.com/questions/54249017/distinct-on-fields-is-not-supported-by-this-database-backend
Jimmies San
So i have to use postgresql for using of distinct
or use python after the distinct query value
Yash
Not exactly
Then what ?
Cesar
do this MODEL.objects.values('COLUMN').distinct()
Jimmies San
How ?
https://stackoverflow.com/questions/12382232/django-query-distinct-values-works-but-i-cant-use-the-query-result
Raudin
It should return 3 for 6 like a circular list but it's returning 2.
The number 1 in the itemgetter func is the index of the element that you want
Jimmies San
Then what ?
then learn how to use google, maybe before.
Anonymous
Write a Django based web server to parse a user request (POST), and write it to a CSV file
Anonymous
Please help i dont have time to make the code tomorrow is my submission day.
Anonymous
And i am a student
Dennoh
😂
Firdaus
😆
Anonymous
i am just trying to rum my existing project and having the following error
Jimmies San
use a pastebin service man. come on
Jimmies San
and the error is pretty easy to understand. read the last line.
Anonymous
yes this true i am new
Anonymous
ModuleNotFoundError: No module named 'tx_backend' this one
Anonymous
can you assist me how to deal with it
Hussein
How can I pass a username from the link of the application
Jimmies San
you are trying to import something, this something is missing
Jimmies San
check your virtualenv, requirements, and apps
Anonymous
ok thanks
Zaryab
Reverse for 'post-delete' with arguments '('',)' not found. 1 pattern(s) tried: ['post\\/(?P<pk>[0-9]+)\\/delete\\/$']