Charly
How can I fix this?
There nothing to fix
Charly
ts not an issue because printing is rarelly used for functionality on serializer or views
I'm
Probably because your __str__ method returns only the name.
Yeah,I got it. its about displaying data. Thanks.
Nir
So you know how Django rest framework views work?
Yes , I've been using class based views extending apiview
Charly
Yes , I've been using class based views extending apiview
So then you should know how to add a method with an action, right?
Ayass
.annotate( worked_at=Value(date(year, month, day), output_field=DateField()), ) print(item.worked_at, type(item.worked_at)) result = 2024-01-08 <class 'NoneType'> why NoneType ? not datetime.date ?
ruthless
How you install pillow
ruthless
Hmm write like this pip3 install Pillow
Anonymous
Why do we use str and other main in python/ Django
JairamJavv
Why do we use str and other main in python/ Django
Can you give any example for this?
Anonymous
I am trying to ask about __
JairamJavv
Ok the underscores!
Anonymous
Using (__) after and befor str
Anonymous
Dunder variables
JairamJavv
Yeah single _ describes that they are private variables or methods
JairamJavv
So in python single _ specifies partial private and double __ specifies complete private
Anonymous
Okay
Anonymous
And init is related to package
Anonymous
__ init __
JairamJavv
Yes ‘__init__’ specifies that a folder is a python package
Anonymous
Okay
JairamJavv
Noted
Also the difference between partial and fully private is that partial private can be access using the object with some modifications but fully private can’t. But you will find mostly double __ than single _ in most of the python packages…
JairamJavv
Ok
naveen
What is get_or_create method
Anonymous
#question What is the advantage of static?
Victor
What is get_or_create method
https://docs.djangoproject.com/en/5.0/ref/models/querysets/#get-or-create
Anonymous
#question What is the advantage of static?
{% extends 'base.html' %} {% load static %} {% block head %} <link rel="stylesheet" href="{% static 'css/style3.css' %}"> {% endblock %} {% block body %} <div class="html"> <div class="project-card" style="background-image: url('/static/image/a.png');"> <div class="project-author"><div class="author">@Owner</div></div> <hr> <div class="project-title"> Name </div> <div class="project-subtitle"> Lorem ipsum dolor sit, amet consectetur adipisicing elit. Doloremque, minus? <br> Language: Python </div> <a href="#"><div class="down-btn"> Download </div></a> </div> </div> {% endblock %}
dosya
Hello there! I implemented the user registration, login, logout parts of my website. But i have some problems with implementing the email verification thing. I don’t really understand how to implement it. Please, can someone help me?
Charly
I did not understand at all
Do you know what are static files?
Charly
Yes
So static is for serving static files
Ali
Hi can anybody answer this question? What's the best for processing realtime data? Django or nodejs?
Doragonsureiyā
Hi can anybody answer this question? What's the best for processing realtime data? Django or nodejs?
Your question is not related to Django. If it's a Python related question go to @Python group, otherwise please move to @PythonOfftopic group and ask there.
Anonymous
So static is for serving static files
It's easier to write the file url than using the static tag, I think
Charly
It's easier to write the file url than using the static tag, I think
no, because it can be located in different places depending on the environment
Charly
for example when you are in dev mode you serve directly through django dev server, when you deploy it yo use nginx or your webserver, in large deployments you can even use a CDN
Muflone
It's easier to write the file url than using the static tag, I think
If you'd need to change the static root when you install the app in production you'd have to change all the URLs in the project
refleks1a
Hello everyone, i am trying my django project but when I run "docker compose up" I get this error django.db.utils.OperationalError: (2005, "Unknown server host 'db' (-2)")
refleks1a
and MYSQL_HOST in .env file MYSQL_HOST=db
Muflone
Remove the container_name or use db_cont
refleks1a
it doesn't solve the issue
Charly
it doesn't solve the issue
yo need to restart it after that
refleks1a
I did
Muflone
cat /etc/hosts From the container
clouded
docker-compose restart api (provided the services are already running).
Gaston
I did
Host is the value of your db server so if u don't have a second container called db declared on the composer of the django project and on the same doxker network u Will fail to connect, provide a container db or use a local mysql on your workstation
Gaston
Or simple use sqlite default
Elisa
I have a program for login in python django. But when I go to the login page it is not going to the next page. The new page should contain a button.When we click on the button a form should appear..This is the part of the code that I have. View.py def signup(request): if request.method == 'POST': username = request.POST["username"] password = request.POST["password"] user = auth.authenticate(username=username, password=password) if user is not None: auth.login(request, user) return redirect('button_view) else: messages.info(request, "invalid") return redirect('signup') return render(request, 'login.html') View.py def button_view(request): context = {} return render(request, 'button.html', context) button.html <div> <a class="btn btn-warning" href=""> open window </a><br> </div> Is there any correction to be done in this?
Elisa
Could you please help me..
Elisa
Okay
Elisa
look carefully at the return redirect('button_view) line
okay I edited but I am not getting output and not going to the next page
I'm
Does anyone know why should we use csrfToken when we are posting in DRF? I know the application but I am using token authentication. Why should I use csrf too? Ehat is the difference between csrftoken and token authentication? The procedure of both look the same. A token is created when a user has logged in and in every url header the browser should give us that token to check.
refleks1a
Host is the value of your db server so if u don't have a second container called db declared on the composer of the django project and on the same doxker network u Will fail to connect, provide a container db or use a local mysql on your workstation
docker-compose version: "3.9" services: api: build: context: . dockerfile: ./docker/local/django/Dockerfile container_name: "api_cont" command: python manage.py migrate --no-input && python manage.py collectstatic --no-input && python manage.py runserver 0.0.0.0:8000 volumes: - .:/app - static_volume:/app/staticfiles - media_volume:/app/mediafiles ports: - "8000:8000" env_file: - .env depends_on: - db networks: - lu-react db: image: mysql container_name: "db_cont" volumes: - mysql_data:/var/lib/mysql/data/ environment: - MYSQL_ROOT_PASSWORD=${MYSQL_PASSWORD} - MYSQL_DATABASE=${MYSQL_NAME} networks: - lu-react networks: lu-react: driver: bridge volumes: mysql_data: static_volume: media_volume: MYSQL_HOST in .env MYSQL_HOST=db
Anonymous
Hi I'm using dj_rest_auth I like to login just by email not username and username will be unrequired what should I do?
Anonymous
Custom user
I'm using custom user
Anonymous
but login view get both username and email
Anonymous
I like to login just by email
Behzad
Can you recommend a good book for Django Rest? Yes, I searched the sites and saw your comments, I don't want you to say that it is on the internet, don't ask here. If someone has read the book and found it really good, I would be grateful
refleks1a
I solved the problem, thanks
Ha$H
hi i’m mid level in django and i don’t have any idea for project :( please give me some ideas 🤯💤
Doragonsureiyā
hi i’m mid level in django and i don’t have any idea for project :( please give me some ideas 🤯💤
Adding the word Django to your Off-Topic question doesn't magically turn it to a Django related question, so delete your question here and move to the @PythonOfftopic group and ask there.
ruthless
Hello guys I have a problem
ruthless
With OpenCv module
Doragonsureiyā
With OpenCv module
Your question is not related to Django. If it's a Python related question go to @Python group, otherwise please move to @PythonOfftopic group and ask there.
ruthless
cv2.CascadeClassifier() How can I add .xml file and path in django
Doragonsureiyā
cv2.CascadeClassifier() How can I add .xml file and path in django
Your question is not related to Django. If it's a Python related question go to @Python group, otherwise please move to @PythonOfftopic group and ask there.