David H
Values and values list should work efficiently. What do you mean by efficiency? Time to run the code? If that's the case, you can test the options in terms of time.
But Values and values list allows you to obtain certain attributes of your model, not to "add" a calculated one
.
yes
It’s no. You don’t have a url named dashboard in there. Add it or remove it from the template if you don’t need it.
.
I was wondering about something like @property or anotate (I don't know which one is more efficient)
If I assume @property attribute is “obtained” in the template, then annotate is more efficient because it runs in views. DB > views > template
David H
If I assume @property attribute is “obtained” in the template, then annotate is more efficient because it runs in views. DB > views > template
@property is 'created' in the queryset by python, it doesn't involve database stuff, it's not calculated in template
David H
Can you share a brief line how you do that?
@property is a django decorator in the models, not a self implementation
Vlad
@property is a django decorator in the models, not a self implementation
OK, could you state your question once again or provide more details? It is not that clear
David H
Okey, imagine a simple case in which you have an init and end date. So, now, you are requested to store the time range between the dates in each querystet object's. (It's not a real use case, only for this explanation)
David H
The options I said are good choices, but I don't really know it there is a better one
.
@property is a django decorator in the models, not a self implementation
I know that. I wanna see how you obtain property attributes of each item in a queryset. If you’re doing list comprehension, that that’s definitely less efficient than doing annotate.
.
LOGIN_REDIRECT_URL = 'dashboard'
That’s not defining a url name in urls.py, that’s called defining a variable in settings.py You didn’t do the urls.py part that’s why you’re getting that error. Once again if you don’t need that url just remove it from the template where you’re calling that url.
David H
Annotate 'delegates' the processing in the SQL engine and @property in your own server
01110010
How can I host Django on alwaysdata hosting platform , their docs ain’t helping much
Charly
How can I host Django on alwaysdata hosting platform , their docs ain’t helping much
What' s the issue whit this? https://help.alwaysdata.com/en/languages/python/django/
01110010
It’s just don’t work
Charly
It’s just don’t work
Thats not helpful in order to help you
01110010
Thanks for your help tho, I’m gonna begin the process again and figure out what went wrong
01110010
What website ?
Bekhruzbek
Write the name of a site that teaches how to work with media files in Django
Mh
How to pass variables between views in django
01110010
using sessions
01110010
request.session
Mh
Can you give the syntax
Charly
Can you give the syntax
Or you can start by searching in the documentation about what he told you
Mh
Ok
01110010
Here request.session["has_commented"] = True There’s more here https://docs.djangoproject.com/en/4.2/topics/http/sessions/
SATISH
Anyone can solve my problem django related
Charly
Anyone can solve my problem django related
Solve? Not Try to help, yes. If you provide all details and context.
SATISH
If I login button click then only Login person data show
Charly
How
Filter in the view by request.user
SATISH
def loginpage(request): if request.method=='POST': username = request.POST.get('username') password1 = request.POST.get('password1') user=authenticate(request,username=username,password=password1) if user is not None: login(request,user) return redirect('select') else: return HttpResponse("Username and Password Incorrect") return render(request,'login.html')
SATISH
see the code
José Jorge
Solve? Not Try to help, yes. If you provide all details and context.
@Carlangueitor how I Can take de backup in Django automatically and then resto de that with an action button
Doragonsureiyā
@Carlangueitor how I Can take de backup in Django automatically and then resto de that with an action button
Don't tag people randomly, even if they seem knowledgeable. Most of the time, the person you tagged doesn't even know about the topic you just brought up. If people want to help you, they will - just be patient.
SATISH
After Login i mention Your all data show (only login Person) or and write data Two button mention
SATISH
def selectpage(request): return render(request,'select.html')
SATISH
def displaypage(request,id): data = ArticalData.objects.get(id=id) return render (request,'display.html',{'data':data})
SATISH
Do what I told you here
ya i mention but not got ans
Charly
ya i mention but not got ans
https://t.me/django/243563
SATISH
https://t.me/django/243563
login() missing 1 required positional argument: 'user' this error
José Jorge
ya i mention but not got ans
You need filter the data by the login user just Like Charly Román tell you, after that you Can show the data.
Charly
login() missing 1 required positional argument: 'user' this error
you don' t need to login, jsut use request.user
José Jorge
You Can use Django Forms to improve your code and make that more efficency
José Jorge
Django have a model form for user
SATISH
Reverse for 'display' with no arguments not found. 1 pattern(s) tried: ['display/(?P<id>[^/]+)\\Z']
SATISH
<a href="{% url 'display' %}" class="btn btn-outline-info btn-lg ml-5">Display All Articals</a> here any changes
SATISH
path('display/<id>',views.displaypage,name='display'), and Url
SATISH
Filter data by user just Like you did here by id
i mention but all data show also previous login persion without id if i mention id then Error
José Jorge
When you want show specifies data of a user you need have a identificator. When you go to show that data you Filter all data by the identificator(flag). The identificator the most times will Be the id of the user.
Bekhruzbek
Watch a video tutorial on how to post a video pls
Vorke
Is it possible to change user groups from Django admin dashboard?
Tamerlan
Who can give advice cms for content management?
Doragonsureiyā
Who can give advice cms for content management?
Your question is not related to Django. If it's a Python related question go to @Python group, otherwise please move to @PythonOfftopic group and ask there.
Doragonsureiyā
In django
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.
Masoud
def delete_number(request, contact_id): contact_delete = Contact.objects.get(id=contact_id) contact_delete.delete() return redirect('contacts:list')
David H
Hi, I have a question! Is it possible to iterate in parallell over a queryset in django?
Masoud
def delete_number(request, contact_id): contact_delete = Contact.objects.get(id=contact_id) contact_delete.delete() return redirect('contacts:list')
i have contact from , i will click to delete that contact remove as database and deleted know this def is not working
Shahzodbek
Assalam alaykum guys. What are the most secure authentication for django. Currently, I am using rest framework jwt authentication but I am not quite sure if it is safe.
Shahzodbek
I am using django jwt auth in my front end application. As you might know, jwt token holds user information and it is visible in browser. Therefore, I am kinda worried about it, or is that OK?
Dullah
Hi I have a django crud application working just fine, what i want is to add the delete confirmation form as a pop modal to the list view (im using function based view) without using bootstrap.
.
Hi I have a django crud application working just fine, what i want is to add the delete confirmation form as a pop modal to the list view (im using function based view) without using bootstrap.
1. Create a view class inherited from Django’s DeleteView, and link a URL to it 2. In the confirmation form, make it a POST request to the delete URL 3. Now submitting the form will straight away delete that item