Paritosh
yw :)
I tried by uploading a new image. the http request sayg getting the image.. but 404 is returned... image is there in my documents folder
Aadhi
Should we needed to perform makemigrations and migrate for this?
Mirco
Yes
what does your query return ?
inchidi
Yes
check if the file stored in correct directory. you can see the correct directory by running this via django shell from django.conf import settings print(settings.MEDIA_ROOT)
Paritosh
what does your query return ?
[05/Feb/2019 15:18:24] "GET /media/documents/20024086_1532823170117918_2584869575454715795_o.jpg HTTP/1.1" 404 2638
Paritosh
doesnt matter yet, just check it first
i got this error - Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/anaconda3/lib/python3.6/site-packages/django/conf/__init__.py", line 57, in getattr self._setup(name) File "/anaconda3/lib/python3.6/site-packages/django/conf/__init__.py", line 42, in _setup % (desc, ENVIRONMENT_VARIABLE)) django.core.exceptions.ImproperlyConfigured: Requested setting MEDIA_ROOT, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
Paritosh
is this django shell?
no ... from terminal
inchidi
use django shell, python manage.py shell
inchidi
dont forget that python here should point to python you use for the project
Paritosh
from django.conf import settings ...: print(settings.MEDIA_ROOT) /Users/mac/mrpash/loginpage/media
Paritosh
i get this
inchidi
so, file /Users/mac/mrpash/loginpage/media/documents/20024086_1532823170117918_2584869575454715795_o.jpg exists?
inchidi
then the last thing to do is make sure your django serve that by set this in your root urls.py urlpatterns = [ ... ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
inchidi
static and settings from: from django.conf import settings from django.conf.urls.static import static
Paritosh
thanq so much man
inchidi
can you tell me why we need to set this ?
you can read this part of official docs for that info
inchidi
always forgot it 🤣
yeah me too, since we will only do it once for each project and its optional
Anonymous
Hey dose anyone know away i could debug javascript without console.log ???
Anonymous
you are OT
Huh ???
George
Hey dose anyone know away i could debug javascript without console.log ???
Send an ajax call with the answer to an android app specificly designed for that
Anonymous
😂😂😂 come on !!!
cj
Hey dose anyone know away i could debug javascript without console.log ???
use browser debugger with breakpoints 🤷🏻‍♂🤷🏻‍♂🤷🏻‍♂
Anonymous
.....
cj
.....
you asked how to debug... then use a debugger 🤷🏻‍♂ you want to debug JS, then use the browser debugger 🤷🏻‍♂🤷🏻‍♂🤷🏻‍♂
Adil
Hey everyone. İ need your wise advice and help😄
cj
I honestly didn't know there's another way
console.log is not mean to debug... but... nvm 🤷🏻‍♂🤷🏻‍♂🤷🏻‍♂🤷🏻‍♂
Adil
Im trying to create website for internet store of electronics. I have a navbar, side bar, and content. So i though that i should put navbar and sidebar in one html and extend it as always. But the problem is, sidebar's content is being parsed from db. So when i load othe pages, view for filling the sidebar content doesnt work obviously, so, what can u advice me to do?
Ronald
console.log is not mean to debug... but... nvm 🤷🏻‍♂🤷🏻‍♂🤷🏻‍♂🤷🏻‍♂
I use code with a linter and then console.log when I find "bugs". 🤷🏼‍♂️ 😂
Adil
https://ibb.co/g72wTnF https://ibb.co/bzvHmFS
Adil
here are the pictures of what i mean
inchidi
https://ibb.co/g72wTnF https://ibb.co/bzvHmFS
what variable you iterate there for the sidebar menu?
Adil
İ tender it from homepage view
Adil
Oh, i think u want me to try to render this variable every time?
inchidi
i mean your context name like {% for menu in menus %}
inchidi
you are using something like this to render the menu right?
Adil
exactly
inchidi
you can wrap the sidebar with if like this: {% if menus %} <div class="sidebar"> {% for menu in menus %} ... {% endfor %} </div> {% endif %}
Adil
i want it to always have content, but the view for filling it works only homepage urlpattern
inchidi
then what content you want to show?
Adil
one second, i will provide more screenshots
Adil
https://dropmefiles.com/UWT3M take a look please😊
Krunal
When I create function in view and call it in nav bar it's working fine but same link can accessible directly from URL. How can I stop it?
tk
Hi anyone having videos of django and django restframework
tk
From where to learn django and rest easily
tk
Is udemy videos are good??
cj
reading docs are the way to learn... but... 🤷🏻‍♂️
tk
But??
cj
but people still want to use videos, IDK why 🤷🏻‍♂️
tk
Ok from where to read docs
cj
Ok from where to read docs
Django: https://www.djangoproject.com/start/ DRF: https://www.django-rest-framework.org/tutorial/quickstart/
tk
Thanks bro
Krunal
How to protect views?
Mirco
George
How to protect views?
Hug them till they stop crying
Django
Hug them till they stop crying
😂😂😂😂😂😂😂😂
cj
Hug them till they stop crying
that's overprotecting, just cheer them up a little
George
that's overprotecting, just cheer them up a little
Is there any tutorial for that? Pls send cod
Krunal
I have created function for index. HTML in views.py and rendering it on login button. Problem is Index.Html page can be accessible without login.
cj
Is there any tutorial for that? Pls send cod
if not views_are_protected: self.cheer_up_views()