#29529: FilePathField path attribute gets resolved when running makemigrations.
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
Sebastiaan Arendsen |
Type: | Status: new
Uncategorized |
Component: | Version: 2.0
Migrations | Keywords: migration,
Severity: Normal | filepathfield, makemigrations
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
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:
{{{
#!python
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/29529>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.f98a7c6f90af8f190a7728e54cbd25d1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.