Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django admin site change_list customization
Homepage/templates/admin/Homepage mypath @admin.register(gradeScalesSetting) class gradeScalesSettingAdmin(admin.ModelAdmin): list_display = ('configuration_select', 'NumberOfGrades', 'Rounding','Precision', 'Status',) change_list_template = 'admin/Homepage/view.html' after i click Grade Scale Settings how to connect it to my views.py? thi is what i want to code in my views.py def gradescales(request): gradeScalesSettings = gradeScalesSetting.objects.all() configurations = configuration.objects.all() rounding = gradeScalesSetting.objects.all().values_list('Rounding', flat=True).distinct() print(rounding) return render(request, 'Homepage/gradescale.html', {"rounding": rounding,"gradeScalesSetting":gradeScalesSettings,"configurations":configurations}) UPDATE when i tried this @admin.register(gradeScalesSetting) class gradeScalesSettingAdmin(admin.ModelAdmin): def new_NumberOfGrades(self, obj): if obj.NumberOfGrades == 'Grade Scale Settings': return '<a href="view.html" </a>' # this url will redirect to your views function list_display = ('configuration_select', 'new_NumberOfGrades', 'Rounding','Precision', 'Status',) is there any way to connect it to my views.py? this is what i want to show in my view.html that is why i want to connect it to my views.py -
One div inside another, both clickable. When pressing the inner one, the outer is also triggered
what I would like to achieve is something like that: I have some div (a blog post to be precise, like reddit) and I want this this div to be whole clickable. It has a lot of data, like author, timeposted, content, img etc. But on the bottom is a save button which allows users to save it for later. But when I click the save button it also tiggers the post's onlick what causes that user is redirected to the detail page of the post. I do not want that. I only want to trigger save button. Image of the situation: What I do have is that: <div onclick="location.href='/post/{{ post.id }}/';" style="cursor: pointer; "> <article class="media post"> <div class="media-body"> <!-- Whole body, user, date, content, img etc. --> <div> <a id="save-post-{{post.id}}" href="javascript:void(0);" onclick="save_post('{{post.pk}}', '{{user.pk}}', this.id, '{{ csrf_token }}');"> Save </a> </div> </div> </article> </div> How do I do that, the save button is only triggered? -
CSS Grid/Flexbox for dynamic content in Django
I am using Django for a project, and I have a wireframe CSS grid layout, 4 across at the moment, and I want to know how I can replace these wireframe components with dynamic content using Django. I know that {% for post in posts %} would work for me in a straight down list way, but how can I make this work in a grid system, so it'll break to a new line whenever it reaches 4 across in the grid. I am stumped and haven't found anything online on how to do it. -
play song in django...please help me for solving that issue..i will pay small money for it..bt i need the answe quickly
help in audio play in django iam making a website using django..in my default.html page everything working good..iam collecting all details from database and fetch to default page..bt when clicking on each image i want to play the song that associated with..bt i dont know the code for that..please help me modesl page class Songs(models.Model): Title = models.CharField(max_length=100) Film = models.CharField(max_length=100) Composer = models.CharField(max_length=100) Artist = models.CharField(max_length=100) Duration = models.CharField(max_length=100) Language = models.CharField(max_length=100) Latest = models.BooleanField(default=False) Img = models.ImageField(upload_to='pics') Audio = models.FileField(upload_to='musics/')``` def default(request): son = Songs.objects.all() return render(request, 'default.html', {'son' : son}) //////default page//////// <div class="row"> {% for i in son %} {% if i.Latest %} <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12"> <a style="text-decoration: none;" href="" class="fon acol profile-img-container"><img class=" imgsize" src="{{ i.Img.url }}"><i class="fa fa-play fa-5x profile-img-i-container iconcolor"></i><h6><br>Song : {{ i.Title }}</h6><h6>Movie : {{ i.Film }}</h6></a> <audio controls autoplay loop preload="metadata" style="width: 100%;background-color: #aa09f2"> <source src="{{ i.Audio.url }}" type="audio/mpeg"> Your browser does not support the audio element. </audio> {% endif %} </div> {% endfor %} </div></div> i want to play not like this..it is playing for every images..i need to play the media player when clickin on an image..can anyone help me -
Keep data in divs when comming back from other page
Firstly, I didn't know how to give a short description of the problem in the title, let me explain it here. I'm creating social site, with all common features like/comments etc. Imagine Twitter/Instagram. I do have main/home page where all posts are displayed. Every post has a like button, so when it is clicked it triggers a AJAX function to send request to Django server to update the database with new like. This JS function also changes the style of the button, so user can know that he liked it. So far so good. Now when he decides that he want to comment this post, he clicks it and is redirected to the new page - the detail page. Here when the page is loading with data from server his like he gave earlier is visible(the div is red). All right, he commented, but know when pressing back button, in order to go to the home page, his like under the post is not more visible without reloading the page. I will demonstrate it using images. Now I'm using JS function to reload whole page, to get from Django server all new data, but I don't think it is good … -
"TypeError: Input 'global_step' of 'ResourceApplyAdagradDA' Op has type int32 that does not match expected type of int64." What is this bug?
While I was trying to use the AdaGradDual Optimizer, I got an error for the batch size I had entered. The batch size I entered was 300 because I have 60000 samples to train. My code: import tensorflow as tf from tensorflow import keras import matplotlib.pyplot as plt import numpy as np import time start_time = time.time() data = tf.keras.datasets.fashion_mnist (train_images, train_labels), (test_images, test_labels) = data.load_data() class_names = ['T-shirt', 'Trouser', 'Pullover', 'Dress', 'Coat', 'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle Boot'] train_images = train_images/255.0 test_images = test_images/255.0 optimizer1 = tf.compat.v1.train.AdagradDAOptimizer(0.001,0) model = keras.Sequential([ keras.layers.Flatten(input_shape=(28, 28)), keras.layers.Dense(100, activation="softsign"), keras.layers.Dense(10, activation="softmax") ]) model.compile(optimizer=optimizer1, loss="sparse_categorical_crossentropy", metrics=["accuracy"]) model.fit(train_images, train_labels, epochs=5) test_loss, test_acc1 = model.evaluate(test_images, test_labels) print("Test acc is:", test_acc1) print("--- %s seconds ---" % (time.time() - start_time)) Error: --------------------------------------------------------------------------- ValueError Traceback (most recent call last) /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/op_def_library.py in _apply_op_helper(self, op_type_name, name, **keywords) 527 as_ref=input_arg.is_ref, --> 528 preferred_dtype=default_dtype) 529 except TypeError as err: 13 frames /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/ops.py in internal_convert_to_tensor(value, dtype, name, as_ref, preferred_dtype, ctx, accepted_result_types) 1272 "Tensor conversion requested dtype %s for Tensor with dtype %s: %r" % -> 1273 (dtype.name, value.dtype.name, value)) 1274 return value ValueError: Tensor conversion requested dtype int64 for Tensor with dtype int32: <tf.Tensor 'training_16/AdagradDA/update_dense_22/kernel/Identity:0' shape=() dtype=int32> During handling of the above exception, another exception … -
how to convert RawQuerySet to int
i know this is a strange question but i need to reduce one from the RawQuerySet. i need to reduce a the value output by the .raw command but i do not know how to do this. i have tried to convenvert the RawQuerySet to the queryset dictionary tuple but i don`t know what to do from their. i am getting the data in the following query data = bio_eq.objects.raw('SELECT bio_eq_amount from bio_lab_bio_eq where bio_eq_id=bio_eq_id') i am not sure how to take this and extract the data and turn it into a integer -
django select_related() calls database each time object is referenced, instead of just once
using select_related, each time I reference the query set, another call to the database is made. instead of caching the result. models.py .... class Album(models.Model): user = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.CASCADE, ) title = models.CharField(max_length=255) description = models.CharField(max_length=255, null=True) class Photo(models.Model): album = models.ForeignKey(Album, on_delete=models.CASCADE) name = models.TextField(unique=True) ... views.py .... photos = Photo.objects.select_related('album').filter(album_id = id).all() print(photos) print(photos) print(photos) .... will result in 4 different calls to the database for each reference to "photos", as verified by manage.py runserver_plus --print-sql is this normal? or am I not using select_related() properly? -
Are there flaws in my current understanding of classes and functions?
I have just started learning about Django and have finished classes and objects in Python. One common snippet that I see all the time is: from django.db import models class Topic(models.Model): """A topic the user is learning about""" text = models.CharField(max_length=200) Is it ok to say that there is some file called django.db in the system and there is a class called models inside it and Model is an attribute of the class? Also, django.db is not a Python (.py) file, so how can it contain a class? Now, Is CharField is function inside the class models or is it something else? -
Django admin site change_list customization
Homepage/templates/admin/Homepage mypath @admin.register(gradeScalesSetting) class gradeScalesSettingAdmin(admin.ModelAdmin): list_display = ('configuration_select', 'NumberOfGrades', 'Rounding','Precision', 'Status',) change_list_template = 'admin/Homepage/view.html' after i click Grade Scale Settings how to connect it to my views.py? thi is what i want to code in my views.py def gradescales(request): gradeScalesSettings = gradeScalesSetting.objects.all() configurations = configuration.objects.all() rounding = gradeScalesSetting.objects.all().values_list('Rounding', flat=True).distinct() print(rounding) return render(request, 'Homepage/gradescale.html', {"rounding": rounding,"gradeScalesSetting":gradeScalesSettings,"configurations":configurations}) -
Conditional Relationships between Two Tables in Django?
The following image shows a rough draft of my proposed database structure that I will develop for Django. Briefly, I have a list of ocean Buoys which have children tables of their forecast conditions and observed conditions. I'd like Users to be able to make a log of their surf sessions (surfLogs table) in which they input their location, time of surf session, and their own rating. I'd like the program to then look in the buoysConditions table for the buoy nearest the user's logged location and time and append to the surfLog table the relevant buoyConditions. This will allow the user to keep track of what conditions work best for them (and also eventually create notifications for the user automatically). I don't know what the name for this process of joining the tables is, so I'm having some trouble finding documentation on it. I think in SQL it's termed a join or update. How is this accomplished with Django? Thanks! -
Trouble getting my HTML button linked to a Python function using Django
I am attempting to take data from an HTML page form hosted on Django's localhost development server and send it to a database in Models. I'm attempting to follow this solution, but I'm not sure how to link the function to the reference to the HTML in views.py. Here's my views.py currently: # djangotemplates/example/views.py from django.shortcuts import render from django.views.generic import TemplateView # Import TemplateView from django.http import HttpResponse from pathfinder.models import characterTable def addCharacter(sUserID, sPlayerName, sRace, sPlayerClass, sStr, sCon, sDex, sInt, sWis, sCha): c = characterTable() c.userID=sUserID c.playerName = sPlayerName #... rest of fields go here c.save() def request_page(request): if(request.GET.get('mybtn')): userID = 'testUser' addCharacter(userID, string(request.GET.get('characterName')), string(request.GET.get('race')), string(request.GET.get('class')), string(request.GET.get('characterName')), string(request.GET.get('strength')), string(request.GET.get('dexterity')), string(request.GET.get('constitution')), string(request.GET.get('intelligence')), string(request.GET.get('wisdom')), string(request.GET.get('charisma'))) # Add the two views we have been talking about all this time :) class HomePageView(TemplateView): template_name = "index.html" class AboutPageView(TemplateView): template_name = "about.html" And here is the HTML, in my templates folder: <!-- djangotemplates/example/templates/index.html--> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Welcome Home</title> </head> <body> <a href="{% url 'home' %}">Go Home</a> <a href="{% url 'about' %}">About This Site</a> <form name = "characterForm" id = "characterForm" method = "get" action = "#"> Character Name:<br> <input type="text" name="characterName" id ="characterName"> <br> Race:<br> <select name = "race" … -
Why doesnt work edit model by list_filter with custom model manager?
For Post model I created a custom manager: #models.py class ObjectsOnManager(models.Manager): def get_queryset(self): return super(ObjectsOnManager, self).get_queryset().filter(status='on') class OnOffStatusModel(models.Model): ON = 'on' OFF = 'off' STATUS_CHOICES = ( (ON, 'Показывать'), (OFF, 'Не показывать'), ) status = models.CharField("Статус", max_length=15, choices=STATUS_CHOICES, default=ON) objects_on = ObjectsOnManager() objects = models.Manager() class Meta: abstract = True class Post(OnOffStatusModel): # fields ...... Then changed get_queryset in modelAdmin #admin.py class PostAdmin(admin.ModelAdmin): form = PostImageControlForm fields = ('count', 'status', 'image', 'title', 'descript', 'body', 'main_post', ) list_display = ('title', 'main_post', 'count',) list_editable = ('main_post', 'status') list_filter = ('category', 'main_post', 'status') def get_queryset(self, request): return Post.objects.all() So if I edit model on the change model page it is ok, but if i tried to edit on the change list page I have got the error enter image description here -
I import the module TinyMCE and the django isnt working
I think I have a outdated verison of TinyMCE and i was wondering how to fix the ImportError: cannot import name 'TinyMCE' from 'tinymce'. It was working before i form.py from django import forms from tinymce import TinyMCE from .models import Post, Comment class TinyMCEWidget(TinyMCE): def use_required_attribute(self, *args): return False class PostForm(forms.ModelForm): content = forms.CharField( widget=TinyMCEWidget( attrs={'required': False, 'cols': 30, 'rows': 10} ) ) class Meta: model = Post fields = ('title', 'overview', 'content', 'thumbnail', 'categories', 'featured', 'previous_post', 'next_post') class CommentForm(forms.ModelForm): content = forms.CharField(widget=forms.Textarea(attrs={ 'class': 'form-control', 'placeholder': 'Type your comment', 'id': 'usercomment', 'rows': '4' })) class Meta: model = Comment fields = ('content', ) -
DJANGO - please guys need help in signals pre_save
when i try to make a slugfield , and when i write the pre_save code it doesn't reconize my model i don't know why , please help this is my model : from django.db import models from post.utils import unique_slug_generator from django.db.models import signals from django.db.models.signals import pre_save class product(models.Model): title=models.CharField(max_length=50) slug=models.SlugField(max_length=50,unique=True) photo=models.ImageField(upload_to='img') price=models.PositiveIntegerField(default=0) discription=models.TextField(max_length=255) def __str__(self): return self.title def slug_save(sender,instance,*args,**kwargs): if not instance.slug: instance.slug=unique_slug_generator(instance,instance.title,instance.slug) pre_save.connect(slug_save, sender =product) utils.py: from django.utils.text import slugify def unique_slug_generator(model_instance,title,slug_field): slug=slugify(title) model_class=model_istance.__clas__ while model_class._default_manager.filter(slug=slug).exists(): object_pk=model_class._default_manager.latest(pk) object_pk=object_pk.pk + 1 slug=f'{slug}-{object_pk}' return slug the error message : class product(models.Model): File "C:\Users\Madara\Desktop\khkh\sluger\post\models.py", line 28, in product pre_save.connect(slug_save, sender =product) NameError: name 'product' is not defined -
Django pass argument to view from html form
I have an html page that contains a dropdown selector. I have this encased in a form and I essentially want to just reload the same page with a different value passed in when Update is clicked. Here is the html: <form action="{% url 'analyze:plot' %}"> <select> {% for name in x_keys %} <option name="x_key_name" id="{{ name }}" value="{{ name }}">{{ name }}</option> {% endfor %} </select> <input type="submit" value="Update"> </form> Here is the view def plot(request, x_key='test_key'): svg_dict = { 'svg': get_fig(x_key=x_key), 'x_keys': ScatterKeysXAxis.objects.all(), } # set the plot data plt.cla() # clean up plt so it can be re-used return render(request, 'analyze/plot.html', svg_dict) How do I set the x_key within the view from the html form? Is there a better way to do what I am describing? -
Redirecting to wrong URL Django
I've been working on a Django project that has multiple types of users. Hence, I'm creating more than one signup page, one for each type of user. I created one page for users to chose if they want to sign up as a mentor or a student so they can later be given a right form. However, my urls don't work properly and both 'register' and 'register_student' urls take me to the view I created for register. What am I doing wrong? My register/urls.py : urlpatterns = [ path('', views.register, name='register'), path('', views.student_register, name='student_register'), ] My register/templates/register/register.html {% block content %} <h2>Sign up</h2> <p class="lead">Select below the type of account you want to create</p> <a href="{% url 'student_register' %}" class="btn btn-student btn-lg" role="button">I'm a student</a> {% endblock %} My register/views.py def register(request): return render(request, "register/register.html") def student_register(request): if request.method == "POST": student_form = StudentRegisterForm(request.POST) if student_form.is_valid(): user = student_form.save(commit=False) user.is_student = True user.save() else: student_form = StudentRegisterForm() return render(request, "register/student_register.html", {"student_form": student_form}) And my app's ursl: mentorapp/mentorapp/urls: urlpatterns = [ path('', include("django.contrib.auth.urls")), # gives access to django log-in/out pages path('mainpage/', include('mainpage.urls')), path('register/', include('register.urls')), path('student_register/', include('register.urls')), ] localhost:8000/register shows the 'register.html' page and when I click on 'I'm a student' url … -
How to resolve 'no pg_hba.conf entry for host' error for django app?
I am building a web app using django. I am trying to connect the app to the Azure Database for PostgreSQL. I get this error when I use the "python manage.py makemigrations" command in the powershell. -
Django filter by a specific day
I have an application that I need to pick one day and it returns me the total number of events as well as the list of active events that day. Each event has a duration. I can filter for today, but how do I do if I want to filter for any other day? model class Event(models.Model): name = models.CharField(max_length=50, null=True, blank=True, verbose_name='Name') start_date = models.DateTimeField(null=True, blank=False, verbose_name='Start') end_date = models.DateTimeField(null=True, blank=False, verbose_name='End') def __str__(self): return '{}'.format(self.name) view def total_events(request): events = Event.objects.filter(Q(start_date__lte=timezone.now()) & Q(end_date__gte=timezone.now())) total_events = events.count() context = { 'events': events, 'total_events': total_events, } return render(request, 'list.html', context) template <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Event Search</title> </head> <body> <br> <br> DAY: <input type="text"> <button>Filter</button> <br> <br> <b>Total of active events in filtered day:</b> {{ total_events }} <br> <b>List of active events in filtered day:</b> <table> <tr> {% for event in events %} <td> {{ event.name }} </td> {% endfor %} </tr> </table> </body> </html> The output is like this: Can some one give me a direction to follow? thanks! -
Nested Models when API Endpoint differs in field names from model with Django Rest Framework
Let's say I receive the following json: { "id": 1234, "created_at": "2019-10-22T14:18:09-04:00", "person": { "id": 7234, "name": "John Smith" }, "ticket": { "id": 5432, "person_id": 7234, "name": "How to fix this function?" } } And I want to serialize and then save to a db with the following tables: Event, Person, and Ticket where Ticket is described as follows: class Ticket(models.Model): id = models.PositiveIntegerField(primary_key=True) person = models.ForeignKey('Person') name = models.CharField(max_length=100) What ought the Ticket Serializer to look like? Currently, I have what doesn't work: class TicketSerializer(serializers.ModelSerializer): person_id = serializers.IntegerField() class Meta: model = models.Ticket def to_internal_value(self, data): try: data['person'] = data['person_id'] except KeyError: pass return super().to_internal_value(data) class EventSerializer(UniqueFieldsMixin, NestedCreateMixin, serializers.ModelSerializer): person = PersonSerializer() ticket = TicketSerializer() class Meta: model = models.Event The error I get reads: rest_framework.exceptions.ValidationError: {'ticket': {'person': [ErrorDetail(string='Invalid pk "7234" - object does not exist.', code='does_not_exist')]}} -
How to PATCH a column in table according to an id from another table in django
I am building a django application. I have a question here. This is my models.py class Device(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) device_name = models.CharField(max_length=200, null=True, blank=True ) created_at = models.DateTimeField(auto_now_add=True) def __str__(self): return str(self.id) class StatusActivity(models.Model): OFFLINE = 1 ONLINE = 2 STATUS = ( (OFFLINE, ('Offline')), (ONLINE, ('Online')), ) id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) device_id = models.ForeignKey(Device, related_name='status_activity', on_delete=models.CASCADE) changed_to = models.PositiveSmallIntegerField(choices=STATUS) modified_at = models.DateTimeField(auto_now_add=True) I want to write an api that takes id of Device and change its relational data(changed_to field) in StatusActivity table. How should my views.py should be ? from rest_framework import generics, status from rest_framework.response import Response from .models import Device, StatusActivity from .serializers import DeviceSerializer, StatusActivitySerializer class DeviceListView(generics.ListAPIView): queryset = Device.objects.all() serializer_class = DeviceSerializer class DeviceListByIdView(generics.UpdateAPIView): queryset = Device.objects.filter(id=self.request.id) serializer_class = StatusActivitySerializer def patch(self, request, *args, **kwargs): super(DeviceListByIdView, self).patch(request, args, kwargs) instance = self.get_object() serializer = self.get_serializer(instance) data = serializer.data response = {"status_code": status.HTTP_200_OK, "message": "Successfully updated", "result": data} return Response(response) -
Show the count of inline items in the admin view
I want to show the count of a related item in the parent items listing in django. But I keep getting an error. models.py class TblHoldings(models.Model): item_code = models.CharField(unique=True, max_length=5) product_name = models.CharField(max_length=45) service_provider = models.ForeignKey(TblHoldingsServiceProviders,on_delete=models.CASCADE, related_name='service_provider',db_column='service_provider') account_details = models.CharField(max_length=100) purchase_cost = models.IntegerField() current_value = models.IntegerField() power_of = models.CharField(max_length=45, blank=True, null=True) purchase_date = models.DateTimeField(blank=True, null=True) goal_term = models.CharField(max_length=40, default="M",choices=FIN_GOAL_TERM) created_at = models.DateTimeField(auto_now_add=True, null=True, blank=True) updated_at = models.DateTimeField(auto_now=True, null=True, blank=True) def __str__(self): return self.product_name + ' at ' + self.service_provider.provider_name class Meta: verbose_name = 'Holding' verbose_name_plural = 'Holdings' managed = True db_table = 'tbl_holdings' class TblHoldingsSubProducts(models.Model): item_code = models.CharField(max_length=5, blank=True, null=True) holding_id = models.ForeignKey(TblHoldings, default= 1,on_delete = models.CASCADE,related_name='holding_id', db_column='holding_id' ) product_name = models.CharField(max_length=45) account_details = models.CharField(max_length=100) purchase_cost = models.IntegerField() current_value = models.IntegerField() power_of = models.CharField(max_length=45) purchase_date = models.DateTimeField(blank=True, null=True) maturity_date = models.DateTimeField(blank=True, null=True) created_at = models.DateTimeField(auto_now_add=True, null=True, blank=True) updated_at = models.DateTimeField(auto_now=True, null=True, blank=True) def __str__(self): return self.product_name class Meta: verbose_name = 'Holdings Sub Product' verbose_name_plural = 'Holdings Sub Products' managed = True db_table = 'tbl_holdings_sub_products' admin.py class HoldingsSubProductsInline(admin.TabularInline): model = TblHoldingsSubProducts @admin.register(TblHoldings) class HoldingsAdmin(admin.ModelAdmin): list_display = ('item_code', 'product_name', 'service_provider', 'power_of','current_value', 'purchase_date', 'subproduct_count') list_filter = ('goal_term', 'power_of', 'product_name', 'service_provider') ordering = ('purchase_date',) search_fields = ('product_name',) inlines = [ HoldingsSubProductsInline, ] def subproduct_count(self, … -
Django returns a error of circular import
enter image description hereWhen I wrote urlpatterns I got such error: django.core.exceptions.ImproperlyConfigured: The included URLconf '' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably ca used by a circular import. -
How to Create a Scheduled Post in Django?
I would like to publish the shipment according to the specified date and time. For example, when I send the article today, I want it to be published automatically when the time comes tomorrow. (or at any date and time) How can I do it? Relevant part of the model: With this model, date and time are determined for post. models.py published = models.DateTimeField(default=timezone.now, verbose_name="Yayımlanma Tarihi",) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) views.py def post_index(request): post_list = Post.objects.all() query = request.GET.get('q') if query: post_list = post_list.filter( Q(title__icontains=query) | Q(content__icontains=query) | Q(author__first_name__icontains=query) | Q(author__last_name__icontains=query) ).distinct() paginator = Paginator(post_list, 5) # Show 25 contacts per page page = request.GET.get('sayfa') posts = paginator.get_page(page) return render(request, 'post/index.html', {'posts': posts}) -
heroku limit with django analyzing files without model?
i created an app using django and heroku to upload pdf files and get some specific data out of them. After deploying I found few things. 1: There is a limit in the http response which i believe is around 30 to 40 secs, however some of these files are super big and it may require a bit more time. Is there a way to increase the time response? if not, any other server you may recommend? 2: Because I am not using a db to storage the files, cannot find anywhere is django or heroku has a limit for handling files without saving them in a db. any specific limits?