Documentation Index
Fetch the complete documentation index at: https://mintlify.com/diegolozadev/DataMed/llms.txt
Use this file to discover all available pages before exploring further.
User Management
DataMed uses Django’s built-in authentication system to manage user accounts, sessions, and permissions. All healthcare staff need user accounts to access the system.User Model
DataMed uses Django’s defaultUser model with these core fields:
- username: Unique identifier for login
- email: User’s email address
- first_name: User’s first name
- last_name: User’s last name
- is_staff: Can access Django admin interface
- is_active: Account is enabled
- is_superuser: Has all permissions
- last_login: Timestamp of last successful login
- date_joined: Account creation date
Creating Users
Via Django Admin
Via Management Command
Create a superuser account from the command line:Programmatically
Create users in Django shell or scripts:Permission Levels
DataMed uses Django’s three-tier permission system:Regular Users
- Can log in to DataMed
- Can access patient records and clinical forms
- Cannot access Django admin interface
- Settings:
is_staff=False,is_superuser=False
Staff Users
- All regular user permissions
- Can access Django admin interface
- Can view but not modify system configuration
- Settings:
is_staff=True,is_superuser=False
Superusers
- All staff user permissions
- Can create/modify users and permissions
- Can access all admin features
- Settings:
is_staff=True,is_superuser=True
Authentication Flow
DataMed uses session-based authentication configured inconfig/settings.py:
config/settings.py
Login Process
Logout Process
Users can log out at any time, which destroys their session and redirects to the login page.Protecting Views
All DataMed views are protected with the@login_required decorator:
apps/patients/views.py
Tracking User Activity
DataMed tracks which user registered each clinical exam usingForeignKey relationships:
apps/exams/models.py
- All clinical exams track
registrado_por(registered by user) - All models have
created_attimestamp - User info preserved even if account is deleted (
SET_NULL)
Managing Existing Users
Updating User Information
- Django Admin
- Django Shell
- Navigate to
/admin/auth/user/ - Click on the user you want to modify
- Update fields and click Save
Resetting Passwords
- Django Admin
- Management Command
- Django Shell
- Go to
/admin/auth/user/ - Click on the user
- Click this form link under Password field
- Enter new password twice and save
Deactivating Users
Disable user accounts without deleting them:Deactivated users cannot log in but their historical data (exams registered, etc.) remains intact.
Security Best Practices
Use Strong Passwords
Use Strong Passwords
Django enforces password validation rules by default:
- Minimum 8 characters
- Cannot be entirely numeric
- Cannot be too similar to username
- Cannot be a commonly used password
Regular Password Rotation
Regular Password Rotation
Require users to change passwords periodically, especially for accounts with elevated privileges.
Monitor Failed Login Attempts
Monitor Failed Login Attempts
Review Django logs for repeated failed login attempts:
Use HTTPS in Production
Use HTTPS in Production
Always deploy DataMed behind HTTPS to protect session cookies and credentials in transit.
Audit User Permissions
Audit User Permissions
Regularly review who has
is_staff and is_superuser access:Common Tasks
List All Users
Find Users Without Recent Activity
Grant Staff Access
Next Steps
Configuration
Configure environment and security settings
Deployment
Deploy DataMed to production
API Authentication
Understand session-based authentication
Database Schema
Explore user relationships in the data model