T2ABIZZ
Hello , how can i add this to the django rest when the owner add new product so i get his information?(the username and the phone number of the user who sent post methode). I have The user model and the product field
salar
I use jwt
simply use request.user in your views to get your user object
T2ABIZZ
simply use request.user in your views to get your user object
If i want to get firstname of the user so it should be request.user.firstname? Or what?
salar
If i want to get firstname of the user so it should be request.user.firstname? Or what?
if you have firstname in user model yes it will be request.user.firstname(request.user is an object of your user model)
T2ABIZZ
Okay thank you.
salar
Sayidbek
Good night, there! I want my model auto-create slug for each song, and tried this: https://stackoverflow.com/questions/50436658/how-to-auto-generate-slug-from-my-album-model-in-django-2-0-4 It didn't work for me. Is it too old or I am wrong?
Роман
You'll find many useful tips
How can I add for my page in admin a model?
Arsen
In admin.py add a special class
Брат
import <your model> admin.site.register(<your model>)
Брат
that is it
Jal ⬡
Hello guys, will you know of any tutorial that I can see that teaches me to make a model to put several images to the same product? I'm creating an ecommerce,
Jal ⬡
Sorry for my bad English
Old
Hello friends! How I can import to Postgres a csv table and import from SQLite.?
Andrej
Hello friends! How I can import to Postgres a csv table and import from SQLite.?
1. read the csv file 2. connect to Postgres 3. insert to postgres the csv entries 4. read the sqlite db entries and cache them in Python 5. connect and insert to postgres the cached entries
Andrej
Cache using pandas?
In a variable
Andrej
Cache using pandas?
Read the file/ sqlite db and write it directly to Postgres
Old
Thank you so much
Mihail
I just renewed django from 2 to 4 version. Can you help me, how can I back my admin pannel model view to state as in 2 version?
Нефор
No way
Нефор
This is the end
Mihail
😭
Shubham
I just renewed django from 2 to 4 version. Can you help me, how can I back my admin pannel model view to state as in 2 version?
Not sure but you can generate a requirements.txt of your code and change the Django version to 2 in that file then run the requirements.txt it may work not sure
Ali Hasan
Hello guys, will you know of any tutorial that I can see that teaches me to make a model to put several images to the same product? I'm creating an ecommerce,
You need a Product model and a ProductImage model that has a foreign key to the Product model. So basically each product has many ProductImage
Masoud
hi i have this error when use celery and rabbitmq error is: File "/code/orders/urls.py", line 2, in <module> from . import views File "/code/orders/views.py", line 5, in <module> from .tasks import order_created File "/code/orders/tasks.py", line 1, in <module> from celery import task ImportError: cannot import name 'task' from 'celery' (/usr/local/lib/python3.10/site-packages/celery/__init__.py)
Abdullah
Hello Please how i can add discount system in django to ecommerce Web application
Abdullah
If there any tutorial or documents?
Phansivang
Someone please help with me Django Pagination with bootstrap the list number of Page not only previous and next page .
Phansivang
Not until you explain your difficulties.
I want to work with bootstrap pagination I don't know how to loop and get all the list of page number
Mihail
Create virtual env and install ur django version pip install django==(version)
this is not a problem, to install django of previous version. Problem is to use the same admin pannel in new django as in previous
Anvesh
Requiement: want to bypass the behaviour of datetime field created_at with auto_now=True, creating a model object. Basically I want to migrate data from one table to another. The table at which I want to dump data, doesn’t store the created_at value of the source table data, rather it uses the time at which the new object is created.
Jal ⬡
hi guys
Jal ⬡
i have this : [15/May/2022 12:48:35] "GET /tienda/carrito/1?cantidad=12 HTTP/1.1" 200 12915
Jal ⬡
How do I get the variable 'cantidad' with its value?
Jal ⬡
i try whit request.GET.get('cantidad')
Jal ⬡
but when i print it say 'none'
Anonymous
request.query_params.get("cantidad")
Anonymous
Try this
Jal ⬡
request.query_params.get("cantidad")
'WSGIRequest' object has no attribute 'query_params' he says this
Jal ⬡
well I leave this here in case someone could help me with this error please https://es.stackoverflow.com/questions/534266/wsgirequest-object-has-no-attribute-query-params
Fariz
i try whit request.GET.get('cantidad')
Try request.GET['cantidad']
Jal ⬡
Jal ⬡
https://es.stackoverflow.com/questions/534266/wsgirequest-object-has-no-attribute-query-params
Mihail
are any ways to get all created by me apps_names? which are noted in AppConfig.name?
D
How to change different database in django
Denis
How to change different database in django
Go to Youtube and there you'll see the instruction
Akash
How to change different database in django
You can change in settings.py
Denis
I swaped from SQLite3 to PostreSQL this way
Denis
Also you can see the documantation of database you want use
Shubham
Can you send you url.py and views.py code if you have written some earlier?
Doragonsureiyā
To share code or error tracebacks, use a pasting service, like: - https://linkode.org - https://dpaste.org
Anil
Can you update xml file without loosing <?xml version="1.0"encoding="UTF-8"?> Using etree module
Doragonsureiyā
Can you update xml file without loosing <?xml version="1.0"encoding="UTF-8"?> Using etree 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.
Christian
That's just basic python, not Django. https://www.google.com/search?q=python+sort+dictionary+list
x
How send data django to Js 🙂
x
How ?
Baqer
How ?
Serialazers
👑 Dharmzeey
Please I have a model(Profile) that relies on the default User Model, it gets created whenever a new user registers. But whenever I create a superuser , the Profile doesn't get created when then leads to error. Please is there a way or any docs that explains how I can do it and when I createsuperuser, the Profile also get created
Kim
Yes
What are you using? Django Signals?
👑 Dharmzeey
I'll send my pastebin now So you can help me
Kim
Would you mind if I see the code?!
👑 Dharmzeey
Would you mind if I see the code?!
https://pastebin.com/XapTpubY
👑 Dharmzeey
The views.py and the urls.py
Kim
So you are creating a new user directly from ProfileCreateView, right?