inchidi
https://docs.djangoproject.com/en/2.0/ref/contrib/staticfiles/#settings
Anonymous
STATICFILES_DIRS
i change it but get a error : ?: (staticfiles.E002) The STATICFILES_DIRS setting should not contain the STATIC_ROOT setting. so what can i do
Anonymous
calm down and focus
ok thank you from your help
inchidi
its because your static root value inside your staticfiles_dirs
inchidi
change STATIC_ROOT to something else, maybe static_root directory instead static
Django Bot
>> Links - A comprehensive Django CBV guide — /var/ - PyConWeb 2018
Anonymous
nice!
thank you so much it work Truly with your help i fix STATICFILES_DIRS and run mange.py collectstatic and it worked
Prayashi🍩
Any python expert?
Anonymous
Nope
inchidi
too bad, i like gb but...
Anonymous
Prayashi🍩
I really need help😭😭
Anonymous
It's development halted a while ago
inchidi
Prayashi🍩
Hmm
Prayashi🍩
Actually I don't know much about python
Prayashi🍩
But I am interested in it
Prayashi🍩
I wanted to create a bot in telegram
inchidi
But I am interested in it
heres some resource to start @pythonres
Anonymous
I wanted to create a bot in telegram
you can use python telegram bot
Prayashi🍩
I want to create a bot
Anonymous
I want to create a bot
https://t.me/pythontelegrambotgroup
Prayashi🍩
Which can delete messages
Prayashi🍩
Post message with buttons
Django Bot
>> Links - Blazing fast tests in Django - python-database-sanitizer - django-material
Django Bot
>> Links - Python 2.7, Django and namespace packages · Martin Sanders
mλdcodez
Need help with this, shared question yesterday, no response, so i decided to ask on Stack Overflow https://stackoverflow.com/questions/50515991/attrs-for-widget-isnt-working-issue-with-from-django-contrib-auth-models-impo
Django Bot
>> Links - django-model-path-converter - Playing around with PyPy performance while running Django. - ic-labs/django-icekit: GLAMkit is a next-generation Python CMS by the Inter - cookiecutter-django/{{cookiecutter.project_slug}}/compose/production/django
Django Bot
>> Links - cookiecutter-django/start at master · pydanny/cookiecutter-django
Django Bot
>> Links - Blazing fast tests in Django
Django Bot
>> Links - Building Modern Applications with Django and Vue.js
Django Bot
>> Links - RevSys Python Builds
Django Bot
>> Links - graphene-django
Django Bot
>> Links - Django Packages : Reusable apps, sites and tools directory - Djangocon: Graphql in python and django - Patrick Arminio
Arnak
Hi there! Can some one help me understand, I have class CustomUser(User): mobile = PhoneNumberField(unique=True) created_on = models.DateTimeField(auto_now_add=True) active = models.BooleanField(default = False) objects = UserManager() and use rest framework with 'rest_framework.authtoken' REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.TokenAuthentication', ) } when I use permission_class class Isstaff(permissions.BasePermission): def has_permission(self, request, view): if request.method == 'GET' and request.user and request.user.groups.filter(name='API'): return True return False class AccountList(generics.ListAPIView): permission_classes = (Isstaff,) queryset = Account.objects.all() serializer_class = AccountSerializer filter_backends = (DjangoFilterBackend,) filter_fields = ('abonement', 'secret', 'pin') I get "Authentication credentials were not provided."
Arnak
My request.user is in API group
Arnak
but if I don't use permission, everything work
inchidi
My request.user is in API group
what is the result of bool(user.groups.filter(name='API')) via django shell if user is user you are using?
Arnak
from django.contrib.auth.models import User bool(user.groups.filter(name='API')) Traceback (most recent call last): File "<console>", line 1, in <module> NameError: name 'user' is not defined
inchidi
user= ....get(username="...")
Arnak
sorry bool(user.groups.filter(name='API')) True
inchidi
sorry bool(user.groups.filter(name='API')) True
have idea which one from those condition false?
inchidi
request.user
what do you want to achieve by request.user?
Arnak
Request user must be in group API, if not permission must be denied
inchidi
Request user must be in group API, if not permission must be denied
i mean, if you remove request.user then there is no problem right?
Arnak
No, I tried it, problem was still
inchidi
request.user
then why you answer my question by this?
Arnak
then why you answer my question by this?
Sorry, it wasn’t answer, most likely it was a question
inchidi
Sorry, it wasn’t answer, most likely it was a question
then you need to know that first. try one by one those condition and find at least one that make has_permission return False
inchidi
by modify Isstaff to: class Isstaff(permissions.BasePermission): def has_permission(self, request, view): return request.method == 'GET' then try access the api endpoint
Arnak
I get answer
inchidi
then try again with the other class Isstaff(permissions.BasePermission): def has_permission(self, request, view): return request.user
inchidi
if you still get answer then try again with class Isstaff(permissions.BasePermission): def has_permission(self, request, view): return request.user.groups.filter(name='API')
inchidi
inchidi
{"detail":"Authentication credentials were not provided."}
usually you get this response when your token invalid tho
Anonymous
hey i want to sort question in my home page according to date
Arnak
usually you get this response when your token invalid tho
token valid when I didn't use request.user.groups.filter(name='API')
inchidi
token valid when I didn't use request.user.groups.filter(name='API')
yes, i think first step you can try print(request.user.username)
inchidi
are you sure its same user?
so you can really sure about this
inchidi
hey can you help me?
try using queryset.order_by('-id')
Anonymous
thank you
inchidi
request.user my user
whats the username of that user?
Arnak
root
Arnak
it's realy magic )
inchidi
this pic doesnt mean anything tho
inchidi
yes, i think first step you can try print(request.user.username)
can you screenshot your runserver log at the result of print part?
Arnak
can you screenshot your runserver log at the result of print part?
how can i do that? I use uwsgi not runserver and print request.user.username in my log file
Arnak
where i can print this, in api response?
Arnak
for example def list(self, request): print(request.user.username) return Response("Something", status=status.HTTP_404_NOT_FOUND)