18:43:52 web.1 | /bin/sh: 1: gunicorn: not found
[DONE] Killing all processes with signal SIGINT
18:43:52 web.1 Exited with exit code null
18:45:02 web.1 | [2019-11-05 18:45:02 +0300] [3843] [INFO] Starting gunicorn 19.9.0
18:45:02 web.1 | [2019-11-05 18:45:02 +0300] [3843] [INFO] Listening at: http://0.0.0.0:5000 (3843)
18:45:02 web.1 | [2019-11-05 18:45:02 +0300] [3843] [INFO] Using worker: sync
18:45:02 web.1 | [2019-11-05 18:45:02 +0300] [3849] [INFO] Booting worker with pid: 3849
18:45:02 web.1 | [2019-11-05 18:45:02 +0300] [3849] [ERROR] Exception in worker process
18:45:02 web.1 | Traceback (most recent call last):
18:45:02 web.1 | File "***/myvenv/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
18:45:02 web.1 | worker.init_process()
18:45:02 web.1 | File "***/myvenv/lib/python3.6/site-packages/gunicorn/workers/base.py", line 129, in init_process
18:45:02 web.1 | self.load_wsgi()
18:45:02 web.1 | File "***/myvenv/lib/python3.6/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
18:45:02 web.1 | self.wsgi = self.app.wsgi()
18:45:02 web.1 | File "***/myvenv/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
18:45:02 web.1 | self.callable = self.load()
18:45:02 web.1 | File "***/myvenv/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
18:45:02 web.1 | return self.load_wsgiapp()
18:45:02 web.1 | File "***/myvenv/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
18:45:02 web.1 | return util.import_app(self.app_uri)
18:45:02 web.1 | File "***/myvenv/lib/python3.6/site-packages/gunicorn/util.py", line 350, in import_app
18:45:02 web.1 | __import__(module)
18:45:02 web.1 | ModuleNotFoundError: No module named 'st.wsgi'
18:45:02 web.1 | [2019-11-05 18:45:02 +0300] [3849] [INFO] Worker exiting (pid: 3849)
18:45:02 web.1 | [2019-11-05 18:45:02 +0300] [3843] [INFO] Shutting down: Master
18:45:02 web.1 | [2019-11-05 18:45:02 +0300] [3843] [INFO] Reason: Worker failed to boot.
[DONE] Killing all processes with signal SIGINT
18:45:02 web.1 Exited with exit code null
gunicorn --pythonpath /home/ubuntu/courses_api/env,/home/don1k/courses_api/Courses --bind 0.0.0.0:8000 Courses.wsgi
/home/ubuntu/courses_api/env
? home/don1k/courses_api/Courses
- это вроде приложениеgunicorn --pythonpath /home/***/myvenv/bin/python3,/home/***/st --bind 0.0.0.0:8000 st.wsgi
unrecognized arguments: st.wsgi
[2019-11-05 19:38:11 +0300] [5998] [INFO] Worker exiting (pid: 5998)
[2019-11-05 19:38:11 +0300] [5995] [INFO] Shutting down: Master
[2019-11-05 19:38:11 +0300] [5995] [INFO] Reason: Worker failed to boot.
class Post(models.Model):
author_post_id = models.ForeignKey(
User,
on_delete=models.CASCADE,
verbose_name = "Автор поста"
)
title = models.CharField("Название", max_length=150, db_index=True)
images = models.ImageField("Картинка для главной страницы",
upload_to='img_post',
default='img_post/def.png',
height_field=None, width_field=None,
max_length=100)
index = models.CharField("Позиция для особых постов",
max_length=10,
choices=index_post, default=7)
class Meta:
verbose_name = "Пост"
verbose_name_plural = "Посты"
def __str__(self):
return self.title
def get_absolute_url(self):
return reverse('detail', args=[str(self.slug)])
class PostAdmin(admin.ModelAdmin):
list_display = ('title', 'date_pub','type_pub', 'index', )
list_filter = ('type_pub','author_post_id',)
def get_readonly_fields(self, request, obj=None):
if not request.user.is_superuser:
return ['author_post_id']
else:
return super().get_readonly_fields(request, obj)
def save_model(self, request, obj, form, change):
Post.username = request.user.id
super().save_model(request, obj, form, change)
save_model
в obj
у меня попадает class 'mainpage.models.Post', который в model.py и у которого есть
author_post_id, но при обращении
obj.author_post_id
Post has no author_post_id
request.user
или request.user.username
не пойму логику.def get_readonly_fields(self, request, obj=None):
if not request.user.is_superuser:
return ['author_post_id']
else:
return super().get_readonly_fields(request, obj)
, работает корректно для суперпользователя, но для автора я не задал значение ForeignKey по умолчанию и в БД выходит NULL. Вот и ломаю голову как в author_post_id
передать текущего пользователя print(format(User.username))
в консоли выводитсяdjango.db.models.query_utils.DeferredAttribute object at 0x7fce43218a58Как сделать читабельный вывод?