Денис
Guys,who know how to convert this " <QuerySet [<Tag: body>]>" to "body"? ( this is lib taggit)
You don't have to convert anything. QuerySet is almost like a list. Just get an object from it and grab its string representation or whatever is inside
SkyLord
Hello Guys does anyone have working with: https://github.com/rossp/django-menu or maybe someone knows something similar thanks
Денис
Hello Guys does anyone have working with: https://github.com/rossp/django-menu or maybe someone knows something similar thanks
Just tell us about your problem. Don't make people say "Yes, I do!" and wait for you to do this anyway.
SkyLord
I want to realize the menu functionality BUT I want the user to enter django-admin to create several menu points, for each menu point to define slug and then these menu items are displayed on the front
Денис
I want to realize the menu functionality BUT I want the user to enter django-admin to create several menu points, for each menu point to define slug and then these menu items are displayed on the front
No problem. Model class Menu, inside some... say, item = CharField() Register it in admin panel (many tutorials on that) And in your base.html template or elsewhere place something like {% if menu %} {% for item in menu %} # html representation of item {% endfor %} {% endif %}
Денис
And edit your menu in Django admin as much as you want
Денис
You can even create a custom template tag with all HTML menu content you want
SkyLord
Thanks
Денис
no working example for you, though. But you gave me an idea, thanks. A nice way of creating a customizable menu
SkyLord
So if we generalize the menu it is the same as the categories ???
Денис
So if we generalize the menu it is the same as the categories ???
Generally menu is just a set of items. I don't see any objectives to keep items in DB. Especially if the items just keep URLS inside. Then you have just two fields in your MenuItem class: name = CharField() url = URLField()
Денис
but I can hardly see any reason not to hardcode menu items in html templates.
Денис
Also, you can create a Menu model and a MenuItem model and relate them via ForeignKey. Then you can create several Menu's with different sets of MenuItems
SkyLord
However, we have for example an application with urls.py in which we define uri. now we create Menu model, and add it in django admin. can we from the admin create a menu and link this menu to an uri from the urls.py file ????
Денис
However, we have for example an application with urls.py in which we define uri. now we create Menu model, and add it in django admin. can we from the admin create a menu and link this menu to an uri from the urls.py file ????
well... you can override a get_absolute_url() inside some model and create a ForeignKey to it from you MenuItem. Then you can choose related model object in the admin panel and take its url
Денис
I can't explain it in detail, i should first try it myself. No time for this now.
SkyLord
Something like CMS (joomla, wordpress) I create menu, then create article and link this menu to article
SkyLord
Ok, thanks
Денис
or Wagtail
Anonymous
https://dpaste.de/NT42
Claudio
Hi everyone, i have a question: If i have two models: A, B A has a many to many relation with B So if i type a.b.all() I get all b objects, that's why it is needed to use a Prefetch object If B has a many to many relation back to A, can I count all the A objects of a B object of A? For now i can do (pseudo code): A.prefetch(B).annotate(Count: 'a_count', 'B__A') but the count goes inside the first A object, not in the B one I want to be able to do A.B.a_count
Claudio
Okay, I did it If someone needs the solution is to override the queryset on the prefetch object, and attach there a count annotation, example: objects = Prefetch("b", queryset=B.objects.annotate(a_count=Count('a'))
Shikhar
Guys I'm having some problems while designing the site. I'm trying to put image, title and content in a card but it's not working. Need help
Shikhar
Bootstrap has a card widget implemented
I'm using the same feature
Денис
No access to dpaste.de for me
Денис
I'm using the same feature
If you need help rather than just someone to talk then just provide your code via pastebin or something. But remember that this is not a Django-specific question and we don’t necessarily bother solving it.
Kumar
Hey, what is slug in Django?
Kumar
When we should use it?
Kumar
I'm trying to write unit test for models, came across this term..
Muflone
Hey, what is slug in Django?
A field with numbers, characters and dashes only. It's what you would use for a webpage. BTW the Django documentation explains it better
Kumar
Okk, thanks...
Kumar
I'll give a read to docs...
Anonymous
No access to dpaste.de for me
ok it’s solved thnQ
Rahulraj
Hi
Rahulraj
Any one have an example implementation of a bootstrap carousel with django
Rahulraj
Its working with static files
Rahulraj
But when i try to do with dynamic loading its not working
Tommaso
Hi, I am developing an app in Django. I have built an app that allows my users to upload large amount of data, as they were copiling many forms per time.. In particular, I am allowing them to download a template (excel sheet) with indications on how to compile it correctly and upload it. Now I want my app to read these files, extract data from the excel sheets and store it into another model that I have already prepared. Can you please point me a tutorial or a resource expaining how to do it?
Anonymous
How can i hide my password from django setting . i put it in there for forget password option to send the password for the user , yet i want it to not seen like string
Anonymous
why the user must get a chance to recover thier password
Muflone
why the user must get a chance to recover thier password
Wrong, users must be able to reset passwords, not to recover it Only broken systems allow password recovery
Anonymous
what i did is to reset password it need the emaila and password to send the reset message to the user by email but when i put my email and password in my code to send by my emailmy password is visible bcos i put it like string there
Muflone
You don't need any password to reset it, just invent a new password and send it to the user email
Anonymous
ya now u r close to understand me to send an email it needs an email who send it the reciever now what i need is the sender ( email who send the rest password message to the user email) must put password in django setting isnt it ?
Muflone
You mean the smtp password? Not the user password
Anonymous
yes
Muflone
If you don't want to write your smtp password the only choice is to use a service that enables you to send email like sendgrid
Muflone
Or use the internal mail server, if the hosting server has one
Bernard Kwey
How can I change my database by default to MySQL
Sencer
How can I change my database by default to MySQL
First you have to dump your data if necessary, otherwise you have to change settings.py file. It's all written in django documents https://docs.djangoproject.com/
Sencer
After you changed setting file and you have dumped data, you can restore it by loaddata
Bernard Kwey
Thanks
Alek
Hello everyone, please advise the tutorial on how to register with sending an email message? (I use vps on reg.ru)
Shikhar
How to show image in template whose url is stored in database
Rainur
<img src= "{{image.url}}"
Денис
How to show image in template whose url is stored in database
<img src="{{ image.url }}">
Денис
depends on whether full or partial URL is stored, though
Shikhar
<img src="{{ image.url }}">
So there is no need to add extension??
Shikhar
Like .jpg
S
Anyone worked on Django captcha ?
Денис
So there is no need to add extension??
as a rule, URL already contains an extension. Otherwise, browser should recognize the image nevertheless.
Anonymous
Hi guys, how can I set columns names in intermediate many to many table?
Anonymous
Only create separate model?
Денис
Hi guys, how can I set columns names in intermediate many to many table?
maybe this will clear something https://docs.djangoproject.com/en/2.2/ref/models/fields/#django.db.models.ManyToManyField.through
Денис
If you don’t specify an explicit through model, there is still an implicit through model class you can use to directly access the table created to hold the association. It has three fields to link the models. So a separate model is created no matter how you define ManyToManyField.
Anonymous
Also what if I dont wanna to create id filed on intermediate table, is there a way of doing that?
Ram
What’s the difference between generics.ListApiView, APIView, viewsets and there are few others modules to inherit for class based views. I don’t get the difference. Can someone tell me about that?
Willie
Hello experts, is anyone using virtual environment Django in python 3.8 ?
Денис
Hello experts, is anyone using virtual environment Django in python 3.8 ?
1. Offtopic (not Django-related) 2. Meta question (no real problem described). Just say what's your problem.
Angel
hi guy's i try to do a search bar, can you help me with some documentations
Angel
i was try to do it with ajax but i was find library q wich is better option
Angel
??
Luis
hi guy's i try to do a search bar, can you help me with some documentations
Read about django-filters https://simpleisbetterthancomplex.com/tutorial/2016/11/28/how-to-filter-querysets-dynamically.html You may use it with rest-framework https://www.django-rest-framework.org/api-guide/filtering/
Eddie
Guys i need help