How to create a personnal account in django? - django

I was wondering of how to create a personal account in django.
For example I have two users in my project the details of one user-login cannot be seen by another...I mean User1 will have his/her personal data which will be not visible to User2...
Basically,I mean to say how to differentiate datas of Users in django...
Any guess??
Actually I am very much new to django. Thats why facing this difficulty.It will be real help if anyone can suggest me to solve this problem..
Thank you...

Related

Adding custom data to Django's admin dashboard

I'm having a bit of trouble with Django again.
I have a simple e-commerce website project that I'm working on for my graduation. It sells books. I've got basic functionalities down, such as adding categories and products, client sign-ups and logins, a session-based shopping cart, a checkout page fully connected to a payment API, and an orders model to keep track of data.
My professor has asked me now to to add relevant reports in the Admin panel, talked to me a while about what would be relevant to see and all. So, I've got in mind what I'm hoping to make.
I want to have two containers in the main dashboard page, which would display some quick analytics (like, how many books the store has sold in the past seven days, how much money from sales the site has made in the past month), as well as links in the sidebar: I want each relevant app within my project to have their own reports section in the Admin panel, maybe led to from a link underneath their models. I've separated the storefront, accounts, orders, shopping cart, and checkout, for instance, in different apps
The problem is I can't really figure out how to actually... do that...
I've fiddled with the layout and templates on the admin; I've figured out how to add custom links to the admin page, and change its design elements, for instance. But I'm not sure how to link the data I want to the dashboard. It feels like the answer is right in front of me and I can't reach it...
I guess my question is, how can I add my reports to the Django admin page per app, and how can I add these containers that I want in the dashboard?
I've guessed that I have to start out by building a view for each report. So I am currently reading the Django docs on the Admin page again, as well as looking at questions similar to mine.
But any information y'all can share that could ease up this process and save me some time would be very much appreciated. Thanks so much!
PS: If it helps, I am overriding the admin templates by having all the .html pages copied on my project's templates folder - it's how I got it to display the store's header in the admin dashboard.

Can Users have other Users in a Relationship in Django?

So, I am fairly new to Django and I know there is just one User type. I am wondering what is the best way for me to go about setting up my models.
My site needs 4 different types of users: admins (including superuser), teachers, students, parents. I want only admin to be able to use the built in admin UI. I want teachers to have some admin features but only on frontend UI.
So far I have extended AbstractBaseUser and BaseUserManager to create users that can be assigned the 4 roles mentioned above and a few different things. They are working and I can manage authorization of page views with them, but this is just scratching the surface of what I hope to do.
But how do I manage this when I want a teacher to have many students in a class and only see those students when they login? I want these students to be assigned to teacher by the admin and then allow the teacher to have some permissions with the student info.
Can I use signals to create a Teacher model that belongs to aUser with a role of teacher and that same Teacher model has_many``Students. The ``Student would also have been created instantly with the User having a role of student.
I am thinking along the lines of how you would create a Profile with a new User.
I know how to associate Teachers and Students and Parents, etc but it is confusing to me when they are all user types as well.
Or is there a way to do this with just keeping them as ``Users``` with roles and relating them in another way?
Thanks for the help.
Why don't you try this :-
https://simpleisbetterthancomplex.com/tutorial/2018/01/18/how-to-implement-multiple-user-types-with-django.html
I think this is the answer you are looking for.
Let me know if you need further explanation.
Happy coding :-)

Django Questionnaire app

I guys I am very new to Django and app dev and I am having trouble to structure my app.
I am creating an app to send team questionaire.So wokflow is the following:
1) I create a team_project (Team_name)
2) Send Invitations to team members using Emails
3) Based on that invitation Team_member signIn (creating a new user) and are directly assigned to that team created.
I have no idea how to handle that and especially part 3
If you could give me a direction how to do it I will really appreciate
Thx you very much
What you want is a common requirement, so perhaps there is already a library or solution for it.
to write the code from scratch, which is not recommended,
You can define a custom url , like example.com/join_team/some_random_looking_unique_string/
create a model which keeps a random string, email , and maybe some kind of expiration policy. Read the unique string in your view, and retrieve the record associated with it. send a form to get more details like password and etc and save the user in database.
I also found this repo that I think does what you want:
https://github.com/bee-keeper/django-invitations
explain more in your question, and you can get more detailed answers!

Need admin access to my Facebook app

The developer who wrote my app initially is the only person who has admin rights to the app. Now it's being worked on by other developers and I cannot get him to grant me admin access. I've looked for ways around this but have not found a way yet, any help from the community would be much appreciated.
Thanks in advance!
OK so I figured out that it takes about 5 min to just get a new ID and recode my app. I haven't done it yet but it should be a breeze. One thing I'm worried about however, my app asked for users to verify who they were much more in the early stages and I hope a new ID doesn't resent the trust factor.

Grant users with 'anti-permissions' in django

I'm working on a django project in which users can post articles and vote on them. But the users are not supposed to vote on their own articles. Currently I'm using the permission system with django-guardian. My idea is to grant a kind of 'anti-permission' so that only the author can't vote on their own articles.
My reasoning is that in this way all the permissions can be handled in a unified protocol, separately from view functions(instead of putting conditions inside them). And if there comes future requirements like this, they can be handled elegantly.
But it does not look semantically right to use "permissions" in this way. Just wondering if there's a better way of doing it?
Thanks for your help! :)
Write a manager that takes the context and then returns a list of objects that the user can vote on.
Use this manager in your view.