With flutter I am using sqflite package for my reminder feature where user will be able to create a reminder, and I am using django for my other backend tasks, now the problem is, there will multiple users in an app and each user will have their own user_id and password to login into the app (the users are created from django) and since reminder feature will use sqflite package to store the user data it can't differentiate between users, meaning: if user "A" logged into the app and created a reminder and then user "B" logged into the app then he will also see the reminder created by user "A", user "B" will be able to see only the reminders set by user "A" not other personal data of user A which are coming from django server.
So is there any way that I can make the reminder only visible to that particular users who created them ? or any way I can connect my sqflite package with my django??
CodePudding user response:
I have been using Flutter and Django for sometimes now, the best way to do it is to do the following :
- Install and use Django Rest Framework (DRF)
- Use the token authentification provided by DRF
- When a user logged in your Flutter, save the token on the local storage of the device
- On your Django application filter the queryset based on the request user, by default DRF will act like a session based authentification so request the user is trivial
CodePudding user response:
This isn't really specific to just Flutter/SQFLite and Django.
You need to design your backend app's API in a way that each user can only see and modify their own data, and in that way each user's app's local database only has their own data.
Without seeing any more code or knowing the design of your app(s), it's hard to help in a more specific way.