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:Create database objects
Maps API data to Django models (User, BaseItem, Jersey, Club, Brand, Season, etc.)
Basic usage
Arguments and options
User ID from Football Kit Archive to import
Username in your FootyCollect system to assign items to. If not provided, creates a new user.Example:
Maximum time to wait for scraping in seconds.Example:
Page size for paginated requests.Example:
Preview mode - don’t create any database objects.Example:
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: