populate_user_collection command imports user collections from the Football Kit Archive (via FKAPI) into FootyCollect. This is useful for testing, data migration, or bulk importing collections.
How it works
The command performs these steps:1
Scrape collection
Calls FKAPI to scrape the user’s collection from Football Kit Archive
2
Wait for completion
Waits for scraping to complete or uses cached data
3
Fetch paginated data
Retrieves collection entries in batches
4
Create database objects
Maps API data to Django models (User, BaseItem, Jersey, Club, Brand, Season, etc.)
5
Download assets
Creates Photo objects and downloads entry images
Basic usage
Arguments and options
integer
required
User ID from Football Kit Archive to import
string
Username in your FootyCollect system to assign items to. If not provided, creates a new user.Example:
integer
default:"120"
Maximum time to wait for scraping in seconds.Example:
integer
default:"20"
Page size for paginated requests.Example:
boolean
Preview mode - don’t create any database objects.Example:
string
Path to JSON file with collection data (for testing without FKAPI).Example:
Requirements
Ensure these environment variables are set:FKA_API_IP- FKAPI server IP/hostnameAPI_KEY- API key for FKAPI access
Example workflows
Import to existing user
Test import with dry run
Import from JSON file (testing)
What gets created
The command creates and links these models:- User - New user or uses existing
--target-username - Club, Brand, Season, Competition - Referenced entities
- Kit - Kit metadata from FKAPI
- BaseItem & Jersey - Collection items (uses Multi-Table Inheritance)
- Color - Primary and secondary colors
- Size - Jersey sizes
- Photo - Entry images with automatic AVIF optimization
Output example
Troubleshooting
Scraping timeout
Scraping timeout
If scraping times out, increase
--wait-timeout:FKAPI connection error
FKAPI connection error
Verify FKAPI is running and environment variables are set:
Duplicate items
Duplicate items
The command checks for existing items to avoid duplicates. If you get duplicate errors, ensure your database constraints are properly set up.
Photo download failures
Photo download failures
Photo downloads are logged. Check logs for failed downloads:
Related
FKAPI Integration
Learn about FKAPI setup and configuration
Bulk Operations
API documentation for bulk operations