Mirco
maybe, Okey
strongly recommended 😊
Welis
strongly recommended 😊
yeah, I'll do it 👍
Misael
this works xperfect thanks a lot!
You're welcome. 👍
Anders (izzno / gooood) 🇳🇴
I am using a JSON field for attributes and just realized DRE serializes the JSON field along with the rest of my model! Thats awsome...
Lucian
{% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}
Lucian
…in Django templates.
Andrey
Hi gays. I need help... How to make a field manytomany not required? Sorry for bad english...
Andrey
In Django 2.2. Not working blank=True and null=True
Anders (izzno / gooood) 🇳🇴
😉
https://imgur.com/RP5hPGO
Mirco
https://imgur.com/RP5hPGO
is attributes PG's JSONField ?
Anders (izzno / gooood) 🇳🇴
yes
Sander
oh yes), it's work, Thanks)
Still not the way to go buddy, you should really move it to the view
Welis
Still not the way to go buddy, you should really move it to the view
but this {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %} dosen't logic in my context, it's just help me for build html tags))
Orack
can anyone share easiest example
Orack
for drf authentication
Welis
can anyone share easiest example
from django.conf.urls import include, url from rest_framework_jwt.views import ( obtain_jwt_token, refresh_jwt_token, verify_jwt_token, ) from server.api.v1.urls import router as v1_router urlpatterns = [ url('auth/login/', obtain_jwt_token), url('auth/token_verify/', verify_jwt_token), url('auth/token_refresh/', refresh_jwt_token), url('v1/', include(v1_router.urls)), ] :D
Welis
So x % 2 isn't logic?
if i move it to views so will more code
Welis
So x % 2 isn't logic?
it's small logic )
Welis
Still not the way to go buddy, you should really move it to the view
and i finishing project, don't make work for me please :D
entropy
Hi! I am a creating a report(csv file)in one of my APIs and it will be downloaded by the client once it’s done. But I want the api to send it via email if it’s taking too long (based on a setting). How can I achieve this? i.e. if the report is created within 5 mins, it will be downloaded, but when it’s already 5 mins it will be sent to email.
entropy
Please help me. TIA
Orack
what is jwt ?
Sander
what is jwt ?
JSON Web Token
Abdulwahab
✋🏼 .. I've a question I'm working on a Django project intended for students & teachers I create a model called 'profile' with boolean variable called 'is_student'. The 'profile' linked with the 'User' model via OneToOneField relationship .. I need to access 'is_student' from a view function , how ?! what I need is, when the user submit on a student registration form .. after creating a profile object, mark 'is_student' variable as True. How do I do that ? Thank you in advance.
Anders (izzno / gooood) 🇳🇴
https://github.com/izznogooood/myfamilycart/blob/master/users/signals.py
Abdulwahab
https://github.com/izznogooood/myfamilycart/blob/master/users/signals.py
great ! that's what I did exactly .. but .. since the signal gets called after saving a new User to create a new profile for this user, whether this user is student or teacher .. from the signal how can I differentiate ?
Anders (izzno / gooood) 🇳🇴
Why use a signal then? Just link them in the view, kind of what unknown suggested
Orack
which is better
Orack
normal authentication from database or jwt
cj
normal authentication from database or jwt
jwt uses authentication from database to give you the token 🤷🏻‍♂️
cj
so, jwt is just an extra layer on top of db authentication
cj
if you want to protect your API with authentication, let me recommend you to take a look to djoser package for that 🙂
cj
(it supports JWT too)
Anders (izzno / gooood) 🇳🇴
djangorestframework-api-key ...
Anders (izzno / gooood) 🇳🇴
dead simple. Same principle.
Anders (izzno / gooood) 🇳🇴
(If you're using DRE that is...)
Orack
i started learning django just 3 days ago
Orack
its getting confusing now
Orack
😭
Mirco
(If you're using DRE that is...)
Just for my curiosity 😂 why do you refer to DRF using E instead of F ?
cj
is this djoser ?
no, that's another package
cj
is this djoser ?
this is djoser: https://github.com/sunscrapers/djoser
Anders (izzno / gooood) 🇳🇴
Just for my curiosity 😂 why do you refer to DRF using E instead of F ?
omg, I have no idea why I'm stuck with that miss spelling...
Anders (izzno / gooood) 🇳🇴
google autocorrect maybe
Nope, its a brainfart
Orack
finally
Orack
djoser was sooper easyyy]
Orack
"access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTYyMDg2NTEyLCJqdGkiOiJhMzgyMWZiZjg0ZmQ0NDg5YjQxNTg3OWQ0NGM5MGE0ZiIsInVzZXJfaWQiOjJ9.ZVwIjN31-AIYllL6cCTiJHDc7ZrpjNMkvXOnsOt8-8Q",
Orack
i got this token
Orack
what should i do with it
Alexey
what should i do with it
Add to headers Authorization: Token your_token
Alexey
what should i do with it
Or Replace "Token" with "Bearer" if it is jwt token
Orack
but
Orack
localhost:8000/bucketlists
Orack
the url works without token
Alexey
https://www.django-rest-framework.org/api-guide/authentication/#tokenauthentication
Orack
urlpatterns = [ url(r'^admin/$', admin.site.urls), url(r'^auth/', include('djoser.urls')), url(r'^auth/', include('djoser.urls.authtoken')), url(r'^auth/', include('djoser.urls.jwt')), url('', include('api.urls')), # Add this line #url('us/',include(router.urls)), ]
Alexey
https://www.django-rest-framework.org/api-guide/permissions/#isauthenticated
Alexey
but im using djoser not this
https://djoser.readthedocs.io/en/latest/authentication_backends.html#authentication-backends
Abdulwahab
student = Profile.create(user=new_user,is_student=True)
student = Profile.objects.get_or_create(user=u, is_student=True) This solved my problem .. 🙏🏻 Thanks
Orack
What about this?
adding 'rest_framework.permissions.IsAuthenticated',
Orack
WrappedAttributeError at /bucketlists/ 'IsAuthenticated' object has no attribute 'authenticate' Request Method: GET Request URL: http://127.0.0.1:8000/bucketlists/