Ronald
nginx will load the static files
Ronald
like css js etc
Leonardo
Hi there, how can I return get_FOO_display value for a view in a queryset?
Mirco
u can also call it into template by passing your qs
Leonardo
Mirco
call python method on template?
let's say u have a field called foo u can pass your qs to the template via your view then into template u can call get_foo_display using your model instance here there's an example idk if it's exactly what you're looking for
Leonardo
Ooooh see... when I tried do that i did with ()
Leonardo
now it's worked without ()
Leonardo
thank you mirco 👍
Mirco
yep, when u use it into templates is like an attribute ( if I don't go wrong 😂 ) when u use it inside your view, models etc. it's a method so u know when use () or not
Anders (izzno / gooood) ๐Ÿ‡ณ๐Ÿ‡ด
gunicorn should run as a service
Why does not more people put their apps in docker containers ?
Tushar
Gear Up for Winters! Microsoft AI Challenge is here! https://www.linkedin.com/pulse/gear-up-winter-ai-puneet-agrawal/?fbclid=IwAR1a4aiDkypzR0IVLQYGEiwB0Y2SEeUuMk2nZDUp-65-CG93e6xko-Un6gU
amit
I am making a social networking site like fb , twitter . I am also using messaging and notifications . I wanted to knkw which technology/services should i use for best efficency and takes less time to make it working and has less lag .
Mirco
imho django-channels could be the best way
amit
imho django-channels could be the best way
Are channels suited for both notifications n messaging , any link containg channels doc/ services will be helpful ?
Anders (izzno / gooood) ๐Ÿ‡ณ๐Ÿ‡ด
George
ah, I C
IPython
Anders (izzno / gooood) ๐Ÿ‡ณ๐Ÿ‡ด
Whats that ?
George
I C#
Anders (izzno / gooood) ๐Ÿ‡ณ๐Ÿ‡ด
omg
Leonardo
guys, my django production is not finding my media directory to serve media files
Anders (izzno / gooood) ๐Ÿ‡ณ๐Ÿ‡ด
:D
Leonardo
Not Found The requested URL /media/22316.pdf was not found on this server.
George
guys, my django production is not finding my media directory to serve media files
When you collectstatic it changes to the general of the app
Anders (izzno / gooood) ๐Ÿ‡ณ๐Ÿ‡ด
(its also an interactive shell)
George
You have to change the dir in the settings
Anders (izzno / gooood) ๐Ÿ‡ณ๐Ÿ‡ด
Anders (izzno / gooood) ๐Ÿ‡ณ๐Ÿ‡ด
It servers static files by default but not media.
George
App_container has media of app1, app2, ... When you collecstatic
George
Change settings.py
Anders (izzno / gooood) ๐Ÿ‡ณ๐Ÿ‡ด
https://simpleisbetterthancomplex.com/tutorial/2016/08/01/how-to-upload-files-with-django.html Had a bookmark ;)
Anders (izzno / gooood) ๐Ÿ‡ณ๐Ÿ‡ด
It's in there.
Leonardo
my upload is working as well, the problem is serve the file now
Leonardo
when i try visualize the file i'm getting this error
George
Check where fo you upload and where does it try to get it
Anders (izzno / gooood) ๐Ÿ‡ณ๐Ÿ‡ด
By serve the file you meen ? Can you browse it?
Leonardo
the same place than development, base_dir/media_cdn
George
But, is it absolute or relative?
George
You may have to give absolute route
Leonardo
it's absolute
George
Its something i will have to do and :(
Leonardo
STATIC_URL = '/static/' MEDIA_URL = '/media/' STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static') ] STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'static_cdn') MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'media_cdn')
Leonardo
i'm using static_cdn and media_cdn to emulate s3
Leonardo
but it's working fine in my local, i don't know if the problem is the production
George
Mind when you do collectstatic the routes change
Leonardo
my static css is working fine
Leonardo
idk why media is not
Leonardo
is the same path
George
https://docs.djangoproject.com/en/2.1/howto/static-files/
Leonardo
oh
Leonardo
maybe is nginx config
George
Maybe is godly work
Leonardo
i added location /media { autoindex on; alias /home/myusername/myproject/media/; }
Leonardo
oops, it's wrong
Leonardo
location /media { alias /home/ubuntu/project/master/media_cdn/; }
Leonardo
that
George
Lol
Leonardo
i added that
Leonardo
and is not working
Leonardo
location /static { alias /home/ubuntu/project/master/static_cdn/; } location /media { alias /home/ubuntu/project/master/media_cdn/; }
Leonardo
my /static works fine
George
Perfect :)
Leonardo
but /media not
Leonardo
:(
Anders (izzno / gooood) ๐Ÿ‡ณ๐Ÿ‡ด
file permissions ?
Anders (izzno / gooood) ๐Ÿ‡ณ๐Ÿ‡ด
or dir permission ?
Leonardo
what perm i need?
Leonardo
i hate work with permissions
Anders (izzno / gooood) ๐Ÿ‡ณ๐Ÿ‡ด
for nginx to serve them
Anders (izzno / gooood) ๐Ÿ‡ณ๐Ÿ‡ด
Look at static "ls -l" and then media and compare
Leonardo
hmm they are different
Leonardo
ubuntu@ip-172-31-45-170:~/project/master$ ls -l media_cdn/ total 572 -rw-r--r-- 1 ubuntu ubuntu 583299 Oct 31 19:02 22316.pdf ubuntu@ip-172-31-45-170:~/project/master$ ls -l static_cdn/ total 8 drwxrwxr-x 6 ubuntu ubuntu 4096 Oct 26 14:02 admin drwxrwxr-x 2 ubuntu ubuntu 4096 Oct 26 14:02 css
Anders (izzno / gooood) ๐Ÿ‡ณ๐Ÿ‡ด
same owner