Description
I have a special case where I want to create a model containing the path to some local files on the server/dev machine. Seeing as the place where these files are stored is different on different machines I have the following:
import os
from django.conf import settings
from django.db import models
class LocalFiles(models.Model):
name = models.CharField(max_length=255)
file = models.FilePathField(path=os.path.join(settings.LOCAL_FILE_DIR, 'example_dir'))
Now when running manage.py makemigrations it will resolve the path based on the machine it is being run on. Eg: /home/<username>/server_files/example_dir
I had to manually change the migration to include the os.path.join() part to not break this when running the migration on production/other machine.
bceadd2788dc (django/django 3.0), dependencies installed and tests runnable from the first minute. You are graded by hidden tests taken from the fix that was actually merged upstream.