Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django has_perm function don't work as expected
i've got a problem with the django has_perm function as mentioned above. It always returns True, even when the user hasn't got the specific permission. So my Setup is: Customized User Model class MyAccountManager(BaseUserManager): def create_user(self, email, username, password=None): if not email: raise ValueError("Users must have an email address") if not username: raise ValueError("Users must have an username") user = self.model( email=self.normalize_email(email), username=username, ) user.set_password(password) user.save(using=self._db) return user def create_superuser(self, email, username, password): user = self.create_user( email=self.normalize_email(email), password=password, username=username ) user.is_admin = True user.is_staff = True user.is_superuser = True user.save(using=self._db) return user class Accounts(AbstractBaseUser, PermissionsMixin): email = models.EmailField(verbose_name='email', max_length=60, unique=True) is_admin = models.BooleanField(default=False) is_active = models.BooleanField(default=True) is_staff = models.BooleanField(default=False) is_superuser = models.BooleanField(default=False) objects = MyAccountManager() USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] def __str__(self): return self.email def has_perm(self, perm, obj=None): return True def has_module_perms(self, app_label): return True two user profile classes with specific permissions class Organizations(Accounts, PermissionsMixin): name = models.CharField(max_length=30) standort = models.CharField(max_length=30) def __str__(self): return self.name class Meta: permissions = [("is_organization", "is organization")] verbose_name = 'Organization' verbose_name_plural = 'Organizations' class Clients(Accounts, PermissionsMixin): name = models.CharField(max_length=30) organization = models.ForeignKey(Accounts, on_delete=models.CASCADE, null=True, blank= True, related_name='client') def __str__(self): return self.name class Meta: permissions = [("is_client", "is client")] verbose_name = 'Client' verbose_name_plural = 'Clients' … -
many to many relationship generating value error on api post request
i'm trying to send a post request to database and i encountered the following error. ValueError: "<Item: x>" needs to have a value for field "id" before this many-to-many relationship can be used. here are my models class Farmers(models.Model): First_Name = models.CharField(max_length=15) Last_Name = models.CharField(max_length=15) code =models.IntegerField(default=1) phone = PhoneField(blank=True, help_text='Contact phone number') class Item(models.Model): category = models.CharField(max_length=20) ammount_in_KG = models.IntegerField(default=1) price = models.FloatField() farmer = models.ManyToManyField( Farmers ) slug = models.SlugField(default=sluger) description = models.TextField(blank=True) image = models.ImageField(blank=True) here are the the serializers class ItemSerializer(serializers.ModelSerializer): class Meta: model = Item fields = ['id','category', 'ammount_in_KG', 'price','farmer'] class FarmerSerializer(serializers.ModelSerializer): class Meta: model = Farmers fields = ['id','First_Name', 'Last_Name','code'] here are the viewsets @api_view(['POST',]) def api_create_item_view(request): item = Item() if request.method == "POST": serializer=ItemSerializer(item ,data=request.data)#data is gonna get changed data = {} if serializer.is_valid(): serializer.save() data["success"] = "create successful" return Response(data=data) return Response(serializer.errors ,status=status.HTTP_400_BAD_REQUEST) i tried to send the request using python requests with the following data post_data={"item":"x","ammount_in_KG":"6", "farmer":[1]} i googled the solution is to save item model before farmer is added but i found that confusing in my case. i'm new to django restframework and API requests so please help me out. Thanks in advance -
Access a postgresql instance set up on GCE from local host via proxy
Can I access a postgresql instance set up on Google Cloud Engine from my local host via cloud_sql_proxy or another way? I'm trying to move a postgresql database from Cloud SQL to Compute Engine for testing purposes. So far, I 've ben using cloud_sql_proxy to run Django migrations on Cloud SQL from may local host, and I'd like to do the same with the database set up on GCE. -
Django Extra Views - Delete "InlineFormset" if condition is met on Update
So I'm using Django Extra Views to set up an orderform which includes both bookings and payments. Employees can create an Order which includes one or several Bookings and optionally include several Payments. Since the payments are optional, the total amount will be checked on saving the form. If the total payment > 0, the payment_formset is saved. The problem now is, what if an employee makes a mistake and wants to remove a payment? I do need a "min_num: 1" on the PaymentInlineForm on creating the form but I want to check if the total_payment == 0, and if it does, remove the associated payment records. I tried using payment_formset.delete() but it gives me the error; 'PaymentFormFormSet' object has no attribute 'delete' views.py - Inlines # Setting up the order form with inlines class BookingInline(InlineFormSetFactory): model = Booking form_class = BookingForm prefix = 'booking_formset' factory_kwargs = { 'extra': 0, 'min_num': 1, 'validate_min': True, 'can_delete': True } class PaymentInline(InlineFormSetFactory): model = Payment form_class = PaymentForm prefix = 'payment_formset' factory_kwargs = { 'extra': 0, 'min_num': 1, 'validate_min': False, 'can_delete': True } views.py - OrderUpdateView class OrderUpdateView(LoginRequiredMixin, NamedFormsetsMixin, UpdateWithInlinesView): model = Order inlines = [BookingInline, PaymentInline] inlines_names = ['booking_formset', 'payment_formset'] form_class = … -
language_check Remote end closed connection without response issue
I'm using language-check python package in one of my Django projects. I've installed it using pip install --upgrade language-check command. It was working fine in my device. Then I've hosted the project to an AWS ec2 instance. When I try to use the package it gives me to the following error : language_check.Error: http://127.0.0.1:8081: Remote end closed connection without response And this is my inbound rules : How can I solve the issue? Thanks in advance! -
Why is Python opengraph.OpenGraph not refreshing?
I'm calling the opengraph.OpenGraph function in Django from different post request, each one with a different url but sometimes it returns the same information and I don't know why. This is the ajax that I call many times with different urls: $.post('/getInfo', {url : url}) .done(function(res){ console.log(res) }).fail(function(){ console.log("fail") }) And the OpenGraph code: import opengraph def getInfoLink(url): url_original = url info = None try: info = opengraph.OpenGraph(url=url) return info except Exception: url = 'https://' + url try: info = opengraph.OpenGraph(url=url) return info except Exception: url = 'http://' + url_original try: info = opengraph.OpenGraph(url=url) return info except Exception: return None def getInfo(request): url = request.POST.get('url', '') print(url) # prints the right url info = getInfoLink(url) print(info) # sometimes prints the same object even when different url return JsonResponse({'info' : info}) I need to have the information corresponding to each url. -
How To Create Movie Recommendation ML Model and Deploy it to Django
I want to Learn ML and create a FYP on Movie Recommendation system and deploy it to Django. but im stucked in i cannot find any useful tutorial to deploy ML model to Django , i need some help then i will start learning ML -
How can I get the request parameter and return django rest-framework
I fetch the API like with this code http://127.0.0.1:8000/api/mytexts/?genre=93 class MyTextSerializer(serializers.ModelSerializer): class Meta: model = MyText fields = ('id','text','genre') it returns id text genre successfully. then now, I want to return the fetch code 93 in json. So,I altered the code,but can't figure out yet.. class MyTextSerializer(serializers.ModelSerializer): fetchBy = serializers.SerializerMethodField() class Meta: model = MyText fields = ('id','text','genre','fetchBy) def get_fetchBy: # error 'MyTextSerializer' object has no attribute 'get_fetchBy' return ???? -
Problem uploading using ImageField in Django on Heroku
I have an ImageField and I'm also using AWS S3. Locally this works perfectly and I am able to upload the image and view it. However, when I try to do this on heroku I get this error: expected string or bytes-like object For my ImageField in my models.py it is: image = models.ImageField(blank=False) In settings.py I have: AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID') AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY') AWS_STORAGE_BUCKET_NAME = os.environ.get('AWS_STORAGE_BUCKET_NAME') AWS_S3_FILE_OVERWRITE = False AWS_DEFAULT_ACL = None DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' AWS_S3_REGION_NAME = 'the location im using' django_heroku.settings(locals()) So not quite sure how to fix it so it works in heroku like it does locally. Thanks -
Django accessing dynamic form value from html page to views
Html code input type="text" name="a" value="{{abc}}" disabled views.py x=request.POST['a'] I am trying to access html textbox value name=a and which has a dynamic value It give MultiValueDictKey error So i change views.py code to x=request.POST.get('a') And i tried to print x it prints None instead of the value in textbox Please help -
Django accessing dynamic form value from html page to views.py
Html code '''''' views.py '''x=request.POST['a']''' I am trying to access html textbox value name=a and which has a dynamic value It give MultiValueDictKey error So i change views.py code to '''x=request.POST.get('a')''' And i tried to print x it prints None instead of the value in textbox Please help -
Django error TypeError at /admin/ 'set' object is not reversible
I just learned Django, I'm following the 'Writing your first Django app' from the website. But when I come to the Django Admin part, I got an error. TypeError at /admin/ 'set' object is not reversible Request Method: GET Request URL: http://localhost:8000/admin/ Django Version: 3.0.2 Exception Type: TypeError Exception Value: 'set' object is not reversible Exception Location: D:\python\lib\site-packages\django\urls\resolvers.py in _populate, line 455 Python Executable: D:\python\python.exe Python Version: 3.8.1 Python Path: ['D:\\python\\projek\\mysite', 'D:\\python\\python38.zip', 'D:\\python\\DLLs', 'D:\\python\\lib', 'D:\\python', 'D:\\python\\lib\\site-packages'] Server time: Sat, 1 Feb 2020 08:37:20 +0000 I realize that the error comes when I add new path to the urls.py file as the tutorial told. Here is my urls.py code from django.contrib import admin from django.urls import include, path urlpatterns = [ path('polls/', include('polls.urls')), <<---- This is the problem path('admin/', admin.site.urls), ] When I add the polls path the error comes, but when I comment that line the app work. What's wrong with my code? -
Django test not creating auth database for multi-database setup
I am trying to write unit tests for a multi-database django app. I am using a custom router for all these databases, and I have configured it to route auth and contenttypes to a specific DB (call it DB_1) which also contains other tables, one of them is called Account and has a foreign key to the User model from auth. Everything is working fine in general and now I am trying to write unit tests, but when the test runner is creating the test database, and all of my models for app_1 are created in DB_1, the auth tables are not created which causes a django.db.utils.OperationalError: no such table: auth_user error. here is the exact traceback: $ python3 ./manage.py test -v 3 app_1 Skipping setup of unused database(s): DB_2, DB_3, DB_4, DB_5, default. Creating test database for alias 'DB_1' ('file:memorydb_DB_1?mode=memory&cache=shared')... Operations to perform: Synchronize unmigrated apps: app_1, app_2, app_3, app_4, app_5 Apply all migrations: auth, contenttypes Running pre-migrate handlers for application app_2 Running pre-migrate handlers for application app_1 Running pre-migrate handlers for application auth Running pre-migrate handlers for application contenttypes Synchronizing apps without migrations: Creating tables... Creating table ACCOUNT Creating table another_one Creating table and_another_one Creating table etc Running … -
Tasks in Django 3 stops working after running for a few days: "InterfaceError: connection already closed"
I run a Django project as an Azure web app with a postgresql database, and recently updated to Django 3. I run background tasks with apscheduler Everything runs fine for a few days, and then suddenly all tasks fail until i restart the application. I get the following error from the application when trying to start tasks. The web site still works fine, its only the background tasks that stop working. Any ideas? I am not entirely sure if the problem is related to Django 3. I run a similar application with Django 3 on Heroku without any problems. 2020-02-01T07:46:31.022070581Z: [ERROR] Job "ParseRawData (trigger: interval[0:01:00], next run at: 2020-02-01 07:47:30 UTC)" raised an exception 2020-02-01T07:46:31.022113180Z: [ERROR] Traceback (most recent call last): 2020-02-01T07:46:31.022118880Z: [ERROR] File "/antenv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 238, in _cursor 2020-02-01T07:46:31.022122680Z: [ERROR] return self._prepare_cursor(self.create_cursor(name)) 2020-02-01T07:46:31.022126080Z: [ERROR] File "/antenv/lib/python3.8/site-packages/django/utils/asyncio.py", line 26, in inner 2020-02-01T07:46:31.022129580Z: [ERROR] return func(*args, **kwargs) 2020-02-01T07:46:31.022132780Z: [ERROR] File "/antenv/lib/python3.8/site-packages/django/db/backends/postgresql/base.py", line 231, in create_cursor 2020-02-01T07:46:31.022142980Z: [ERROR] cursor = self.connection.cursor() 2020-02-01T07:46:31.022146480Z: [ERROR] psycopg2.InterfaceError: connection already closed 2020-02-01T07:46:31.022149480Z: [ERROR] 2020-02-01T07:46:31.022152480Z: [ERROR] The above exception was the direct cause of the following exception: 2020-02-01T07:46:31.022155580Z: [ERROR] 2020-02-01T07:46:31.022158380Z: [ERROR] Traceback (most recent call last): 2020-02-01T07:46:31.022161480Z: [ERROR] File "/antenv/lib/python3.8/site-packages/apscheduler/executors/base.py", line 125, in run_job 2020-02-01T07:46:31.022164580Z: [ERROR] retval … -
Django Foreignkey with edit fields and select field how to put in form
I apologise if that question was raised before. But I have been struggling with this for weeks and couldn't find anything useful. I have the following problem (it is simplified a lot but essentially my problem is presented) I have Model that has a lot of fields. Its called class DocAide(models.Model): id = models.AutoField(primary_key=True) pulse = models.DecimalField('Pulse', max_digits=3, decimal_places=0) weight = models.DecimalField('Weight (kg)', max_digits=3, decimal_places=0) bp_sys = models.DecimalField('BP Sys', max_digits=3, decimal_places=0) bp_dia = models.DecimalField('BP Dia', max_digits=3, decimal_places=0) temperature = models.DecimalField('Temp. deg C', max_digits=2, decimal_places=1) drugs = models.ManyToManyField(Drug, blank=True) date = models.DateField(editable=False, default=timezone.now) doctors_notes = models.TextField('Patient is complaining about:', default='') note = models.TextField(max_length=100, default='') The ForeignKey Drugs has Names of drugs with quantity I would like to have the possibility to select multiple drugs but with edit fields that show what dosage needs to be taken and when, it should be like a prescription. The Model looks like this ` class Drug(models.Model): id = models.AutoField(primary_key=True) name = models.CharField(max_length=100, default='') QUANTITY_STR = ['Bottle', 'Tablet' 'Injection', 'Capsules', 'other'] QUANTITY = ((str, str) for str in QUANTITY_STR) quantity = models.CharField(max_length=2, choices=QUANTITY, default='Bottle') category = models.CharField(max_length=150, default='') strength = models.CharField(max_length=150, default='') in_supply_stock = models.PositiveIntegerField(default=0) in_main_stock = models.PositiveIntegerField(default=0) date = models.DateField(editable=False, default=timezone.now) charge = models.PositiveIntegerField(default=0) morning … -
Default file not found nginx - django
I'm getting this error while starting nginx Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details. systemctl status nginx.service nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Sat 2020-02-01 07:48:50 UTC; 24s ago Docs: man:nginx(8) Process: 16875 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS) Process: 17525 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE) Main PID: 16513 (code=exited, status=0/SUCCESS) Feb 01 07:48:50 quick-timetable systemd[1]: Starting A high performance web server and a reverse proxy server... Feb 01 07:48:50 quick-timetable nginx[17525]: nginx: [emerg] open() "/etc/nginx/sites-enabled/default" failed (2: No such file or directory) in /etc/nginx/nginx.conf:62 Feb 01 07:48:50 quick-timetable nginx[17525]: nginx: configuration file /etc/nginx/nginx.conf test failed Feb 01 07:48:50 quick-timetable systemd[1]: nginx.service: Control process exited, code=exited status=1 Feb 01 07:48:50 quick-timetable systemd[1]: nginx.service: Failed with result 'exit-code'. Feb 01 07:48:50 quick-timetable systemd[1]: Failed to start A high performance web server and a reverse proxy server. ls /etc/nginx/sites-available/ quick_timetable.conf sudo tail /var/log/nginx/error-log 2020/02/01 07:29:54 [emerg] 16878#16878: open() "/etc/nginx/sites-enabled/default" failed (2: No such file or directory) in /etc/nginx/nginx.conf:62 2020/02/01 07:33:50 [emerg] 17007#17007: … -
How to handle thousands of requests per minute with Python, RabbitMQ and Redis
I'm needing some advices of how to improve a message flow. I'm trying to improve my server and do callbacks on better way. Currently what is the common flow: My client send me few data to issue an invoice I may need from 2 to 20 seconds to issue that invoice (Can't speed up this as have third part server involved) I return the invoice issued to client as JSON Also when one invoice has it status updated I fire an callback to client with the new JSON. The problem, I may need handle millions of invoices per day. I do not want to scale to hundreds of servers as the million requests happens few times per month. What I'm trying to accomplish: Client send few data to issue invoice I store data on database, and put it on RabbitMQ queue to issue invoice As soon as the invoice is ready, it updates itself on database and send itself to next queue (client notification) Notify client's web hook that the invoice is generated with those data Questions what are the pro and cons of allow client's server be one of workers listening to receive message from my RabbitMQ? Should I … -
How to connect Django app and HTML template with proper styling?
Whenever I run django file connected with template, it shows me no styling but whenever I just run the html file it shows me the page with proper styling. How to solve this problem? Although the links are same in both html file and whenever I connect it with django. You can see it. app URL from django.urls import path from . import views urlpatterns = [ path('', views.index, name='index') ] project url from django.contrib import admin from django.urls import path, include urlpatterns = [ path('', include('app1.urls')), path('admin/', admin.site.urls) ] views.py from django.shortcuts import render from django.http import HttpResponse def index(request): return render(request, 'index.html'); index.html <!DOCTYPE html> <html> <head> <title></title> <link rel="shortcut icon" href="favicon.ico"> <link rel="stylesheet" href="css/animate.css"> <link rel="stylesheet" href="css/icomoon.css"> </head> <body> <header role="banner" id="fh5co-header"> <div class="fluid-container"> <nav class="navbar navbar-default navbar-fixed-top js-fullheight"> <div id="navbar" class="navbar-collapse js-fullheight"> <ul class="nav navbar-nav navbar-left"> <li class="active"><a href="#" data-nav-section="home"><span>Home</span></a></li> <li><a href="#" data-nav-section="services"><span>Services</span></a></li> <li><a href="#" data-nav-section="explore"><span>Project</span></a></li> <li><a href="#" data-nav-section="pricing"><span>Pricing</span></a></li> <li><a href="#" data-nav-section="team"><span>Team</span></a></li> </ul> </div> </nav> </div> </header> </body> </html> -
How to upload image using django raw form
Im trying to upload image using django raw form. How do I get image from the form? So that I can assign it to a model and save it? Is there a method like cleaned_data.get() for images? models.py class University(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) name = models.CharField(max_length=255) about = models.TextField(max_length = 2083) facts = models.TextField(max_length=2083, blank=True, null=True) type_of_university = models.CharField(max_length = 20, choices = UNIVERSITY_TYPE_CHOICES) logo = models.ImageField(upload_to = 'logo', blank=True, null=True) cover_photo = models.ImageField(upload_to= 'cover_photo', blank=True, null=True) def __str__(self): return self.name forms.py class UniversityForm(forms.Form): name = forms.CharField(max_length=255) about = forms.CharField() facts = forms.CharField(required=False) type_of_university = forms.ChoiceField(choices=UNIVERSITY_TYPE_CHOICES) logo = forms.ImageField(required=False) cover_photo = forms.ImageField(required=False) views.py class UniversityFormView(View): def get(self, *args, **kwargs): main_form = UniversityForm() context = { 'main_form':main_form } return render (self.request, 'university/initial_form.html', context) def post(self, *args, **kwargs): main_form = UniversityForm(self.request.POST, self.request.FILES) context = { 'main_form': main_form } if main_form.is_valid(): name = main_form.cleaned_data.get('name') about = main_form.cleaned_data.get('about') facts = main_form.cleaned_data.get('facts') type_of_university = main_form.cleaned_data.get('type_of_university') logo = main_form.cleaned_data.get()'logo') cover_photo = main_form.cleaned_data.get('cover_photo') university = University( user = self.request.user, name = name, about = about, facts = facts, type_of_university = type_of_university, logo = logo, cover_photo = cover_photo ) university.save() messages.success(self.request, "Form submitted successfully!") return redirect('address_form') else: messages.warning(self.request, "Something went wrong!") return redirect('university_form') return render (self.request, 'university/initial_form.html', … -
How to connect and send data from Flutter frontend to Django backend without rest framework ? am newbie in it
I am developing application using flutter for front-end and django framework for backend with sqlite i need to send data such as media and text msg from flutter app to django and database ... i am new in it ... -
How to post array of objects in django rest framework?
I am trying to post array of objects in JSON data using Postman , but unable to create the object,how will i achieve it?Here is my code ``` models.py ``` class Classes(models.Model): name = models.CharField(max_length=250, blank=True, null=True) description = models.CharField(max_length=1000, blank=True, null=True) class ClassDaySlot(models.Model): class_id = models.ForeignKey(Classes, on_delete=models.CASCADE, blank=True, null=True,related_name='dayslot_classes') day = models.CharField(max_length=50, blank=True, null=True) class ClassTimeSlot(models.Model): day_slot_id = models.ForeignKey(ClassDaySlot, on_delete=models.CASCADE, blank=True, null=True,related_name='my_class_timeslot') start_slot_time = models.TimeField(blank=True, null=True) end_slot_time = models.TimeField(blank=True, null=True) ``` serializers.py ``` class ClassUpdateSerializer(serializers.ModelSerializer): class_day = serializers.ListField() class_time = serializers.ListField() class Meta: model = Classes def create(self, validated_data): dayslot_validated_data = validated_data.pop('class_day', None) timeslot_validated_data = validated_data.pop('class_time', None) classes = Classes.objects.create(**validated_data) if dayslot_validated_data: for day_slot in dayslot_validated_data: created_day_class = ClassDaySlot.objects.create(**day_slot, class_id=classes) if timelot_validated_data: for time_slot in timeslot_validated_data: ClassTimeSlot.objects.create(**time_slot, day_slot_id=created_day_class) return classes I have to post json data in postman exactly like this: { "class_day":[{ "day":"friday", "class_time":[ { "start_slot_time":"08:00:00+0000", "end_slot_time":"09:00:00+0000" } ] }] } I am getting this error: "ClassDaySlot() got an unexpected keyword argument 'class_time'". if i give "class_time" outside "class_day" list, it works but i don't want that, what i want is to post array of "day" and "class_time" objects which i mentioned in the above JSON format.Any idea how to achieve this -
Heroku application Error Log/gunicorn/django
I am trying to run my django web application on heroku. The below is my Folder Structure: myblog/ myblog/ ... wsgi.py Procfile requirements.txt runtime.txt ... Procfile: web: gunicorn myblog.wsgi:application --log-file =- Log: 2020-02-01T05:24:18.000000+00:00 app[api]: Build started by user myusername@gmail.com 2020-02-01T05:24:53.555023+00:00 app[api]: Deploy f80dc625 by user myusername@gmail.com 2020-02-01T05:24:53.555023+00:00 app[api]: Release v15 created by user myusername@gmail.com 2020-02-01T05:24:54.464684+00:00 heroku[web.1]: State changed from crashed to starting 2020-02-01T05:24:58.015753+00:00 heroku[web.1]: Starting process with command `gunicorn myblog.wsgi:application --log-file =-` 2020-02-01T05:24:59.499501+00:00 heroku[web.1]: State changed from starting to crashed 2020-02-01T05:24:59.502671+00:00 heroku[web.1]: State changed from crashed to starting 2020-02-01T05:24:59.481315+00:00 heroku[web.1]: Process exited with status 3 2020-02-01T05:25:03.393607+00:00 heroku[web.1]: Starting process with command `gunicorn myblog.wsgi:application --log-file =-` 2020-02-01T05:25:03.000000+00:00 app[api]: Build succeeded 2020-02-01T05:25:05.386497+00:00 heroku[web.1]: State changed from starting to crashed 2020-02-01T05:25:05.370403+00:00 heroku[web.1]: Process exited with status 3 2020-02-01T05:25:15.342838+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=cryptic-peak-88710.herokuapp.com request_id=40f22193-b420-48c8-a79b-d037e97e9c8b fwd="211.229.239.157" dyno= connect= service= status=503 bytes= protocol=https 2020-02-01T05:25:16.518964+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=cryptic-peak-88710.herokuapp.com request_id=10407ff6-814b-4a34-9fd6- 31e33e90f0e6 fwd="211.229.239.157" dyno= connect= service= status=503 bytes= protocol=https I have tried web: gunicorn project.wsgi:application --preload --workers 1 web: gunicorn project.wsgi:application --log-file=- Please help me find a way to run my application on heroku. -
Why after sign up Django admin is taking users rather than user profile infos?
views.py page def user_login(request): if request.method=='POST': username=request.POST.get('uname') password=request.POST.get('psw') user=authenticate(username=username,password=password) if user: if user.is_active: login(request,user) return HttpResponseRedirect(reverse('index')) else: return HttpResponse('account not active') else: print ('Username or Password not found') #print ('username: {} and password{}'.format(username,password)) return HttpResponse('invalid login') else: return render(request,'chelaapp/login.html') -
No module named 'sendgrid_backend' in django
When sending an email on heroku I get this error: No module named 'sendgrid_backend' I have this set up in settings.py: EMAIL_BACKEND = "sendgrid_backend.SendgridBackend" SENDGRID_API_KEY = os.environ.get("SENDGRID_API_KEY") EMAIL_PORT = 587 EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.sendgrid.net' EMAIL_HOST_USER = 'apikey' EMAIL_HOST_PASSWORD = os.environ.get('SENDGRID_API_KEY') I also did install of sendgrid using pip and included it in the requirements.txt -
import sixImportError: cannot import name 'six' from 'django.utils'
Django-taggit not working in Django 3.0,It works fine in previous versions like django-2.2. Because it depends on six library which is not there in django.utils in 3.0