Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Multi Column Table in Django Template from List
I have a list following list = {a,1,b,2,c,3,d,4,.....} I want to show it in Django template with 4 column like below <table> <tr> <td>a</td> <td>1</td> <td>b</td> <td>2</td> </tr> <tr> <td>c</td> <td>3</td> <td>d</td> <td>4</td> </tr> </table> How can I do that in Django Template -
How to translate this query into django orm
select user_id, count(*) from e_order group by 1 having count(*) > 1 How I can translate this query in Django ORM? -
Easy way to develop private messaging on django?
What are the possible ways to introduce messaging functionality between two users on a django website? Does anyone have any good resources or advice on learning how to do this -
How to serialize nested objects with related models?
i am really new to DRM and i have to following problem I have three related models. Now i want to for each sensor values to the related patient. My models look like: class Sensor(models.Model): sensor_name = models.CharField(max_length=200, primary_key=True) sensor_refreshRate = models.FloatField() sensor_prio = models.IntegerField(choices=[ (1, 1), (2, 2), (3, 3), (4, 4), ], default='1') sensor_typ = models.CharField(max_length=200, choices=[ ('bar', 'bar'), ('pie', 'pie'), ('line', 'line'), ('text', 'text'), ], default='bar') class Patient(models.Model): firstName = models.CharField(max_length=200) lastName = models.CharField(max_length=200) age = models.IntegerField() doctor = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.CASCADE) sensor = models.ManyToManyField(Sensor) class Value(models.Model): value_date = models.DateTimeField(auto_now_add=True) value = models.FloatField() sensor = models.ForeignKey(Sensor, on_delete=models.CASCADE) Now i would like to send a JSON file which looks like: [ { "value": 445.0, "sensor": "Pressure", "patient": 3 }, { "value": 478.0, "sensor": "Temperature", "patient": 3 } ] Now i am not sure how to serialize my JSON. Thanks in advance -
Multi user-type Django DRF authentication
I'm using Django DRF for a personal project. I'm trying to customize authentication with 2 types of users, and also use email for validation (not username). My approach was to have an "Account" model (with account_type on it), and then "Bar" and "RegularUser" on 2 separeted models, inheriting from "Account". I don't want to use is_admin and is_superuser flags. I don't understand if I need to add "BaseUserManager" classes to every model or only on "RegularUser" and "Bar". Also I don't know if I need a serializer for Account model or don't. Here is my account model: class AccountManager(BaseUserManager): def create_user(self, account_type, email, password): account = self.model( account_type=account_type, email=self.normalize_email(email), ) account.set_password(password) account.save(using=self._db) return account class Account(AbstractBaseUser): email = models.EmailField(max_length=60, unique=True) account_type = models.SmallIntegerField() objects = AccountManager() USERNAME_FIELD = 'email' And here is my Bar model: class BarManager(BaseUserManager): def create_user(self, email, name, password, city, **extra_fields): if not email: raise ValueError("Missing Email") if not name: raise ValueError("Missing Name") bar = self.model( account_type=1, city=city, email=self.normalize_email(email), name=name, **extra_fields, ) bar.set_password(password) bar.save(using=self._db) return bar def create_superuser(self, email, password, name, city, **extra_fields): bar = self.create_user( city=city, email=self.normalize_email(email), name=name, password=password, **extra_fields, ) bar.is_admin = False bar.is_staff = True bar.is_superuser = False bar.save(using=self._db) return bar class Bar(Account, AbstractBaseUser): … -
Django REST Framework. How do I create two identical tags with different values?
Another Django REST Framework problem that I don't understand how to solve? There are two objects image_1 and image_2. In serializers.py: class someClass(serializers.ModelSerializer): image_1 = serializers.ImageField(source='image_1') image_2 = serializers.ImageField(source='image_2') class Meta: model = onlyimage fields = ['image_1', 'image_2'] In the output, I get: <image_1>https://domain-name.com/media/image_1</image_1> <image_2>https://domain-name.com/media/image_2</image_2> I want the tag not to be numbered like in the example below: <image>https://domain-name.com/media/image_1</image> <image>https://domain-name.com/media/image_2</image> But if you change in serializers.py, of course, an error occurs: class someClass(serializers.ModelSerializer): image = serializers.ImageField(source='image_1') image = serializers.ImageField(source='image_2') class Meta: model = onlyimage fields = ['image', 'image'] -
Database Error at BackEnd no Exception message supplied
I am creating a website using Django as BackEnd and MongoDB as my DataBase but I am experiencing an error while trying to add data into my Patient model using the admin dashboard, 1st entry doesn't trigger any exception however when I try to add 2nd patient my app crashes, and here are the screenshots of my model and my traceback My Patient Model This model is inherited from the base model and also holds a self reference. The TraceBack can be found here: https://dpaste.com/GB2REDLGA However I tried to change my database and upon shifting to SQLite the error was gone. I don't know what is causing this error. Little help would be awesome. -
Django - CSS file not working. Getting error 404 . "Failed to load resource: the server responded with a status of 404 (Not Found)"
I know this question has been asked many times and I have seen all the answers given, but none of them worked for me. I am a newbie and trying to get access to CSS files in my Django template but it is not working, I have tried many options but none of them worked for me. Here I am using Django 2.2 in my project. Can you please help me to find out the mistake? settings.py # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/2.0/howto/static-files/ STATIC_URL = '/static/' MEDIA_URL = '/images/' STAICFILES_DIRS = [ os.path.join(BASE_DIR, 'static') ] MEDIA_ROOT = os.path.join(BASE_DIR, 'static/images') urls.py from django.conf import settings from django.conf.urls.static import static from django.contrib import admin from django.urls import path, include urlpatterns = [] urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) urlpatterns = [ path('admin/', admin.site.urls), path('', include('GalaxyOffset.urls')), ] basic.css body{ background: url('{% static "../images/photo1.jpg" %}') no-repeat center center fixed; -webkit-background-size: cover; -moj-background-size: cover; -o-background-size: cover; background-size: cover; background-color: #f5fbff; } basic.html <!doctype html> <html lang="en"> <head> {% load static %} <link rel="stylesheet" type="text/css" href="{% static '/css/basic.css' %}"> <title>{% block title%} {% endblock %} | Galaxy Offset</title> </head> <body> <div class="container"> <h1>Welcome to the first page </h1> {% block body %} … -
django - how do i use an input from a select form to compare data in my database and output it on another page?
<form method = "POST"> {% csrf_token %} <div class = "lookback" <label for = "time"></label> <select name = "time" id = "time"> <option value = "today">Today</option> <option value = "yesterday">Yesterday</option> <option value = "lastweek">Last Week</option> <option value = "lastmonth">Last Month</option> <option value = "lastyear">Last Year</option> <option value = "forever">Forever</option> </select> <button><a type= "button" class = "Look" id = "look" href = "">Look Back?!</a></button> </form> ** Above is the portion of HTML page i am using to get the select value so that I can use it in my views.py to filter out the data and output it on another page. ** def retro(request): if request.method == "POST": time = ThoughtForm(request.POST) today = timezone.now().date() if time == "Yesterday": yesterday = timezone.now().date() - timedelta(days=1) data = Thought.objects.filter(date__gte=yesterday, date__lt=today) elif time == "Last Week": week = timezone.now().date() - timedelta(days=7) data = Thought.objects.filter(date__gte=week, date__lt=today) elif time == "Last Month": month = timezone.now().date() - timedelta(days=30) data = Thought.objects.filter(date__gte=month, date__lt=today) elif time == "Last Year": year = timezone.now().date() - timedelta(days=365) data = Thought.objects.filter(date__gte=year, date__lt=today) elif time == "Forever": data = Thought.objects.all else: data = Thought.objects.filter(date__gte=today, date__lt=today) return render(request,'look.html', {'data' : data}) else: return render(request, 'retro.html') When I use the submit button of the retro.html (the one … -
Auto Delete a Django object from the database based on DateTimeField
Let's imagine a simple Food model with a name and an expiration date, my goal is to auto delete the object after the expiration date is reached. I want to delete objects from the database (postgresql in my case) just after exp_date is reached, not filter by exp_date__gt=datetime.datetime.now() in my code then cron/celery once a while a script that filter by exp_date__lt=datetime.datetime.now() and then delete Food(models.Model): name = models.CharField(max_length=200) exp_date = models.DateTimeField() *I could do it with a vanilla view when the object is accessed via an endpoint or even with the DRF like so : class GetFood(APIView): def check_date(self, food): """ checking expiration date """ if food.exp_date <= datetime.datetime.now(): food.delete() return False def get(self, request, *args, **kwargs): id = self.kwargs["id"] if Food.objects.filter(pk=id).exists(): food = Food.objects.get(pk=id) if self.check_date(food) == False: return Response({"error": "not found"}, status.HTTP_404_NOT_FOUND) else: name = food.name return Response({"food":name}, status.HTTP_200_OK) else: return Response({"error":"not found"},status.HTTP_404_NOT_FOUND) but it would not delete the object if no one try to access it via an endpoint. *I could also set cronjob with a script that query the database for every Food object which has an expiration date smaller than today and then delete themor even setup Celery. It would indeed just need to … -
Django app on heroku, ModuleNotFoundError: No module named 'spread'
I am strugling with running my app on heroku. Everything works fine on a local machine. Ive deployed a django app to heroku with no issues (git push heroku master is working properly) however whenever I am trying to heroku open heroku logs are pointing out an error ModuleNotFoundError: No module named 'spread' I've researched most of the stackoverflow related questions and google articules and tutorials but with no sucess. I hope this is just some simple issue that I cant figure out. Any help will be much appriciated. Thanks heroku logs --tail error presented at the bottom 2020-12-18T12:55:21.766372+00:00 heroku[web.1]: State changed from crashed to starting 2020-12-18T12:55:29.108110+00:00 heroku[web.1]: Starting process with command `gunicorn spread.wsgi` 2020-12-18T12:55:32.531785+00:00 app[web.1]: [2020-12-18 12:55:32 +0000] [4] [INFO] Starting gunicorn 20.0.4 2020-12-18T12:55:32.532683+00:00 app[web.1]: [2020-12-18 12:55:32 +0000] [4] [INFO] Listening at: http://0.0.0.0:48488 (4) 2020-12-18T12:55:32.532859+00:00 app[web.1]: [2020-12-18 12:55:32 +0000] [4] [INFO] Using worker: sync 2020-12-18T12:55:32.542317+00:00 app[web.1]: [2020-12-18 12:55:32 +0000] [10] [INFO] Booting worker with pid: 10 2020-12-18T12:55:32.562471+00:00 app[web.1]: [2020-12-18 12:55:32 +0000] [10] [ERROR] Exception in worker process 2020-12-18T12:55:32.562473+00:00 app[web.1]: Traceback (most recent call last): 2020-12-18T12:55:32.562473+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker 2020-12-18T12:55:32.562474+00:00 app[web.1]: worker.init_process() 2020-12-18T12:55:32.562475+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 119, in init_process 2020-12-18T12:55:32.562475+00:00 app[web.1]: self.load_wsgi() 2020-12-18T12:55:32.562475+00:00 app[web.1]: File … -
Django Instagram no longer shows feed (429 Client error)
I use Django_instagram app to put the media feed onto a website, I use local memory cache to save the media and so a request is made once every 288880 seconds. This was working fine for ages, but a week ago it stopped working on both Production and Development servers. ERROR:root:user profile "###########" not found Traceback (most recent call last): File "C:\Program Files\Python38\lib\site-packages\django_instagram\scraper.py", line 28, in instagram_scrap_profile page.raise_for_status() File "C:\Program Files\Python38\lib\site-packages\requests\models.py", line 941, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 429 Client Error: - for url: https://www.instagram.com/accounts/login/ ERROR:root:scripts not found Traceback (most recent call last): File "C:\Program Files\Python38\lib\site-packages\django_instagram\scraper.py", line 44, in instagram_profile_js return tree.xpath('//script') AttributeError: 'NoneType' object has no attribute 'xpath' please note that the username of the profile is definitely correct, I've changed it too ######## just for security and privacy concern. also something worth noting is that there is an open issue since April for a similar issue: https://github.com/marcopompili/django-instagram/issues/26 But it has been working fine for me. I've tried clearing browser and server caches and cookies. I've tried to check all code again for any errors. Any help or clarification would be appreciated. Is there any good alternatives perhaps? thank you! -
How to do counts into get_queryset() functions, using Django Rest Framework and viewsets?
I want to do a query inside the get_queryset() function and retorn some totals. But this function just return an QS object. I have the following code into my views.py. serializer_class = omrActionQueueItemSerializer def get_queryset(self): omr_action_queue = self.request.query_params.get('omr_action_queue', None) status = self.request.query_params.get('status', None) queryset = OmrActionQueueItem.objects.all() queryset = queryset.filter(omr_action_queue=omr_action_queue) queryset = queryset.filter(status=status) return queryset This works for filtering, but if I count I get an error message saying that my answer is a value, not a QS. This is my serializer.py: class omrActionQueueItemSerializer(serializers.ModelSerializer): class Meta: model = OmrActionQueueItem fields = "__all__" My final goal is to summarize my table in something like this: { 'total_pending': 19 'total_complete': 5 'total_processing': 2 } And this is my models.py: class OmrActionQueueItem(models.Model): # id created by default omr_action_queue = models.ForeignKey(OmrActionQueue, on_delete=models.DO_NOTHING) params_content = models.TextField() process_content = models.TextField(default=None) created_at = models.DateTimeField(default=datetime.now()) updated_at = models.DateTimeField(null=True) status = models.CharField(max_length=50, default="pending") enabled = models.BooleanField(default=1) deleted = models.BooleanField(default=1) -
Adding a UniqueConstraint to a ManyToMany field
I want to add a constraint to my database so that an application can only ever be associated with one vacancy. I don't want to be able to go in from the shell or django admin page, go into a vacancy and select an application that is already associated with a vacancy. I would like some kind of validation error to be raised. But I am a little unsure how I should go about this? models.py class Vacancy(models.Model): CATEGORY_CHOICES = [ ('ADMINISTRATION', 'Administration'), ('CONSULTING', 'Consulting'), ('ENGINEERING', 'Engineering'), ('FINANCE', 'Finance'), ('RETAIL', 'Retail'), ('SALES', 'Sales'), ] employer = models.ForeignKey('Employer', on_delete=models.CASCADE) job_title = models.CharField(max_length=35, default=None) main_duties = models.TextField(default=None, validators=[ MinLengthValidator(650), MaxLengthValidator(2000) ]) person_spec = models.TextField(default=None, validators=[ MinLengthValidator(650), MaxLengthValidator(2000) ]) salary = models.PositiveIntegerField(default=None, validators=[ MinValueValidator(20000), MaxValueValidator(99000) ]) city = models.CharField(choices=CITY_CHOICES, max_length=11, default=None) category = models.CharField(choices=CATEGORY_CHOICES, max_length=15, default=None) max_applications = models.PositiveSmallIntegerField(blank=True, null=True) deadline = models.DateField(default=None) applications = models.ManyToManyField('Application', blank=True, related_name='submissions') class Meta: verbose_name_plural = 'vacancies' constraints = [ models.UniqueConstraint(fields=['id', 'applications'], name="unique_application") ] class Application(models.Model): STAGES = [ ('pre-selection', 'PRE-SELECTION'), ('shortlisted', 'SHORTLISTED'), ('rejected pre-interview', 'REJECTED PRE-INTERVIEW'), ('rejected post-interview', 'REJECTED POST-INTERVIEW'), ('successful', 'SUCCESSFUL') ] candidate = models.ForeignKey('Candidate', on_delete=models.CASCADE) job = models.ForeignKey('Vacancy', on_delete=models.CASCADE) cv = models.CharField(max_length=60, default=None) cover_letter = models.TextField(default=None, validators=[ MinLengthValidator(0), MaxLengthValidator(2000) ]) submitted = models.DateTimeField(auto_now_add=True) stage … -
How to load my media files on Django Framework?
I cannot upload my media files. In the URL I noticed that the text 'courses' appears,Instead of 'media' (http://127.0.0.1:8000/**cursos**/courses/images/pythondev.png) (http://127.0.0.1:8000/**media**/courses/images/pythondev.png) settings.py STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') urls.py from django.contrib import admin from django.urls import path, include # Import settings to load image on DEBUG MODE from django.conf import settings from django.conf.urls.static import static admin.autodiscover() urlpatterns = [ path('', include('core.urls')), path('cursos/', include('courses.urls')), path('admin/', admin.site.urls), ] urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT courses\urls.py from django.urls import path, include from courses import views app_name = 'courses' urlpatterns = [ path('', views.index, name='index') ] courses\view.py from django.shortcuts import render # Create your views here. from .models import Course def index(request): courses = Course.objects.all() template_name = 'courses/index.html' context = { 'courses': courses } return render(request, template_name, context) -
Avoid multiple try catch in python3
I have created my custom exception and placed that in django settings file. I have a created a create api operation.My api takes data as input and calls multiple third party create api's if any one fails it reverts create operation of all third party api's. class InsertionOrderViewset(viewsets.ViewSet): #my api ''' Manages insertion order dsp operations''' def create(self, request, format=None): try: // create api 1 except error as e: return e try: // create api 2 except error as e: // undo api 1 return e try: // create api 3 except error as e: // undo api 1 // undo api 2 return e Is there a way to avoid writing multiple try catch in such rollback scenerios? -
Evaluate escape sequences in QR code generated by django-qr-code
In my project (Django 3.0 python 3.6) I'm using django-qr-code to generate a QR-code from internal data. This QR-code will be used to fill a form in another application. To do so "Tab Key" must be evaluated in the QR-Code. According to the Barcode Reference, the escape sequence for Horizontal Tab is \t. Now, here is the problem Lets say i want to generate a Qr-Code that populates two inputs firstname and lastname, i tried the following code : {% qr_from_text "firstname_value \t lastname_value" size="m" image_format="png" error_correction="L" %} The expected behavior is filling the first input and then the second one, but it only fills the first input with the sequence "firstname_value \t lastname_value", which means the the escape sequence \t is not interpreted correctly . Thanks in advance for your help -
Django problem, code cannot find css and js static files. Somehow I haven't django nginx conf
my problem is [18/Dec/2020 12:56:24] "GET /login/?next=/ HTTP/1.1" 200 6096 [18/Dec/2020 12:56:24] "GET /static/grappelli/stylesheets/screen.css HTTP/1.1" 404 179 [18/Dec/2020 12:56:24] "GET /static/grappelli/jquery/ui/jquery-ui.min.css HTTP/1.1" 404 179 [18/Dec/2020 12:56:24] "GET /static/grappelli/stylesheets/mueller/grid/output.css HTTP/1.1" 404 179 [18/Dec/2020 12:56:24] "GET /static/grappelli/jquery/jquery.min.js HTTP/1.1" 404 179 [18/Dec/2020 12:56:24] "GET /static/grappelli/jquery/jquery-migrate-3.0.1.min.js HTTP/1.1" 404 179 [18/Dec/2020 12:56:24] "GET /static/grappelli/jquery/ui/jquery-ui.min.js HTTP/1.1" 404 179 [18/Dec/2020 12:56:24] "GET /static/grappelli/js/grappelli.min.js HTTP/1.1" 404 179 But with DEBUG = True everything works well. But I want to work without Debug. I saw a similar problem here(stackoverflow) where STATIC_URL = '/static/' conflicted with nginx django, but I couldn't find any django config anywhere in /etc/nginx/. I installed nginx after django, I think this might be a problem. What to do now, how to fix it? Thanks for help. -
Name issue. Can't change the name of the Models in django database
from django.db import models # Create your models here. class Course (models.Model): name = models.CharField(max_length=100) language= models.CharField(max_length=100) price= models.CharField(max_length=100) def __str__(self): return self.name in django database the object dosent change name still named Course object (1) in the list. Why does it not change? def str(self): return self.name what should one do to make django show the courses names? This should be correct. no errors or anything it just simply dosent do what it should. it seems strange. -
Can't create Django superuser
There is no anything in my Django project (just two empty apps and their names in settings.py). The project is taken from git. I need to work on it locally. I worked fine, until I tried to change username to email in user registration. I did there some manipulations (don't remember which exactly, as I am stuck on this problem probably for a week or more). When I try to create superuser, there appears this error: Traceback (most recent call last): File "/home/laptop/WorkProjects/Mindsum/Apps/mindsum_be/env/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "/home/laptop/WorkProjects/Mindsum/Apps/mindsum_be/env/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py", line 413, in execute return Database.Cursor.execute(self, query, params) sqlite3.OperationalError: no such table: auth_user The above exception was the direct cause of the following exception: Traceback (most recent call last): File "manage.py", line 22, in <module> main() File "manage.py", line 18, in main execute_from_command_line(sys.argv) File "/home/laptop/WorkProjects/Mindsum/Apps/mindsum_be/env/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line utility.execute() File "/home/laptop/WorkProjects/Mindsum/Apps/mindsum_be/env/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/laptop/WorkProjects/Mindsum/Apps/mindsum_be/env/lib/python3.8/site-packages/django/core/management/base.py", line 330, in run_from_argv self.execute(*args, **cmd_options) File "/home/laptop/WorkProjects/Mindsum/Apps/mindsum_be/env/lib/python3.8/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 79, in execute return super().execute(*args, **options) File "/home/laptop/WorkProjects/Mindsum/Apps/mindsum_be/env/lib/python3.8/site-packages/django/core/management/base.py", line 371, in execute output = self.handle(*args, **options) File "/home/laptop/WorkProjects/Mindsum/Apps/mindsum_be/env/lib/python3.8/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 100, in handle default_username = get_default_username() File "/home/laptop/WorkProjects/Mindsum/Apps/mindsum_be/env/lib/python3.8/site-packages/django/contrib/auth/management/__init__.py", line 140, in get_default_username auth_app.User._default_manager.get(username=default_username) File "/home/laptop/WorkProjects/Mindsum/Apps/mindsum_be/env/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method return getattr(self.get_queryset(), … -
Downloaded font face in django not working
I am trying to implement the downloaded font face either in the template or either in the css file both are not working. I have downloaded the fonts and store in the structure like this Static folder css (sub folder inside the static folder) --style.css file inside the css folder fonts (sub folder inside the static folder) --ZillaSlab-Regular.ttf file inside the fonts folder this is how implement the font face in django inside the css file @font-face { font-family: 'Zilla Slab', serif; src: local('ZillaSlab'), url("../fonts/ZillaSlab-Regular.ttf") format('truetype'); } body{ font-family: 'Zilla Slab', serif !important; } I have also tried to implement via static block in the template but it is also not working @font-face { font-family: 'Zilla Slab', serif; src: local('ZillaSlab'), url("{% static '/fonts/ZillaSlab-Regular.ttf' %}") format('truetype'); } body{ font-family: 'Zilla Slab', serif !important; } -
Updating specific files with git for django app on heroku
I deployed my django app to heroku and its working well. When I change something in project on local files and want to push to heroku It always push all files and it takes time. > git add templates/post/detail.html > git commit -am "read more" [master 153e38f] read more 2 files changed, 3 insertions(+), 3 deletions(-) > git push heroku master I use these commands. But it's deploying everything: Enumerating objects: 13, done. Counting objects: 100% (13/13), done. Delta compression using up to 8 threads Compressing objects: 100% (7/7), done. Writing objects: 100% (7/7), 695 bytes | 695.00 KiB/s, done. Total 7 (delta 5), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Python app detected remote: ! Python has released a security update! Please consider upgrading to python-3.8.6 remote: Learn More: https://devcenter.heroku.com/articles/python-runtimes remote: -----> No change in requirements detected, installing from cache remote: -----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2 remote: -----> Installing SQLite3 remote: -----> Installing requirements with pip remote: -----> $ python manage.py collectstatic --noinput remote: 1392 static files copied to '/tmp/build_57ea00eb/staticfiles', 3734 post-processed. remote: remote: -----> Discovering process types remote: Procfile declares types -> web remote: remote: -----> … -
Users can add a movie and other people, except the creator, can rate it. And remember a user can onlyrate a movie once
Users can add a movie and other people, except the creator, can rate it. And remember a user can only rate a movie once and even after logging in api, my database is not showing please help -
How to delete file in python inside docker container?
The code below is part of my code. In my local machine, everything is fine.However, I deploy my code and inside of docker container,it gives the error "result": "[Errno 13] Permission denied: path". What could be solution to delete in docker container also? I tried os.remove() also,It didn't work. path = "/mypath/" output = path + "myfile.pdf" result_file = open(output, "w+b") pisa_res = pisa.CreatePDF( source_html, dest = result_file) result_file.close() with open(output, "rb") as pdf_file: encoded_string = base64.b64encode(pdf_file.read()) os.system(f"rm -rf {output}") -
How to use mysql-connector mysql adapter with django??/
I cannot use mysqlclient package in the hosting server because it is a shared hosting server and they would not let me have a root privilige!! so I found about the mysql-connector adapter, I guess it is developed by MySQL but I could not find anyone using it to connect to the database, does someone know how to use it?? please help