Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to get json data from django views using ajax
I have a form as follows <form id="bar_graph_form" method="post" action="display_bar_graph" name="bar_graph_form"> {% csrf_token %} <select class="form-select bar_dropdown" aria-label="Default select example" name="bar_graph_dropdown"> <option selected>Select data to visualise</option> <option value="1">By category</option> <option value="2">By language</option> </select> </form> <div class="bar_graph_container"> </div> The idea is that when the dropdown value is changed, the form has to submit via ajax and trigger the django view My JS code is as follows function dropdown_change_function(event) { event.preventDefault(); var data = new FormData($('#bar_graph_form').get(0)); console.log('this is happening') $.ajax({ url: $(this).attr('action'), type: $(this).attr('method'), data: data, cache: false, processData: false, contentType: false, success: function (data) { console.log('form submitted successfully') console.log(data) } }) } $(document).ready(function() { $('.bar_dropdown').on('change', function() { document.forms['bar_graph_form'].submit(dropdown_change_function); }) }) Using this code, I am able to successfully submit the form on dropdown change, but the ajax function is not called. Here is my django view def display_bar_graph(request): if request.method == 'POST': user_select = request.POST['bar_graph_dropdown'] if int(user_select) == 1: graph = open('./graphs/bar1.html', 'r').read() if int(user_select) == 2: graph = open('./graphs/bar2.html', 'r').read() context = {'html_data': graph} print('the form was submitted using ajax') return JsonResponse(context) What I am trying to do is to display a particular plotly based graph in the template. I already have the graphs saved as HTML files and would … -
DJANGO: I have been trying do calculation in Views and call function whenever i click on a button
Hello & Thank YOU For Helping ME. I have been trying to make calculations using django but i keep on hitting different errors. the latest one was Base 10 error in django. VIEWS.PY def subs(request, pk): sw = Swimmers.objects.filter(id=pk).values('sessions').first() sw_list = sw sw_lists = sw +1 return JsonResponse(sw_lists, safe=False) MODEL.PY class Swimmers(models.Model): name = models.CharField(max_length=200, blank=False) lastname = models.CharField(max_length=200, blank=False) idno = models.CharField(max_length=200, blank=False, null=True) sessions = models.IntegerField(blank=False) totalsessions = models.CharField(max_length=200, blank=False ) dateofpayment = models.CharField(max_length=200, blank=False) phone = models.CharField(max_length=30, blank=False, null=True) date_from = models.DateField(null=True) date_to = models.DateField(null=True) type_choice = ( ("basic", "Basic"), ("3x1 week", "3x1 Week"), ("1 session", "1 Session"), ("2x1", "2x1"), ) type = models.CharField(max_length=200, blank=False, null=True, choices=type_choice, default=type_choice) ammount = models.DecimalField(max_digits=6, decimal_places=2, blank=False, null=True) registration = models.DateField(default=timezone.now) keenphone = models.CharField(max_length=30, blank=False, null=True) def __str__(self): return self.name URLS.PY path('swimminglist/', views.SWGIndex.as_view(), name="swimminglist"), path('create/', views.SWGCreateView.as_view(), name='create_swimmer'), path('update/<int:pk>', views.SWGUpdateView.as_view(), name='update_swimmer'), path('read/<int:pk>', views.SWGReadView.as_view(), name='read_swimmer'), path('delete/<int:pk>', views.SWGDeleteView.as_view(), name='delete_swimmer'), path('subt/<int:pk>', views.subs, name='subt'), Thank You For The Help And Support Much Appreciate It. Have A Blessed Day You All. -
null value in column "cover_photo" violates not-null constraint
Here's the error, which is strange because I use github search to search my repository and there's nothing called "cover_photo": null value in column "cover_photo" violates not-null constraint and here's the associated code, i ensured all the model fields have null=True, but that didn't fix it.: class Anon(models.Model): username = models.OneToOneField(User, default=None, null=True, unique=True, on_delete=models.CASCADE) first_name = models.CharField(max_length=70, default=None, null=True) last_name = models.CharField(max_length=70, default=None, null=True) topic_expert = models.CharField(max_length=70, default=None, null=True) company = models.CharField(max_length=70, default=None, null=True) title = models.CharField(max_length=70, default=None, null=True) trailings = models.CharField(max_length=70, default=None, null=True) email = models.EmailField(max_length=70, null=True) password = models.CharField(max_length=70, default=None, null=True) password2 = models.CharField(max_length=70, default=None, null=True) missionstatement = models.TextField(max_length=300, default=None, null=True) interests = models.TextField(max_length=300, default=None, null=True) profileImages = models.ManyToManyField(Profile_image, default=None, null=True) experiences = models.ManyToManyField(Experience, default=None, null=True) professional_experience = models.OneToOneField(Professional_Experience, default=None, null=True, on_delete=models.CASCADE) education_experience = models.OneToOneField(Education_Experience, default=None, null=True, on_delete=models.CASCADE) language_experience = models.OneToOneField(Language_Experience, default=None, null=True, on_delete=models.CASCADE) expertises = models.ManyToManyField(Expertise, default=None, null=True) latest_change_date = models.DateTimeField(default=timezone.now) #playlists = models.ManyToManyField(Playlist)= sent_messages = models.ManyToManyField(Comment, default=None, related_name='sent_messages', null=True) received_messages = models.ManyToManyField(Comment, default=None, related_name='received_messages', null=True) posted_comments = models.ManyToManyField(Comment, default=None, related_name='posted_comments', null=True) saved_comments = models.ManyToManyField(Comment, default=None, related_name='saved_comments', null=True) posts = models.ManyToManyField(Post, blank=True, default=None, null=True) categories = models.ManyToManyField(Category, default=None, null=True) post_sort = models.IntegerField(choices=POST_SORT_CHOICES, default=0) references = models.IntegerField(default=0) topic_sections = models.ManyToManyField(Topic_Section, default=None, null=True) sub_topic_sections = models.ManyToManyField(Sub_Topic, default=None, null=True) … -
Sort search results in django
I have a function that returns a queryset and an html file with the results, def get_queryset(self): # new query = self.request.GET.get('q') sort = '-date' post_list = Post.objects.filter( Q(title__icontains=query) #| Q(title__icontains=query) another field ).order_by(sort) return post_list form: <form class="form-inline my-2 my-lg-0" action="{% url 'search_results' %}" method="get"> <input class="form-control" name="q" type="text" placeholder="חפש מאמרים"> <button class="btn btn-outline-success my-sm-0" type="submit">חפש</button> </form> In the template for the results I want there to be a couple of links to sort by date, votes etc... -
How to set Unique Constraint across multiple tables in django?
We have two models, they are in One to One relationship: class A(models.Model): first_field_A = ... second_field_A = ... class B(models.Model): first_field_B = ... a = models.OneToOneField(A, on_delete=models.CASCADE) I need to define a Unique Constraint for first_field_A and second_field_A of model A and first_field_B of model B. Is that even possible? I have tried this: class A(models.Model): ... class Meta: constraints = [UniqueConstraint(name='unique_constraint', fields=['first_field_A', 'second_field_A', 'b__first_field_B'] ) ] and I've got this error: django.core.exceptions.FieldDoesNotExist: A has no field named 'b__first_field_B' Why we don't have access to fields of related tables? What is the alternative? -
ModuleNotFoundError: No module named 'django' get it from apache2 err log from ubuntu 20
this is the whole error log [Sun Apr 10 10:18:09.057500 2022] [wsgi:error] [pid 122773:tid 140541313599232] [remote 83.244.126.186:58941] Traceback (most recent call last): [Sun Apr 10 10:18:09.057553 2022] [wsgi:error] [pid 122773:tid 140541313599232] [remote 83.244.126.186:58941] File "/home/sk/saree3co/sash/wsgi.py", line 12, in [Sun Apr 10 10:18:09.057560 2022] [wsgi:error] [pid 122773:tid 140541313599232] [remote 83.244.126.186:58941] from django.core.wsgi import get_wsgi_application [Sun Apr 10 10:18:09.057584 2022] [wsgi:error] [pid 122773:tid 140541313599232] [remote 83.244.126.186:58941] ModuleNotFoundError: No module named 'django' [Sun Apr 10 10:18:11.068338 2022] [wsgi:error] [pid 122773:tid 140541204494080] [remote 83.244.126.186:58940] mod_wsgi (pid=122773): Failed to exec Python script file '/home/sk/saree3co/sash/wsgi.py'. [Sun Apr 10 10:18:11.068391 2022] [wsgi:error] [pid 122773:tid 140541204494080] [remote 83.244.126.186:58940] mod_wsgi (pid=122773): Exception occurred processing WSGI script '/home/sk/saree3co/sash/wsgi.py'. [Sun Apr 10 10:18:11.068510 2022] [wsgi:error] [pid 122773:tid 140541204494080] [remote 83.244.126.186:58940] Traceback (most recent call last): [Sun Apr 10 10:18:11.068531 2022] [wsgi:error] [pid 122773:tid 140541204494080] [remote 83.244.126.186:58940] File "/home/sk/saree3co/sash/wsgi.py", line 12, in [Sun Apr 10 10:18:11.068534 2022] [wsgi:error] [pid 122773:tid 140541204494080] [remote 83.244.126.186:58940] from django.core.wsgi import get_wsgi_application [Sun Apr 10 10:18:11.068548 2022] [wsgi:error] [pid 122773:tid 140541204494080] [remote 83.244.126.186:58940] ModuleNotFoundError: No module named 'django' -
how can I receive notification by another user using channels in django?
actually, this is the first time I use channels but it's an easy concept to understand. I followed a tutorial that took me to the way in which I can send the notification the real-time but there's a part that I can't see at any tutorial where they are oblivious to it. all tutorials show how can send a notification or messages via chat when I do that for a single user after I open the new page, the page works fine. for example, if I logged in by username "test" and opened a new browser logged in by username "test" will be working fine the problem is that: when I try to open for example an "incognito page" by google chrome to use a different user such as "new test" username that I want him to receive the notification we can consider him a target user from the sender on the main page "test". now the data is changing in the data but I can't see that change in front of my eyes unless I reload the web page. when I tested that out I see javascript doesn't receive any of the data in the "new test" user and … -
Django Template Tag Filter
How do I display a list of students of a particular level using template tags? {% for student in student_list %} <li>{{ student.name }}</li> <li>{{ student.level }}</li> {% endfor %} This code just displays the list of all students’ names and levels, but I just want it to show the names of students that are, for example, freshmen. Is that possible and how do I do that? -
Django. Datefield format in html
I want do like this: enter image description here date = models.DateField(auto_now_add=True, auto_now=False) View: class Blog(ListView): model = Post template_name = 'blog/blog.html' context_object_name = 'posts' def get_context_data(self, *, object_list=None, **kwargs): context = super().get_context_data(**kwargs) return context def get_queryset(self): post = Post.objects.filter().select_related().defer() return post HTML: <a href="#" class="blog_item_date"> <h3>{{ post.date.day }}</h3> <p>{{ post.date|date: 'M' }}</p> </a> But i get error is: Could not parse the remainder: ': 'M'' from 'post.date|date: 'M'' -
DJANGO I am trying to add +1 whenever i click on a button Add - invalid literal for int() with base 10: 'sessions'
invalid literal for int() with base 10: 'sessions' MYCODE def subs(request, pk): sw = Swimmers.objects.filter(id=pk).values('sessions').first() sw_list = list(map(int, sw )) sw_lists = list(map(lambda x: x + 1, sw_list )) return JsonResponse(list(sw_lists), safe=False) -
How to use custom function for account activation in django graphql auth
I am using django-graphql-auth to send account activation email. It has below method, https://github.com/PedroBern/django-graphql-auth/blob/master/graphql_auth/mixins.py#L200 However I need to use my own custom function since I am using third party api service. Using my function I am able to send the email however I am not sure how can I override the default behavior. I am seeing there is an async_email_fucn at below, https://github.com/PedroBern/django-graphql-auth/blob/master/graphql_auth/mixins.py#L219 Please suggest. -
Django template- If an DateTimeField value taken from Foreignkey passed to a url, an error occurs: 'str' object has no attribute 'strftime'
I'm quite new to django and trying to figure out why I'm getting an AttributeError: 'str' object has no attribute 'strftime' when passing a datetime object to a url from a DateTimeField() value thru ForeignKey. Here are the sample codes I'm using and trying to pass last_checked value from Scrape Model. model.py class Site(models.Model): ... class Scrape(models.Model): ... last_checked = models.DateTimeField(auto_now_add=True) site = models.ForeignKey(Site, on_delete=models.SET_NULL, related_name='scrapes') url.py from django.urls import path, register_converter from . import views class DateConverter: regex = '\d{4}-\d{1,2}-\d{1,2}' def to_python(self, value): return datetime.strptime(value, '%Y-%m-%d').date() def to_url(self, value): return value.strftime('%Y-%m-%d') register_converter(DateConverter, 'date') urlpatterns = [ path('task/<pk>/<date:date_scraped>/', views.scrape_data_csv, name='scrape-csv'), ] If I'm passing the value directly from Scrape model queryset to the template like this. Everything works perfectly! <a href="{% url 'scrape-csv' site.pk scrape.last.last_checked %}" > </a> However if I passed the value to Site model queryset thru ForeignKey, which is the way to I need to have, here I get the error occurs: {% for site in sites %} <a href="{% url 'scrape-csv' site.pk site.scrapes.last.last_checked %}" > </a> {% endfor%} If we checked the values, both the same datetime objects: {{ scrape.last.last_checked }} # April 8, 2022, 10:14 a.m. {{ site.scrapes.last.last_checked }} # April 8, 2022, 10:14 a.m. … -
Django's CKEditor not appearing in Admin Panel
I have a simple Django application that allows me to create an article. It contains a title, date, author (auto applied) and body. Using the RichTextField, I created my body in the models, however, a simple plain text area is appearing in my admin instead of my RichTextField, see here Something I found during an HTML inspection is this. I didn't add that and I have no idea how to fix that as well. Here is all the relevant code Admin.py from django.contrib import admin # Register your models here. from .models import Article admin.site.site_header = 'Neostorm Admin' @admin.register(Article) class ArticleAdmin(admin.ModelAdmin): class Media: js = ('ckeditor/ckeditor/ckeditor.js',) def save_model(self, request, obj, form, change): obj.user = request.user super().save_model(request, obj, form, change) Models.py from django.db import models from ckeditor_uploader.fields import RichTextUploadingField from django.contrib.auth.models import User # Create your models here. class Article(models.Model): title = models.CharField(max_length=50) body = RichTextUploadingField(blank=True, null=True) #Order the articles model by the date of update created_at = models.DateTimeField(auto_now=True) user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True, null=True, editable=False) Relevant settings.py configurations STATIC_URL = 'static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = "images/" CKEDITOR_BASEPATH = "/static/ckeditor/ckeditor/" CKEDITOR_UPLOAD_PATH = 'articles/' CKEDITORBackGround = '#7D001D' CKEDITOR_CONFIGS = { 'default': { "width": "100%", 'skin': 'moono-lisa', … -
Specific Viewing Privilege's in HTML and Python
I'm making a college events website for a project and one of the requirements is to be able to make events that are private for your student organization or your university. So all events should be tagged as either Public, Private(can only view if you attend the same university as the event creator), or RSO(can only view if you are in the same student organization as the event creator). I have managed to make a page where you can view all the events but I can't figure out how to make it so you can only view these events under the provided circumstances. Right now all the events no matter what the tag is show up for everyone looking at the events list page. Any ideas on how to do this? -
How to format date 20220410 to 2022-04-10 in Python?
I need help formatting the date. I have a variable date as an integer like this: date = 20220410 # YYMMDD Desired format: 2022-04-10 I written some algorithms to do this with for loops. But didn't work! -
Django reset password get Server Error 500 when deployed to production in Azure
I'm trying to implement a reset password feature in my Django app using django.contrib.auth` like this: from django.urls import path from .import views from django.contrib.auth import views as auth_views from django.conf import settings from django.conf.urls.static import static urlpatterns = [ path('', views.index, name='index'), path("login", views.login_view, name="login"), path("logout", views.logout_view, name="logout"), path('register', views.register, name='register'), path('admin_main', views.admin_main, name='admin_main'), path('admin_csv', views.admin_csv, name='admin_csv'), path('admin_pdf', views.admin_pdf, name='admin_pdf'), path('reset_password/', auth_views.PasswordResetView.as_view(), name="reset_password"), path('reset_password_sent/', auth_views.PasswordResetDoneView.as_view(), name="password_reset_done"), path('reset/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(), name="password_reset_confirm"), path('reset_password_complete/', auth_views.PasswordResetCompleteView.as_view(), name="password_reset_complete"), ] if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) Everything works just fine during development but in production (Azure App Service) when I introduce the email to reset the password and submit the form, I get "Server Error (500)" and the reset password mail is not send, any idea why could this be? -
Django: tags showing in HTML template even after adding safe tag
I am working on an app. In the HTML template, the text (entered from admin) shows the paragraph tags. I have added the safe tag in my template file. Template file: <div class="container details"> <h5> Category: {{ single.category }} <br> </h5> <h2>{{ single.title }}</h2> <h4> {{ single.content|safe }} </h4> </div> </section> (^^ of course it's got the extends tag and block tag and all that, but this is the part with the error) admin.py from django.contrib import admin from .models import * admin.site.register(Category) admin.site.register(Post) admin.site.register(Tag) Please help 💀 -
Django manage.py runscript causes EOFError when using input()
I am trying to build a script in Django that generates a report based on user input. myscript.py def run(): # analyze some data user_input = input('Enter a value:') # do secondary analysis based on input value When I execute this script with python manage.py runscript myscript, it works until input() is called. "Enter a value:" is printed to the console, but instead of waiting for the user to enter a value, the program terminates with EOFError: EOF when reading a line. What is going on here? Note: Passing arguments to the script with --script-args is not an acceptable workaround because the input value must be determined by the user after the initial data analysis. -
Django two filter
In Django (mongodb), I do two separate filters based on GET requests from my rest api. I'm sure there is data at the intersection of the two filters. However, the result of the two filters has 0 results. Can you check if my filters are wrong? country is manytomanyfield. brand is foreignkey. queryset = Mymodel.objects.all() country = self.request.query_params.get('country', None) brand = self.request.query_params.get('brand', None) if country: queryset = queryset.filter(country__name=country) if brand: queryset = queryset.filter(brand__name__icontains=brand) return queryset -
Transferring user input from one page to another
I am making a website that allows students to find upcoming study sessions for their courses. I am doing this in Django and HTML. A student uploads their courses to the site and they are shown on the courses page as buttons (ex. CS 101 - Intro to CS). When a student clicks on one of their courses (button), it is supposed to bring them to a page that shows available study sessions for that course. I am stuck because I do not know how to properly filter the available study sessions on the next page based on which course is clicked. Is there a way to store the info of the course as a variable so when the button is clicked I can use that variable to filter the results? -
how to send verification email to specific users only in django-allauth
I'm using django-tenants for multi-tenancy,All things are good with allauth package. But the problem is: I've signup form for "subscribers" they must receive an email confirmation and a custom signup form for every "subscribers" to enable them to create users under their subdomains, But the "created users" must receive an email with an initial password not confirmation email. Really I tried many things to perform this mission but with no solution and I searched in many threads here but unfortunately useless, I tried to override def send_mail(self, template_prefix, email, context):, def send_confirmation_mail(self, request, emailconfirmation, signup): and class CustomConfirmEmailView(ConfirmEmailView):. I knew that I've missed something but I don't know what is it. If I send a confirmation email to "subscribers", "created users" affected , And if I change settings to prevent sending confirmation email the "subscribers" affected Also I've a custom login form in adapter.py file to enable users to login with username. class CustomLoginView(LoginView): template_name = 'account/subdomain/login.html' This is my settings ACCOUNT_ADAPTER = 'apps.authentication.adapter.CustomAccountAdapter' AUTH_USER_MODEL = 'authentication.CustomUser' ACCOUNT_FORMS = { 'login': 'apps.authentication.forms.CustomLoginForm', 'signup': 'apps.authentication.forms.CustomUserCreationForm' } LOGIN_REDIRECT_URL = '/' ACCOUNT_LOGOUT_REDIRECT_URL = 'account_login' # created users must redirect to their subdomain login page not public login page ACCOUNT_LOGOUT_ON_GET = True # If … -
Django: How can I create a User view that allows a User to amend or delete their existing bookings
I am developing a restaurant booking service using Django. I have my Model - Views - Templates all working just fine. Now I want to create a view for an authenticated user to view only their existing bookings. In the same view, I would also like them to be able to amend and/or deleted any of their bookings. So far I have managed to get the code right for the authenticated user to only see their bookings but at this point, they cannot do anything with it. models.py; class Booking(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) table = models.ForeignKey(Table, on_delete=models.CASCADE) group_size = models.PositiveIntegerField() date = models.DateField(blank=False) start_time = models.TimeField(auto_now_add=False, blank=False) end_time = models.TimeField(auto_now_add=False, blank=False) comment = models.TextField(blank=True) created_on = models.DateTimeField(auto_now_add=True) approved = models.BooleanField(default=True) def __str__(self): return f'{self.table}. Booked by {self.user} for {self.group_size} people, for the {self.date} at {self.start_time}. Status {self.approved}' views.py; class BookingList(TemplateView): template_name = 'user_booking.html' def get_context_data(self, **kwargs): return super().get_context_data( bookings=self.request.user.booking_set.all(), **kwargs ) html_template; {% for booking in user.booking_set.all %} <h2>{{ booking }}</h2> {% endfor %} output; Table 4, WINDOW. Capacity 4 guests. Booked by admin for 4 people, for the 2022-04-30 at 18:00:00. Status True Table 1, OUTSIDE. Capacity 2 guests. Booked by admin for 2 people, for the 2022-04-30 … -
Django - DRF - Authentication credentials were not provided. - just in Production. What is the cause?
Problem During the deployment of my backend API to Heroku trough Docker container I encounter the following error with status 403(Forbidden) whenever I try to access some data where the user has to be authenticated: { "detail": "Authentication credentials were not provided." } In development everything works as expected. I am aware of the similar question Django Rest Framework - Authentication credentials were not provided. However here the solution is connected with Apache configuration, which strips the AUTHENTICATION header. During the debugging of the issue I found out, the AUTHENTICATION header is available for the application, and in fact the token can be obtained and read without any issue. As a test I have written my own permission class where I have found out, the request.user.is_authenticated line in development gives True but in production gives False with the exact same data and test case. class AuthOrReadOnly(BasePermission): def has_permission(self, request, view): print(request.user.is_authenticated) if request.method in permissions.SAFE_METHODS: return True if request.user.is_authenticated: return True return False SOLUTION to the problem itself I needed to add authentication_classes = (JWTAuthentication,) for my each APIview class where I need to access authenticated content. Example: class RegistrationsForUserView(APIView): permission_classes = [ permissions.IsAuthenticatedOrReadOnly, ] authentication_classes = (JWTAuthentication,) serializer_class = … -
django.contrib.auth.models.User.customer.RelatedObjectDoesNotExist: User has no customer. thats my bug imy ecommerce web app
def cart(request): if request.user.is_authenticated: customer = request.user.customer order, created = Order.objects.get_or_create(customer=customer, complete= False) items = order.orderitem_set.all() else: items = [] context = {'items':items} return render(request,'store/cart.html', context) that is my add to cart code but it still display that there is no related object -
The problem with my code is forcing the user to change the image also when he want to change only content or title of his article
Hello everyone I have project blog platform the user can add,and edit blog. The blog contain (title, slug, contenet, image), I used Django and Django Rest Framework to build website, and for frontend ReactJS. my problem is when I edit blog I couldn't edit blog until change image but for content and title I can change one of them while I can't update blog until I change the image, This is an error when just update title without change image model.py def upload_path(instance, filename): return 'img/{filename}'.format(filename=filename) class Blog(models.Model): title = models.CharField(max_length=250) slug = models.SlugField(max_length=250, unique=True, null=True) content = models.TextField() published = models.DateTimeField(default=timezone.now) author = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='blog_blog') objects = models.Manager() # default manager image = models.ImageField(_("Image"), upload_to=upload_path, null=True) class Meta: def __str__(self): return self.title view.py class EditBlog(generics.UpdateAPIView): permission_classes = [permissions.IsAuthenticated, IsOwnerOrReadOnly] serializer_class = BlogSerializer queryset = Blog.objects.all() in React edit.js import React, { useState, useEffect } from 'react'; import { useNavigate, useParams } from 'react-router-dom'; import axiosInstance from '../../../axios'; import WriteCss from '../../../assets/CSSStyle/WriteBlog.module.css'; import { Image } from 'antd'; export function Edit() { const navigate = useNavigate(); const { id } = useParams(); const initialFormData = Object.freeze({ title: '', slug: '', content: '', }); const [formData, updateFormData] = useState(initialFormData); …