0

Im Trying to use Symlink in my Django Project:

os.symlink(static_file_path, media_file_path)

But what i get in result is: Undefined variable from import: symlink

Alasdair
  • 298,606
  • 55
  • 578
  • 516
LighFusion
  • 126
  • 10

1 Answers1

0

os.symlink is part of the os package, which is included with Python. You don't have to install it.

import os
os.symlink(source, link_name)
Alasdair
  • 298,606
  • 55
  • 578
  • 516
  • Well its same at me, but i still get this error - Undefined variable from import: symlink . Maybe im using old version of python ? – LighFusion Sep 19 '15 at 14:28
  • Are you using Windows? The docs say that symlink doesn't work with Windows in Python 2. – Alasdair Sep 19 '15 at 14:41
  • my god, why is that ? yes im using windows python 2.7, maybe its because its not installed there ? – LighFusion Sep 19 '15 at 15:39
  • thx man anyway, i solved this using that post http://stackoverflow.com/questions/6260149/os-symlink-support-in-windows ! thx for hint. – LighFusion Sep 19 '15 at 16:05
  • It has not always been possible to add symlinks in Windows, so when `os.symlink` was added for Windows, it was added to Python 3 only. Python 2.7 was the last Python 2 release in 2010. There are bug fixes and security fixes, but no new features are added to Python 2 since then. – Alasdair Sep 19 '15 at 16:31