Глеб
for i in URL.objects.get(id=55): print(i)
TypeError: 'URL' object is not iterable
William
Do you want to display data in html?
Глеб
Do you want to display data in html?
i need store data in variable in views.py
William
why?
Глеб
why?
ooooohhhhhh. I need query shortened url. I should redirect using that url to full_url which i should query form database too
William
are you creating URL shortening application
William
?
Глеб
I should create it by steps, because i don't know django. And i try to get data from database
William
You need to get the URL from input then you need to store.
Глеб
i did it
Глеб
You need to get the URL from input then you need to store.
My model with id 55 stores two variables full_url and short_url. Data for full_url had gotten from modelform, data for short_url had generated using data from full_url and these two variables saved in postgresql database
Groot
Anyone know how apply filter on db object so that if there is any match in the field it gives data Example : i have label I want to filter the db object so that it return every field which have matched text
Groot
Simple modelname.object.filter(column_name="data") Match the exact same data
Groot
ita modelname..objects.filter()
It match the same data
s.Rathnabalu
Which platforms clear to study django api
Groot
Contains didn't working
Groot
Sorry
Groot
Solved
hehe
Which database is best for django?
Naol
start or restart the postgres service.
hehe
Thx
Anonymous
Any reference?
https://www.django-rest-framework.org/
Sumit
Then, use multiple image fields.
But the number of image to be uploaded for a product is not fixed, it is upto the user.
Anonymous
But the number of image to be uploaded for a product is not fixed, it is upto the user.
create another model for images and connect product it with foreignkey(One to many feild).. with that you cam havr multiple images for single product..
Anonymous
That's why I am using whitenose but I think when I am uploading image it is stored in heroku media that's why it's getting deleted
check corey schafer on youtube, he has a youtube tutorial on how to solve this problem using AWS S3
Aaron
Is this a good place to ask if Django would be suitable for my project?
Anonymous
depends on what type of project it is
Markez
Hello guys and working on a project and with swagger My API documentation UI on Swagger shows duplicate endpoints in this format POST /core/data POST /core/data{format} Anyone with any idea how I can have it not show the second one with parameters description
M***
How to execute a function in every day midnight at 12:00
M***
How can we automatically set it???
Mirco
How can we automatically set it???
Using crontab or something like Celery beat or Django Q
.
apscheduler
Aaron
depends on what type of project it is
Web based estimating tool including parts database with attributes and pricing, labor calculations, reporting. Eventually I’d like to feed back actual performance against estimate to create metrics and analytics.
Groot
Hey guys Anyone knows how to iterate on list elements in django template
Abdusamad
Hey guys Anyone knows how to iterate on list elements in django template
First you have to return the list in views.py In the HTML file implement this {% for i in list %} <li>item: {{i}}</li> {% endfor %}
Devo
Does anyone used celery and message broker ?
Anonymous
Hey guys I have a parent model (Tutorial) and a child model (Comment) I want to filter Comments from Tutorial queryset (for example confirmed comments) to aggregate comments count later How can I do this?
Anonymous
Or you can do Category.comment_set.all().count()
Onks
parent model or parent class inside the same model?
Anonymous
Comment.objects.filter(category=<category>).count()
It's already done and I tried to do it this way but it didn't work as I expected tutorial_queryset.filter( comments__is_active=True, comments__confirm_status=ConfirmStatusChoices.CONFIRMED ).aggregate( comments_count=Count('comments') ) It seems it filters tutorials instead of comments
Anonymous
Try to partial execute it
Anonymous
Anonymous
Maybe you can iterate over tutorials, and in circle define comments for every tutorial
Yes it may work but it will make lots of queries for db :(
Anonymous
In some situations it's good to use "prefetch_related" etc
Anonymous
And caches
Anonymous
It can do part of job
Anonymous
In some situations it's good to use "prefetch_related" etc
Yes i can give it a filtered queryset to prefetch Thanks a lot i'll check it
Conditional elector of HRE
Why django form is not displayed?Here is the code - https://qna.habr.com/q/993075
Mirco
Do it inside your view, it's easier
Groot
I need in template
Groot
Left that i found a solution How can i apply condition like {%if key==i%} ........ {%endif%}
Anonymous
Hello can you expalin me how can use related_name ? with simple example
William
Hello can you expalin me how can use related_name ? with simple example
related_name is a manually created field name for the relationships. By default django will create related_name like RelationModelNameinLowerCase_set
Rushabh
Any example?
{% for i in corona.countries_stat %} {% ifequal i.country_name corona_search %} Here corona_search from views file.
William
How to access a dictionary element in a Django template? - Stack Overflow https://stackoverflow.com/questions/1275735/how-to-access-a-dictionary-element-in-a-django-template
William
Any example?
Check this.
Groot
Got it thanks
Groot
Buddy
Mirco
Left that i found a solution How can i apply condition like {%if key==i%} ........ {%endif%}
That kind of stuff should be done inside the view as best practice Leave the template only the role of presentation layer. Anyway another easy way is to create a custom simple filter that returns you the value or the keys
Sherry
How can we do file/IMG upload In django signals