b
my problem is, when a new user registers, it gets all the data in the dB
Mirco
can I share my code here?
With pastebin or similar, yes
b
and all the users should assign their own new separate data as they continue to using the site
b
isn't it supposed to be like that?
yeah but still it is my first time and I don't know it supposed to work
Xavier
and all the users should assign their own new separate data as they continue to using the site
why? that's really inconvenient and inconsistent, also why the user have the right to create data, the website will create it for them
b
why? that's really inconvenient and inconsistent, also why the user have the right to create data, the website will create it for them
what I'm trying to say it, I've built a site that sends mass emails, it has functionality such as drafts, To email list, From email list, so when user register so user supposed to get clean site without any data of other users
b
have u read the docs?
I've watched tutorial, I'm sharing the for better understanding
b
model.py
b
decorators
b
from django.http import HttpResponse from django.shortcuts import redirect def unauthenticated_user(view_func): def wrapper_func(request, *args, **kwargs): if request.user.is_authenticated: return redirect('home') else: return view_func(request, *args, **kwargs) return wrapper_func def allowed_users(allowed_roles = []): def decorator(view_func): def wrapper_fun(request, *args, **kwargs): group = None if request.user.groups.exists(): group = request.user.groups.all()[0].name if group in allowed_roles: return view_func(request, *args, **kwargs) else: return HttpResponse("you ain't authoizez where you wanna reach") return wrapper_fun return decorator
Xavier
!paste use pastebin
Doragonsureiyā
To share code or error tracebacks please use an online pasting service, here is a list of suggested sites: - https://del.dog - https://dpaste.org - https://linkode.org - https://hastebin.com - https://bin.kv2.dev
b
btw why will one user get the data of another user unless u are providing it?
for now all the users are getting all the that are saved, so I wanna restrict user to access that data
Xavier
for now all the users are getting all the that are saved, so I wanna restrict user to access that data
they should not get what's saved read your code and figure it and if u just copy pasted that code from somewhere then try understand it
b
they should not get what's saved read your code and figure it and if u just copy pasted that code from somewhere then try understand it
exactly, they shouldn't maybe. that's what I'm trying to figure out and I've coded whole code by myself
Xavier
exactly, they shouldn't maybe. that's what I'm trying to figure out and I've coded whole code by myself
ah then u gotta see the logics it's a problem in the view if u want a headstart
Raffaele
unpopolar opinion: pycharm professional is the best IDE in the world
b
@login_required(login_url='login') @allowed_users(allowed_roles = ['user'])
b
i did this in view
b
@unauthenticated_user
b
this on login and register view
Xavier
no one will do it except you
Raffaele
b
but the restrictions are working, also the unauthorized decorator
b
what I'm asking is, is this the right thing I did for my problems that I explained above or i should need to more
b
I've tried in many ways this code so still there's a problem in it I'll look into it
wanderer
Guys i deployed my webapp to heroku if i keep Debug=True it works
wanderer
but for Debug=False it show Error 500
wanderer
not working when debug is false
wanderer
says error 500
b
uploaded where?
wanderer
heroku
wanderer
there maybe an error
the why is it working in debug true
b
there maybe be something be showing up like, heroku logs tail
b
try that, it'll show where the error at
wanderer
no thats only for deployment errors i guess
wanderer
my webapp is succesfully deployed
b
that's what's debug False is for
wanderer
in localhost?
on on heroku
b
on on heroku
then that is a deployment I guess
wanderer
yes
b
and that's way to trace error, heroku logs tail
Anonymous
Rahul
How to update all field except one particular field in Django ?
Rahul
Please help me
Anonymous
How is your model set up?
Rahul
?
Let me explain
Anonymous
Yeah sure
Rahul
One table is there as a insurance type - gold, silver, and other
Rahul
And one user table in that table insurance type is foreign key
Anonymous
Okay
Rahul
So while registration user will select one insurance type
Rahul
Then while update user details we can change insurance type
Anonymous
Cool
Rahul
And once user will try then will throw error
Anonymous
So, it throws an error when you are updating the existing data?
Rahul
So, it throws an error when you are updating the existing data?
No i want to make a api like that to send error as a response
Anonymous
Oh
Anonymous
So use try except block
Anonymous
Catch the error
Anonymous
And pass it as a message
Rahul
Error is not coming
Anonymous
Error is not coming
What is the error?
Rahul
If user will pass other insurance type then i have to send error msg
Rahul
How to handle in put api
Anonymous
Oh, so once a user of registered, they can't change their insurance type?
Anonymous
Ohk