Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django ModelFormset Forms Returning Empty Data
I have been trying to solve this for weeks to no avail, and would really appreciate some help. Background I'm creating a Django app which takes input of a user's educational experience, and wanted to provide users with the ability to add new experiences via an "Add More" button (i.e if they had an undergrad and masters). I'm doing this using ModelFormsets and Jquery, following this answer: Dynamically adding a form to a Django formset with Ajax. Problem When accessing the cleaned_data of the formset, only the first initial form has values in its cleaned_data, the additional generated forms return an empty dictionary with no cleaned data in them. Views.py EducationFormset = modelformset_factory(Education, form=EducationForm, fields=('institution', 'degree', 'major', 'major_start_date', 'major_end_date', 'major_description', 'gpa',)) if request.method == 'POST': formset = EducationFormset(request.POST, request.Files) if formset.is_valid(): formset.save() for form in formset.forms: print(form.cleaned_data) else: print(formset.errors) else: formset = EducationFormset(queryset=Education.objects.none()) context = { 'user_form': user_form, 'education_form': education_form, 'experience_form': experience_form, 'formset':formset, } return render(request, 'create.html', context) HTML {{ formset.management_form }} <div id="form_set"> <div class="form-group"> {% for form in formset.forms %} {{form.errors}} <table class="no_error"> {{form.as_table}} </table> {% endfor %} </div> </div> <div id="empty_form" style="display:none"> <table class="no_error"> {{formset.empty_form.as_table}} </table> </div> <script> $('#add_more').click(function() { var form_idx = $('#id_form-TOTAL_FORMS').val(); $('#form_set').append($('#empty_form').html().replace(/__prefix__/g, form_idx)); $('#id_form-TOTAL_FORMS').val(parseInt(form_idx) … -
Django - Grouping data and showing the choices's name in template
I am trying to create a pie chart (chart.js). My goal is grouping titles and displaying how many people work by title in piechart. Models.py class Personel(models.Model): name = models.CharField(max_length=30) surName = models.CharField(max_length=20) titles= models.IntegerField(choices=((1,"Researcher"),(2,"Technician"),(3, "Support Personel")),default=1) def __str__(self): return f"{self.name},{self.surName}" class Meta: db_table = "personel" verbose_name_plural = "Ar-Ge Personeller" Views.py def index(request): personel_titles = Personel.objects.values('titles').annotate(Count('titles')) context = { "personel_titles" : personel_titles, } return render(request, 'core/index.html',context) >>> print(personel_titles) >>> {'titles': 1, 'titles__count': 10} {'titles': 2, 'titles__count': 11} {'titles': 3, 'titles__count': 3}> It is okay for me and all I need is in here. But I couldn't figure out how can I display title's name in my template(also in chart label) Template {% for title in personel_titles %}<p>{{ title.get_titles_display }}</p>{% endfor %} What am I missing? How can I return the choice's name in values? -
django rest framework apis using legacy db without creating django default tables
I am going to develop django rest framework apis using postgres legacy database in which apart from the existing tables no other default django tables should be created. I would like to know without creating any django default tables or doing migrations, can i able to access records from tables using ORM? Can i able to access admin page without creating django auth table (i.e superuser)? If no for both questions, only way to connect to db is using any db adapter like psycopg2? -
Convert Django model form based system into a raw HTML based form system for signup
I have a class-based view system for signup in Django which uses Django's model form. but I need to render my custom build HTML form in place of that. My models.py: from django.contrib.auth.models import AbstractUser from django.db import models class User(AbstractUser): is_student = models.BooleanField(default=False) is_teacher = models.BooleanField(default=False) class Student(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True) quizzes = models.ManyToManyField(Quiz, through='TakenQuiz') interests = models.ManyToManyField(Subject, related_name='interested_students') And views.py: class StudentSignUpView(CreateView): model = User form_class = StudentSignUpForm template_name = 'registration/signup_form.html' def get_context_data(self, **kwargs): kwargs['user_type'] = 'student' return super().get_context_data(**kwargs) def form_valid(self, form): user = form.save() login(self.request, user) return redirect('students:quiz_list') This system has a form.py also which made the hard work and render the Django model form. Now I need to replace these types of Django's default model form with my custom build HTML form something like this link. How can I use the following types of simple system which will receive data from views.py and will create a user? if request.method == 'POST': this_username = request.POST['username'] this_password = request.POST['password'] this_otherKindofStuff = request.POST['otherKindofStuff'] Student_signup = TableA.objects.create(name=this_name, password=this_password, otherKindofStuff=this_otherKindofStuff) Student_signup.save() -
Page not found at /
I'm new to django and according to tutorial i've created the project: views.py code: from django.http import HttpResponse def home(request): return HttpResponse("This is the home page") def about(request): data = "This is our about page" return HttpResponse(data) urls.py code: from django.contrib import admin from django.urls import path from . import views urlpatterns = [ path('admin/', admin.site.urls), path('home/', views.home), path('about/', views.about), ] Error i get while running the app: what am i missing? -
Foreign key default value in django model
I'm starting an app with django; i love it so far but i've trouble initializing my database. To sum up, i need a table user and a table role; a user has a FK to role. Upon creation a user must have this role set explicitly or defaulting to a default role 'Regular user'. I could create the model without the database, then manually create the role, then add the default and migrate; but that does not look nice; I tried adding to the database in-between the two models definition but obviously it does not work as the tables are not created during the makemigration command. Is there any way to achieve what I want ? Here is my current models if it helps; feel free to report any non-sense in this; i'm learning. Thx ;) from django.db import models class Role(models.Model): name = models.CharField(max_length=100) identifier = models.CharField(max_length=20) ts_create = models.DateTimeField(auto_now_add=True) ts_update = models.DateTimeField(auto_now=True, default=None, null=True) def __str__(self): return self.name userRole = Role.objects.get_or_create(name="Regular user", identifier="USER") adminRole = Role.objects.get_or_create(name="Administrator", identifier="ADMIN") ownerRole = Role.objects.get_or_create(name="Owner", identifier="OWNER") class User(models.Model): username = models.CharField(max_length=100, unique=True) user_type = models.ForeignKey(Role, related_name="user_type", on_delete=models.PROTECT, default=userRole) roles = models.ManyToManyField(Role, related_name="roles", db_table="core_roles_assignations") ts_create = models.DateTimeField(auto_now_add=True) ts_update = models.DateTimeField(auto_now=True, default=None, null=True) def __str__(self): … -
Django: Booking() got an unexpected keyword argument 'chek_in'
I'm creating a booking appin django and I'm a bit new on this, when I try to book a room I keep getting the following error: Booking( ) got an unexpected keyword argument 'chek_in' I'm following the code on the following git address, but I keep making the same mistake no matter how many times I keep writing the code: https://github.com/Darshan4114/Django_HMS I appreciate any help you can bring. Below my codes: Availability.py import datetime from hotel.models import Room, Booking def check_availability(room, check_in, check_out): avail_list = [] booking_list = Booking.objects.filter(room=room) for booking in booking_list: if check_in > booking.check_out or booking.check_out < check_in: avail_list.append(True) else: avail_list.append(False) return all(avail_list) Views from django.shortcuts import render, HttpResponse from django.views.generic import ListView, FormView, View from .models import Room, Booking from .forms import AvailabilityForm from hotel.booking_functions.availability import check_availability class RoomListView(ListView): model=Room class BookingList(ListView): model=Booking class RoomDetailView(View): def get(self, request, *args, **kwargs): category = self.kwargs.get('category', None) form = AvailabilityForm() room_list = Room.objects.filter(category=category) if len(room_list)>0: room = room_list[0] room_category = dict(room.ROOM_CATEGORIES).get(room.category, None) context = { 'room_category': room_category, 'form': form, } return render(request, 'room_detail_view.html', context) else: return HttpResponse ('Category does not exist') def post(self, request, *args, **kwargs): category = self.kwargs.get('category', None) room_list = Room.objects.filter(category=category) form = AvailabilityForm(request.POST) if form.is_valid(): data … -
Django import-export Sheet Name
I'm using the third party library Django-import-export for importing/exporting data from template. When i try to export data from view , i want to define Sheet name myself (in xlsx format default is Tablib Dataset). When i do in dataset dataset = Dataset(title="cogs") i can define title myself. def export(request): modelResource = ModelResource() model = Model.objects.filter(boolField =True ) dataset = modelResource.export(model) response = HttpResponse(dataset.xlsx, content_type='application/vnd.ms-excel') response['Content-Disposition'] = 'attachment; filename="model.xlsx"' return response When this function works , SheetName is Tablib Dataset , but if i export the file in csv , sheetname is same as filename. Is there any way that i can define sheetname myself ? -
Django Image Upload working but not General File
I am facing a situation where I am able to upload Images, but not general files. I am using javascript to track the progress, which says file upload is successful, but file is not there in the media folder. When I do that for images, it works. Basically, image upload was working, and I tried to copy the same thing and do it for general file upload. Here is the code below. Models class Upload(models.Model): # image upload model image = models.ImageField(upload_to='images') def __str__(self): return str(self.pk) class FileUpload(models.Model): # file upload model video = models.FileField(upload_to='fileuploads/') def __str__(self): return str(self.pk) Forms: class UploadForm(forms.ModelForm): class Meta: model = Upload fields = ('image',) class FileUploadForm(forms.ModelForm): class Meta: model = FileUpload fields = ('video',) Views: def home_view(request): form = UploadForm(request.POST or None, request.FILES or None) if request.is_ajax(): if form.is_valid(): form.save() return JsonResponse({'message': 'hell yeah'}) context = { 'form': form, } return render(request, 'uploads/main.html', context) def file_view(request): form = FileUploadForm(request.POST or None, request.FILES or None) if request.is_ajax(): if form.is_valid(): form.save() return JsonResponse({'message': 'hell yeah'}) context = { 'form': form, } return render(request, 'uploads/main1.html', context) The HTML template for Image Upload {% extends "uploads/base.html" %} {% block content %} <div id="alert-box"></div> <div id="image-box"></div> <br> <form action="" … -
Django Server Side Implementation. Database per client vs a single database
I am curious on how some of more seasoned backend devs would do this. I am writing an app and I have 2 options. Have it multi tenants vs Single For example, Say I am writing a recipe app, there are ingredients and there recipes, and restaurants. Each Restaurant can have recipes, Each recipe can have ingredients and other recipes, So it can be nested. Now with every request beside authentication I need to check if a recipe or ingredient is owned by the right restaurant. So this gets complicated as one can imagine. I have to write validations. Also since technically one should only do semantic validations in serializer do I have to do these validations in my modelView. I literally have to check if my nested json( since there is recipes in recipes) is valid via my serializer (serialier does this nicely with out an hassle) but then I have to parse the json and read each ID of ingredient and/or recipe id and check if it belongs to the right restaurant. There is also another issue. Recipe A can have Recipe B which can Have recipe A, but I am saving that for another post. If i … -
Django Group By using annotate
i have there 2 models class Car(TimeStampedModel): name = models.CharField(_('Car Name'), max_length=50) manager = models.ForeignKey( 'cars.Manager', verbose_name=_('Car Manager'), related_name='cars', on_delete=models.CASCADE ) def __str__(self): return self.name class Manager(models.Model): name = models.CharField(_('Name'), max_length=25) class Meta: verbose_name = _('Car Manager') verbose_name_plural = _('Car Managers') def __str__(self): return self.name and then on the serializer, i try to get number_of_managed_cars by each manager using this way def get(self, request): cars_managers = Manager.objects.all().annotate(number_of_managed_cars=Count('cars')) serializer = CarManagerSerializer(cars_managers, many=True) serializer_data = serializer.data return Response(serializer_data, status=status.HTTP_200_OK) then i try to hit the endpoint: { { "id": 1, "name": "John Doe", } } there's no number_of_managed_cars on the result. where did i miss ? -
Django - KeyError at /auctions/create 'category.' (New to Django, any help is appreciated!)
I am new to Django and creating a dropdown menu so that users can choose a category from the dropdown. This category will be saved on an entry on the website, when a user creates a new entry. I migrated the model, but I'm getting: KeyError at /auctions/create 'category.' Any help is really appreciated. Views.py (Code for creating the dropdown menu for categories) models.py forms.py Here is the create part in views.py for creating a new entry. 'form' for CreateForm() is the model form for creating the entry. 'form1' for CategoryForm() is the model form for the category drop down list. The create function was working completely fine, until I added in the parts for the categories and category form. urls.py for applicable functions (I have tried many variations for the category one but I'm still having trouble figuring out what it should be, I have tried str and int.) Sorry I'm a beginner but any help would be great! path("auctions/create", views.create, name="create"), path("listings/<int:id>", views.listingpage, name="listingpage"), path("cat/<int:id>", views.cat, name="cat"), -
Cannot migrate model in django
I'm trying to create a following/follower system on my django project, and I created a model to do so, but I cannot migrate it. Here is the code: from django.db import models from django.contrib.auth.models import User class Follow(models.Model): follow_user = models.ForeignKey(User, models.DO_NOTHING, related_name="user") follow_followed = models.ForeignKey(User, models.DO_NOTHING, related_name="followed") I can create the migration, but when I migrate, it gives me this error: django.db.utils.OperationalError: foreign key mismatch - "blog_main_following_following" referencing "blog_main_following" I have no idea what this means. Can anyone help me resolve this error? -
how to keep messages showing with django-channels
i'm looking for suggestions: Everytime i click on one of the links (on the right under Module), i lose the messages showing in the chat box, is there a way to prevent that, thank you very much. build with django channels and jquery, followed the docs on channels. -
how can I turn boostrap studio designs into django templatates
I just started using bootstrap studio and I would like to convert the design I do in it into django templates directly. I have tried to follow up on the solution provided at https://github.com/lingster/django-bootstrap-studio-tools and https://github.com/AbcSxyZ/bootstrap-studio-to-django-template but I have failed to figure it out where to find django_export.sh. Could someone help me out on where I can get the path to this django_export.sh script? -
Django Creating Virtual Environment Errors
I'm trying to set up a virtual environment but I cannot figure it out. I've installed Python 3.5.0 as that's the last Python version compatible with Django according to their website. Then, I executed successfully: pip3 install virtualenvwrapper-win However, after trying to set up the environment, I get a bunch of errors: PS C:\Users\nollb> mkvirtualenv my_django_environment Traceback (most recent call last): File "c:\users\nollb\appdata\local\programs\python\python35\lib\runpy.py", line 170, in _ run_module_as_main "__main__", mod_spec) File "c:\users\nollb\appdata\local\programs\python\python35\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\nollb\AppData\Local\Programs\Python\Python35\Scripts\virtualenv.exe\__main__.py", line 5, in <module> File "c:\users\nollb\appdata\local\programs\python\python35\lib\site-packages\virtualenv\__init__.py", line 3, in <module> from .run import cli_run, session_via_cli File "c:\users\nollb\appdata\local\programs\python\python35\lib\site-packages\virtualenv\run\__init__.py", line 12, in <module> from .plugin.activators import ActivationSelector File "c:\users\nollb\appdata\local\programs\python\python35\lib\site-packages\virtualenv\run\plugin\activators.py", line 6, in <module> from .base import ComponentBuilder File "c:\users\nollb\appdata\local\programs\python\python35\lib\site-packages\virtualenv\run\plugin\base.py", line 9, in <module> from importlib_metadata import entry_points File "c:\users\nollb\appdata\local\programs\python\python35\lib\site-packages\importlib_metadata\__init__.py", line 88 dist: Optional['Distribution'] = None ^ SyntaxError: invalid syntax The system cannot find the path specified. The system cannot find the path specified. The system cannot find the path specified. Is setting up an environment really necessary for creating a small-ish website, and no other django work would be done on my computer? And if it is necessary, what have I done wrong? -
Running Django Project after Cloning from Github not working?
I happened to push my repo from my other computer and perhaps could have missed some files? I omitted the sqlite file since my application was just routing and serving web pages/forms. Anyways, I am attempting to python manage.py runserver and I keep getting an error message. It says : python manage.py runserver Watching for file changes with StatReloader Performing system checks... Exception in thread django-main-thread: Traceback (most recent call last): File "/home/alejandro/anaconda3/lib/python3.7/threading.py", line 917, in _bootstrap_inner self.run() File "/home/alejandro/anaconda3/lib/python3.7/threading.py", line 865, in run self._target(*self._args, **self._kwargs) File "/home/alejandro/anaconda3/lib/python3.7/site-packages/django/utils/autoreload.py", line 54, in wrapper fn(*args, **kwargs) File "/home/alejandro/anaconda3/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run self.check(display_num_errors=True) File "/home/alejandro/anaconda3/lib/python3.7/site-packages/django/core/management/base.py", line 390, in check include_deployment_checks=include_deployment_checks, File "/home/alejandro/anaconda3/lib/python3.7/site-packages/django/core/management/base.py", line 377, in _run_checks return checks.run_checks(**kwargs) File "/home/alejandro/anaconda3/lib/python3.7/site-packages/django/core/checks/registry.py", line 72, in run_checks new_errors = check(app_configs=app_configs) File "/home/alejandro/anaconda3/lib/python3.7/site-packages/django/core/checks/urls.py", line 40, in check_url_namespaces_unique all_namespaces = _load_all_namespaces(resolver) File "/home/alejandro/anaconda3/lib/python3.7/site-packages/django/core/checks/urls.py", line 57, in _load_all_namespaces url_patterns = getattr(resolver, 'url_patterns', []) File "/home/alejandro/anaconda3/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/home/alejandro/anaconda3/lib/python3.7/site-packages/django/urls/resolvers.py", line 579, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/home/alejandro/anaconda3/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/home/alejandro/anaconda3/lib/python3.7/site-packages/django/urls/resolvers.py", line 572, in urlconf_module return import_module(self.urlconf_name) File "/home/alejandro/anaconda3/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line … -
Adding data to the database through the front-end in django
I am writing a small blog and I will like to have a page through which I will be updating the website without going to the admin panel but it seems am not getting something right. I've writing a view function but it is not responding yet. Am still a newbie Below is my models.py file class UserUpload(models.Model): artist = models.CharField(max_length=300) title = models.CharField(max_length=200, unique=True) slug = models.SlugField(default='', blank=True, unique=True) thumbnail = models.ImageField(blank=False) audio_file = models.FileField(default='') music_tag = models.ManyToManyField(MusicTag) uploaded_date = models.DateTimeField(default=timezone.now) page_views = models.IntegerField(default=0) moderation = models.BooleanField(default=False) class Meta: ordering = ['-uploaded_date'] def save(self): self.uploaded_date = timezone.now() self.slug = slugify(self.title) super(UserUpload, self).save() def __str__(self): return self.title + ' by ' + self.artist def get_absolute_url(self): return reverse('music:detail', kwargs={'slug': self.slug}) This is my views.py file def upload(request): if request.method == 'POST': AUDIO_FILE_TYPE = ['wav', 'mp3', 'ogg'] IMAGE_FILE_TYPE = ['png', 'jpg', 'jpeg'] form = UserMusicForm(request.POST or None, request.FILES or None) if form.is_valid(): form.save(commit=False) form.artist = request.POST.get('artist') form.title = request.POST.get('title') form.thumbnail = request.POST.FILES('thumbnail') form.audio_file = request.POST.FILES('audio_file') form.music_tag = request.POST.get('music_tag') messages.success(request, 'has been successfully uploaded') if form.thumbnail.url.split('.')[-1] not in IMAGE_FILE_TYPE: context = { "form": form, "message": "Image file must be PNG, JPG, or JPEG" } return render(request, "music/upload1.html", context) if form.audio_file.url.split('.')[-1] not in AUDIO_FILE_TYPE: … -
css adding linear-gradient to background does not work, but adding single color does
I am trying to add a linear gradient background to the login page of my website, however I cannot seem to get it to work. #login { background-image: linear-gradient(red, yellow); } <body id="login" class="vh-center"> ... </body> I have tried; background-image: linear-gradient(red, yellow);, and background-image: linear-gradient(red, yellow); If I add background: red;, It works as expected Am I missing something here? Edit: css #login { background: linear-gradient(red, yellow); } Screenshot: css #login { background: red; } Screenshot: -
Adding List of Related IDs to returned values in a Django Queryset
According to the example in Django's Docs, I can obtain a list of reverse related objects like this: Blog.objects.values('entry__id') Which would presumably give me the ids of all related Entry objects. If I wanted this information in addition to all the other information returned in a normal .values() call, is there a short way to add it on? Or do I need to explicitly list all of the models' fields in .values() to have the reverse keys included in the output? -
How to create a function that counts total string objects in my ArrayField column for my model?
Trying to create a column in my model called, stock_count, that finds the sum of the total string objects in my ArrayField(), aka stock_list. Here is my function. def total_stocks_calc(self): self.stock_count = Bucket.objects.aggregate(Sum('stock_list', distinct=True)) self.save() However it doesn't seem to be doing anything, no calculating, leaving the field blank in my model, admin page, and DRF interface... Here is my model. class Bucket(models.Model): owner = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='buckets') users = models.ManyToManyField(settings.AUTH_USER_MODEL) category = models.CharField(max_length=30, choices=category_options) name = models.CharField(max_length=35) created = models.DateTimeField(default=timezone.now) slug = models.SlugField(unique=True, blank=True) stock_count = models.IntegerField(blank=True, null=True) stock_list = ArrayField(models.CharField(max_length=6,null=True),size=30,null=True) about = models.CharField(max_length=75) objects = models.Manager() bucketobjects = BucketObjects() class Meta: ordering = ('-created',) def total_stocks_calc(self): self.stock_count = Bucket.objects.aggregate(Sum('stock_list', distinct=True)) self.save() def __unicode__(self): return self.stock_list Would like to know the proper way to count total items in ArrayField(), thank you in advance. -
Why django page may not load?
Project in /root/code/mysite, i activating venv ". ./env/bin/activate", starting server "python3 manage.py runserver 0.0.0.0:8000", all ok System check identified no issues (0 silenced). December 25, 2020 - 00:27:24 Django version 2.2.17, using settings 'main.settings' Starting development server at http://0.0.0.0:8000/ Quit the server with CONTROL-C., but on http://IP:8000 nothing. What could be the problem? -
Bootstrap Table from Model
I have a table that I am trying to convert from static, mock data into real, live SQLite3 data. I am hoping to display my SQLite3 table within my HTML code including all three of my columns (Question | Answer | Pub_Date) and then display the values in the table. My current code (below) adds the list of questions in, but it is adding them in as values from left to right rather than up and down (screenshot below). What would I need to adjust to get my simple table shown rather than the fake data? <table class="table table-hover"> <thead> <tr style="font-family: Graphik Black; font-size: 14px"> <th scope="col">#</th> <th scope="col">First</th> <th scope="col">Last</th> </tr> </thead> <tbody> <tr style="font-family: Graphik; font-size: 12px"> <th scope="row" class="container">1</th> {% for question in latest_question_list %} <td><li style="font-weight: 500;"><a href="{% url 'polls:detail' question.id %}">{{ question.question_text }}</a></li></td> {% endfor %} <td><button type="button" class="btn btn-danger btn-sm badge-pill" style="font-size: 11px; width:60px" data-toggle="modal" data-target="#new">Edit</button></td> </tr> <tr style="font-family: Graphik; font-size: 12px"> <th scope="row">2</th> <td>Jacob</td> <td>Thornton</td> <td><button type="button" class="btn btn-danger btn-sm badge-pill" style="font-size: 11px; width:60px" data-toggle="modal" data-target="#new">Edit</button></td> </tr> <tr style="font-family: Graphik; font-size: 12px"> <th scope="row">3</th> <td colspan="2">Larry the Bird</td> <td><button type="button" class="btn btn-danger btn-sm badge-pill" style="font-size: 11px; width:60px"data-toggle="modal" data-target="#new">Edit</button></td> </tr> </tbody> </table> Desired … -
How to upload Large Files to heroku from a GitHub repository?
Im trying to upload Large files from GitHub respository to my heroku app. This files are uploaded correctly to the repository through LFS method. In Heroku the deployment method is already connected to my github repository. The problem is that the files are not uploaded correctly to Heroku, due to the size of these files, and therefore the python script (views.py) that must read these files, cannot find them. At the end, the deployment is unsuccessful and none of the files are uploaded correctly. The sizes of this 3 files are: 40.7 mb, 65.1 mb and 227 mb -
Django psycopg2.errors.StringDataRightTruncation: value too long for type character varying(200)
Facing the above error when running the django app. What exactly needs to be changed though? The comment_body = models.TextField() aspect most probably is the culprit since it stores reddit comments which can be of varying lengths. Models.py from django.db import models # Create your models here. class Subreddit(models.Model): # Field for storing the name of a subreddit subreddit_name = models.CharField(max_length=200, unique=True) # Field for storing the time the model object was last saved last_updated = models.DateTimeField(auto_now=True) class Submission(models.Model): subreddit = models.ForeignKey(Subreddit, on_delete=models.CASCADE) # The Reddit submission id of the object submission_id = models.CharField(max_length=200, unique=True) # Reddit Submission URL url = models.URLField(max_length=200) # Reddit Submission Title title = models.CharField(max_length=200) class SubmissionComment(models.Model): # Parent submission object submission = models.ForeignKey(Submission, on_delete=models.CASCADE) # Text of the comment comment_body = models.TextField() class Meme(models.Model): memeurl = models.URLField(max_length=200)