Reputation: 35
I am following a tutorial on youtube for deploying a django app on DigitalOcean.
I type in: python3 manage.py collectstatic
This is the error message I get:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/home/mochimoko/django_project/venv/lib/python3.5/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/mochimoko/django_project/venv/lib/python3.5/site-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "/home/mochimoko/django_project/venv/lib/python3.5/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/mochimoko/django_project/venv/lib/python3.5/site-packages/django/apps/registry.py", line 112, in populate
app_config.import_models()
File "/home/mochimoko/django_project/venv/lib/python3.5/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 661, in exec_module
File "<frozen importlib._bootstrap_external>", line 767, in get_code
File "<frozen importlib._bootstrap_external>", line 727, in source_to_code
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/home/mochimoko/django_project/users/models.py", line 11
return f'{self.user.username} Profile'
I know the code is right cause I got in straight from GitHub. I am a complete beginner at this. I know that indentation could be the issue here but everything looks fine to me.
Here is the code for the manage.py file:
from django.db import models
from django.contrib.auth.models import User
from PIL import Image
class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
image = models.ImageField(default='default.jpg', upload_to='profile_pics')
def __str__(self):
return f'{self.user.username} Profile'
def save(self, *args, **kawrgs):
super().save(*args, **kawrgs)
img = Image.open(self.image.path)
if img.height > 300 or img.width > 300:
output_size = (300, 300)
img.thumbnail(output_size)
img.save(self.image.path)
Upvotes: 0
Views: 362
Reputation: 5669
You are trying to use f-string
in Python 3.5 but they appeared in Python 3.6.
Change f'{self.user.username} Profile'
to be '{} Profile'.format(self.user.username)
or change your Python to be 3.6.
Upvotes: 2