Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to extract the data from the uploaded file using filesystemstorage in django?
Hi I am learning python I tried uploading a file using FileSystemStorage defualt class that is defualt class in django and the file is uploading but I want to extract the data from the uploaded file that is being stored media folder like name: "soso" age: "so" the code which I tried so far is as below views.py: from django.shortcuts import render from django.conf import settings from django.core.files.storage import FileSystemStorage def index(request): if request.method == 'POST' and request.FILES['myfile']: myfile = request.FILES['myfile'] fs = FileSystemStorage() filename = fs.save(myfile.name, myfile) uploaded_file_url = fs.url(filename) return render(request, 'index.html', { 'uploaded_file_url': uploaded_file_url }) return render(request, 'index.html') index.html: {% block content %} <form method="post" enctype="multipart/form-data"> {% csrf_token %} <input type="file" name="myfile"> <button type="submit">Upload</button> </form> {% if uploaded_file_url %} <p>File uploaded at: <a href="{{ uploaded_file_url }}">{{ uploaded_file_url }}</a></p> {% endif %} <p><a href="{% url 'home' %}">Return to home</a></p> {% endblock %} -
Django - How access the value of an instance in views.py
I have this model class Post(models.Model): title = models.CharField(max_length=100) title2 = models.CharField( max_length=100) content = models.TextField(default=timezone.now) content2 = models.TextField(default=timezone.now) post_image = models.ImageField(upload_to='post_pics') post_image2 = models.ImageField(upload_to='post2_pics') date_posted = models.DateTimeField(default=timezone.now) author = models.ForeignKey(User, on_delete=models.CASCADE) Then I have this simple view function that allows me to access each of its field in my HTML: def home(request): postings = { 'listings' : Post.objects.all(), } return render(request, 'front/front.html', postings) {% for listings in listings%} <h1>{{listings.content}}</h1> {% endfor %} With this, I'm able to access the content field for every instance of that model and display it My question is how can I access the content field in my view function and change it. The content field holds a zipcode and I want to use an API to display the city of that zipcode(which I already know how to do) and pass it back to the h1 tag. Each instance holds a unique zipcode so I need it to apply for each instance. How would I approach this? -
How to use object.id to make another object, creator of the current object?
I have two models in my django application 'Client' and 'Installment'. Below is my models.py: models.py rom django.db import models from django.utils import timezone from django.urls import reverse # Create your models here. class Client(models.Model): name = models.CharField(max_length = 100) dob = models.SlugField(max_length = 100) CNIC = models.SlugField(max_length = 100) property_type = models.CharField(max_length = 100) down_payment = models.IntegerField() date_posted = models.DateTimeField(default=timezone.now) def __str__(self): return self.name def get_absolute_url(self): return reverse('client_details',kwargs={ 'pk' : self.pk}) class Installment(models.Model): client = models.ForeignKey(Client, null=True, on_delete=models.CASCADE) installment_month = models.CharField(max_length = 100) installment_amount = models.IntegerField() installment_date = models.DateTimeField(default=timezone.now) def __str__(self): return self.installment_month def get_absolute_url(self): return reverse('installment_confirmation') and my views.py view.py # To create new client class ClientCreateView(CreateView): model = Client fields = ['name', 'dob', 'CNIC', 'property_type', 'down_payment'] # To add new installment class AddInstallmentView(CreateView): model = Installment #template_name = "property_details/addinstallment_form.html" fields = ['installment_month', 'installment_amount'] And the URL that I have to add a new installment is below: urlpatterns = [ path('', ClientListView.as_view(), name='client_list'), path('new/', ClientCreateView.as_view(), name='add_client'), path('<int:pk>/', ClientDetailView.as_view(), name='client_details'), path('<int:pk>/Add-Installment', AddInstallmentView.as_view(), name='add_installment'), path('confirmation/', views.installment_added, name='installment_confirmation'), ] You can see that the URL for adding new installment is unique. For example, /<local_server_addr>/<client.id>/Add-Installment (because of <int:pk> above) I can create a new client and also I can add installment. But … -
How to obtain geo co-ordinates of a remote user in group video chat?
I am building a group video chat application in Django with the help of Agora where I want to show the user their geo distance from every other user. To a given user, the UI would look something like this (along with the video of course) User A - (User A's remote video) - 5 miles away from you User B - (User B's remote video) - 100 miles away from you User C - (User C's remote video) - 10 miles away from you User D (local user - you) Now in the video chat, a user can log off & a new user can join the call any time. To compute the geo distance of a remote user with the local user, I need geo-coordinates of both the parties. I can obtain the geo-location of the local user by integrating with some location library. I am confused on how to obtain the geo-coordinates of the remote user? My django code flow looks something like renders links to views.py ----> video.html -------> agora.js Video.html renders the video chat room. I am using Agora to power the group video chat whose code is defined in agora.js. Any time a new … -
Is there a way to show Django messages in Django admin site?
I need to display a Django message on the Django admin index site. I am looking for a way to add certain conditions for the message to be displayed and pass it to Django index site. Is there a way to achieve that? -
how do i seed some data in to my table , that i have fetched from a specific extrernal api in Django?
so my requirment is i need to fetch some data from a github api and seed it into the table in my django api application. so while the app is running it should always be seeded with that data.. And then i need to make a REST api using that Table data which is already seeded with github api data. im a beginner and i have searched a lot but couldnt find what to do ? i have already created mmy fuction to fetch data and also i have created a model based on my requirment. all i need to know where should i put that code so that it seeds my table when the application runs so that i can create a rest api using that table data .. this is the data fetching code(which i currently have put in view as a function to see if its working) def apiOverview(request): mainarr=[] url = 'https://api.github.com/repos/afhammk/components/contents' try: r = requests.get(url, auth=("afhammk","token")) fish = r.json() for ele in fish: try: desc=requests.get("https://api.github.com/repos/afhammk/components/contents/"+ele["name"]+"/description.txt?ref=main" ,auth=("afhammk","token")).json() content=str(base64.b64decode(desc["content"])) name=content.split("'")[1::2][0] description=content.split("'")[1::2][1] y=Task(component=ele["name"],url=ele["html_url"],owner=name,description=description) y.save() except: mainarr=["cant fetch second url"] except: mainarr=["cant fetch first url"] below is the model i created class Task(models.Model): component=models.CharField(max_length=200) owner=models.CharField(max_length=200) description=models.CharField(max_length=200) url=models.CharField(max_length=200) def __str__(self): … -
how can i get category name instead of the ID
I'm working on a small project using Django Rest Framework, I have two models ( contacts and category) So a contact can be in a category, I have a foreign key between the models, I would like to know how can I get data category name instead of getting the id number. This is my code : class Category(models.Model): cat_name = models.CharField(blank=False, max_length=255) comment = models.CharField(blank=False, max_length=255) private = models.BooleanField(default=False) allowed = models.BooleanField(default=False) def __str__(self): return self.name class Contact(models.Model): category = models.ForeignKey(Category, on_delete=models.DO_NOTHING) first_name = models.CharField(max_length=60) last_name = models.CharField(max_length=60) My serializer class ContactSerializer(serializers.ModelSerializer): class Meta: model = Contact fields = "__all__" Result I get : "first_name": "John", "last_name": "Doe", "category": 1 ( i want to get the name of the category instead of the id ) -
Refused to execute script from 'chunk.js' because its MIME type ('text/html') is not executable,and strict MIME type checking is enabled
i have a django rest framework + reactjs app in frontend , It has deployed successfully in aws, and it's working fine in debug mode, When i change to production: i get these errors: Refused to execute script from '***ff1c1f05.chunk.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled. Refused to apply style from 'https://www.dentistconsultationhub.ai/static/css/main.85597d13.chunk.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled. can anyone explain to me what mayb be the problem ? cordially -
Django Model Form not saving to database
I have the following ModelForm which when I use as below it is not saving to the database. I have tried other posts and answers on here but cannot get this to save. If I use the same Class Base View (CreateView) and use the input of {{form}} in the HTML I can get this working and it saves to the database, but I need to have the form fields added separately in the HTML page as below that has been created for me with separate inputs. The output of the post prints in the terminal ok, but then as mentioned not to the database. Hope this all makes sense and thanks in advance for any help I can get on this. models.py class ASPBookings(models.Model): program_types = ( ('Athlete Speaker & Expert Program', 'Athlete Speaker & Expert Program'), ('Be Fit. Be Well', 'Be Fit. Be Well') ) presentation_form_options = ( ('Face to Face', 'Face to Face'), ('Virtual', 'Virtual'), ) organisation_types = ( ('Goverment School', 'Goverment School'), ('Community Organisation', 'Community Organisation'), ('Non-Goverment School', 'Non-Goverment School'), ('Other', 'Other') ) contact_name = models.CharField(max_length=80) program_type = models.CharField(max_length=120,choices=program_types) booking_date = models.DateField() booking_time = models.DateTimeField(default=datetime.now()) duration = models.CharField(max_length=10, default="1") email = models.EmailField() phone_number = models.CharField(max_length=120) speaker_brief … -
django 3.1 passing raw column aliases to QuerySet.order_by() is deprecated
I'm working on a project which just moved to django 3.1. And I need to remove the usage of this "passing raw column aliases to QuerySet.order_by()" thing. However, I am not sure if my project is using it. So I need to understand how "passing raw column aliases to QuerySet.order_by()" actually works, if someone could provide me an example of the code that does the passing of raw column aliases to QuerySet.order_by(), it would be really helpful and appreciated. -
Django - Accessing Model Field in class based view
I have this model class Post(models.Model): title = models.CharField(max_length=100) title2 = models.CharField( max_length=100) content = models.TextField(default=timezone.now) content2 = models.TextField(default=timezone.now) post_image = models.ImageField(upload_to='post_pics') post_image2 = models.ImageField(upload_to='post2_pics') date_posted = models.DateTimeField(default=timezone.now) author = models.ForeignKey(User, on_delete=models.CASCADE) and this function based view that uses the model: class PostListView(ListView): model = Post template_name = 'front/front.html' context_object_name = 'listings' ordering = ['-date_posted'] def get_context_data(self, **kwargs): check_for_zipcode = #where I want to access the author for the current instance context = super().get_context_data(**kwargs) context['zipcodes'] = check_for_zipcode return context All I want to know is how can I access the author field in the class-based view. I can access the author in my HTML like so" {% for listings in listings %} <h3>listings.author</h3> {% endfor %} With this, I'll get back the author field for every instance of that model. How would I get the author for the instance in the variable check_for_zipcode? I tried self.author, self.listings.author, etc; but nothing works -
Django Forms: non-model field won't render value with "view" permission
I'm having trouble displaying values of non-model fields in custom form for admin site. When user has only view permission, on object editing, model fields are filled and rendered as read-only, while non-model fields are not rendering any values. Django version: 2.1.15 forms.py class AccountModelForm(forms.ModelForm): custom_field1 = forms.IntegerField() custom_field2 = forms.IntegerField() class Meta: model = Account fields = '__all__' def __init__(self, *args, **kwargs): super(AccountModelForm, self).__init__(*args, **kwargs) # initializing non-model fields with values self.initial['custom_field1'] = 3 self.initial['custom_field2'] = 5 admin.py @admin.register(Account) class AccountAdmin(admin.ModelAdmin): form = AccountModelForm def get_fieldsets(self, request, obj=None): model_fields = ('Info', {'fields': [f.name for f in self.model._meta.fields]}) return ( model_fields, ('Advanced options', { 'classes': ('collapse',), 'fields': ('custom_field1', 'custom_field2') }) ) Result... I don't know what I'm doing wrong, I would appreciate any help. Thanks in advance. -
With Django ORM, get the item (the whole object!) from a related dataset with the greater or lower value for one property
I have this: # models.py from django.db import models as m class Station(m.Model): name = m.CharField(max_length=255) # etc... class Moment(m.Model): date = m.DateField() time = m.TimeField() class HumidityMeasurement(m.Model): station = m.ForeignKey(Station, on_delete=m.CASCADE, related_name='humidity_set') moment = m.ForeignKey(Moment, on_delete=m.CASCADE) relative = m.FloatField(null=True, default=None) #etc... And I have to get the maximum and minimum relative humidity record from each station. This is my view: # views.py class MinMaxView(GenericViewSet): queryset = Station.objects @action(detail=False, methods=['GET']) def station(self, request, *args, **kwargs): queryset = self.get_queryset().prefetch_related('humidity_set') result = [] for station in queryset: # here I get a list and `trim` useless data h_list = [st for st in station.humidity_set.all() if not st.relative is None and not st.relative == -9999] # get max and min from the list of objects h_max = max(h_list, key=lambda obj: obj.relative) h_min = min(h_list, key=lambda obj: obj.relative) # no serializers here, go old school humidity = { 'max': { 'value': h_max.relative, 'date': f'{h_max.moment.date} - {h_max.moment.time}' }, 'min': { 'value': h_min.relative, 'date': f'{h_min.moment.date} - {h_min.moment.time}' } } station_data = { station.name: { 'humidity': humidity, # 'temperature': temperature, # 'pressure': pressure, # 'wind': wind, # 'rain': rain, # 'radiation': radiation, }, } result.append(station_data) return Response(result, status=status.HTTP_200_OK) Ok. It is working, but I have a database … -
Django sorting by a category and pagination combining both in one function view
I'm trying to sort my projects by categories: all, css, HTML, Django, and so on. and also trying to add pagination when showing all projects have a limit of 6 projects per page. I'm stuck and have trouble combining either the pagination work or the filter/ sorting the items work, here's my code. Please Help :) models.py class Category (models.Model): category_name = models.CharField(max_length=150) slug = models.SlugField(unique=True) class Meta: ordering = ('-category_name',) def __str__(self): return self.category_name def get_absolute_url(self): return reverse('mainpages:project_by_category', args=[self.slug]) class Project(models.Model): category = models.ForeignKey(Category, on_delete=models.CASCADE, default='', null=True) title = models.CharField(max_length=100) description = models.TextField() technology = models.CharField(max_length=20) proj_url = models.URLField(max_length=200, blank=True) blog_link = models.URLField(max_length=200, blank=True) image = models.ImageField(default='post-img.jpg', upload_to='proj-img') class Meta: ordering = ('-title',) def __str__(self): return self.title view.py def portfolioView(request, category_slug=None): # added category = None categories = Category.objects.all() # filtering by project projs = Project.objects.all() # paginator added projects = Project.objects.all() paginator = Paginator(projects, 3) page = request.GET.get('page') try: projects = paginator.page(page) except PageNotAnInteger: projects = paginator.page(1) except EmptyPage: projects = paginator.page(paginator.num_pages) # added if category_slug: category = get_object_or_404(Category, slug=category_slug) projs = projs.filter(category=category) # return render(request, 'mainpages/portfolio.html', { 'category': category, 'categories': categories, 'projects': projects, 'page': page, 'projs': projs, }) def projectDetail(request, pk): project = Project.objects.get(pk=pk) context = { … -
Passing variables in django browser string
I am doing a search on the page with the ability to filter. It is necessary to pass the selected fields to form the correct queryset. What is the best way to do this? I am creating str variable in urls. But what if you need to pass 10 or more filter conditions? how to organize dynamically passed variables? urls from django.urls import path from .views import * urlpatterns = [ path('', OrdersHomeView.as_view(), name='orders_home'), path('filter/<str:tag>', OrdersFilterView.as_view(), name='orders_filter'), ] I understand what to do through ?var=&var2=, as in php, but I can't figure out how? it is possible to just process the string str, but maybe there is some django magic? -
Context value for the variable {{ media }} in django views
There is a {{ media }} variable used in some of the django admin templates. delete_confirmation.html, change_form.html , and delete_selected_confirmation.html . This variable adds several javascript files including jQuery library to the templates. I want to know what is the value passed to the context variable in the views that call those templates. My purpose is to use the same javascript files in the templates that I create for the custom views in the django admin. Thank you. -
DJANGO : error updating cart shipping cost
Thankyou to everyone that has helped to date. I have completed my project and built a functioning ecom cart. I still have one error, when updating the checkout values the cart adds the shipping cost twice for each line item rather than based on total cart items. That is, if there are three widgets only it will charge 9.95 but if there 3 widgest and 1 watzet the shipping is charged at 19.90(i.e. 2 line items and 2 x 9.95) PLEASE HELP!! The code is below: MODELS.PY from django.db import models from django.contrib.auth.models import User from django.urls import reverse from ckeditor.fields import RichTextField # Create your models here. class Customer(models.Model): user = models.OneToOneField(User, null=True, blank=True, on_delete=models.CASCADE) name = models.CharField(max_length=200, null=True) email = models.CharField(max_length=200) def __str__(self): return self.name class Product(models.Model): name = models.CharField(max_length=200) price = models.FloatField() digital = models.BooleanField(default=False,null=True, blank=True) image = models.ImageField(null=True, blank=True) short_desc = models.CharField(max_length=255) long_desc = RichTextField(blank=True, null=True) product_image = models.ImageField(null=True, blank=True, upload_to ="images/") product_image_2 = models.ImageField(null=True, blank=True, upload_to ="images/") product_image_3 = models.ImageField(null=True, blank=True, upload_to ="images/") red_hot_special = models.BooleanField(default=False) feature_product = models.BooleanField(default=False) weekly_special = models.BooleanField(default=False) tax_exempt = models.BooleanField(default=False) options_sched = [ ('1', 'exempt'), ('2', 'two'), ('3', 'three'), ('4', 'four'), ] schedule = models.CharField(max_length = 10,choices = options_sched,default='1') def … -
Serializer not working correctly when trying to incorporate username of user
I have a serializer, I'm trying to add an additional field, from a different model. The goal is to add the username from the user who requested the data. Here is my serializer, I try to accomplish my goal using the username variable and adding it to fields. class BucketListSerializer(serializers.ModelSerializer, EagerLoadingMixin): stock_count = serializers.SerializerMethodField() username = serializers.CharField(source='User.username', read_only=True) model = Bucket fields = ('id','username','category','name','stock_count', 'stock_list','owner','admin_user', 'guest_user','about','created','slug', 'bucket_return', 'bucket_sectors','bucket_pos_neg') def get_stock_count(self, obj): if obj.stock_count: return obj.stock_count return 0 There aren't any syntax errors with this serializer, however the username field is not working. There is no data in the dictionary returned with the key username User model: class CustomAccountManager(BaseUserManager): def create_superuser(self, email, username, first_name, last_name, password, **other_fields): other_fields.setdefault('is_staff', True) other_fields.setdefault('is_superuser', True) other_fields.setdefault('is_active', True) if other_fields.get('is_staff') is not True: raise ValueError( 'Superuser must be assigned to is_staff=True.') if other_fields.get('is_superuser') is not True: raise ValueError( 'Superuser must be assigned to is_superuser=True.') return self.create_user(email, username, first_name, last_name, password, **other_fields) def create_user(self, email, username, first_name, last_name, password, **other_fields): if not email: raise ValueError(_('You must provide an email address')) if not username: raise ValueError(_('You must provide a username')) if not first_name: raise ValueError(_('You must provide your first name')) if not last_name: raise ValueError(_('You must provide your … -
Django - Passing a variable to class based views
In a function based view I can pass on a variable like so: def zip(request): check_for_zipcode = request.user.profile.location zipcodes = { 'check_for_zipcode' : check_for_zipcode } return render(request, 'front/post_form.html', zipcodes) Then I'll be able to access check_for_zipcode in my HTML. But how would I do that in a class based view? Let's say I have the following class based view. class PostCreateView(LoginRequiredMixin, CreateView): model = Post fields = ['title', 'content', 'post_image', 'title2', 'content2', 'post_image2'] def form_valid(self, form): form.instance.author = self.request.user return super().form_valid(form) How would I pass on check_for_zipcode = request.user.profile.location in to that class based view? -
what changes are required in VS COde And Django for the following script of python?
Actually I am working on the python script in VS Code by using django framework. I am using phpMyAdmin this is the script. ''' dates=str(datetime.datetime.now().date()) #dates1=str((datetime.datetime.now()-datetime.timedelta(days=1)).date()) f1=open('let\hhh\html\WB/'+dates+'.csv','w') f1.write('ID, Name, add, p, c) db = MySQLdb.connect("localhost","user","","meta") cursor = db.cursor() sql = "select ID from meta where ........ cursor.execute(sql) results=cursor.fetchall() ''' what changes required in VS Code and Django to implement the script? What to write in models? I am using phpMyAdmin -
How to use base_template variable in Django login.html
I have a very simple Django 3.1 project that uses the basic login-authentication found in the Mozilla tutorial (https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Authentication). It works great, but I'd like to change the extends base_generic line to a variable. For example, logged_out.html, currently looks like this: {% extends "base_generic.html" %} {% block content %} <p>Logged out!</p> <a href="{% url 'login'%}">Click here to login again.</a> {% endblock %} I'd like it to look like this: {% extends base_template %} <-- Here's the change I'd like to make {% block content %} <p>Logged out!</p> <a href="{% url 'login'%}">Click here to login again.</a> {% endblock %} I've been able to do this successfully for all the templates that I create, but I can't figure out how to do this for the "built-in" login-authentication pages, such as login.html, logged_out.html, password_reset_form.html, etc Thank you! -
How do you properly protect a multitenancy model from the tenants in Django (using django-schemas)?
I'm kind of at a loss here. I'm setting up a multi-tenant project for practice with Django and I decided to use django-tenants because it has the most active Github repo. The problem I've run into has to do with exposing the tenant model to all the tenants. I don't want the tenants to see who the other tenants are. They cannot add, edit or remove any of them but they can see them. I don't want that. What I've tried doing was making two admins (admin and masteradmin) then only registering the tenant model with the master admin. However, if a tenant goes to /masteradmin/ the same problem persists. I figure that django.contrib.admin doesn't know about the tenants and this is why but I'm stuck. What do I do to solve this problem properly? I'm out of resources to read and options to try. Project settings.py apps: SHARED_APPS = ( 'django_tenants', # mandatory, should always be before any django app 'customers', # you must list the app where your tenant model resides in 'website', 'admin_interface', 'colorfield', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'biller_customers', ) TENANT_APPS = ( 'django.contrib.contenttypes', # your tenant-specific apps 'biller_customers', ) Tenant app models.py file: from … -
How to create or save Data using RestFramework viewsets.?
I created two models that are interlinked with each other. class Company(models.Model): company_name = models.CharField(max_length=50, unique=True) created = models.DateTimeField(auto_now_add=True) def __str__(self): return self.company_name class Order_Placement(models.Model): company = models.ForeignKey(Company, on_delete=models.SET_NULL, null=True) product_quantity = models.IntegerField() product_price = models.FloatField() product_total_price = models.FloatField(blank=True, null=True) other_cost = models.FloatField() cost_of_sale = models.FloatField(blank=True, null=True) advance_payment = models.FloatField() remaining_payment = models.FloatField(default=0.0, blank=True) date = models.DateTimeField(auto_now_add=True) def save(self, *args, **kwargs): self.product_total_price = self.product_price * self.product_quantity self.cost_of_sale = self.product_total_price + self.other_cost self.remaining_payment = self.cost_of_sale - self.advance_payment super(Order_Placement, self).save(*args, *kwargs) def __str__(self): return str(self.company) + ' : ' + str(self.date.date()) I am trying to create a view that will help me to create an object or instant of the Order_placemen model But when I try to post Data it rises an error while saving with post request: Here I created a serializer for both company and Order_placement class CompanySerializer(s.ModelSerializer): class Meta: model = m.Company fields = '__all__' class Order_PlacementSerializer(s.ModelSerializer): class Meta: model = m.Order_Placement fields = '__all__' def to_representation(self, instance): response = super().to_representation(instance) response['company'] = CompanySerializer(instance.company).data return response and I created a view for OrderPlacement using Django rest_framework.viewsets.ViewSet class OrderProccessViewset(viewsets.ViewSet): def create(self, request): try: serializer = s.Order_PlacementSerializer(data=request.data, context={"request": request}) serializer.is_valid(raise_exception=True) serializer.save() dict_response = {"error": False, "message": "Order Save Successfully"} except: dict_response … -
Configuring CSRF tokens with apollo client and graphene-django
I am having trouble properly setting up csrf tokens in the authlink header. const authLink = setContext((_, { headers }) => { const token = localStorage.getItem(AUTH_TOKEN) return { "headers": { 'X-CSRFToken' : getCookie('csrftoken'), "Authorization": token ? `JWT ${token}` : '', ...headers, }, }; }); The request being sent looks ok from the browser devtools, as you can see at the bottom the csrf token looks right? I cleared my browser data to make sure it wasn't old, but I'm not sure if that's effective anyways. accept: */* Accept-Encoding: gzip, deflate, br Accept-Language: en-US,en;q=0.9 Authorization Connection: keep-alive Content-Length: 505 content-type: application/json Host: localhost:8000 Origin: http://localhost:3000 Referer: http://localhost:3000/ Sec-Fetch-Dest: empty Sec-Fetch-Mode: cors Sec-Fetch-Site: same-site User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36 Edg/89.0.774.63 X-CSRFToken: LsV83sz3Rb5RRIlNcRN3AgnniodwsSMpvXwMGquPGRbvoPpISfKv6MBEf86rVzVp The error I get through the site is CSRF verification failed. Request aborted my django server shows Forbidden (CSRF cookie not set.) -
Learning Backend Development
I am looking to create a courses website similar to https://brilliant.org/courses/ which allows users to create accounts and register for premade courses. I would like for each student to have their own dashboard which displays various statistics like how much time they spent on a course and what courses they are enrolled in. This is for a nonprofit organization aimed at elementary through early high school students. Currently, I know the very basics of frontend development (HTML, CSS, JS) and some python however I am unsure where to start to learn backend development to actually create user accounts and courses. Since I am learning python on the side I would prefer to use Django, where is a good place to start for someone with absolutely no prior computer science or web dev experience?