Doragonsureiyā
How to get latest entry form db tables
What are you talking about?
zeus
How to get latest entry form db tables in django
Maxim
How to get latest entry form db tables in django
you just repeated what you already said it doesn't make your question any clearer
zeus
Ok I need only the last registered person details then I can pass it to my template
chipolino
How to get latest entry form db tables
sort in reverse order and ask first
chipolino
How to get latest entry form db tables in django
maybe you mean How to get latest entry from db tables in django
chipolino
from not form
chipolino
Thank you ❤️
maybe there is a function in django last then it is not necessary to sort in reverse order only in direct
Suren
query = self.request.GET.get('q') sights = Sights.objects.filter( Q(title__icontains=query) | Q(content__icontains=query) ) how to reply that query is not found, if it is not found?
 
How to get latest entry form db tables
you can use one of these: 1- books.objects.all().last() 2- queryset.reverse()[0]
.
hi the form just does not appeare and i couldn't find out where the problem is here is the view def updateWorker(request,pk): formName = 'Worker' worker = Staff.objects.get(worker_id=pk) form = StaffForm(instance=worker) if request.method == 'POST': worker.name = request.POST.get('name') worker.age = request.POST.get('age') worker.address = request.POST.get('address') worker.department = request.POST.get('department') worker.title = request.POST.get('title') worker.email = request.POST.get('email') worker.phone = request.POST.get('phone') worker.salary = request.POST.get('salary') worker.rate = request.POST.get('rate') worker.save() return redirect('home') context = {formName:'formName',form:'form',worker:'worker'} return render(request, 'users/test1.html',context)
rtg
Hi! I continue with error in DJANGO-ALLAUTH using google API: Access blocked: The request from this application is invalid....Error 400: redirect_uri_mismatch
rtg
Does anyone master this tool?
Mirco
Does anyone master this tool?
You have to register your redirect URIs into Google app for oauth2
rtg
Now is ok, i delete the "Orígenes autorizados de JavaScript" url and now is ok
rtg
now only have URI redirect http://localhost:8000/accounts/google/login/callback/ And other (Javascript... is null). But is ok.
rtg
thanks!
Mirco
Doragonsureiyā
thanks!
You're welcome! 😊
.
hello i made a view to update an object but when i send the form i still get this error {{Cannot assign "'2'": "Staff.department" must be a "Department" instance.}} in models i've made a field to replace the id with "worker_id" is this the probelm ? the model: class Staff(models.Model): name = models.CharField(max_length=200,null=True) age = models.IntegerField() address = models.CharField(max_length=25,null=True) worker_id = models.AutoField(primary_key=True)
V
[ {“Dg set”: “Diesel generator”}, {“Organization”: “Organisation”}, {“Group”: “Organization”}, {“Orange”: “Kinnu”}, {“Orange”: “narangi”} ] Expected Output: [[“Organization”, “Organisation”, “Group”], [“Dg set”, “Diesel generator”], [“Orange”, “Kinnu”, “narangi”]]
h
Hey all, hope you are doing great. I have one small question to ask, why the initialization of middlewares happens from bottom to top? To explain it a bit more lets say I have 2 custom middleware A and B and I have added a print statement at the init function now the one thing I noticed is that the print statement for B is executed first and then the A part. As the initialization happens as soon as we start the dev server I do not get why the execution of initialization is bottom to top? Thanks
C.
I try to use gunicorn deploy django at windows but I have an error ModuleNotFoundError: No module named 'fcntl'
Muhammadali
Muhammadali
if you want deploy to ubuntu server I’ll help with my pleasure
C.
Thanks a lot for your kind support
Rohan
if you want deploy to ubuntu server I’ll help with my pleasure
Please help me, I tried deploying in AWS Ubuntu with gunicorn and nginx but static files were not loading
Doragonsureiyā
Please help me, I tried deploying in AWS Ubuntu with gunicorn and nginx but static files were not loading
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.
UnforgivenIII
hey guys can u pls tell road map to find good job in django
داودخان
AttributeError: 'DjangoTestAdapter' object has no attribute 'factory' getting this error in test
Pavel
Hello friends, could someone point me to the most noticeable errors in the project. No one has ever reviewed my code, so I may not be aware of many mistakes and bad practices. Thanks to those who respond. Github: https://github.com/welel/noted
Adorilson
Hello friends, could someone point me to the most noticeable errors in the project. No one has ever reviewed my code, so I may not be aware of many mistakes and bad practices. Thanks to those who respond. Github: https://github.com/welel/noted
Great code, guy. I notived that some .mo files was commited (at least ru language). In fact, this file extension was not in .gitginore file. This is something that I would fixed.
Same
Hello. Does anyone know why when I add whitenoise to my Django project in production, it only shows me a Server Error 500 and no message in the console?
Riad
Should I learn html rendering stuffs in django? Web development now a days are heavily api based. Is there any point to learn html rendering?
chipolino
Should I learn html rendering stuffs in django? Web development now a days are heavily api based. Is there any point to learn html rendering?
if you start work in frontend you will need it, but template system in django less and less. My opinion
chipolino
in spa you use html layout elements
chipolino
for example in react const root = ReactDOM.createRoot(document.getElementById('root')); root.render(<h1>Hello world!</h1>);
chipolino
Using raw html css is too boing and tedious now, SPA is everywhere.
const root = ReactDOM.createRoot( document.getElementById('root') ); function tick() { const element = ( <div> <h1>Hello, world!</h1> <h2>It is {new Date().toLocaleTimeString()}.</h2> </div> ); root.render(element);} setInterval(tick, 1000);
Same
what do you mean by whitenoise?
It is a library for handling static files.
Riad
in spa you use html layout elements
yeah but they only consume api. I asked whether django templaes are still a thing or not for learning in 2023
chipolino
It is a library for handling static files.
I can't help you I don't know this library
Riad
I am fluent in DRF, and hesitating should I learn django templating or not
chipolino
in yout study list
Same
I am trying to deploy a production project in Render, so I resorted to Whitenoise to handle static files as it is what the render documentation recommends, but I have not been successful in deploying
chipolino
do you use proxy server in your project?
Same
did you call? python manage.py collectstatic
Yes, when I run the manage collectstatic the project works fine, but if I add the WhiteNoise configuration to the settings it stops working
chipolino
did you read this doc? https://whitenoise.evans.io/en/latest/django.html
chipolino
is it library?
Same
what is Render?
It is similar to Heroku
Same
or PythonAnyWhere
chipolino
try to run the project on local machine
chipolino
use docker docker-compos or venv if you can
Same
try to run the project on local machine
It gives me the same error. I also came to think that it was a compatibility issue with the platform or something like that.
Same
use docker docker-compos or venv if you can
I am using venv. I already tried it with docker and the same error
chipolino
try to get css for example or js from simple http request in browser by full adress
chipolino
try to start new empty project and just add WhiteNoise
Same
try to get css for example or js from simple http request in browser by full adress
Regardless of the address, it gives me the error. This does not happen if, for example, I load a page that only returns a "Hello world" with HttpResponse
Mekdim
i'm facing a problem with rendering back the datas on the html page i have model with pdf = models.FileField(upload_to='Files/',db_column="PDF" ,null=True,blank=True) then inside my view def pdfViewPage(request,id): try: currenSelectedPdfItemObject = PdfInformation.objects.get(id = id) context = { "pdf":currenSelectedPdfItemObject.pdf, "tittle":currenSelectedPdfItemObject.tittle } return render(request, 'pdfView.html',context) except: pass the problem rises now when i try to render the pdf on the webpage here is the code from the template file <div class="mainPdfDisplayHolder"> <div id="pdf"> <object class="mainPdfDisplay" data="{{ pdf.url }}" width="80%" height="90vh" style="border: 1px solid black;"> </object> </div> </div> 👆 this won't display the pdf file i don't really get it what i am missing here , when i try if the file works like the base url with the file path the pdf file will displayed but when it comes to the template it won't open i've tried embed and iframe also but doesn't seem to work and i am stuck here for about day any suggestion would be appreciated thanks u!
Doragonsureiyā
Are you looking for Django REST Framework documentation? Here you have it: https://www.django-rest-framework.org/
Ashish
Hello sir,i am new in python so i really don't know much,so please can you help me to find a solution of the problem Write a programme to implement 8-puzzle using steepest ascent hill climbing in python?