Overview
Deltas are the fundamental unit of change in QFieldCloud’s synchronization system. Each delta represents a single edit operation (create, update, or delete) performed in QField mobile app. The delta system enables offline editing with robust conflict detection and resolution.Delta Model
TheDelta model tracks individual edit operations:
core/models.py:2103.
Delta Methods
Three types of operations:Create
Adds a new feature to a layer:Patch
Modifies an existing feature’s attributes or geometry:Delete
Removes a feature from a layer:Delta Status
Deltas progress through various status states:Status Flow
- PENDING - Delta uploaded, waiting for apply job
- STARTED - Apply job is processing this delta
- APPLIED - Successfully applied to dataset
- CONFLICT - Conflicting change detected
- ERROR - Application failed due to error
- UNPERMITTED - User lacks permission to apply
- IGNORED - Explicitly skipped during application
- NOT_APPLIED - Failed to apply for other reasons
core/models.py:2109.
Deltafile Format
Structure
A deltafile is a JSON document containing multiple deltas:Validation
Deltafiles are validated against JSON schema:- Required fields present
- Valid UUID formats
- Supported delta methods
- Valid geometry (if present)
- Project ID matches request
core/views/deltas_views.py:78.
Uploading Deltas
API Endpoint
Request
Multipart form data with deltafile:Upload Process
-
Receive Deltafile
- Extract from multipart request
- Parse JSON content
-
Validation
-
Duplicate Detection
-
Create Delta Objects
-
Permission Check
-
Auto-Apply
core/views/deltas_views.py:67.
Apply Jobs
ApplyJob Model
core/models.py:2403.
ApplyJobDelta Through Model
Tracks status of each delta within a job:core/models.py:2426.
Apply Process
-
Job Creation
- Collect pending deltas
- Create ApplyJob instance
- Link deltas via ApplyJobDelta
-
Worker Execution
- QGIS worker container starts
- Opens project file
- Processes deltas sequentially
-
Per-Delta Application
- Validate delta structure
- Check for conflicts
- Apply to layer
- Record outcome
-
Completion
- Update delta statuses
- Save modified project files
- Update project timestamp
Conflict Detection
What Causes Conflicts?
Conflicts occur when:-
Concurrent Edits
- Same feature edited on desktop and mobile
- Multiple mobile devices edit same feature
-
Stale Data
- Mobile package outdated
- Desktop changes not yet packaged
-
Deleted Features
- Feature deleted on desktop, edited on mobile
- Feature edited on desktop, deleted on mobile
Conflict Detection Logic
During delta application:- Delta’s
oldvalues - Current feature state
- If different, someone else made changes
Conflict Resolution
Automatic Resolution
Whenproject.overwrite_conflicts=True:
- Field data collection workflows
- Single editor per feature
- Time-based priority (latest wins)
Manual Resolution
Whenproject.overwrite_conflicts=False:
- Review conflicting deltas
- Decide which changes to keep
- Manually resolve via API or UI
- Re-trigger apply job
Resolution Strategies
- Last Write Wins - Automatic, simple
- Manual Review - Time-consuming, precise
- Attribute-Level - Merge non-conflicting attributes
- Time-Based - Prefer changes from specific time range
Delta Querying
List All Deltas
Filter by Deltafile
Status Summary
Get delta count by status:core/models.py:2161.
Geometry Handling
Geometry Fields
Deltas store geometries for spatial operations:- SRID 4326 - WGS84 coordinate system
- 4D - Supports X, Y, Z, M dimensions
Use Cases
- Spatial queries on deltas
- Visualization of changes
- Conflict detection based on location
- Analysis of field coverage
Faulty Deltafiles
When deltafile upload fails:- Preserved for debugging
- Include error traceback
- Track client information
- Help identify systematic issues
core/models.py:2679 and core/views/deltas_views.py:162.
Best Practices
Field Workflow
- Sync Frequently - Upload deltas at least daily
- Check Status - Monitor apply job outcomes
- Handle Conflicts - Review and resolve promptly
- Update Packages - Refresh mobile data regularly
Conflict Prevention
- Partition Work - Assign geographic areas to users
- Feature Locking - Coordinate who edits what
- Frequent Sync - Reduce time between updates
- Latest Packages - Download fresh data before fieldwork
Performance
- Batch Deltas - Upload in deltafiles, not individually
- Optimize Apply - Let automatic apply handle routine cases
- Monitor Jobs - Track apply job duration
- Clean Old Deltas - Archive applied deltas periodically
Troubleshooting
- Check Permissions - Verify user can create deltas
- Validate Schema - Ensure deltafile format correct
- Review Logs - Check apply job output
- Test Locally - Reproduce issues in QGIS
API Reference
Upload Deltafile
multipart/form-data
Field: file containing deltafile JSON
List Deltas
Trigger Apply (Deprecated)
Related Resources
- Synchronization - Full sync workflow
- Projects - Conflict resolution settings
- Jobs - Apply job status and monitoring