Anonymous
learn database design
Some good resources to learn from?
niwla23
I want to make a webapp with a secret page. I have a table with the user and an access bool. whats the easiest way to check in views.py if the user is in access and the boolis 1/True?
Alexey
If request.user....
niwla23
and then? I need something like is in access and access == true
Mirco
and then? I need something like is in access and access == true
Why don't you create a custom permission for that view ?
niwla23
how?
Mirco
how?
Official docs , permissions section 😁
niwla23
Official docs , permissions section 😁
in which file are they defined?
Mirco
in which file are they defined?
permissions.py for example , but you can choose by yourself https://docs.djangoproject.com/en/2.2/topics/auth/default/#permissions-and-authorization
niwla23
Sorry, i cant find it in the doc. So i just have to create permissions.py at the main app or at the functional app?
Alexey
Or https://www.django-rest-framework.org/api-guide/permissions/ ? :)
Mirco
Sorry, i cant find it in the doc. So i just have to create permissions.py at the main app or at the functional app?
It depends where you need , if they are specific to an app so inside that app
niwla23
ok, is contenttype required?
niwla23
there is a field content–type and i dont understand it
Mirco
there is a field content–type and i dont understand it
What are u using ? DRF or not ? To get your scenario
niwla23
whats drf?
Mirco
Django Rest Framework Anyway you're not using it
niwla23
right
Mirco
right
https://docs.djangoproject.com/en/2.2/topics/auth/default/#django.contrib.auth.decorators.user_passes_test Even better
niwla23
ok
niwla23
class T21Turma(models.Model): class Meta: permissions = (("can_view_boletim", "Can view boletim"), ("can_view_mensalidades", "Can view mensalidades"),)
niwla23
So I can just paste this in a permissions.py file and i will see the permissions in the admin panel?
niwla23
how then?????
Alexey
Create new permissions.py in app dir
niwla23
ok and then? I want "global permissions"
Mirco
ok and then? I want "global permissions"
You wanna block a view in your web app or into admin panel ?
niwla23
webapp
Mirco
https://docs.djangoproject.com/en/2.2/topics/auth/default/#django.contrib.auth.decorators.user_passes_test Even better
So read here please and you will learn new things and maybe understand better how Django helps you
Mirco
With that decorator on the view you wanna block, you can also redirect a user to a view when he tries to visit that page and he doesn't match your rules
niwla23
I want to CREATE A PERMISSION
niwla23
and: whats content_type?
Mirco
I want to CREATE A PERMISSION
In your opinion what am I telling you ? But if you don't wanna read documentation and try to understand, I cannot do so much more
Mirco
I want to CREATE A PERMISSION
I'm suggesting you another , easier way, to restrict view by using a Django useful decorator
niwla23
and how can i manage it? Which rule?
Mirco
Django still hasn't can_view permission related to a view , just for admin panel at the moment
Mirco
and how can i manage it? Which rule?
https://docs.djangoproject.com/en/2.2/topics/auth/default/#django.contrib.auth.decorators.user_passes_test
niwla23
Again: I want to allow a few specific users the access to a site what does a email cor username check help there? And i read the doc, theres an @permission_requiered decorator. My onliest Problem is actually that i dont know how to create a permission
niwla23
and my problem is content_type
Mirco
Again: I want to allow a few specific users the access to a site what does a email cor username check help there? And i read the doc, theres an @permission_requiered decorator. My onliest Problem is actually that i dont know how to create a permission
I'm trying to explain better Well, for example you can use a boolean as you said at the beginning to know which type of user is Then write a property to check that boolean value easily Then , with that decorator on the view you wanna restrict , you can test if the user has that boolean or not by using a simple function Clearer ?
niwla23
yes, but id still like to understand content_type
Mirco
yes, but id still like to understand content_type
If u use the decorator I'm suggesting you there's no need to write a custom permission, so neither content_type
Mirco
If into the future you wanna use a permission, content_type will be used to understand what model is
niwla23
so is it requiered?
niwla23
but i dont have a model...
Mirco
but i dont have a model...
Custom user ? How do you know which kind of user is ?
niwla23
I want to have a permiision and use the perm decorator to check if a user has it.
niwla23
A kind of "stand-alone permission"
inchidi
How to set otp system in django website
simply you create otp and send it to user, where you at already?
godmode
Not... My mistake
godmode
I got two apps , and the urls of the seccond are not being loaded
godmode
Why cannot be... Whats do ypu do when you want yo registrer another app?
inchidi
Why cannot be... Whats do ypu do when you want yo registrer another app?
add the app to INSTALLED_APPS and include the app urls in root urls
godmode
I already did this and it's not working
godmode
ok, let me make a push to github
Murshid
If entry_time between 1:00 to 2:00 and exit_time graterthan 5:00 how to query this
Murshid
Is there any option for between
godmode
@Inchidi https://github.com/Godm0de/uec.git
godmode
it should be an easy problem
godmode
just adding another app and trying to solve this anytime i do 127.0.0.1:8000/dashboard
godmode
i should see... Hello or something
godmode
how? it's private
godmode
but it should be posible to share
godmode
hold on
inchidi
you can use range then
Albert
did you set SERVER_EMAIL already?
Yes. My config: EMAIL_HOST = 'smtp.yandex.ru' EMAIL_HOST_USER = 'notifications81818@ya.ru' EMAIL_HOST_PASSWORD = '*****' EMAIL_PORT = 587 EMAIL_USE_TLS = True DEFAULT_FROM_EMAIL = 'notifications81818@ya.ru' SERVER_EMAIL = 'notifications81818@ya.ru' ADMINS = [ ('Albert', 'alb.sult@gmail.com'), ] MANAGERS = ADMINS
godmode
@Inchidi https://github.com/Godm0de/uec.git
godmode
Now it should be work
inchidi
you can give it a shot
godmode
@Inchidi have you seen my code?