Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
error when trying to authenticate on react using django rest as backend
pages/Login.js Error const mapStateToProps = (state) => ({ isAuthenticated: state.auth.isAuthenticated, # Error on this line }); TypeError: "Cannot read property 'isAuthenticated' of undefined" first time creating full stack app using django rest + react. everything works on the backend, but on the front when i go to http://localhost:3000/login and try to login i get an error, i tried everything but i cant figure this out. i've added the authentication related files, if anyone identify a problem please let me know. thanks :) action/auth.js import { setAlertMsgAndType } from './alert'; import { LOGIN_SUCCESS, LOGIN_FAIL, } from './types'; export const login = (email, password) => async (dispatch) => { const config = { headers: { 'Content-Type': 'application/json', }, }; const body = JSON.stringify({ email, password }); try { const res = await axios.post( 'http://localhost:8000/api/token/', body, config ); dispatch({ type: LOGIN_SUCCESS, payload: res.data, }); dispatch(setAlertMsgAndType('Authenticated successfully', 'success')); } catch (err) { dispatch({ type: LOGIN_FAIL, }); dispatch(setAlertMsgAndType('Error Authenticating', 'error')); } }; reducers/auth.js import { SIGNUP_SUCCESS, SIGNUP_FAIL, LOGIN_SUCCESS, LOGIN_FAIL, LOGOUT, } from '../actions/types'; const initialState = { token: localStorage.getItem('token'), isAuthenticated: null, loading: false, }; export default function authReducer(state = initialState, action) { const { type, payload } = action; switch (type) { case LOGIN_SUCCESS: localStorage.setItem('token', … -
Creating multiple charts based on dictionary length
I am building a dashboard website for some water quality sensors I have that send the information as an API in JSON format. The plan is to create real-time charts using that data using chart.js and django. Right now I am turning the JSON file to dictionaries like so: JSON file: { "11:00:00 AM": { "Temperatura": 30, "pH": 7.1, "Conductividad": 759, "Cloro Residual": 1.1, "Turbidez": 0, "Color": "<5", "pH de la Det de color": 7.12, "Solidos totales": 512, "S�lidos disueltos": 494, "S�lidos suspendidos totales": 0, "Dureza total como CaCO3": 227.24, "Alcalinidad como CaCO3": 227.7, "Cloruros": 64.02, "Fluoruros": 0.91, "Nitrogeno Amoniacal": 0, "Nitrogeno de nitritos": 0, "Nitrogeno de nitratos": 4.47, "Sulfatos": 37.27, "Sustancias activas al azul de metileno": 0, "Fenoles": 0, "Coliformes totales": 0, "Aluminio": 0, "Arsenico": 0.015, "Bario": 0.1784, "Calcio": 79.7, "Cadmio": 0, "Cromo": 0.0085, "Cobre": 0, "Fierro": 0.0327, "Potasio": 12.18, "Magnesio": 13.37, "Manganeso": 0, "Sodio": 55.75, "Plomo": 0, "Zinc": 0, "Mercurio": 0 }, I am then turning them to dictionaries with all of the values like so: ['11:00:00 AM', '11:10:05 AM', '11:20:10 AM', '11:30:14 AM', '11:40:19 AM', '11:50:24 AM', '12:00:29 PM', '12:10:34 PM', '12:20:38 PM', '12:30:43 PM', '12:40:48 PM', '12:50:53 PM', '01:00:58 PM', '01:11:03 PM', '01:21:07 PM', '01:31:07 PM'] … -
Django Combined registration form
I want to put the registration and login form on the same page. Before that I had it in 2 functions def loginPage() and def registerPage(). Now I combined them together in to one def loginPage() and there is error and I dont know what is the problem here. Please help <div class="container" id="container"> <div class="form-container sign-up-container"> <form method="POST" action="#"> {% csrf_token %} <h1>Create Account</h1> <!-- <div class="social-container"> <a href="#" class="social"><i class="fab fa-facebook-f"></i></a> <a href="#" class="social"><i class="fab fa-google-plus-g"></i></a> <a href="#" class="social"><i class="fab fa-linkedin-in"></i></a> </div>--> <span>or use your email for registration</span> {{form.username}} {{form.email}} {{form.password1}} {{form.password2}} <input class="btn login_btn" type="submit" value="Register Account"> <button type='submit' name='submit' value='sign_up'></button> </form> </div> {{form.errors}} <div class="form-container sign-in-container"> <form method="POST" action="#"> {% csrf_token %} <h1>Sign in</h1> <div class="social-container"> <a href="#" class="social"><i class="fab fa-facebook-f"></i></a> <a href="#" class="social"><i class="fab fa-google-plus-g"></i></a> <a href="#" class="social"><i class="fab fa-linkedin-in"></i></a> </div> <span>or use your account</span> <input type="text" name="username" placeholder="Email" /> <input type="password" name="password" placeholder="Password" /> <a href="#">Forgot your password?</a> <input class="btn login_btn" type="submit" value="Login"> <button type='submit' name='submit' value='sign_in'></button> </form> </div> {% for message in messages %} <p id="messages">{{message}}</p> {% endfor %} <div class="overlay-container"> <div class="overlay"> <div class="overlay-panel overlay-left"> <h1>Welcome Back!</h1> <p>To keep connected with us please login with your personal info</p> <button class="ghost" id="signIn">Sign In</button> … -
default data type of primary keys in models (django), The current path, url '/app' didn't match any of these
As far as I know, the default data type of id is integer for models in Django. For example, if I have such a model inside my models.py file, Django sets a id(primary key) for every instance of it and Django increments it automatically like 1,2,3 etc. : class AuctionListing(models.Model): name = models.CharField(max_length=200) url = models.URLField() def __str__(self): return f"{self.name}" Since it sets id(primary key) automatically as a data type of integer, I can create such a url in the url.py file : path("<int:listing_id>", views.listing, name="listing") And my views.py file: def index(request): return render(request, "auctions/index.html", {"auctionList":AuctionListing.objects.all()} ) also, index.html file : {% for listing in auctionList %} <a href="url 'listing' listing.id"><img src = "{{listing.url}}" alt = "{{listing.name}}"></a> {% endfor %} The issue with this, when it passes listing.id to the path("int:listing_id", views.listing, name = "listing"), it doesn't pass id as integer but as str. That's why, path doesn't accept it since it is int:listing_id and when I go to the page, it gives me this error : " The current path, url 'listing' listing.id, didn't match any of these". When I change int:listing_id to str:listing_id it works. I wonder if the default data type of id is a string data … -
How to filter by dropdown and search in Django, JQuery and Ajax?
I have a Postgresql database containing 5 columns. id region_name subregion_code zone_code building_code #Database Details Total row = 300k Distinct region name total = 221 Each region have 1+ subregion code (code value start from 1, 2, 3, ..) Each subregion have 1+ zone code (code value start from 1, 2, 3, ..) Each zone code have 200+ building code (code value start from 1, 2, 3, ..) All are inter-related. #What I want?? I have a search page where user can search thier buidling details using building_code. First select region_name (choose from dropdown distinct list) Then, select subregion_code of this selected region_name (choose from dropdown distinct list) Then, select zone_code of this selected subregion_code Finally, type building_code and search building details of this selected zone_code #Django Model Class RBC(models.Model): id = models.AutoField(primary_key=True) region_name = models.CharField(max_length=255) subregion_code = models.IntegerField() zone_code = models.IntegerField() building_code = models.IntegerField() def __str__(self): return self.region_name How can I do it? Thanks! -
Django Tutorial: Reverse for 'results' with arguments '(1,)' not found error
I'm currently following the Django tutorial and got stuck at module 4 since I keep getting the following error message: NoReverseMatch at /polls/1/vote/ Reverse for 'results' with arguments '(1,)' not found. 1 pattern(s) tried: ['polls/int:question_id>/results/$'] Below my codes so far: views.py: from django.shortcuts import get_object_or_404, render from django.http import HttpResponse, HttpResponseRedirect, Http404 from django.urls import reverse from .models import Choice, Question def index(request): latest_question_list = Question.objects.order_by('-pub_date')[:5] context = {'latest_question_list': latest_question_list} return render(request, 'polls/index.html', context) def detail(request, question_id): question = get_object_or_404(Question, pk=question_id) return render(request, 'polls/detail.html', {'question' : question}) def results(request, question_id): question = get_object_or_404(Question, pk=question_id) return render(request, 'polls/results.html', {'question': question}) def vote(request, question_id): question = get_object_or_404(Question, pk=question_id) try: selected_choice = question.choice_set.get(pk=request.POST['choice']) except (KeyError, Choice.DoesNotExist): # Redisplay the question voting form. return render(request, 'polls/detail.html', { 'question': question, 'error_message': "You didn't select a choice.", }) else: selected_choice.votes += 1 selected_choice.save() return HttpResponseRedirect(reverse('polls:results', args=(question.id,))) urls.py: from django.urls import path from . import views app_name = 'polls' urlpatterns = [ path('', views.index, name='index'), path('<int:question_id>/', views.detail, name='detail'), path('int:question_id>/results/', views.results, name='results'), path('<int:question_id>/vote/', views.vote, name='vote'), ] reults.html: <h1>{{ question.question_text }}</h1> <ul> {% for choice in question.choice_set.all %} <li>{{ choice.choice_text }} -- {{ choice.votes }} vote{{ choice.votes|pluralize }}</li> {% endfor %} </ul> <a href="{% url 'polls:detail' question.id %}">Vote again?</a> … -
Django lt+gt condition Vs. not equal condition
I have the following model class P(models.Model): name = models.CharField(max_length=30, blank=False) class pr(models.Model): p = models.ForeignKey(P, on_delete=models.CASCADE, related_name='cs') r = models.CharField(max_length=1) c = models.ForeignKey(P, on_delete=models.CASCADE, related_name='ps') rc = models.PositiveSmallIntegerField() class Meta: unique_together = (('p', 'c'),) and the data "id","name" 69,"Hunter" 104,"Savannah" 198,"Adrian" 205,"Andrew" 213,"Matthew" 214,"Aiden" 218,"Madison" 219,"Harper" --- "id","r","rc","c_id","p_id" 7556,"F",1,219,213 7557,"M",1,219,218 7559,"H",3,218,213 7572,"F",1,214,213 7573,"M",1,214,218 7604,"F",1,198,213 7605,"M",1,198,218 7788,"H",3,104,205 7789,"F",1,104,213 7790,"M",1,104,218 7866,"M",1,69,104 7867,"F",1,69,205 the following two queries should produce similar results A = P.objects.filter(Q(Q(ps__rc__lt = 3) | Q(ps__rc__gt = 3)), ps__p__cs__c = 198).exclude(pk = 198).annotate(bt=Count('ps__rc', filter=Q(ps__rc = 1, ps__p__cs__rc = 1))) B = P.objects.filter(~Q(ps__rc = 3), ps__p__cs__c = 198).exclude(pk = 198).annotate(bt=Count('ps__rc', filter=Q(ps__rc = 1, ps__p__cs__rc = 1))) strangely; query A produce the expected results but B is missing model instance 104! After further troubleshooting I found that query B generates the following SQL: SELECT "eftapp_p"."id", "eftapp_p"."name", COUNT("eftapp_pr"."rc") FILTER (WHERE (T4."rc" = 1 AND "eftapp_pr"."rc" = 1)) AS "bt" FROM "eftapp_p" LEFT OUTER JOIN "eftapp_pr" ON ("eftapp_p"."id" = "eftapp_pr"."c_id") LEFT OUTER JOIN "eftapp_p" T3 ON ("eftapp_pr"."p_id" = T3."id") LEFT OUTER JOIN "eftapp_pr" T4 ON (T3."id" = T4."p_id") WHERE (NOT ("eftapp_p"."id" IN (SELECT U1."c_id" FROM "eftapp_pr" U1 WHERE U1."rc" = 3)) AND T4."c_id" = 198 AND NOT ("eftapp_p"."id" = 198)) GROUP BY "eftapp_p"."id" Is … -
Standard way to implement data input table's frontend for Django
I need to build a website with the following types of data input table. I want to use html, css, js and bootstrap for the frontend and Django for the backend and SQLite also as Django's default database system. Now I am confused about what is the standard way to implement this type of input table's frontend. I can generally implement a table and inside the cell(means inside <td> tag) I can put another <input> tag to take input data and send it in the database from the user). Or I can use an editable table (Actually I do not know if it is possible to use this type of editable table to send data in the database or not). Here I need an add row button and delete row icon also like the picture to add/remove the input row if needed, and I don't know how to implement it also thus it will easily reachable from the backend. So please suggest to me what is the best way and how I should implement this frontend thus I won't be trouble to implement this website's backend also. -
How to upload pdf file in django model and handle as json object?
Field:cv_file Explanation:A json object with only Unique UUID field. Upon POST, server will respond with a FILE ID TOKEN in response's cv_file json object. Restriction to handle:JSON Object, REQUIRED Field:cv_file.tsync_id Explanation:UUID type unique string ID for cv_file entity - Needs to be internally generated from API Client side Restriction to handle:Plain Text, max length = 55, REQUIRED -
django: loop through images to show one per page
i want to make the images appear one per page as in "template/1" shows image 1 and so on. i got pagination from bootstrap but i couldn't figure out how to link the images in my template. i already have static set up and most of my website ready but i don't have any relevant code to show except this list i tried. def imageview(request): context_dict = {} files = os.listdir(os.path.join(os.path.join(BASE_DIR, 'static'), "app_name/images/")) context_dict['files'] = files return render(request, 'images.html', context=context_dict) -
django long-running process
My Django app has a function that enables end-user to retrieve data from a third-party server and store the data on S3 bucket. This function can be running for a long time of 1-2 hours depending on the requested data. Apart from setting the timeout for my Gunicorn to a very large number, maybe 99999 seconds, is there another alternative? The app is on AWS micro instance, if this is relevant. -
Create a project management app in Django - DAGs and Dependencies
I'm working in a Project management app. One of the points that the app needs is the possibility to create Tasks that have dependencies, i.e. Task 2 depends on Task 1, Task 3 depends on Task 2 and Task B, etc. This would generate a DAG (directed acyclic graph). The problem is how to store this "graph" using the Django default ORM. I've come with a solution that uses Many-to-Many relationship (Task with self) and a trigger to avoid creating cycles, but I still don't know how to implement some operations such as getting the whole graph from a single node. Does anyone have an idea on how to implement it nicely? This would allow to perform an implementation of the Critical Path Method, for example. Thanks -
Why won't my django user creation forms show the styling
The styling works with the same class on a different form. But won't work on my login and register pages. i am going to add some extra text because stack overflow is telling me i have too much code entered. Here is the form.py file: class CreateUserForm(UserCreationForm): class Meta: model = User fields = ['username', 'email', 'password1', 'password2'] username = forms.TextInput(attrs={'class': 'form_input_text'}) email = forms.EmailInput(attrs={'class': 'form_input_text'}) password1 = forms.PasswordInput(attrs={'class': 'form_input_text'}) password2 = forms.PasswordInput(attrs={'class': 'form_input_text'}) Here is the template: {% block content%} <div class="content_section"> <div class="sub_header_container"> <p class="sub_header">Register</p> <form method="POST" class="input_group"> {% csrf_token %} <div class="input_prompt"> <div class="txt_field"> {{ form.username.label }} {{ form.username }} </div> </div> <div class="input_prompt"> <div class="txt_field"> {{ form.email.label }} {{ form.email }} </div> <div class="input_prompt"> <div class="txt_field"> {{ form.password1.label }} {{ form.password1 }} </div> <div class="input_prompt"> <div class="txt_field"> {{ form.password2.label }} {{ form.password2 }} </div> <div class="submit_container"> <input type="submit" name="create User" value="Submit"> </div> <div> <small>Already have an account? <a href="{% url 'login' %}">Sign In</a></small> </div> </form> </div> {% endblock content %} -
authenticate() not working properly for django
Basically what I have done so far is create a registration page where the user makes their username and password, then that password is stored in as a hashed password (md5 hasher). The problem I am having is logging in. The user inputs their username and password then the password is authenticated by using authenticate() method in django. The problem is that authenticate() is returning None instead of matching the user and password in the database. I dont know if this affects anything but I am using PostgreSQL. models.py class MyAccountManager(BaseUserManager): def create_user(self, email,username,first_name,password= None): if not email: raise ValueError('User must have an email address') if not username: raise ValueError('User must have a username') if not first_name: raise ValueError('User must have a first name') user= self.model( email=self.normalize_email(email), username= username, first_name= first_name ) user.set_password(password) user.save(using=self._db) return user def create_superuser(self, email, username, first_name, password): user= self.create_user( email= self.normalize_email(email), username=username, first_name= first_name, password= password, ) user.is_admin= True user.is_staff= True user.is_superuser= True user.save(using=self._db) return user class User(AbstractBaseUser, models.Model): email = models.EmailField(verbose_name='email', max_length=60, unique=True) username = models.CharField(max_length=30, unique=True) date_joined = models.DateTimeField(auto_now_add=True, verbose_name='date joined') last_login = models.DateTimeField(verbose_name='last login', auto_now=True) is_admin = models.BooleanField(default=False) is_staff = models.BooleanField(default=False) is_superuser = models.BooleanField(default=False) is_active = models.BooleanField(default=True) first_name = models.CharField(max_length=30) last_name = … -
Pagination next and previous button is not working(After doing Filter operation)
I have Implemented Pagination and filter both options and I am using Django template tags to work both together. (As without/before implementation when I do filter it is not working as expected. ) Please find the below code. templatetags @register.simple_tag def relative_url(value, field_name, urlencode=None): url = '?{}={}'.format(field_name, value) if urlencode: querystring = urlencode.split('&') filtered_querystring = filter(lambda p: p.split('=')[0] != field_name, querystring) encoded_querystring = '&'.join(filtered_querystring) url = '{}&{}'.format(url, encoded_querystring) return url pagination.html {% if page.has_other_pages %} <ul class="pagination"> {% if page.has_previous %} <li><a href="?page={{ page.previous_page_number }}">&laquo;</a></li> {% else %} <li class="disabled"><span>&laquo;</span></li> {% endif %} {% for i in page.paginator.page_range %} {% if page.number == i %} <li class="active"><span>{{ i }} <span class="sr-only">(current)</span></span></li> {% else %} <li> <a href="{% relative_url i 'page' request.GET.urlencode %}">{{ i }}</a> </li> {% endif %} {% endfor %} {% if page.has_next %} <li><a href="?page={{ page.next_page_number }}">&raquo;</a></li> {% else %} <li class="disabled"><span>&raquo;</span></li> {% endif %} </ul> {% endif %} except next and previous (after filtering result) another thing is working fine. I know this problem is because of the URL and not able to figure out how to define it correctly in pagination.html -
Video streaming Using Django, JS, HTML, Ajax
I am trying to make a video streaming website Currently i have made one and that one uses the resource as this Here you can see that it is loading under media tab but i want to stream using a method like Youtube Uses (using xhr/ajax) as you can see here all the video data is being loaded using xhr for this i tried using method described in this article https://medium.com/canal-tech/how-video-streaming-works-on-the-web-an-introduction-7919739f7e1 but i doesn't work -
Django + SQL Server + update_or_create = ERROR 23000
Why does the following code give me an error when trying to write to a SQL Server but not on sqlite3 or mysql? obj, created = cls.objects.using(database_data).update_or_create(**item) The datamodel is defined below: class fubar(models.Model) region = models.CharField(max_length=32, default='ABCD') market_participant = models.CharField(max_length=32, default='ACME') trade_date = models.DateField() interval_begin = models.DateTimeField() interval_end = models.DateTimeField() interval_type = models.CharField(max_length=32, default='5MIN') location = models.CharField(max_length=32, default=None, null=True, blank=True) location_type = models.CharField(max_length=32, default=None) class Meta: unique_together = [ 'region', 'market_participant', 'trade_date', 'interval_begin', 'interval_end', 'interval_type', 'location', 'location_type' ] IntegrityError: ( '23000', "[23000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server] Cannot insert duplicate key row in object 'dbo.foo` with unique index 'foo_region_market_participant_trade_date_interval_begin_inte_d7d3bf7e_uniq'. The duplicate key value is (ABCD, ACME, 2020-12-06, 2020-12-06 00:00:00.0000000, 2020-12-06 00:05:00.0000000, 5MIN, BAZ, QUX). (2601) (SQLExecDirectW)" ) Note: Error code was originally one line. I have re-formatted for readability. -
Serializition & JSON Data Error - Python DJANGO
I know that there are also posts regarding the same questions and I have tried them all but could not figure out and going nuts. I am doing a project where a member can join by paying a membership fee and created a Decimal field in Models and trying to pull the data and add it into the payment method (using iyzico https://dev.iyzipay.com/en) but no matter what I can do I can get the answer. My serialized data is below. [{"model": "instructor.post", "pk": 6, "fields": {"price": "1.00"}}] I have tried to loop through but got all sorts of error such as "string indices must be integers" or "expected two arguments got one" Need to reach the price and define it to the database so the user who wants to buy it can see how much the price is. views.py def groups_detail(request, slug): class LazyEncoder(DjangoJSONEncoder): def default(self, obj): if isinstance(obj, Decimal): return str(obj) return super().default(obj) serializedData = serialize('json', Post.objects.all(), cls=LazyEncoder, fields=('price')) print(serializedData) visitor = Profile_Member.objects.filter(email=request.user.email) Profile = Profile_Member.objects.get(email=request.user.email) email = Profile.email name = Profile.name surname = Profile.surname phone = Profile.phone idNumber = Profile.idNumber city = Profile.city country = Profile.country zipCode = Profile.zipCode registrationAddress = Profile.registrationAddress options = { 'api_key': 'sandbox-JKPhjjDBTNdPokHv0u3OlhuA8KvLky6o', 'secret_key': … -
Djongo remote connection problems
I can not to connet to mongoDB remote database. Djongo try to connect to localhost. I try to solved it reinstalling djongo 1.2.38 like in Cant connect remote mongodb server with django/djongo but then the model can not find ArrayField. -
Querying a User Profile model
I'm having trouble with this query. Users application models.py class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) current_story = models.PositiveSmallIntegerField(null=True) return f'{self.user.username} Profile' To avoid confusion, the 'current_story' will eventually be a foreign key for the Books.story model (excluded here) once I learn how to do use a foreign key across apps. Books application models.py class character(models.Model): fk_user = models.ForeignKey(User, default='1', on_delete=models.CASCADE) fk_story = models.ForeignKey(story, default='1', on_delete=models.CASCADE) name = models.CharField(max_length=100, default='', null=True) def __str__(self): return self.name class Meta: ordering = ('name', ) views.py from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin from users.models import Profile from .models import (character) class listof_characters(LoginRequiredMixin, ListView): model = character template_name = '/list_characters.html' context_object_name = 'characters' ordering = ['name'] def get_queryset(self): ? This is where i'm stuck. I need character.fk_story = User.profile.current_story. I don't how to phrase this query, I've tried several different things based on other answers and I've tried User.current_story, User.userprofile.current_story as well. I just need to filter the list of characters by current user's 'current_story' value. -
Wsgi file modification for flask to django
When I host my flask app using apache2/mod_wsgi. My wsgi file is like this: #!/usr/bin/python3.8 import logging import sys logging.basicConfig(level=logging.DEBUG) sys.path.insert(0, '/repo_location') from main import app as application When I try this repo locally all I have to do is python main.py I am moving this repo to Django. I can run it locally. python manage.py runserver In this case how would my .wsgi file change? totally confused! -
how to integrate cloudinary in existing django project [closed]
How do I integrate Cloudinary in an existing Django project, where already most of photos and media files are stored in the file folder system like in development? I also need to upload those previous media files to cloudinary. I looked into the cloudinary documentation, and i saw about auto-upload (Lazy-migration) but i am still unclear about it. -
I want to learn django from beginners to advance
I have learned python now and some basics of Django can anyone suggest where can I learn advanced topics of Django free? -
Can't migrate new models
Hi my code was running smoothly as i was following a tutorial but at a new step while adding new component in the model Order (processing, aprouved, refunbd_requested, refund_granted) the code crashed, the migrations operated but can't migrate i need help please. my models.py from django.conf import settings from django.db import models from django.shortcuts import reverse from django_countries.fields import CountryField class Order(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete= models.CASCADE) items = models.ManyToManyField(OrderItem) start_date = models.DateTimeField(auto_now_add=True) ordered_date = models.DateTimeField() ordered = models.BooleanField(default=False) billing_address = models.ForeignKey('BillingAddress', on_delete= models.SET_NULL, blank=True, null=True) payment = models.ForeignKey('Payment', on_delete= models.SET_NULL, blank=True, null=True) coupon = models.ForeignKey('Coupon', on_delete= models.SET_NULL, blank=True, null=True) processing = models.BooleanField(default=False) aprouved = models.BooleanField(default=False) refund_requested = models.BooleanField(default=False) refund_granted = models.BooleanField(default=False) def __str__(self): return self.user.username def get_total(self): total = 0 for order_item in self.items.all(): total += order_item.get_final_price() if self.coupon: total -= self.coupon.amount return total The last line of code for the error traceback after the migration, i try python manage.py migrate but i get that at the last line. File "C:\Users\18094\AppData\Local\Programs\Python\Python37\lib\sitepackages\django\utils\dateparse.py", line 107, in parse_datetimematch = datetime_re.match(value) -
How to set django admin panel not to load css from aws s3 but from default?
In my django project i am using amazon s3 to store files (media, css, js). The site is loading properly but django admin panel does not, it is in plain html. How do I make it work properly, what should I add or change in my settings? S3 configuration: AWS_ACCESS_KEY_ID = '***' AWS_SECRET_ACCESS_KEY = '***' AWS_STORAGE_BUCKET_NAME = '***' AWS_S3_HOST = 's3.eu-central-1.amazonaws.com' AWS_S3_REGION_NAME="eu-central-1" AWS_S3_FILE_OVERWRITE = False AWS_DEFAULT_ACL = None DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'