Брат
You should override post function in your class
Jean-Yves
i don't wanna use a POST method
Брат
3 - Class based views - Django REST framework https://www.django-rest-framework.org/tutorial/3-class-based-views/
Jean-Yves
it's kind of specific, i wanna do it with get but , I can't come yet
Брат
it's kind of specific, i wanna do it with get but , I can't come yet
You mean by going to some URL, your A object should be created?
Брат
I know only one way of doing this don't take it serious and ask from others: 1. Go to urls and set up new path which will include 'somename/<field1>/<field2>/, YourViewName.as_view() 2. Get the object in your view with those fields and create it
fateme
hi guys. have you ever got in trouble with .heic photo format and django imagefield ? It seems django imagrfield does not support the .heic photo formating! have you any solotion?
fateme
try file field instead
does it make diffrence ? 🤔
Benson
Good day guys. I'm trying to implement a location feature on a django real estate project. in the project, a user will see a property and alongside it a map that shows the property on it represented by a marker. Thing is, I'm a beginner and don't know how to do it yet. I'd like to ask how one goes about it from the bottom up, from the back end ( I figured out the interface. ) I know this is a HUGE ask, but I'm politely asking anyway. Any assistance will be highly appreciated. Thanks.
BigBad
Hello, what are the best versions of Django to start learning now? And are any versions backwards compatible?
Alik
Guys, need help. both functions are trying to change the same object. Works only the last one launched. How can i fix it? @transaction.atomic Def foo(pk): Obj=Object.objects.get(pk) Obj.foo += 1 Obj.save() @transaction.atomic Def bar(pk): Obj=Object.objects.get(pk) Obj.bar += 1 Obj.save()
There are several ways to avoid race conditions, 1. Try to use F functions obj.bar = F(‘bar’) + 1 obj.foo = F(‘foo’) + 1 2. Try to use update fields parameter when calling obj.save(update_fields=[‘foo’])
Brian
Well, Here's a code share(https://codeshare.io/ayvgRn) of the issue. I'll appreciate anyone who'll engage me on this.
Brian
read carefully https://t.me/django/198347
Apologies. I just sent the link here:https://t.me/django/198348
Maxim
Apologies. I just sent the link here:https://t.me/django/198348
you did not do what is strongly recommended in the last line
Brian
So is anyone aware of what could be the issue with my urls set up? The documentation led me to this set up but still I can't get past the error 404.. Code here: https://codeshare.io/ayvgRn
....
https://stackoverflow.com/questions/71184672/when-i-trying-to-object-save-i-got-an-error-missing-1-required-keyword-only-a , can anyone answer this question ? ?
Gowda
How to authenticate microsoft using DJANGO
Gowda
Django and python
Anonymous
Do you mean like in an array? No. It's because of how relational databases work - they return SETS. The only way is if you are sure that in a queryset you will get only specific number of records. Say we create a log record each hour, then for a day we could use indexes and etc.
Thanks for your answer.. But how would it be possible to sort a SET, if i try to sort queryset using order_by method it would return a queryset with ordered object, what I'm trying to do is get index of single object without having to load all the queryset values.
Брат
Getting default Validation error when trying to create a User.
Брат
http://linkode.org/#8OqTqHM6bGd7Psx3urBMz4
Брат
{ "first_name": "string", "last_name": "string", "username": "anqov", "email": "user@example.com", "password": "string2", "password2": "string" } When posting above dictionary, Im getting default validation error: { "username": [ "A user with that username already exists." ] }
Alex
Thanks for your answer.. But how would it be possible to sort a SET, if i try to sort queryset using order_by method it would return a queryset with ordered object, what I'm trying to do is get index of single object without having to load all the queryset values.
> But how would it be possible to sort a SET From the theoretic perspective, a set not necessarily should be unsorted, like in python. It just can be not sorted. Sets only insure that you don't have repeated elements. > get index of single object without having to load all the queryset values. then just get that element. Simple as that.
Javokhir
from django.contrib.admin.models import LogEntry LogEntry.objects.all().delete()
Javokhir
hi everyone I need help I want to delete recent actions in django admin panel where should I use this code in models.py or admin.py ....
tech-tycoon
I think ,you should put this code in views.py
tech-tycoon
And then connect it to a url and proceed
Ademola
Hi. I am trying to paginate my list in Django table without hitting database.
Ademola
But I want it to affect the listing table directly from front. Not the database.
Alex
hi everyone I need help I want to delete recent actions in django admin panel where should I use this code in models.py or admin.py ....
Why do you want to do that at all? Is this table got like 100kkk records and is hard to manage? For adhoc you can simply run it in django's shell - manage.py shell
Alex
Hi. I am trying to paginate my list in Django table without hitting database.
Well, you could cache the queryset somewhere so it doesn't hit DB. But honestly the question sounds like "I want to pump up my muscle, but don't want exercising."
Pythonista
Can someone help me? How do I consume an external API with django to bring the data to the Front End?
Pythonista
I need a reverse proxy for this, but I don't know how to do it.
Hossein
Can someone help me? How do I consume an external API with django to bring the data to the Front End?
You want to get data from a third party API within django? if yes, you can make requests with requests python library
Anonymous
> But how would it be possible to sort a SET From the theoretic perspective, a set not necessarily should be unsorted, like in python. It just can be not sorted. Sets only insure that you don't have repeated elements. > get index of single object without having to load all the queryset values. then just get that element. Simple as that.
Getting the element wasn't a problem, what i wanted was in what order it sits within the sorted list of (or set?) Queryset, Let's say there's a post created at 1am, 4am & 6am. If i sort the post queryset by 'created_at' field, its order would be 0 - a post created at 1am, 1 - a post created at 4am, 2 - a post created at 6am... If i wanted to get the index of the post made at 6am, I would expect a value 2... I just don't want to load all the posts, just the index of the single element or object within queryset Don't know if my explanation is clear Sorry for my bad English.
Hossein
I did but it didn't work because the headers are not released.
which headers? you can set the headers u want with requests as well. if they're authentication headers, u first need to make a post request and work with the response data. check the API's documentation for that
Rudraksh
def search(request): ids=[] if request.method == 'POST': text=request.POST.get('searchQuery') r1=Cheque.objects.filter(accountName__contains=text) r2=Cheque.objects.filter(chequeNumber__contains=text) r3=Cheque.objects.filter(chequeAmount__contains=text) for i in r1: ids.append(i) for j in r2: if j in ids: continue else: ids.append(j) for k in r3: if k in ids: continue else: ids.append(k) return render(request,'cheque/search.html',{'ids':ids})
Rudraksh
Help me to make it more productive
Rudraksh
what DB?
Sqlite
Rudraksh
use QuerySet.values() method
I get 3 queryset. I want all the unique records from all three into one set. How can i do this ?
Maxim
I get 3 queryset. I want all the unique records from all three into one set. How can i do this ?
all values from the three sources, those that are in all three, or those that are only in one of them ?
Maxim
‎Nithin ask @pythonofftopic
Nithin
Ok
Alex
def search(request): ids=[] if request.method == 'POST': text=request.POST.get('searchQuery') r1=Cheque.objects.filter(accountName__contains=text) r2=Cheque.objects.filter(chequeNumber__contains=text) r3=Cheque.objects.filter(chequeAmount__contains=text) for i in r1: ids.append(i) for j in r2: if j in ids: continue else: ids.append(j) for k in r3: if k in ids: continue else: ids.append(k) return render(request,'cheque/search.html',{'ids':ids})
1 If you only need only specific set of fields, then it's better to use either only or values 2 You actually don't need 3 separate queries - you can unite the conditions by Q def search(request): if request.method == 'POST': text=request.POST.get('searchQuery') qs=Cheque.objects.filter( Q(accountName__contains=text) | Q(chequeNumber__contains=text) | Q(chequeAmount__contain=text) ).only('id') return render(request,'cheque/search.html',{'qs':qs})
Jeff
Hi, I am new to web development and also new to dJango platform...I have created a custom field in my user registration page
Jeff
But the custom field doesn't save into my model... can anyone enlighten me>
Jeff
I have uploaded here https://dpaste.org/TPJ1
Alex
But the custom field doesn't save into my model... can anyone enlighten me>
What field? Also if form.is_valid(): form.save() return redirect("/home") You should create a case when the form is not valid. Then you probably want to pass it back to a user to show errors.
Jeff
genres is the custom field I want to add
Jeff
Yes. I am thinking to create the case if form is not valid.. I planned to do it after settling this genres custom field
Jeff
I am very new to web development... I am still figuring it out ..
Rudraksh
in any case, use set instead of list
def search(request): ids=set() if request.method == 'POST': text=request.POST.get('searchQuery') r1=Cheque.objects.filter(accountName__contains=text) r2=Cheque.objects.filter(chequeNumber__contains=text) r3=Cheque.objects.filter(chequeAmount__contains=text) ids=r1.union(r2) ids=ids.union(r3) return render(request,'cheque/search.html',{'ids':ids})
Alex
I have uploaded here https://dpaste.org/TPJ1
There is nothing I can see here. Probably there are some errors on validation step. So you better to either add a clause for that or use a debugger. Also, regarding your form: https://docs.djangoproject.com/en/4.0/topics/forms/modelforms/#overriding-the-default-fields https://dpaste.org/NTg2
Jeff
Thanks
Coding
I'm new to django I'm building project where I'm using react for frontend and django rest framework for backend. Sqlite database. I want to perform inner join between 4 tables. How to do that.
Jeff
cannot make migration after adding AUTH_USER_MODEL = 'mysite.MyUser'
Richard
Hello to all
Richard
I'm building à new project with django and python.
Richard
However, when I start up Django admin I have not a good display.
Doragonsureiyā
However, when I start up Django admin I have not a good display.
Read this please: http://catb.org/~esr/faqs/smart-questions.html#intro
𝔐𝔞𝔥𝔡𝔦 𝔉𝔦𝔯𝔬𝔲𝔷𝔧𝔞𝔥
Hello, any help is appreciated: https://stackoverflow.com/questions/71193682/drf-serializer-integerfield-validation-to-make-sure-foreignkey-does-exists
Baqer
Hi 👋 I have problem when run command [ docker-compose up --build ] And my error is : Invalid mount config for type "bind" : invalid mount path : " " mount path must be absolute
Yusra
Hey there, I'm using Djoser and for activation user process, how do I send activation link to there email without specifying {EMAIL_HOST_USER,EMAIL_HOST_PASSWORD} in settings file? Any help would be much appreciated.