Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
RecursionError: trouble
models.py from django.db import models CATEGORY_CHOICES=( ( "A" ," ACTION"), ("D" ,"DRAMA"), ("C" , "COMEDY"), ("R" ,"ROMANTIC"), ) class Post(models.Model): title = models.CharField(max_length=200) description = models.TextField( max_length =1000) image =models.ImageField(upload_to ='movies') category =models.CharField(choices= CATEGORY_CHOICES ,max_length =1) def __str__(self): return self.title urls.py from . import views from django.urls import MovieList , MovieDetail urlpatterns = [ path('', MovieList.as_view() , name = 'move_list') path('<int:pk>' MovieDetail.as_view(), name='movie_detail'), ] views.py from django.shortcuts import render from django.views.generic import ListView ,DetailView from . models import MovieList # Create your views here. class MovieList(ListView): models= Movie class MovieDetail(DetailView): model = Movie i don't know how to state problem this is error File "/data/data/com.termux/files/usr/lib/python3.8/inspect.py", line 2479, in init self._kind = _ParameterKind(kind) File "/data/data/com.termux/files/usr/lib/python3.8/enum.py", line 304, in call return cls.new(cls, value) RecursionError: maximum recursion depth exceeded while calling a Python object -
My button does not call the Javascript, any idea why? [closed]
this is my JS: function toggleDarkMode() { var element = document.body; element.classList.toggle("darkMode"); console.log("test") } My HTML: <button onClick="toggleDarkMode">Dark Mode</button> I'm building a webapp in Django. My console outputs nothing when I click on the button. But when I type the function name in the console it prints the function code itself. Any ideas? Thanks! -
Django REST: string in URL is identified as username variable
I have two viewsets. First one is used for administrators to retrieve and modify information about users and second one is there to let user retrieving and modifying his own profile. I am registering first one to address 'users' in router and set lookup_filed in viewset to ('username') so it is possible to retrieve single object by accessing 'users/{username}'. And when I register second viewset to 'users/me' it reads 'me' as username and predictibly returns nothing. If it was regular URL I could simply move 'users/me' above thus avoiding such scenario, but this won't work in router. Is there any way to overcome this issue? My views.py with 2 viewsets: class UsersViewSet(viewsets.ModelViewSet): queryset = User.objects.all() serializer_class = UsersSerializer permission_classes = [permissions.IsAuthenticated, IsAdminOrProhibited] lookup_field = 'username' class ProfileViewSet(mixins.RetrieveModelMixin, mixins.UpdateModelMixin, viewsets.GenericViewSet): serializer_class = ProfileSerializer permission_classes = [permissions.IsAuthenticated, IsOwnerOrProhibited] def get_object(self): obj = get_object_or_404(User, id=self.request.user.id) return obj My serializers: class UsersSerializer(serializers.ModelSerializer): class Meta: fields = ('first_name', 'last_name', 'username', 'email', 'bio', 'role') model = User class ProfileSerializer(serializers.ModelSerializer): class Meta: fileds = ('first_name', 'last_name', 'username', 'email', 'bio', 'role') read_only_fields = ('role') model = User My urls: router = DefaultRouter() router.register('auth/email', ObtainConfirmationCode, basename='obtaincode') router.register('users', UsersViewSet, basename='users') urlpatterns = [ path('v1/', include(router.urls)), ] Any help is appreciated. … -
django SECURE_SSL_REDIRECT with nginx reverse proxy
Is it secure to set SECURE_SSL_REDIRECT=False if I have nginx setup as a reverse proxy serving the site over https? I can access the site over SSL if this is set this to False, where as if it is True, I receive too many redirects response. NOTE: nginx and django run from within docker containers. My nginx.conf looks like: upstream config { server web:8000; } server { listen 443 ssl; server_name _; ssl_certificate /etc/ssl/certs/cert.com.chained.crt; ssl_certificate_key /etc/ssl/certs/cert.com.key; location / { proxy_pass http://config; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_redirect off; } location /staticfiles/ { alias /home/app/web/staticfiles/; } } -
No css styles on Django web-app deployed on heroku
I have created a simple web-app using django when i run it on my localhost it works fine. But after I deployed it to heroku the admin page has no css my setting.py file has configuration STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_URL = '/static/' When I visit my site deployed on heroku the admin page looks like this (ie, no css) And on my localhost it lookscompletely fine i also ran python manage.py collectstatic command In static folder all css are present but when ran on heroku they are not loaded -
django app deployed on Azure VM : wagtail fonts not showing, access to font blocked by CORS policy
the CORS policy problem is kinda common, but i didn't find any topics dealing with an Azure-deployed app. My Web server configuration is a quite simple nginx-gunicorn setup. The problem is I can't figure out how to allow CORS requests. I tried to enable CORS through nginx.conf file, but it didn't change anything. Thank you for answers -
Django - best way to store large amounts of numerical data
I have to import datasets with 50-150 columns and 10000-50000 rows (probably even more in the future) into a database using django and postgreSQL. So currently I have a model "row" which has a float-field for every column. However, when importing data it takes up to a minute per dataset because bulk_create needs to go over all the 50000 rows. The goal is to get the time needed for an import below 5 seconds. So what would be a more efficient way to store it? I thought about using ArrayField or JSONField (for each column), but I am concerned that the queries might become more complicated and slow since it is very important that all the datapoints can be easily accessed to ensure fast visualization in the front-end. Another Idea is to use BinaryField and simply store the whole dataset as a pandas-dataframe or numpy-array. However, this approach seems to be very unclean to me. So do you have recommendations on how to solve this? -
Why does Django rest_framework showing detail invalid signature error?
I am trying to update my django user and it's keeps giving me an error:{"detail":"Invalid signature."} my View: class CurrentUserProfile(generics.UpdateAPIView): queryset = User.objects.all() serializer_class = UserSerializer permission_classes = [permissions.IsAuthenticated] def get_object(self): queryset = self.filter_queryset(self.get_queryset()) # make sure to catch 404's below obj = queryset.get(pk=self.request.user.id) self.check_object_permissions(self.request, obj) return obj def update(self, request, *args, **kwargs): instance = self.get_object() instance.username = request.data.get('username', instance.username) instance.email = request.data.get('email', instance.email) instance.password = request.data.get('password', instance.password) instance.save() serializer = UserSerializer(instance, data=request.data) serializer.is_valid(raise_exception=True) self.perform_update(serializer) return Response(serializer.data) And this is a Serializer: class UserSerializer(serializers.ModelSerializer): email = serializers.EmailField(required=True) # time = serializers.IntegerField(required=True) class Meta: model = User fields = ('id','username', 'password', 'email',) write_only_fields = ('username', 'password', 'email') read_only_fields = ('id', ) def create(self, validated_data): user = User.objects.create_user( username=validated_data['username'], email=validated_data['email'], # time=validated_data['time'] ) user.set_password(validated_data['password']) user.save() return user def update(self, instance, validated_data): if validated_data.get('user') is not None: instance.user.set_password(validated_data['user'].get('password', instance.user.password)) instance.user.username = validated_data['user'].get('username', instance.user.username) instance.user.email = validated_data['user'].get('email', instance.user.email) instance.user.save() return instance I am using jWT token and it works as well. P.S. While making an university project i've got a ton of errors which i don't know why they keep appearing. Maybe you can give me an advice, how you learned django rest and django itself. If i have missed something important , let … -
CSS class is not being applied to HTML image (django)
I am facing a problem where image that I opened in html file with class included is not getting modified by the class in css file. I checked it in sources tab in chrome, and model class is not being processed. I will attach the code: -
filters.FilterSet with a custom field that is not in the model
class SomeFilter(filters.FilterSet): id = NumberInFilter(field_name='id') name = StringInFilter(field_name='name') custom_field_that_is_not_in_model = filters.CharFilter() This displays "[invalid name]:" because field custom_field_that_is_not_in_model is not in the Model (other fields work fine). How can I make it display what I want? I am going to call a custom method on this field. -
Django: Cannot assign "'1'": "Randomisation.pay_ide" must be a "Pays" instance
I have modify my models Randomisation with a FK on Pays model And I have an error when try to register a Randomization Initially, the field pay_ide on my RandomizationForm should be disable and initialized with the user's country. I try to simplify but don't understand how to resolve the problem... thanks for help models.py: class Pays(SafeDeleteModel): """ A class to create a country site instance. """ _safedelete_policy = SOFT_DELETE_CASCADE pay_ide = models.AutoField("Code number", primary_key = True) pay_nom_eng = models.CharField("Nom", max_length = 150) pay_nom_fra = models.CharField("Nom", max_length = 150) pay_abr = models.CharField("Code lettre", max_length = 3) pay_ran = models.IntegerField("Randomization opened in the country? (y/n)", default=0, null=True, blank=True) pay_hor = models.IntegerField("Time zone position relative to GMT",default=0, null=True, blank=True) pay_log = models.CharField("Code lettre", max_length = 50) pay_dat = models.DateTimeField("Date of settings") log = HistoricalRecords() class Meta: db_table = 'adm_pay' verbose_name_plural = 'Pays' ordering = ['pay_nom_fra', 'pay_ide'] permissions = [ ('can_manage_randomization','Can activate randomization'), ] @classmethod def options_list(cls,pays,type,language): if type == 'International' or type == 'National': the_opts_set = Pays.objects.all() if type == 'Site': the_opts_set = Pays.objects.filter(pay_ide = pays) if language == 'en': the_opts_list = [(opt.pay_ide, opt.pay_nom_eng) for opt in the_opts_set] elif language == 'fr': the_opts_list = [(opt.pay_ide, opt.pay_nom_fra) for opt in the_opts_set] else: the_opts_list … -
form.is_valid() returns false in django built in User model
I am using the django built-in User model and connected it to student model using the onetoOne field, I am a beginner so please excuse any unnecessary or excess code that does not effect the error but do inform me if there is any better way, as I am trying to learn. The error comes up that the Http response was None. With slight additional code it prints 'invalid form'. So the error has to be in form.is_valid() or the way I defined the User and student model, or the authentication. forms.py file from django import forms from .models import Student, User #student forms class StudentSignUpForm(forms.Form): name = forms.CharField(max_length=256) roll_no = forms.IntegerField() sem = forms.IntegerField() branch = forms.ChoiceField(choices =[ ('EXTC','EXTC'), ('ETRX','ETRX'), ('Comps','Comps'), ('Bio','Bio'), ('Mech','Mech'), ('Civil','Civil'), ]) email = forms.EmailField() set_password = forms.CharField(max_length=100,widget=forms.PasswordInput) confirm_password = forms.CharField(max_length=100, widget= forms.PasswordInput) def clean_password(self): password1 = self.cleaned_data['set_password'] password2 = self.cleaned_data['confirm_password'] if password1!=password2 and password1 and password2: raise forms.ValidationError('Passwords do not match') def clean_email(self): email = self.cleaned_data.get('email') qs = User.objects.filter(email=email) if qs.exists(): raise forms.ValidationError("email is taken") return email class Login(forms.ModelForm): class Meta: fields=['username','password'] model = User widgets={ 'password':forms.PasswordInput(), } models.py from django.db import models from django.urls import reverse from django.contrib.auth.models import User # Create your models … -
filter MyDjango data based on condition and calculation in django
class Student(): name=models.CharField(max_length=200) surname=models.CharField(max_length=200) class group2020(): name=models.CharField(max_length=200) math=models.DecimalField(decimal_places=2,max_digits=1000) english=models.DecimalField(decimal_places=2,max_digits=1000) biology=models.DecimalField(decimal_places=2,max_digits=1000) chemistry=models.DecimalField(decimal_places=2,max_digits=1000) class group2019(): name=models.CharField(max_length=200) math=models.DecimalField(decimal_places=2,max_digits=1000) english=models.DecimalField(decimal_places=2,max_digits=1000) biology=models.DecimalField(decimal_places=2,max_digits=1000) chemistry=models.DecimalField(decimal_places=2,max_digits=1000) I handle data like: grade=groupA.objects.filter(Q(math__gt=50) & Q(english__gt=68)) which gives me list of student who math grade more tha 50 and english greade more than 68. Howevere I want to get students where math/english is more than 2 and chemistry/mathh is less than 1. i tried groupA.objects.annotate(type1=F(math)/F(english)) however it does not work. How to do that ? -
How can we share channel consumer as api?
I have created a channel that implements some text operations using a shared task which returns the response back to the channel layer. #consumers.py import json import pdb from asgiref.sync import async_to_sync from channels.generic.websocket import AsyncWebsocketConsumer from . import tasks COMMANDS = { 'help': { 'help': 'Display help message.', }, 'sum': { 'args': 2, 'help': 'Calculate sum of two integer arguments. Example: `sum 12 32`.', 'task': 'add' }, 'status': { 'args': 1, 'help': 'Check website status. Example: `status twitter.com`.', 'task': 'url_status' }, } class Consumer(AsyncWebsocketConsumer): async def receive(self, text_data): text_data_json = json.loads(text_data) message = text_data_json['message'] # response_message = 'Please type `help` for the list of the commands.' message_parts = message.split() if message_parts: command = message_parts[0].lower() if command == 'help': response_message = 'List of the available commands:\n' + '\n'.join([f'{command} - {params["help"]} ' for command, params in COMMANDS.items()]) elif command in COMMANDS: if len(message_parts[1:]) != COMMANDS[command]['args']: response_message = f'Wrong arguments for the command `{command}`.' else: getattr(tasks, COMMANDS[command]['task']).delay(self.channel_name, *message_parts[1:]) # response_message = f'Command `{command}` received.' response_message = message await self.channel_layer.send( self.channel_name, { 'type': 'chat_message', 'message': response_message } ) #tasks.py @shared_task def add(channel_layer, x, y): message = '{}+{}={}'.format(x, y, int(x) + int(y)) async_to_sync(channel_layer.send)({"type": "chat.message", "message": message}) I want to share this channel as an … -
Documenting Django using UML
Hello Stack Overflow Community I'm trying to document my project and I have doubled on how to translate Django Views into UML Class Diagrams. I have to mention that I'm not using class views, just normal views. Can you please tell me if this is ok? Do I need to let know the reader what I'm trying to achieve or it is clear what the diagram says? Many thanks in advance for your feedback This is the code def index_crypto(request): import requests import json #Api Call url = 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest?start=1' headers = {'Accepts': 'application/json','X-CMC_PRO_API_KEY':'xxxxxxxxxx',} params = {'convert' :'USD'} api_request = requests.get(url, headers= headers,params= params) #Request Object try: data = json.loads(api_request.content) #JSON file containing data. except Exception as e: data = "Error...." print(e) api_assets= [] for i in data["data"]: api_assets.append(i) return render(request,'index_crypto.html',{'api_assets': api_assets}) -
Why am I getting '[Errno 13] Permission denied: '/static'' when uploading file to django admin even when I have permissions?
I recently finished deploying my website using apache2 and django. I was testing everything, icluding the uploading process. But, when I select a file to upload and hit 'Save', it gives me an error: PermissionError at /admin/path/path2/add/ [Errno 13] Permission denied: '/static' This is my apache2 config file (just the static folder part): Alias /static /home/alexholst/excelsite/static <Directory /home/alexholst/excelsite/static> Require all granted </Directory> I have all the right permissions, since I wrote these commands to allow permissions: sudo chown -R :www-data project/static sudo chmod -R 775 project/static sudo chown :www-data project/db.sqlite3 sudo chmod 664 project/db.sqlite3 sudo chown :www-data project/ This works, since when I do ls -l, the permissions are correct. My settings.py file has this as STATIC_ROOT and STATIC_URL: STATIC_URL = '/static/' STATIC_ROOT = '/home/user/project/static' I dont know if this has to do with anything, but my css does load so i dont think it should have to do with the settings.py. Any suggestions are very much appreciated! -
I want to use a python code in django template
I have this code in my django template: {% for i in concedii %} <tr> <td> {{ i.7 }} </td> <td> {{ i.8 }} </td> {% for d in luna %} <td class="text-center"> {% if d.0 > i.5 > d.1%} {{ i.4 }} {% endif %} </td> {% endfor %} <td>-</td> </tr> {% endfor %} And inside this code I would like to implement this code: val1 = 23.04 # this is the d.0 from django template above val2 = 29.04 # this is the d.1 from django template above tobe1 = 24.04 # this is the i.5 from django template above tobe2 = 27.04 # this is the i.6 from django template above if all(val1 < x < val2 for x in (tobe1, tobe2)): print(saptamani) -
Deploying Keras model in django
I am using Django to build APIs for my project. What I was trying to do is load a Keras Conv Net model to process the requests made to the API's endpoint, but Keras seems to have a problem loading the model in Django. The error is as follows: '_thread._local' object has no attribute 'value' and it points to the line where I load my Keras model. Here's the post request handler in my Django apps view file def post(self, request): image_serializer = MalariaDiseaseSerializers(data=request.data) if image_serializer.is_valid(): image_serializer.save() __model = load_model('trained_models/malaria/malaria.h5') image = cv2.imread("media/"+str(request.FILES['image'])) image_array = Image.fromarray(image , 'RGB') resize_img = image_array.resize((50 , 50)) resize_img = np.array(resize_img).reshape(1,50,50,3)/255. prediction = __model.predict(resize_img) index = np.argmax(prediction) self.__response_data['prediction'] = self.__classes[index] self.__response_data['probability'] = prediction[index] return Response(self.__response_data, status=status.HTTP_201_CREATED) return Response(image_serializer.errors, status=status.HTTP_400_BAD_REQUEST) Can someone help me out with this? Thank you! -
django docs email is not activated after click on email confirmation link in Django mail backend
I created the Django email backend for active the email during the registration. But in my case When I register the account and confirmation email is sent on my email and after click on the confirmation link then it's not activate the user's account and link is not redirected on login page. setting.py EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'smtp.gmail.com' EMAIL_USE_TLS = True EMAIL_PORT = 587 EMAIL_HOST_USER = 'your_mail@gmail.com' EMAIL_HOST_PASSWORD = 'XXXXXXXXXX' ACCOUNT_EMAIL_VERIFICATION = 'mandatory' ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_AUTHENTICATION_METHOD = "USERNAME" ACCOUNT_CONFIRM_EMAIL_ON_GET = True ACCOUNT_EMAIL_CONFIRMATION_ANONYMOUS_REDIRECT_URL = reverse_lazy('account_confirm_complete') ACCOUNT_EMAIL_CONFIRMATION_AUTHENTICATED_REDIRECT_URL = reverse_lazy('account_confirm_complete') urls.py urlpatterns = [ url(r'^user_reg/registration/account-email-verification-sent/', email_view.null_view, name='account_email_verification_sent'), url(r'^user_reg/registration/account-confirm-email/(?P<key>[-:\w]+)/$', VerifyEmailView.as_view(), name='account_confirm_email'), url(r'^user_reg/registration/complete/$', email_view.complete_view, name='account_confirm_complete'), url(r'^user_reg/password-reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', email_view.null_view, name='password_reset_confirm'), path('admin/', admin.site.urls), path('user_reg/', include('users.urls', namespace="users")), path('user_reg/registration/', include('rest_auth.registration.urls')), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) And below the email message Greeting from example.com! You're receiving this e-mail because user usertest has given yours as an e-mail address to connect their account via API. To confirm this is correct, go to http://127.0.0.1:8000/user/registration/account-confirm-email/Mjg:1jSeJC:4btJkSnHSxYN7w5CITEPydcG9cA/ Thank you from example.com! example.com Where is the problem and how can I solve this?. Please help me. Thank you! -
django: cannot connect django app to server in production
I am deploying my django app with AWS EC2, Gunicorn with supervisor and Nginx. I have religiously followed tutorials but my incompetence prevent me to spot where I am mistaken. When connecting to my IP address or my domain name I get an error saying that they cannot be reached or it tryes to connect and then says “took too long to connect” I am thinking it has to issues related with hosts because in development the app works like a charm settings.py ALLOWED_HOSTS = ALLOWED_HOSTS = ['xxx.xxx.xxx.xxx', '127.0.0.1', 'mysite.com','www.mysite.com'] (they also are set up in /etc/hosts/.) My nginx configuration: server { listen 80; server_name xxx.xxx.xxx.xxx mysite.com www.mysite.com; location / { include proxy_params; proxy_pass http://unix:/home/ubuntu/exostocksaas/app.sock; } location /static { autoindex on; alias /home/ubuntu/exostocksaas/inventory4/collected_static/; } } and this is my gunicorn configuration: [program:gunicorn] directory=/home/ubuntu/exostocksaas command=/home/ubuntu/Exos/bin/gunicorn --workers 3 --bind unix:/home/ubuntu/exostocksaas/app.sock in$ autostart=true autorestart=true stderr_logfile=/var/log/gunicorn/gunicorn.err.log stdout_logfile=/var/log/gunicorn/gunicorn.out.log user=root [group:guni] programs:gunicorn And I have also configurate my EC2 instance to also accept trafic from port 8000. when I run runserver 0.0.0.0:8000 (i know its not recommanded but just to test and launch the IP address on port 8000, I get 404 error. At this point I am feeling a little bit lost and not sure … -
Django - Model not created when user creates an account
recently, I created a new model nammed "Points" but when I create a new account, the account's model is not created. The problem may be in my signals.py : (I don't really know how it works) from django.db.models.signals import post_save from django.contrib.auth.models import User from django.dispatch import receiver from .models import Points @receiver(post_save, sender=User) def create_model(sender, instance, created, **kwargs): if created: Points.objects.create(user=instance) @receiver(post_save, sender=User) def save_model(sender, instance, **kwargs): instance.Points.save() Here's my models.py : from django.db import models from django.contrib.auth.models import User class Points(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) points = models.IntegerField(default=0) def __str__(self): return f'{self.user.username}'s points' I'm pretty sure the problem is not in admin.py : from django.contrib import admin from .models import Points admin.site.register(Points) I can create the account's model manually but I want it to be automatic. I created this model the same way when I added a profile picture feature which works but I don't understand where the problem is. -
How do I get all entries of a class if it's related set contains an arbitrary item?
class Book(models.Model): ... class Page(models.Model): book = models.ForeignKey(Book) note = models.ForeignKey(Note) class Note(models.Model): name = models.CharField() From the example above, how can I obtain all Books instances that contain an arbitrary Note? my_note = Note.objects.get(name="Arbitrary") pages_with_my_note = Page.objects.filter(note=my_note) books_with_my_note = Book.objects.filter( ??? ) -
how to save ForeignKey object and its parent object at the same time
Angular 8, Django 3. I have two models Recipe and Ingredients. I am using ngModels on the frontend to send data to Django to create a Recipe model. On one page when you click "submit", all the Recipe and Ingredients data is sent to the backend. From what i read about ManyToOne relationships the models.ForeignKey should go on the model that is part of the "many". So there are "many" Ingredients per Recipe, so i have the Foreignkey on Ingredients. My problem is when I send all this data to Django my Ingredients are not being created because there is no ingredients field on the RecipeSerializer. models.py class Recipe(models.Model): name = models.CharField(max_length=30) class Ingredients(models.Model): name = models.CharField(max_length=50) recipe = models.ForeignKey(Recipe, related_name='ingredients', on_delete=models.CASCADE) views.py class AddRecipe(generics.CreateAPIView): serializer_class = RecipeFullSerializer serializers.py class IngredientSerializer(serializers.ModelSerializer): class Meta: model = Ingredients fields = ['name'] class RecipeFullSerializer(serializers.ModelSerializer): ingredients = IngredientSerializer(many=True, read_only=True) class Meta: model = Recipe fields = ['name', 'ingredients'] sample data ingredients: Array(1) 0: {name: "23"} length: 1 __proto__: Array(0) name: "23" I am getting an array of Ingredients data on the backend just not sure how to save it all with a Foreignkey to Recipes at the same time. I guess I could create … -
Get local date time and time in Django
How can I get the local date and time in Django? I tried this solution. But it works only for the date now. from django.utils import timezone now = timezone.localtime(timezone.now()) #OK date = timezone.localtime(timezone.date()) #Error time = timezone.localtime(timezone.time()) #Error Preferably in the same format as for datetime now = datetime.datetime.now() #'2020-04-28 17:57:34.120383' date = datetime.datetime.now().date() #'2020-04-28 time = datetime.datetime.now().time() #18:12:08.987472 -
whenever i try to add something in database it show this error
My code is working well because when I run this on Mozilla it is working fine and I can also fill up the database but in chrome, I am not able to add something in the database. is this Django bug or I done some setting wrong or it is the fault of chrome? Exception happened during processing of request from ('127.0.0.1', 14264) Traceback (most recent call last): File "C:\Users\raman\AppData\Local\Programs\Python\Python38-32\lib\socketserver.py", line 650, in process_request_thread self.finish_request(request, client_address) File "C:\Users\raman\AppData\Local\Programs\Python\Python38-32\lib\socketserver.py", line 360, in finish_request self.RequestHandlerClass(request, client_address, self) File "C:\Users\raman\AppData\Local\Programs\Python\Python38-32\lib\socketserver.py", line 720, in __init__ self.handle() File "C:\Users\raman\OneDrive\Desktop\Full_stack_practice\django_virtual\venv\lib\site-packages\django\core\servers\basehttp.py", line 174, in handle self.handle_one_request() File "C:\Users\raman\OneDrive\Desktop\Full_stack_practice\django_virtual\venv\lib\site-packages\django\core\servers\basehttp.py", line 182, in handle_one_request self.raw_requestline = self.rfile.readline(65537) File "C:\Users\raman\AppData\Local\Programs\Python\Python38-32\lib\socket.py", line 669, in readinto return self._sock.recv_into(b) ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine ----------------------------------------