Doragonsureiyā
I have coded this in over 6 different ways and each iteration successfully updates but painfully creates an updated record
Please provide a full explanation including all the details that you consider relevant. Your statement is too broad and there is no clear way to answer you, you have to explain: - what you're doing - what you're expecting - what you're using - where you're running the script - what Python version you're using - what packages and their versions you're using - and the most important thing: show the code YOU wrote (read rule 5️⃣ for that) and more details, that way your chances to get help will increase.
🦍S6t0m1 🍃🦂
Django 4.2.6
cj
I have coded this in over 6 different ways and each iteration successfully updates but painfully creates an updated record
have you tried using UpdateView instead? and not overriding get nor post but get_context_data instead?
🦍S6t0m1 🍃🦂
Yes
cj
Yes
show that code
🦍S6t0m1 🍃🦂
Wouldnt my issue be in the post because i am retrieving the values proper and all its just that after submitting updates, a new updated record is created rather than the same record being overwritten
奈姆
The code that you've shared looks right tho.
🦍S6t0m1 🍃🦂
The code that you've shared looks right tho.
It is correct, i just dont kNow why it creates another record
🦍S6t0m1 🍃🦂
That'll cloud the DB if each update produces a new record
奈姆
It is correct, i just dont kNow why it creates another record
It shouldn't be. Share your model code as well.
🦍S6t0m1 🍃🦂
https://pastebin.com/DQeQig6p
🦍S6t0m1 🍃🦂
https://pastebin.com/DQeQig6p
Here is each implementation i coded to update a view , all successfully updates but all painfully creates that other record
🦍S6t0m1 🍃🦂
🦍S6t0m1 🍃🦂
https://pastebin.com/DQeQig6p
I used generic view, class based, function based etc. All come to the same success and bug
🦍S6t0m1 🍃🦂
class Lab(models.Model): PKlab = models.BigAutoField(primary_key=True) - Pastebin.com https://pastebin.com/FThUz9uE
Bakhtiyarov
Hello! Which django admin library has modern beautifull design?
Charly
Hello! Which django admin library has modern beautifull design?
Many, have you done a search before asking here?
The Inspired
Models
I'm having trouble understanding your problem. What exactly is your problem again?
奈姆
I'm having trouble understanding your problem. What exactly is your problem again?
The ORM update operation of his code create a new entry/row during update. I couldn't find the root cause from the code that his shared tho. 😂
The Inspired
that shouldn't be happening
The Inspired
unless they have used POST method to update also
i am osho
hey , i am not able to import forms to my html code , everything is running correctly even getting output without any problem but just form part is not showing in the website ,
i am osho
{% extends "enrol/base.html" %} {% block content %} <h1> Add New Student</h2> <form action="" method="POST"> {% csrf_token %} {{form}} <button type="submit" class="btn btn-success">Add</button> </form> {% endblock content%}
i am osho
this is my code .
i am osho
no bro its not working this way also
Bakhtiyarov
Many, have you done a search before asking here?
Of course. If you used tell the best one
Charly
Of course. If you used tell the best one
There is no best one. It all depends on your needs and tastes
Kasem
Do you have any recommendations for YouTube channels that cover Django topics?
I don't use it but before i asked and told me about this django-jazzmin https://github.com/farridav/django-jazzmin
Doragonsureiyā
Impossible to help without details. Read this please: http://www.catb.org/~esr/faqs/smart-questions.html
cj
that's a very self-explanatory error
mansurbekh
Hi all how to upload django project to free server
mansurbekh
Hi all how to upload django project to free server
I uploaded it to a server called Vercel
mansurbekh
mansurbekh
500: INTERNAL_SERVER_ERROR
when I log in, I get this error, how can I fix it?
Sheljin
Hi all how to upload django project to free server
Python anywhere is free and its working with limitations
mansurbekh
Python anywhere is free and its working with limitations
I'm sorry but I need to upload the project to the server
mansurbekh
should work 24/7 when accessing the site
Sheljin
we can hoist our django project to pythonanywhere for free
Sheljin
it will be accessible 24/7
奈姆
500: INTERNAL_SERVER_ERROR
Find and check the server log. This error is too generic...
奈姆
500: INTERNAL_SERVER_ERROR
I don't use Vercel. You have to figure out (google) how to find the logs... maybe here: https://vercel.com/docs/functions/logs
شهرزاد محمد
Hi all how to upload django project to free server
https://render.com/ or pythonanywhere
Samir
500: INTERNAL_SERVER_ERROR
U cant fix it cuz this is not client error
Alison
Hi guys! I have a question, I have performance losses when using too much template inheritance?
.terrri
if request.method == 'PATCH': id=pk employee=EmployeeList.objects.get(pk=id) serializer=EmployeeSerializer(employee,data=request.data,partial=True) if serializer.is_valid(): serializer.save() return Response({'msg': 'Patch updated partially'}) return Response(serializer.errors) From the front-end does it accept only updated fields or all the fields
.terrri
From the front-end sends all the fields (even unchanged ones), it will still work because the serializer can handle full data due to partial=True. However, it's better practice to send only the updated fields.
export const updateEmployee = async (id, updatedEmployee) => { try { const response = await fetch(http://127.0.0.1:8000/employees/api/${id}, { method: "PATCH", headers: { "Content-Type": "application/json", }, body: JSON.stringify(updatedEmployee), }); console.log("updating..", JSON.stringify(updatedEmployee)); Is this correct format but it's showing undefined 404 not found what may be the root cause I am unable to find it out
sanket 💜
export const updateEmployee = async (id, updatedEmployee) => { try { const response = await fetch(http://127.0.0.1:8000/employees/api/${id}, { method: "PATCH", headers: { "Content-Type": "application/json", }, body: JSON.stringify(updatedEmployee), }); console.log("updating..", JSON.stringify(updatedEmployee)); Is this correct format but it's showing undefined 404 not found what may be the root cause I am unable to find it out
verify the url http://127.0.0.1:8000/employees/api/${id} into the backend Ex: path('employees/api/<int:pk>/', EmployeeDetailView.as_view(), name='employee-detail'), Make sure from the front end side you are passing the id correctly. (Try to debug everything) Also make sure there that you have installed the required Middleware like: django-cors-headers And before testing it directly into front end try to test this API in postman or thunder client.
sanket 💜
Can you please share the code which is written for this functionality. from urls, views & serializers.
Carlos Alberto
export const updateEmployee = async (id, updatedEmployee) => { try { const response = await fetch(http://127.0.0.1:8000/employees/api/${id}, { method: "PATCH", headers: { "Content-Type": "application/json", }, body: JSON.stringify(updatedEmployee), }); console.log("updating..", JSON.stringify(updatedEmployee)); Is this correct format but it's showing undefined 404 not found what may be the root cause I am unable to find it out
Use this code instead export const updateEmployee = async (id, updatedEmployee) => { try { const response = await fetch(`http://127.0.0.1:8000/employees/api/${id}`, { method: "PATCH", headers: { "Content-Type": "application/json", }, body: JSON.stringify(updatedEmployee), }); console.log("Updating...", JSON.stringify(updatedEmployee)); if (!response.ok) { throw new Error(`Error updating employee: ${response.status} ${response.statusText}`); } const data = await response.json(); console.log("Updated employee:", data); return data; } catch (error) { console.error("Failed to update employee:", error.message); throw error; // Re-throw the error for further handling in the caller function. } };
Светлана
Help please. I have a mistake Skipping analyzing "django.urls": module is installed, but missing library stubs or py.typed marker.
Prabhakar
Issue on views.py bro
Doragonsureiyā
Issue on views.py bro
Read this please: http://www.catb.org/~esr/faqs/smart-questions.html
நட்புடன்
I wanna create a custom user like Employee with relevant details I am stuck in authentications Can any one guide me even with any tutorial link is fine I am a newbie in Django
S
I have to implement payment integration from one user to another user in my Django project, how can i do that?
hadi
Hi how can I integrate crypto currency payment in my project ?
Swift
Hi how can I integrate crypto currency payment in my project ?
https://medium.com/coinmonks/crypto-payment-gateway-development-ca4771fa53ca
Кит
What do you think is the best way to make it possible to receive notifications in real time? So that the client simply pings the server with a request: "Are there new notifications?" Or do tracking via the Redis broker, which will send them to the client via Server-Sent Events?
CodeThlete
Hi, I have some issues with csrfmiddlewaretoken. I am able to add new user with old csrfmiddlewaretoken in django's admin panel Why it's happening?? this is my settings.py 'django.middleware.csrf.CsrfViewMiddleware', CSRF_USE_SESSIONS = True # CSRF_COOKIE_SECURE = False # Ensures the CSRF cookie is only sent over HTTPS CSRF_COOKIE_HTTPONLY = True # Ensures the CSRF cookie is not accessible via JavaScript #csrf cookie age session only CSRF_COOKIE_AGE = 3600 CSRF_USE_SESSIONS = False CSRF_COOKIE_SAMESITE = "Strict" CSRF_COOKIE_PATH = '/'
CodeThlete
I was only aware of the csrftoken, wasn't aware of the csrfmiddlewaretoken
Santoshi
Is there anyone who has created a elearning platform with django
Doragonsureiyā
Is there anyone who has created a elearning platform with django
Please don't ask meta questions like: - Any user of $x here? - Anyone used technology $y? - Hello, I need help on $z! Just ask about your problem directly! If you don't know what to ask, please read: http://catb.org/~esr/faqs/smart-questions.html
Ako
Could someone help me solve this problem? In my models, the primary key is named id. I would like the paths in the Swagger documentation generated by drf-spectacular to appear like this: /api/tasks/cards/{card_id}/comments/{comment_id}/ /api/tasks/cards/{card_id}/change-order instead of: /api/tasks/cards/{id}/comments/{id}/ /api/tasks/cards/{id}/change-order I managed to solve this by using lookup_field and overriding get_object. However, I get warnings: Warning [CardViewSet]: could not derive type of path parameter "card_id" because model "tasks.models.card.Card" contained no such field. Consider annotating parameter with @extend_schema. Defaulting to "string". An important point is that I want to keep the primary key name as id, but display card_id in Swagger. I could get rid of the warnings by specifying parameters for each method, but I feel like I'm doing something wrong.
Кит
Channels
WebSockets?