Charly
This one
which specific part of that article you don't understand?
Artur
how can i make a button in my form that create new input label?
Charly
how can i make a button in my form that create new input label?
new label in the same form? then what is going to do with that label?
Artur
new label in the same form? then what is going to do with that label?
there are some charfield labels. and i want the button that create new charfield labels
R@kesh
JavaScript knowledge is mandatory for development using python ans django
R@kesh
Yes
Maxim
where is the question mark then?
R@kesh
Sorry
Maxim
Sorry
the sentence is not in question form, there is no question mark - it doesn't look like a question how will people guess that this is a question? you should apologize to yourself - your question will be ignored
amirHosseinZibaei
Localhost ?
No in production
amirHosseinZibaei
How to change null text in choice field django the default is ----------- I want to change this hyphens?
Naresh
Hi any send me the register and login with password encryption sample code
Shukurillo
I registered my ViewSet how do I know which url end point it uses?
Shukurillo
router.register(r'^countries', CountryViewSet, base_name="country") what does the base_name do in the above code?
Kennedy
Hello guys, I have a model class(Profile) connected to User by OneToOneField. In the profile model how can I get the username registered within the default User model? eg: {{ profile.username }} returns nothing in the view
DN
So many questions? Has anyone got the answers to your questions here ... so far?
Vadim
Formation of a dynamic form. There are checkbox, textarea fields, when they are received, they can be 3 and 5 and 10, etc. How to save them in models?
Vadim
<body class="container"> <h1 name="name">Наименование: {{lr_value}}</h1> <h2>Модель: {{ num_category1 }}</h2> <div> {% for j in num_category2 %} <h3>{{ j }}:</h3> <input type="checkbox" id="scales" name="scales"> <label for="scales">Норма\отклонение</label> <br> <textarea id="story" name="story" rows="5" cols="33"> </textarea> {% endfor %} <form method="POST" action="update/"> {% csrf_token %} <input type="submit" value="Отправить" > <h1>{{ num_catego }}</h1> </form> </div> <br> </body>
Haresh
What is difference between prefetch related and select related ?
DN
Hello guys, I have a model class(Profile) connected to User by OneToOneField. In the profile model how can I get the username registered within the default User model? eg: {{ profile.username }} returns nothing in the view
Created model Profile connected it with User model using OneToOneField(), but when I'm trying to get username or image field which is in my Profile model.. it is showing AttributeError: no such attribute
DN
Hello guys, I have a model class(Profile) connected to User by OneToOneField. In the profile model how can I get the username registered within the default User model? eg: {{ profile.username }} returns nothing in the view
I'm not sure but it looks like Profile is extended model.. username is in default User model which may be user in ur case. So u can try this way.. {{ user.username }}
Shilpy
Can we use elastic search in Django?
Haresh
Any body with prefetch and select related
Doragonsureiyā
Any body with prefetch and select related
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
Shilpy
Any body with prefetch and select related
What I have understood so far after reading a lot is that: 1. Prefetch is used for ManytoMany field and for reverse foreign key. Like you have one table A which has foreign key to table B. Now if you want to access data from B to A then you can use prefetch related (fetching from previous table) 2. For forward foreign key and one to one field we use select related. It does inner join in SQL. 3. Prefetch related can be used in place of select related but vice versa is not true.
Doragonsureiyā
❎ ‎Maxim pardoned ‎Kennedy [933022195] for 2/3: ‎Link to a Telegram group or channel
Maxim
This doesn't work as well. Also the property decorator fails
BTW, use markdown for @property to hide it from Doragonsureiyā's rage
Naresh
Any one have the source code of login function with encryption password
Anand
hi everyone , i building a state model in django the package am using is django-fsm , seems to be there is no longer support from author , can anyone suggest some alternative approach
Bobosher
Any body with prefetch and select related
Well, most of the time you wanna retrieve data from more than one table. In that case, you need an efficient way to play with more than just one model. Let's say you have a Book model that has a ForeignKey relationship to Author model. You wanna get information about all books and their authors in a single view. Let's say you have n books. You'll get all Book objects with a single DB query via Book.objects.all() queryset. But each time you ask for the author of a book, django makes another DB query to retrieve information about the author of this book. In total, django performs n+1 queries: 1 query to get all the books and n queries to get authors of n books. This is what they call n+1 problem. This is where prefetch_related() and select_related() come into the picture. They have different purposes and they work differently. 1. select_related() simply makes a SQL JOIN for each selected relationship in a model. In simple words, you'll get data from multiple tables within a single query. For the example above, it joins the author table to the book table with book.author_id = author.id condition. Instead of n+1 queries, you'll make 1 complex query to retrieve all the necessary data. select_related() is limited to a single relationship level. This means, it can be used for first-level one-to-one and many-to-one relationships. If you have this kinda relationship: Book -> Author -> User, You cannot get data in User model from Book, because they don't have a direct relationship between them. 2. prefetch_related() os designed for more than 1 level relationship (like Author, Book, User example). Since it's not a direct relationship, you cannot make a SQL JOIN here. What prefetch_related() does is simply doing a separate query for each relationship, but in a single batch. You might be wondering then how it could be different from a usual way, if it makes a separate query for each relationship. For example, if loop through all the books and access to its author, django makes a query at the moment where you ask for it, which kills the performance. On the other hand, a queryset using prefetch_related fetches all the necessary data when you ask for all the books and author will be already there when you ask for them. Since many-to-many relationship is technically combination of 2 foreignkeys, you cannot use select_related() with them. Here what you need is prefetch_related().
Dzmitry
Hello everyone! I need help with DateField. How can I change the date format from 'D-M-Y' to 'M-Y'? I tried applying to field SelectDateWidget. I tried to set the date format manually but all these didn't work.
Anonymous
facing a problem as follows - there are two mysql tables in many to many relationship... each table has is_active flags for soft delete now when we are trying to join these, we are not able to apply a filter on is_active = 1 in both the tables. can anyone help
Anonymous
The code sofar looks like this .. roles = Role.objects.filter(organization_id=request.user.primary_organization.id, active_statusexact='ACTIVE').prefetch_related(Prefetch('permissions',queryset=RolePermission.objects.filter(active_statusexact='ACTIVE')))
Doragonsureiyā
Thank you
You're welcome! 😊
Adam
Hi, can anyone suggest a good current book on learning django please?
Adam
why not start with the documentation
It's complicated. Clearly structured information on the example of the project, which is explained in simple language, is easier to perceive
S
Hello everyone! Maybe, somebody can help me. I want to use django-graphql-jwt for authentication in REST requests. How can I do it?
cj
Hello everyone! Maybe, somebody can help me. I want to use django-graphql-jwt for authentication in REST requests. How can I do it?
why do you want to use something related to GraphQL in REST? just use JWT directly in REST, forget about graphql if you're not using it
S
why do you want to use something related to GraphQL in REST? just use JWT directly in REST, forget about graphql if you're not using it
Oh, sorry, I don't clarified. I use GraphQL requests in all project but I need to add a few REST requests. I don't know how use djang-graphql-jwt for it, because I use this module for my graphQL requests
tech-tycoon
Hello ,I want to add a channel layer in my django channels for which ,I need redis server ,so is it trustable to use unofficial redis server from GitHub??
tech-tycoon
How can I use redis server on windows
tech-tycoon
Not a django question.
How to use redis for django channels in windows
Neo
How to use redis for django channels in windows
yours is a redis problem not a django problem. Windows or Linux you would just configure the cache in settings.py the same way
Doragonsureiyā
How to use redis for django channels in windows
Adding the word Django to your Off-Topic question doesn't magically turn it to a Django related question, so move to @PythonOfftopic group and ask there.
Neo
I'll be generous and tell you that you can use docker to achieve what you want but that's all i can say here
Банковские карты
Can someone tell where to write logic in ApiView? Because I get error: detail:not found https://codeshare.io/ZJpbVV
Neo
Can someone tell where to write logic in ApiView? Because I get error: detail:not found https://codeshare.io/ZJpbVV
you must define get, post and other methods that you want to be available and then you need to create urlpatterns for that View
Банковские карты
you must define get, post and other methods that you want to be available and then you need to create urlpatterns for that View
did u have a look at code that i sent? it post method and logic put under if serializer.is_valid()... is that right thing to do?
Neo
okay it worked now
Neo
did u have a look at code that i sent? it post method and logic put under if serializer.is_valid()... is that right thing to do?
Looks fine to me except i would have done if not serializer.is_valid(): return Response(serializer.errors)
Банковские карты
Looks fine to me except i would have done if not serializer.is_valid(): return Response(serializer.errors)
ok, thanks. Strange, i get an error {"detail": "not found"}
Neo
ok, thanks. Strange, i get an error {"detail": "not found"}
could it be from item = get_object_or_404(Product, slug=self.request.data.get('product'))
Банковские карты
could it be from item = get_object_or_404(Product, slug=self.request.data.get('product'))
my endpoint - {{host}}/api/showcase/test1/order/add/?product=margarita&quantity=1
Neo
yes, i get None
i mean i think that the 404 is being raised by that function call get_object_or_404 but since you said your debug print says "None" im not sure anymore you should double check
Банковские карты
i mean i think that the 404 is being raised by that function call get_object_or_404 but since you said your debug print says "None" im not sure anymore you should double check
i changed it to self.request.query_params.get('product') and now have this: The QuerySet value for an exact lookup must be limited to one result using slicing. what is this mean>
Neo
Can you update the pastebin
Aysuliw
Good evening! I made a multi-language webiste in django and I am deploying it to shared hosting. Is there any way installing gettext using pip. Because I have not root access to install it using sudo command. Thanks in advance for your answers!
Aysuliw
use pip with the same user that you deploy, probably you need a virtual environment
I have virtual environment. But I read about gettext is not python package so I cant install it using pip.
Aysuliw
I have virtual environment. But I read about gettext is not python package so I cant install it using pip.
Actually I did pip install gettext But it shows error. Also there is a python-gettext package on the internet but I don't know how to use it.
chappa
how do i display python print to django page?