cj
Exactly
so, not necessarily "should" use whitenoise
Swetty
I replace STATIC_URL for the same as is in debug mode and it helps me
Swetty
I dont understrand why django creates troubles with staticfiles in this way
.
Show me ur docker compose config
Swetty
Use whitenoise
Troble was with incorrect path dir, whitenoice middleware didn't resolve problem
.
Send ur docker confid
Swetty
Send ur docker confid
1 services: 1 web: 2 build: . 3 command: gunicorn mainapp.wsgi:application -- bind 0.0.0:8000 4 volumes: 5 - .:/app 6 ports: 7 - "8000:8000" 8 environment: 9 - DEBUG=${DJANGO_DEBUG} 10 - SECRET_KEY=${DJANGO_SECRET_KEY} 11 - ALLOWED_HOSTS=${DJANGO_ALLOWED_HOSTS}
Swetty
Dockerfile
14 FROM python:3.13-slim 13 12 ENV PYTHONDONTWRITEBYTECODE=1 11 ENV PYTHONUNBUFFERED=1 10 9 WORKDIR /app 8 7 COPY requirements.txt /app/ 6 RUN pip install --upgrade pip && pip install --no -cache-dir -r requirements.txt 5 4 COPY . /app/ 3 RUN echo "yes" | python manage.py collectstatic 2 EXPOSE 8000 1 15 CMD ["gunicorn", "mainapp.wsgi:application", "--b ind", "0.0.0.0:8000"]
.
Then go to settings and fix static url for ur docker
.
Put the same url as ur one in the volume
.
Ans static root to
Swetty
root@5431e8b77615:/app# ls -la total 384 drwxr-xr-x 9 1000 1000 4096 Jun 3 10:45 . drwxr-xr-x 1 root root 4096 Jun 2 18:12 .. -rw-r--r-- 1 1000 1000 176 Jun 1 17:48 .env drwxr-xr-x 4 1000 1000 4096 Jun 2 17:46 .tmp -rw-r--r-- 1 1000 1000 348 Jun 1 12:34 Dockerfiledrwxr-xr-x 5 1000 1000 4096 Jun 1 12:34 blog -rw-r--r-- 1 root root 323584 Jun 3 10:45 db.sqlite3 -rw-r--r-- 1 1000 1000 290 Jun 1 12:34 docker-compose.yml drwxr-xr-x 3 1000 1000 4096 Jun 2 18:12 mainapp -rwxr-xr-x 1 1000 1000 666 Jun 1 12:34 manage.py drwxr-xr-x 5 1000 1000 4096 Jun 2 11:44 polls -rw-r--r-- 1 1000 1000 49 Jun 2 10:01 requirements.txt drwxr-xr-x 3 1000 1000 4096 Jun 2 14:44 sripts drwxr-xr-x 2 1000 1000 4096 Jun 2 17:48 static drwxr-xr-x 4 1000 1000 4096 Jun 2 17:51 staticfiles
.
Not in the containers
Swetty
Those are in ur machine
$ docker exec -it 5431 bash root@5431e8b77615:/app#
.
Add what i tell u
.
And do docker-entrypoint.sh
Swetty
.
Staticfiles in volume
Bæk
hello, please can i used django as a backend for mobile app created with reactNative?
You can also use the backend for both the mobile app and the web app.
Prakhar
Hey can one help to set static files
cj
Hey can one help to set static files
basically first google result: - https://docs.djangoproject.com/en/dev/howto/static-files/ - https://docs.djangoproject.com/en/dev/howto/static-files/deployment/
𝚂𝚘𝚑𝚛𝚎𝚝
Prakhar
What is error?
Solved now
Issa N'golo
Hello world everyone,please what tool do you use to keep the exact version of Python used in a django project? Today I'm trying to put an old client project back online but I don't know which version of Python i used so I used the latest current version 3.13.4 and it creates problems during migrations and I think that's where it comes from. I haven't changed anything in the code. So to avoid this in the future what can you advise me? thanks for your replies
Issa N'golo
I used requirements.txt for the libraries but nothing for the Python version itself.
Issa N'golo
pyenv or Hygeia
It’s pyenv i used. Someones say to skip pyenv and I should use UV.
Abdullah
Hey can one help to set static files
Project level.& App level ?
cj
I did it. I used v3.12.11 and everything works fine!
lesson learned: if the project is old, why even try with the latest Python version? old project: old version that's all
Issa N'golo
lesson learned: if the project is old, why even try with the latest Python version? old project: old version that's all
yeah, i really learned 😅. for me, the latest version of python will always be compatible with old code.
Issa N'golo
In a Django project, I want to use Celery to generate an API key every hour. Is this a good idea or is it too cumbersome to generate a simple API key with Celery? Is there another, simpler way to achieve this? I only have a tiny $5 server.
Milan
I am a beginner in django, could y'all suggest which is the best playlist to learn django and up to which level I have to learn it for getting internships or jobs to get
Divyyanshu
Im building one enterprise level of project which one is more suitable apiview set or baseview set
Charly
Im building one enterprise level of project which one is more suitable apiview set or baseview set
Are you creating an API? Use an API View Set. If you can't use any of the derived classes of base view set then use BaseviewSet
Issa N'golo
Musa
Hello everyone, I'm currently a beginner in Python and have started building an e-commerce website using Flask. However, I'm considering switching to Django as I continue learning more about it. My question is: once the project is built with Django, what are the best approaches to turn it into a mobile application? Can Django serve as the backend for a mobile app effectively? I’d really appreciate your recommendations or insights on the best tools and practices for this kind of transition. Thanks in advance!
Musa
Thanks 👍
Issa N'golo
.
As a beginner to django, what is the learning topics for Fullstack development
.
In django
Priyanshu
Hi, i was working on a django project I am using a viewset and i want to switch my model manager for one of the operation dynamicly. And use the default one in rest all view functions is there a way I can achive this ?
Eng Mohamed
As a beginner to django, what is the learning topics for Fullstack development
Backend Python - sql - api - database Frontend Html - css - js - react - next - tailwind
Alexxx
Hello guys, how can I filter by date? Im using Rest Framework
Charly
Hello guys, how can I filter by date? Im using Rest Framework
MyModel.objects.filter(created_at__date=date.today())
Charly
Like any ither field
Alexxx
Thanks Does it also work if I want to filter between a certain date and another?
Alexxx
Aight, thank you
clouded
Which api is best rest api or fast api
You can't compare those two.
🏅♐Mark
🏅♐Mark
I am asking because when I saw companies job requirements some companies asking django and fast api and some companies asking rest api
clouded
Let me know why?
Because one is a term for describing a technical solution, while the other is a framework that solves problems in a way that the same term describes.