Firdaus
Most do try to read the documentation. But sometimes it is very hard understand. Most of the time it is not about technical understanding, but the language itself. When I first learn English, it looks weird to me. Things that I see as A-B-C, in English it is explained as B-C-A. Something like active/passive, transitive/non-transitive. So I totally understand for newbies asking for other source besides the official guide. Especially those looking for video-based tutorial.
Suren
hi everybody, please let me know how can I iterate string in django templates? I want automatically to add <li> tag to each string. Instead I am able only to do it for each char {% for string in tour.price_includes %} <li>{{ string }}</li> {% endfor %}
Suren
I guess you need to do like this {% for s in string %} <li>{{ s }}</li>
no, let me explain, tour.price includes contains some text, for instance: Airfares & airport taxes Single room supplement - US$ 180.00 Items of personal nature Photo fee at museums & sites Flight: TAS/UGC-US$ 95.00 perpax (subject to change as per Airline) I want to apply <li> tag to each string.
Suren
if I do this way <li>{{ tour.price_includes }}</li> - it will add only one <li> tag to whole text. If I do it like in my sample: {% for string in tour.price_includes %} <li>{{ string }}</li> {% endfor %} It is going to iterate each char from the text. So the question it how to iterate by string
Cyeloth
if I do this way <li>{{ tour.price_includes }}</li> - it will add only one <li> tag to whole text. If I do it like in my sample: {% for string in tour.price_includes %} <li>{{ string }}</li> {% endfor %} It is going to iterate each char from the text. So the question it how to iterate by string
Have you tried saving in list each text? Like: tour.price = ["Airfares & Airport taxes Single room supplement - US$ 180.0", "Another text", "Another"...] So you can iterate for text in tour.price: <li> first text </li> <li> second...</li>
Cyeloth
but how do I save this text in list if it is part of the model? price_includes = models.TextField(max_length=255, blank=True)
interact with the model in views, get a list of every price_include and send it to your html
Cyeloth
like for price_include in MyModel...: price_list.append(price_include) return render(request, YourHtml, { 'price_list' : price_list }) in your html: {% for price in price_list %} <li> {{price}} </li> {% endfor %}
Dima
Hello every one I have auto-generate javaScript file and its name follow the pattern like this: mane.longHash.js so my question is how I can connect this file in my templates/index.html? I know only how to connect static files like this: {% load static %} <script src="{% static "frontend/main.js" %}"></script>
W
check this way and let me know
Deise Freire
Please, I need a kind person to help me, I have no idea why this project does not run, the login image would have to appear, but nothing appears. I'm desperate. https://replit.com/@DeiseF/experiencein-v2 I want to leave this screen https://69c4c8e0-13da-4ac1-8e9c-dbeaae42e1a6.id.repl.co/perfis/ and the image of a login appears
Mohamad
friends, how can I add a checkbox to the model?
Dima
How is that js file generated, and where and how is stored?
its generated by React build. I store it in my static folder
-
I'm trying to use a custom font in my Django app. Here are the relevant lines from my base.html: <link href="{% static '/css/styles.css' %}" rel="stylesheet"/> Here are my relevant lines from the css file: @font-face { font-family: myFirstFont; src: url("css/alfont_com_AlHurra-Font-Regular-2.ttf") format("truetype"); } My CSS is working except for the font. What steps am I missing to get this working?
Vikash
Getting error File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Vikash
data1 = json.dumps(data) data2 = ("format=json&data=" + data1) print(data2) response = requests.post(url=settings.DELHIVERY["URLS"]["order_creation"], headers=headers, json=data1)
Rami
Hello! Does anyone know how to test celery tasks without the message broker? I am using unittest
Pablo E
Hlello !! ,How I make mock test in Django App
Charly
Hlello !! ,How I make mock test in Django App
Depends on the specific part you want to test and mock
Krunal
I am developing e-commerce application with Django rest framework. I want to send email notification on food category for different condition. I might need to send email notification in future for other categories. What is the best approach to develop functionality that any future changes can be handled easily and less changes?
Charly
Yes
So if we don't know these details we can't help you
Vamsi
Iam not able to install django
Charly
Iam not able to install django
What have you tried and what difficulties are you having?
🅼🅸🆃🅷🆄
CODE: class Solution: def twoSum(self, nums, target): for n in nums: if (target - n) in nums: return [nums.index(n), nums.index(target - n)] Solution.twoSum([1,2,5,6,9,8], 11) ERROR: TypeError: Solution.twoSum() missing 1 required positional argument: 'target' can anyone please explain why this error show
Charan Cherry
CODE: class Solution: def twoSum(self, nums, target): for n in nums: if (target - n) in nums: return [nums.index(n), nums.index(target - n)] Solution.twoSum([1,2,5,6,9,8], 11) ERROR: TypeError: Solution.twoSum() missing 1 required positional argument: 'target' can anyone please explain why this error show
class Solution: def twoSum(self, nums, target): for n in nums: if (target - n) in nums: return [nums.index(n), nums.index(target - n)] s1=Solution () result=s1.twoSum([1,2,5,6,9,8], 11) print(result) Final output:[1,4]
Wan
how to accses foreginkeys in request fungsion? class boardingUser(models.Model): name = models.CharField(null=True, max_length=25) class Myrecipe(models.Model): user = models.ForeignKey(boardingUser, on_delete=models.CASCADE, null=True) category = models.CharField(null=True, max_length=20) def __str__(self): return '%s' % (self.user)
Vikash
How to add format=json&data= before json data in python
Samrah
I am getting "similar queries" according to the debug tool. These are my models: https://pastebin.com/qCMypxwz
Samrah
This is what I am doing so far but this is giving me similar queries according to debug tool: productList = Products.objects.prefetch_related('category', 'variants_set__color_id', 'variants_set__image') for productName in productList: products = dict() prod_id = productName.variants_set.all()[0].id products['id'] = prod_id products['category'] = productName.category.category_name products['prod_name'] = productName.prod_name products['brand'] = productName.brand prod_colors = productName.variants_set.all().values_list('color_id__name', flat=True).distinct() prod_images = list(productName.variants_set.all()[0].image.all()) image_list = list() for image in prod_images: image_list.append(image.image_url) products['image'] = image_list products['colors'] = list(prod_colors) price = productName.variants_set.all()[0].price products['price'] = price createdAt = productName.variants_set.all()[0].createdAt products['createdAt'] = createdAt productListDict.append(products)
Suryo Adhy Chandra
Hello... i wanna ask a question about push my project to heroku via cli after i push my project, it said success. but after i see the logs of heroku, there is some message errors
Suryo Adhy Chandra
2022-11-14T08:56:19.411276+00:00 heroku[web.1]: State changed from starting to crashed 2022-11-14T08:56:20.961054+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=tokokuon.herokuapp.com request_id=3281d307-83c4-4d79-98fa-660e40db76e7 fwd="36.80.211.14" dyno= connect= service= status=503 bytes= protocol=https 2022-11-14T08:56:21.352988+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=tokokuon.herokuapp.com request_id=3cdebdb3-e0f2-4cd5-82e6-aba2c985c028 fwd="36.80.211.14" dyno= connect= service= status=503 bytes= protocol=https this is my error.
Suryo Adhy Chandra
thanks for your help before
Suryo Adhy Chandra
how max size?
i mean how many maximum size the project?
.
Hello guys i wanna learn django rest freamwork so i need a good source to learn from
Doragonsureiyā
Hello guys i wanna learn django rest freamwork so i need a good source to learn from
Are you looking for Django REST Framework documentation? Here you have it: https://www.django-rest-framework.org/
Prosto
Hello djangers! Hope someone have an experience with translations. So, I have 2 languages, and I need to add 3rd. if I'll do makemessages, and the compilemessages will it erase my previous translations?
IDK
It shouldnt erase because makemessage adds not existing messages so if some message already translated then it wouldnt erase until you manually overwrite
IDK
ofc
Coder
Has anyone had issues with static files when uploading a django project to the beget server?
Doragonsureiyā
Has anyone had issues with static files when uploading a django project to the beget server?
Don't ask meta questions like: "Any user of $x here?" "Anyone used technology $y?" "Hello, I need help on $z!" Just ask directly! The better you are at explaining the problem, the more likely you are to get help. Asking smart questions
Tolga
hey ı am trying to do hospital managment but ı got confused ı made the custom user model this one but ı dont know is it right can you help me ? https://dpaste.org/VYE5F
Kaleb
Is there anyone worked on an appointment application?
Kaleb
Like i want to parse string time to save as a time object in database but i'm confused
Pooya
Hello guys, please help me with this: How can I make a queue for users to wait when the earlier user finishes the views.py process?
Faraaz
Hello Guys! Can any one help me with this error? RuntimeError at /signup You called this URL via POST, but the URL doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect to the slash URL while maintaining POST data. Change your form to point to 127.0.0.1:8000/signup/ (note the trailing slash), or set APPEND_SLASH=False in your Django settings.
Faraaz
Thanks bro
talha
do I have to use collectstatic everytime to update static files to the aimed directory that I wrote in STATIC_ROOT I am using apache
talha
Yes
thank you!
Doragonsureiyā
thank you!
You're welcome! 😊
Naga Rajan
django.core.exceptions.ImproperlyConfigured: "^SnippetViewSet\.(?P<format>[a-z0-9]+)/?\.(?P<format>[a-z0-9]+)/?$" is not a valid regular expression: redefinition of group name 'format' as group 2; was group 1 at position 46 i got above error when using routers any one help me to solve this
Naga Rajan
and any one give usage of simple routers in drf
Co
Hi , I need help My project can't load css from static file In layout I used {% load static %}
А
django.db.utils.IntegrityError: The row in table 'women_women' with primary key '1' has an invalid foreign key: women_women.user_id contains a value '1' that does not have a corresponding value in auth_user.id.
А
Hi, i need help
А
How to solve a problem?
lilobaje
How to send email (Gmail) Django..any new alternative?
Artyom
How to send email (Gmail) Django..any new alternative?
By going to the official documentation, by reading it.
Artyom
How to send email (Gmail) Django..any new alternative?
And if you end up using Gmail, you should know that it's not going to be easy.
Artyom
How to send email (Gmail) Django..any new alternative?
Buy a domain name, there are companies that will provide you an email address for just buying domain name
Роман
Hi, all! I try u = User.objects.last() u.is_stuff = True u.save() u.refresh_from_db() u.is_stuff and i got False what am i doing wrong?
Jay
Can anyone send me reference for how to upload multiple images in 1 post request in DRF using manytomany relationship
Paul
Is_staff or is_stuff
Surelly here shall be is_fireball