Dullah
Andrew
Hi I learned django & made projects with it but if I want to make these projects with Django-Rest-Framework is the same process of development or it's different approach?? in order to be api developer
Himanshu
Hi guys anyone please help me how to count total product of a session
Himanshu
In django
.
.
.
Med M'bareck
.url
01110010
Its should be
{% load static %}
<img src="{% static 'accounts/alatoo.png' %}" alt="My image">
🧚♂️
{% load static %}
<img src="{% static 'media/images/alatoo.png' %}" alt="My image">
Ashish
Please read about static files in django .. it will clear your doubts
01110010
You got to check your setting to point statics to your picture or asset
STATICFILES_DIRS = ( ‘assets’,)
Jitxs
what is best practice just adding your app in installed app and use app/index.html and app/style.css or configuring the setting.py for templates and static ?
mohamedhk2
Hi,
In Django, I created a custom backend located at MyApp/auth/MyCustomBackend.py and added it to the settings.AUTHENTICATION_BACKENDS.
I added a print statement in the MyCustomBackend.authenticate function at the 1st line,
but I am still getting "Invalid username or password" without any print statement. Can anyone help me figure out why?
01110010
Muhammed
Hey i need a rest Django api that check a token from Google sso if valid Google token and user is existed ge can login but if token is valid but not an existed user it create account for him using Google
Vorke
Yes
Hello, thanks, i have managed
Nimra
Hi there..
I wanted to create custom error pages for my drf application.
Do anyone have any idea about this?
bhzad
Hello, I redirected the user to the home page after logging in the file view, but after logging in, this does not happen, and the same login page is reloaded, but the user is logged in. How can I solve the problem?
I even wrote login_redirect_url in the setting file, but it doesn't work
Shivam
Shivam
Then homepage will show other otherwise go to login page
bhzad
i did this
Amicah
i did this
You first have to make sure home is your root url. Then add the @login before the home view. To make sure that before somebody goes to home they have to be logged in.
RXRX
{% for year in range(2010, 2021) %}
{% for p in files %}
{% if p.year|stringformat:"s" == year|stringformat:"s" %}
Match found for year {{ year }}! <br>
{% else %}
No match found for year {{ year }}.<br>
{% endif %}
{% endfor %}
{% endfor %}
can someone tell me right approach, i dont want tu run the logic inside the loop again. i just want to print all years and print if file found or not found
hadi
hi , how can i set custom permissions for media and static files?
Jitxs
what is best practice just adding your app in installed app and use app/index.html and app/style.css or configuring the setting.py for templates and static ?
Павел
Hello everyone! Can anyone tell me if there is a tool that allows you to take an openapi schema in yaml format and, based on it, automatically generate a package for DRF with ready-made serializers?
Specifically in this order, not the other way around, when you write a serializer and then generate an openapi specification from it.
I found tools for Flask, FastAPI, but I don't see anything for the DRF and Django
Something like this: https://openapi-generator.tech/docs/generators
p.s. all I could find was the drf-yasg and swagger-django-generator. But they don't support openapi 3.0 and django > 4
Mirco
Павел
drf-spectacular and it supports OAS 3
drf-spectacular is a tool that allows you to generate an openapi schema based on written serializers, routes and views
And I need the reverse order: generation of a server package compatible with drf and django, based on the existing openapi specification
For example, there is "openapi-generator", but it only allows you to generate server-side code for flask and fastapi
Mirco
مريم خالد
how can i get only a foreign key of admin user in django without usual user? do anyone have an idea how can i do this?
Amicah
.
.
01110010
مريم خالد
.
.
.
.
MHJ
hello
guys i don't know why my content of render partial doesn't show in web ? who knows about it problem?
Charly
Charly
MHJ
no errors but it don't show the details
Charly
MHJ
MHJ
Charly
Charly
has been not updated since 2018
MHJ
why?
MHJ
ok tnx bro
ibraheem
hi
I want to create an educational system using Django, and I want to add a feature where, after the administrator approves the test results, a PDF certificate is generated for the student. How can I do this?
Doragonsureiyā
🚫 Trey [6015038246] is already banned.
.
ibraheem
ibraheem
i edit the template
.
ibraheem
.
Miqo
Hi
I want to get 5 random objects from my query
How can i do that?
.
Hi
I want to get 5 random objects from my query
How can i do that?
https://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by
“To order randomly, use "?", like so:
Entry.objects.order_by("?")
Note: order_by('?') queries may be expensive and slow, depending on the database backend you’re using.”
Kritesh
Issue is rest of react pages it's required data to access rest of pages means if I pass token as get request he will bee hitting api to get data after tht I can able to go rest of pages
Kritesh
So I want to do it as server side approach broo
Farzin
Hello every one,
In our panel we have multiple event, each event has a map with multiple area, when we click on one of the areas some data will be shown, we needed these data to be updated each time some one click on each of the areas before the are represent the data, what I did was override the to_represention method of django rest to check based on some parameters that comes from user and update the data related on that area on database, it was working without problem on Test system, but now in production I'm facing: maximum recursive error from queryset, why this happens?
DoT
hi everyone
im getting error csrf token request aborted
i added csrf token after post method in form ,...it works fine and page opens(every 1st time when i click login)
when i reload the page and resubmitting the form it shows the csrf request error(every time when i reload or resubmit) anyone can help me??.....
fsociety
DoT
its the code im getting error of csrf ....2nd time submission
Shafin
I have a form with add multiple cities when I click add increment cities input only after insertion I need to update I I give 2 cites then edit and add one more that time update pervious values and insert new cities
Shafin
Help me with this