Adrian
prod = Product.objects.get(Id=3)
prod.images # this sentence get all registries
Samrah
What if I want to get it for all the products and not just one like your query uses get(id=3)
Adrian
Images.objects.all()
Adrian
If you use product.objects.all(), and do a sentence for, you can access to images for each product
Rajat
Please share the code add to cart product to save the Cart model.
World_net
why does command line show "killed" for any command ?
Anuj
Hey developers
Anuj
How to use start project in django
~:$
~:$
https://docs.djangoproject.com/en/4.1/howto/custom-management-commands/
https://simpleisbetterthancomplex.com/tutorial/2018/08/27/how-to-create-custom-django-management-commands.html
Read
Samrah
Images.objects.all()
This will only get me the images but I want to get images that each product has with one query. Like in mysql how we would do this is my doing a join between products table and product_img table on P_ID and do the same with images and product_img table to get a result like so:
P_ID PRODNAME IMG_ID IMAGE
1 shoe1 2 img1
1 shoe 1 3 img2
1 shoe1 4 img3
2 shoe2 3 img2
Frenchie
I am using a serializer1 in another serializer2
When I access the serializer2
The data of serializer1 comes in ORDEREDdict why?
Samrah
Am I being understood?
~:$
~:$
Am I being understood?
https://books.agiliq.com/projects/django-orm-cookbook/en/latest/
It will help you to build your query logic.
mohamed
Hello
I’m trying to create an e-commerce web page
What I need is
After user choose the quantity needs it , I deduct that from database and if order more than what I have , I show message like sorry we don’t have
mohamed
I create a home page that you can see all products after choosing a product, you go to another page to choose how much do you want , in this page , I want to show after user enter the quantity if I have or if I don’t and send message sorry we don’t have based on the quantity I put it in the database from the admin page
OceanMan
mohamed
Yeah I created a table for the quantity of all products I have, and I created a form for the user input, so now I want to compare between them, and show message if I don't have what user input
Gokul
Hi members, I'm currently working on a django project with restapi, I have seen lot of video to make rest api for login, register and authentication but i don't know how to connect this api with frontend like html css or js
Can Anyone help me to do that..?
Anonymous
Anonymous
jaxx
Hi,
I'm trying to update nested object in DRF, followed the tutorial and written the code, however am getting key errro  on
user_data = validated_data.pop("user")
I ve pasted the code link below, please look into it
https://hastebin.com/utozijoxeg.py
ford
Leandro
Hi guys, I've a question.
P ,created=Product.objects.get_or_create()
I don't understand why "created" is there, what's its purpuse.
ford
ford
Depends on your need
jaxx
jaxx
Am getting key error
jaxx
I didn't got any solution so i created values to update foreignkey field and then the values for table.. it's a long codr now. Tested in postman and it works . Don't know it will work when implementing jn react will work or not
ford
Can you print your validate_data before doing pop to check if it really has what you are popping
ford
Никита
The question is who worked with ckeditor django, added their own css blocks, the block itself is displayed when editing, but not saved, my config https://pastebin.com/BV7fdvEN
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ
Can any of my friends give me a website or web application project to earn money?
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ
I will be grateful if you introduce the place that offers programming.
Leandro
sahajah
guys someone knows why the images from database is not showing-up with Debug=False? the static one is loading, but the images from database is not.
i’m using {{ new.image.url }}
sahajah
?
Mat
sahajah
Mat
Like this :
media/{{ new.image.url }}
sahajah
oh okay, i’m gonna try
Mat
Good luck
sahajah
nope :')
Mat
Where are your photos ?(database)
sahajah
BASE_DIR = Path(__file__).resolve().parent.parent
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
Mat
And in models, did you use (upload_to=) ?
sahajah
uhm, no-
sahajah
upload_to='media/'?
Mat
Yes :
ImageField(upload_to="media/")
sahajah
GET /media/blog-1.jpg HTTP/1.1" 404 9768
Mat
In admin management, delete the previous objects and create new ones
sahajah
no 😭
sahajah
just if i turn debug on True it works
sahajah
can i contact u in dm? @mat_do
Mat
Yes of course
sahajah
okay thanks
Honey
Can any one please help me on django
Honey
My task is If I upload excel sheet in upload section
Honey
Under upload section there is dropdown
Honey
After uploading the drop-down should show the coloumb name of the excel sheet uploaded
Mujahed Saleem
Honey check this
https://pythoncircle.com/post/591/how-to-upload-and-process-the-excel-file-in-django/
Vigneswaran
Hi friends I'm using apscheduler so my django application is running two time I'm using --noreload method but i no need any alternative is there because I'm hosting my application in IIS kindly give me ideas or solution friends
Morteza
Honey
Honey
Yes
Javad
Friends, look at this code:
class LikePostView(APIView):
permission_classes = (IsAuthenticated,)
def get(self, request, post_id):
user = request.user
post = get_object_or_404(Post, id=post_id)
if PostLike.objects.filter(user=user, post=post).exists():
PostLike.objects.get(user=user, post=post).delete()
return Response(status=status.HTTP_200_OK)
PostLike.objects.create(user=user, post=post)
return Response(status=status.HTTP_200_OK)
it works fine now. but when change the method to POST, it gives me this error:
401 (Unauthorized)
It's like he can't get the token with the post method
Does anyone know the reason?
Aloooo
Friends, I need help. We have streamed our site with the help of the server, but only html files are visible. CSS and Js files are not active, can you help please?
Aloooo
oh sorry ı cant send photo here
Maxim
Aloooo
ı got it but ıts dıdnt worked
Maxim
Doragonsureiyā
ı got it but ıts dıdnt worked
If you need help, don't just say "not working", explain in detail what's not working the way you expect it to
Aloooo
...