Hamidreza
What you have written means after logged in, the user will be taken to /admin/ Not a good idea
login_url is mean if user not logged in redirected to this url to login right? or im wrong?
Alex
yes i have many
The code you're showing us is absolutly valid. It MUST work. Something is wrong with your setup.
Mirco
login_url is mean if user not logged in redirected to this url to login right? or im wrong?
Yeah sorry, login_url and login_redirect_url are the guys The first one for login page and the second one for redirecting user after logging in
Anonymous
The code you're showing us is absolutly valid. It MUST work. Something is wrong with your setup.
select count(*) from shop_order where date_order LIKE '%2020-11%' = 221
Hamidreza
Yeah sorry, login_url and login_redirect_url are the guys The first one for login page and the second one for redirecting user after logging in
login_required this method have't login_redirect_url parameters 👇🏻 login_required(redirect_field_name: str=..., login_url: Optional[str]=...) -> Callable[[_VIEW], _VIEW]
Alex
select count(*) from shop_order where date_order LIKE '%2020-11%' = 221
And if select count(*) from shop_order where extract('month' FROM date_order) = '11'; ?
Mirco
thats better idea, thank you !
In this way you can avoid specifying it everytime you have the decorator
Anonymous
And if select count(*) from shop_order where extract('month' FROM date_order) = '11'; ?
select count(*) from shop_order where extract(month FROM date_order) = '11'; same result == 221
Alex
PurchaseOrder.objects.filter(date_order__month=11) always empty QuerySet
qset = PurchaseOrder.objects.filter(date_order__month=11) print(qset.query) what does it show?
Anonymous
SELECT shop_order.id, shop_order.order, shop_order.date_order, shop_order.customer_id, shop_order.product_cant, shop_order.supplier_total, shop_order.sale_total FROM shop_order WHERE EXTRACT(MONTH FROM CONVERT_TZ(shop_order.date_order, 'UTC', 'America/New_York')) = 11 ORDER BY shop_order.order ASC
Anonymous
will be smt with the timezone setup!
Anonymous
some recommendation!? change time zone on mysql server !?
Alex
will be smt with the timezone setup!
I doubt that it's TZ problem. Are you 100% sure that you setup the same DB in django's settings as you query with that sql? Are you sure that you didn't setup any DB cache in your django project? Like cachalot for instance.
Anonymous
yes, im sure there is no cache, and the DB setup is correct
Anonymous
after that, remove the timezone convert SELECT shop_order.id, shop_order.order, shop_order.date_order, shop_order.customer_id, shop_order.product_cant, shop_order.supplier_total, shop_order.sale_total FROM shop_order WHERE EXTRACT(MONTH FROM shop_order.date_order) = 11 ORDER BY shop_order.order ASC and then i have the result
Anonymous
it work!!!!
Alex
-_-
Anonymous
but... is that correct!???
Anonymous
i mean, is a good practice!??
inchidi
doesn't work with mysql 😔
https://docs.djangoproject.com/en/3.1/ref/databases/#time-zone-definitions
Alex
i mean, is a good practice!??
I really don't like disabling timezone support. I think there is something is wrong with your mysql instance. But cannot say what.
Anonymous
-_- Ofcourse, wrong tz naming
i dont understand this!? the mysql server is running on remote server, and it have the time zone well configured
inchidi
-_- Ofcourse, wrong tz naming
yes, the main problem is his mysql doesnt have timezone table yet
inchidi
Alex
why!?
I was wrong, nvm. America/New_York is correct
Anonymous
one link in this paragraph is all you need btw
this did the trick!!!!! mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql thks a lot!!!
Anonymous
now, USE_TZ = True and the queries are working!!!
@Garant
Hello! Help plz !!! Model: class A: name = CharField class B: size = int a_link = ForiegnKey(A) I have filtered queryset with B. I need to compose a request that will return similar to: {A.name1 : sum(B.size), A.name2 : sum(B.size)...}
Mirco
wow..great
They are the basics of DRF
Anonymous
I found, already with the identified problem that in the official documentation explains about the use of time zones
Anonymous
right here https://docs.djangoproject.com/en/3.1/topics/i18n/timezones/#migration-guide
Anonymous
Anonymous
I want to make a static website For shop: not for shopping, just to show the pictures of the products and maybe comments, 'how to contact' etc. Do you think that django fits that ? Or I should use just html & css ? Thanks in advance 😄
Anonymous
if you want to build a static website, you don't need anything for the backend 🤷🏻‍♂️
Of course, But, I thought It might be more comfortable to create the website with django tools... Btw, U can have a look here, just found this on the web : https://www.quora.com/Is-it-worth-it-to-use-Django-for-creating-static-websites. I just was interested to hear more opinions..
Mousiol
Does django channels use a pub/sub in redis? Or it uses another system?
on
Hi freelance Django developer ping me. I have project and will pay you
M
Hallo ! I am new here anyone guide me to make my mini project...?
M
I wanted to make smart canteen in python and Django mysql by use editor pycharm / sublime
mukul
that's good
mukul
how may i help you
John
Hey Django Devs. I want to use Cloudinary (on heroku) to store my media file. But I don't seem to be getting the settings quite right.
Carlos
I mean, Quora has a good community
John
Hey guys, please what are those resources for pasting code?
Doragonsureiyā
Hey guys, please what are those resources for pasting code?
To share code or error tracebacks please use an online pasting service, here is a list of suggested sites: - https://del.dog - https://dpaste.org - https://linkode.org - https://hastebin.com - https://bin.kv2.dev
John
okay thanks
Pandu
Witch is the more secure way to authenticate user(internal) in Django.
John
Okay let me recap and ask my question properly.
John
Hey Django Devs. I want to use Cloudinary (on heroku) to store my media file. But I don't seem to be getting the settings quite right.
John
I followed cloudinary offical docs and used this: image = CloudinaryField("product") on my model field. And it worked for production. [old model.py code - https://dpaste.org/6gWq] [old settings.py code - https://dpaste.org/n88Y]
John
But I wanted the files to be on my system during development. So I change the model field back to image = models.ImageField(upload_to="products/%Y/%m/%d", blank=True) [new model.py code - https://dpaste.org/e838] And added "dj3-cloudinary-storage" package then used: DEFAULT_FILE_STORAGE = "cloudinary_storage.storage.MediaCloudinaryStorage" in my settings.py [new settings.py code - https://dpaste.org/d5g8]
John
This made it to save images on my system and on heroku production environment (which disappears after 30mins) I want the images to save on my system during development and on cloudinary during production. How should I go about this?
Dexter
How do I make download able pdf of table which has around gb of data . Can anyone guide me I tried with datatable but django cannot render such huge data I am getting 502 error
Anonymous
Traceback (most recent call last): File "./manage.py", line 15, in <module> from safe_lxml import defuse_xml_libs ImportError: No module named safe_lxml
Mr.B
Safexml is not detected see that
Anonymous
then how can i solve that
Anonymous
hi
Anonymous
I was trying to pass some data to filter the queryset using a get request. but I cannot use the data in django. name = request.data.get('name', None). the name is always empty can someone please help?