Anonymous
Hey guys, I am using Token authentication to generate access_token when logining in through my Android app.
When I try to send a post request from the Android app using the access_token, I get csrf verification failed error which is strange since with token authentication csrf token is not needed.
Carlos
Ghorz
Anonymous
When I add the csrf_exempt to my code it gives an attribute error saying wsgi request has no attribute none
Anonymous
saying wsgi request has no attribute 'auth'
Anonymous
Not none, sorry
𝕬𝖗𝖙𝖊𝖒
Hi, guys. Can you help me?
I made an endpoint with GET and PUT methods. But because of an unknown problem, PUT is working, GET neither(404 error with message: {'detail': 'not found'}, but I see this in Swagger). Code of a viewset of the endpoint: https://pastebin.com/bKZukhj1
URL path looks like https://pastebin.com/DC67gpmK
P.S. In the serializer there is the only meta.
Anonymous
Sending media to the group is blocked, pls should I send to your dm?
Ghorz
Ghorz
Anonymous
🙏pls how can I access pastebin, I don't know what it is
𝕬𝖗𝖙𝖊𝖒
Anonymous
Ok thanks
Anonymous
Anonymous
My code
foxyy999
hey guys, last night i deploy my project on heroku and upload the images,
it was working fine but on morning heroku does not showing images that i uploaded but my admin panel have the images on database.
and my staticfiles making the copy of every image
heres my project link :
https://my-site-ecommerce.herokuapp.com/
foxyy999
Anonymous
Heroku can't store images
foxyy999
Then why last night it's showing the images and I even use whitenoise
Mehmet
There is a "/app/static/images/shoes2.jpg does not exist" error for an image.
Anonymous
foxyy999
Bunty chhatri wala..
Using path
How to make a url like this:
localhost:8000/postcodes/?postcode=8000&radius=90
Basically I'm trying rest api..
Which can accept data from a user..like above..
bitwise
Bunty chhatri wala..
foxyy999
Bunty chhatri wala..
If the images are static.. then it will work..but wont work on user uploaded media files
bitwise
Page not found (404)
Request Method:GETRequest URL:https://my-site-ecommerce.herokuapp.com/images/shoes2.jpgRaised by:django.views.static.serve
“/app/static/images/shoes2.jpg” does not exist
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 404 page.
Bunty chhatri wala..
Using path
How to make a url like this:
localhost:8000/postcodes/?postcode=8000&radius=90
Basically I'm trying rest api..
Which can accept data from a user..like above..
You know something about this?
bitwise
foxyy999
Bunty chhatri wala..
I tried..but its like xyz.com/post/location..
But i dont want a url like this.
bitwise
Bunty chhatri wala..
I'm trying a rest api with single endpoint..
No forms concept..
Only a get request from url
Bunty chhatri wala..
Ok
Bunty chhatri wala..
Let me try
Bunty chhatri wala..
Thank you :)
Anonymous
On line 71,did you import csrf_exempt
Yh I imported csrf_exmept and applied it to all my functions which involves GET requests in order to prevent that csrf verification.
I didn't apply to functions which are for POST requests because I am using rest_framework Token authentication for them
Anonymous
I except tokens to be passes with Authorization headers when making a POST requests.
Anonymous
@himanshi_kat if you can't tackle the issue, try to store your images to AWS
foxyy999
foxyy999
Thanx everyone
Anonymous
👍
𝕬𝖗𝖙𝖊𝖒
Rangubha
𝕬𝖗𝖙𝖊𝖒
Ghorz
Dexter
Which is best way to create views class or function and what is the main difference
Ghorz
Abdul
Shubham
Shubham
Or even in url block if you are using django template
Abdul
Shubham
Yes in django template you must be using {% url 'url_name' %}
Syanty
Try adding
app_name = "yourappname"
before urlpatterns
And
While calling in template
Use {% url 'yourappname: listing-detail' listing.id %}
Syanty
This way works for me
Abdul
I'll try that, thanks.
SiddiqNx™
Hey everyone. How do you manage timezone conversions in Django? Especially in Rest API? And when a client sends a POST request, do you convert dates in the client side or in the server side? Any standard method for handling this?
Anonymous
Apply it
I did and got WSGI attribute error: saying 'auth' doesn't exist
Anonymous
I want to call Twitter api and fetch last 7 days of tweets for any hashtag
Can anyone give me example please.
Dexter
SMC
Bro's How can I save the href link and text when I click on one of the links of collection which is scraped and display on screen. Now the text and link address which I clicked should be useful in another html page . How can I do it ? Please help me regarding this .
SMC
Pandu
I need some help with modifying my Django Admin. I have a 'Bookstore' model which has Four fields: title, author, status and date_borrowed
**The status field is a select field containing two values: 'Available' and 'Borrowed'
What I am trying to achieve is:
When you select the status of the Book as 'Available', the 'date_borrowed' field is still visible. However when you select 'Borrowed', the 'date_borrowed' field should be hidden. I've tried googling online with many results but nothing has worked out. The closest I got was this link (https://stackoverflow.com/questions/47838059/django-admin-show-hide-fields-if-specific-value-is-selected-in-a-dropdown)
But so far no luck.
Here is the project on Github. It's very basic, just Django (no other packages installed)
The Project: https://github.com/fredricksimi/sampleproject/
SmQ
I need some help with modifying my Django Admin. I have a 'Bookstore' model which has Four fields: title, author, status and date_borrowed
**The status field is a select field containing two values: 'Available' and 'Borrowed'
What I am trying to achieve is:
When you select the status of the Book as 'Available', the 'date_borrowed' field is still visible. However when you select 'Borrowed', the 'date_borrowed' field should be hidden. I've tried googling online with many results but nothing has worked out. The closest I got was this link (https://stackoverflow.com/questions/47838059/django-admin-show-hide-fields-if-specific-value-is-selected-in-a-dropdown)
But so far no luck.
Here is the project on Github. It's very basic, just Django (no other packages installed)
The Project: https://github.com/fredricksimi/sampleproject/
I assume you are talking about frontend, Just add some Javascript, fetch the data, check the string if it is 'Borrowed', you can then modify the display attribute of that div showing the date, make it => display: none;
Pandu
Pandu
Is it possible in Admin panel also?
SmQ
Yes, open admin panel and browser's developer tools, target the specific field, you can easily get your desired div, add this inline to the admin panel html
Pandu
Thanks I'll try👍
SmQ
Just locate the admin panel template in your project, and you are set
Anonymous
How can i implement a permission where only the owner/author can edit and delete something and anyone can view with token authentication?
Anonymous