Mostafa
Any help please
Mostafa
I have error in my django rest framework
Mostafa
Serializers file
Arthur
Mostafa
Str object has not attribute values
Mostafa
Error in serializers.py in _readablr_fields line 376
Mostafa
Readable*
Mostafa
@arthur_erikovich any help bro
scoty
Hi guys ,is there anyone who use spyder IDE for django project development? How to use django framework in spyder IDE
Bral Bral
Hey! Is there any option of notifying by email about errors ? The right way is modifying LOGGING in settings.py?
Anonymous
Bral Bral
Mirco
Siddharthan
How to make invoice in django using fo data?
Siddharthan
How to.generate pdf file or customised print.format in django
Yash
Mirco
Share settings
Mirco
Asuran!
From where can I start learning Django?
Astrapel
Asuran!
Thanks! Just saw the resources
A
How can I add csrftoken in every request I'm trying to add csrftoken in every request , is it possible ? How can it be achieved ?
𝚚𝚞𝚊𝚗𝚝𝚊𝚐𝚘𝚗𝚒𝚜𝚝𝚊
𝚚𝚞𝚊𝚗𝚝𝚊𝚐𝚘𝚗𝚒𝚜𝚝𝚊
A
𝚚𝚞𝚊𝚗𝚝𝚊𝚐𝚘𝚗𝚒𝚜𝚝𝚊
How exactly?
https://docs.djangoproject.com/en/3.0/topics/http/middleware/
𝚚𝚞𝚊𝚗𝚝𝚊𝚐𝚘𝚗𝚒𝚜𝚝𝚊
But for what? Authentication?
𝚚𝚞𝚊𝚗𝚝𝚊𝚐𝚘𝚗𝚒𝚜𝚝𝚊
There is more elegant ways
A
𝚚𝚞𝚊𝚗𝚝𝚊𝚐𝚘𝚗𝚒𝚜𝚝𝚊
Yes
Do you use SSR or REST API?
A
Restapi
𝚚𝚞𝚊𝚗𝚝𝚊𝚐𝚘𝚗𝚒𝚜𝚝𝚊
Restapi
Token authentication in DRF is your solution
𝚚𝚞𝚊𝚗𝚝𝚊𝚐𝚘𝚗𝚒𝚜𝚝𝚊
Built in feature
𝚚𝚞𝚊𝚗𝚝𝚊𝚐𝚘𝚗𝚒𝚜𝚝𝚊
And it is the headache of frontend client to set token in every request then
A
I have been given a general instructions :--> Request will set HTTP_AUTHORIZATION header with the user token
{
“X-CSRFToken”: <token>
}
𝚚𝚞𝚊𝚗𝚝𝚊𝚐𝚘𝚗𝚒𝚜𝚝𝚊
Actually CSRF has different purpose
𝚚𝚞𝚊𝚗𝚝𝚊𝚐𝚘𝚗𝚒𝚜𝚝𝚊
https://www.django-rest-framework.org/api-guide/authentication/
𝚚𝚞𝚊𝚗𝚝𝚊𝚐𝚘𝚗𝚒𝚜𝚝𝚊
Here are the more usable practices
A
Thanks
𝚚𝚞𝚊𝚗𝚝𝚊𝚐𝚘𝚗𝚒𝚜𝚝𝚊
Doragonsureiyā
Your question is not related to Django.
Please move to @PythonOfftopic group and ask there.
Gabriel
Kirill
How to pass context variables, uses in base.html to a child template, where {% extends 'base.html' %}
Samuell
about django 3, I want to create an item in the database that is whole and accepted only from number 1, that is 1, 2, 3, 4, never a 0. I thought about using SmallAutoField, but as it is new, no I know how to use it. Is this SmallAutoField to generate numbers automatically or can it be inserted by the user?
cj
Samuell
Samuell
in fact what I want would be to store whole numbers in the database from 1
Samuell
I asked about AutoField because I saw that it started at 1, but I was in doubt if it was autoincrement or not
Samuell
yes
Samuell
I didn't want to be able to check if the user entered 0, for example.
cj
yes
then just create a model with no fields 🤷🏻♂️ and use it's id, it does exactly what you want and you don't have to write anything by yourself, or just add one field with the name you want as IntegerField() and make it a primary_key
Samuell
The field cannot be the id, because it is a time record, the user must enter the number of hours worked, but it can never be 0 or negative hours, type -2
cj
Samuell
hours in decimal, exemple 1.0, 0.5, 1.1
Samuell
cj
yes, I got confused
just use PositiveSmallIntegerField, that's all.... and set a MinValueValidator
Samuell
ahh... yeahh, thank u so much, my friend....
Samuell
I didn't know the MinValueValidator
Samuell
cj
the MinValueValidator work in this case?
Yes, also you can have a max validation too, I guess no one works more than 24 hours a day 🤷🏻♂️
hours_worked = models.FloatField(
validators=(MinValueValidator(1.0), MaxValueValidator(24.0))
)
Samuell
perfect!
Samuell
thank u
Samuell
Samuell
is there a parameter that makes all letters capitalized?
scoty
Yar
Hello guys. I'm searching for great e-commerce(and not only) open-source products for learning typical software enginering problem solutions. Pretix, saleor, oscar for example
Yar
I would be grateful for the projects with beautiful source code
S_8634
Can anyone share login snippet in django..
Asifali
How I can get states depending on countries in django
Oleksandr
Hello guys! Could you help me to set up image uploading via django-tinymce and django-filebrowser.
Which url I have to set for images_upload_url. In tinymce docs mentioned images_upload_url: 'postAcceptor.php’
I have done my best 😤
Here are project settings
Bral Bral
hey guys! If i want receive in email error reporting information about request ( parameters, initiator, etc) i need to create own middleware ? Or there is another way