Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django Rest Framework: After creating an object assign it to other model
I have two models - Meeting Room and Rezervations and now I need to somehow connect these two. So basically my logic for this is simple: User Creates an Meeting room through API and later on he can create reservations for many users (not one). For this I have this model: class Reservations(models.Model): statusTypes = [ (0, "Valid"), (1, "Cancelled") ] to = models.ForeignKey(Employees, on_delete=models.CASCADE) title = models.CharField(max_length=150, blank=False, null=False) status = models.IntegerField(choices=statusTypes, null=False, blank=False, default=0) date_from = models.DateTimeField() date_to = models.DateTimeField() def cancel_reservation(self): self.status = 1 self.save() print('Reservation is now', self.status) return True class Meta: db_table = "Reservations" def __str__(self): return str(self.id) class MeetingRooms(models.Model): public_id = models.UUIDField(default=uuid.uuid4, editable=False, unique=True, blank=False, null=False, max_length=36) creator = models.ForeignKey(Employees, on_delete=models.CASCADE) reservations = models.ManyToManyField(Reservations) secret_key = models.CharField(max_length=128, null=False, blank=False) date_created = models.DateTimeField(auto_now_add=True) # There could be a lot of reservations, so we will just leave it as it is. def create_secretKey(self, secret_key): return make_password(secret_key, hasher="argon2") def check_secretKey(self, secret_key): return check_password(secret_key, self.secret_key) class Meta: db_table = "MeetingRooms" def __str__(self): return str(self.id) But the thing is that I can't figure out how can I do it with rest-framework. RestFramework-MeetingRoom RestFramework-Rezervations Serializers : from rest_framework import serializers from main.models import MeetingRooms, Reservations class MeetingRoomSerializer(serializers.ModelSerializer): class Meta: model … -
I cannot migrate the change I made to the model
I have a User model written in AbstractBaseUser. When I add new fields on this model and run python manage.py makemigrations and then python manage.py migrate --run-syncdb, django tells me that nothing changes. I would like to add that there is no migrations folder inside this User app. -
Django - How could I create a method of allowing the user to edit an existing note?
I'm working on an application which allows users to create, edit, and delete notes for artists and their shows at venues. Currently I have a method for creating new notes and deleting as example, how could I create a method of allowing the user to edit an existing note? Here is what I currently have, I also thrown in repository links as reference to help explain how my application works. https://github.com/claraj/lmn/blob/master/lmn/urls.py #Note related path('notes/latest/', views_notes.latest_notes, name='latest_notes'), path('notes/detail/<int:note_pk>/', views_notes.note_detail, name='note_detail'), path('notes/for_show/<int:show_pk>/', views_notes.notes_for_show, name='notes_for_show'), path('notes/add/<int:show_pk>/', views_notes.new_note, name='new_note'), path('notes/detail/<int:note_pk>/delete', views_notes.delete_note, name='delete_note'), https://github.com/claraj/lmn/blob/master/lmn/views/views_notes.py @login_required def new_note(request, show_pk): show = get_object_or_404(Show, pk=show_pk) if request.method == 'POST' : form = NewNoteForm(request.POST) if form.is_valid(): note = form.save(commit=False) note.user = request.user note.show = show note.save() return redirect('note_detail', note_pk=note.pk) else : form = NewNoteForm() return render(request, 'lmn/notes/new_note.html' , { 'form': form , 'show': show }) @login_required def delete_note(request, note_pk): # Notes for show note = get_object_or_404(Note, pk=note_pk) if note.user == request.user: note.delete() return redirect('latest_notes') else: return HttpResponseForbidden https://github.com/claraj/lmn/blob/master/lmn/templates/lmn/notes/note_list.html <form action="{% url 'delete_note' note.pk %}" method="POST"> {% csrf_token %} <button type="submit" class="delete">Delete</button> </form> -
Troubles accessing a file from a directory from Django's views.py
I am trying to access a Matlab .mat file from a function in my views.py. I'm running into various errors. FileNotFoundErrors or file or directory not found. Depending on what I'm doing in views.py and settings.py to access that file. I have tried and tested various things according to the docs and my various googles, but coming up against a wall. I'm hoping SO can help me out. Right now I have the following configured: views.py import os from django.conf import settings def pig_data(request): file_path = os.path.join(settings.FILE_DIR, 'RingData_21Oct2020_PV96.mat') with open(file_path, 'r') as source: mat = loadmat('RingData_21Oct2020_PV96.mat') fat_mat = mat.items() return redirect('/display') settings.py BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) FILE_DIR = os.path.abspath(os.path.join(BASE_DIR, '/static/main')) The results fat_mat = mat.items() should appear on a simple html page. Nothing crazy. All I'm doing is clicking a button: <button onclick="document.location='/pig_data'">Input</button> My routes are all good and working as expected. urls.py from django.urls import path from . import views urlpatterns = [ path('', views.index), path('calibration', views.calibrate), path('download', views.download), path('display', views.display), path('pig_data', views.pig_data), ] Traceback: File "C:\dev\steady_flux\env\quest_buster\lib\site-packages\django\core\handlers\exception.py" in inner 34. response = get_response(request) File "C:\dev\steady_flux\env\quest_buster\lib\site-packages\django\core\handlers\base.py" in _get_response 115. response = self.process_exception_by_middleware(e, request) File "C:\dev\steady_flux\env\quest_buster\lib\site-packages\django\core\handlers\base.py" in _get_response 113. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\dev\steady_flux\quest_buster\main\views.py" in pig_data 66. with open(file_path, 'r') … -
Django & Celery. Group not executing tasks in parallel
I'm trying to execute some task with different arguments in parallel. For example, I have this function: def printRange(start, stop): for i in range(start, stop, 1): print(i) And I want it to execute in parallel with different start's and stop's. As I working in Django, my Celery config files looks like this: # celery.py from __future__ import absolute_import, unicode_literals import os from celery import Celery os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myProj.settings') app = Celery('myProj') app.config_from_object('django.conf:settings', namespace='CELERY') app.autodiscover_tasks() # __init__.py of project's root folder from .celery import app as celery_app __all__ = ('celery_app',) Next, I have task like one in example: # tasks.py import logging from celery import shared_task @shared_task def test_task(task_number, start, stop): for i in range(start, stop, 1): logging.info(f'task {task_number} says: {i}') As expected output from parallel task, I waited logs like: ... task 0 says: 2312 task 0 says: 2313 task 1 says: 7438 task 0 says: 2314 task 1 says: 7435 ... But, got just linear execution: task 0 says: 0 task 0 says: 1 ... task 0 says: 50000 task 1 says: 50001 task 1 says: 50002 ... task 1 says: 99999 What am I doing wrong? P.S: I had already seen this, and this questions and they don't helped … -
How to extract path params from Django Request object?
Sup people, I'm working on my own role-based authorization decorator for Django and did write some validation classes to be used for each role. My validation classes currently are receiving, as arguments, the request object, and the view itself. But for some roles, I need to extract a client_id from my URL to verify some rules. How can I extract this as a key-value pair from the Request object? I know that Django injects the path params as key-value pairs using keyword arguments but how could I extract this from the request? -
Django 3.1 not serving media files correctly
I have a project running in Django 3.1, and suddenly it has started to fail serving media files (static files uploaded by users), even though I haven't changed anything in settings.py or elsewhere. My main urls.py: from django.urls import path, include from django.conf import settings from django.conf.urls.static import static urlpatterns = [ path('admin/', admin.site.urls), path('cart/', include('cart.urls', namespace='cart')), path('', include('contacts.urls', namespace='contacts')), path('customers/', include('customers.urls', namespace='customers')), path('orders/', include('orders.urls', namespace='orders')), path('account/', include('account.urls')), path('', include('catalog.urls', namespace='catalog')), ] if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) From my settings.py: from pathlib import Path import os # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath( os.path.join(__file__, os.pardir)))) DEBUG = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.1/howto/static-files/ STATIC_ROOT = os.path.join(BASE_DIR, 'static/') STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join('static'), ) MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media/') I don't know and can't figure out where the mistake is, but runserver just keeps throwing 404 when trying to load media files, even though static files (CSS/JS) are being served correctly. -
In django, how do I post a parent and multiple child models at the same time?
So I am trying to make a website that keeps track of when our dogs were taken out last. I have it set up so that there are database models for users, dogs, posts, and actions (what each dog did when they were taken out), which is a child model for the post model. The problem that I am facing currently is trying to create a post and action models for each dog via a post webpage. The error I keep getting is an attribute error for the action model. I have tried to set it up my views in multiple different ways but none seem to work. How can I fix this? forms.py: from django import forms from dog_log_app.models import * class Log_Form(forms.ModelForm): class Meta: model = Post fields = ("issues",) class Action_Form(forms.ModelForm): class Meta: model = Action fields = ("peed", "pooped") views.py: from django.shortcuts import render from django.views.generic import ListView, CreateView from .models import Post, Dog, Action from dog_log_app.forms import * from django import forms from django.contrib.auth.models import User from django.http import HttpResponse, HttpResponseRedirect def home(request): context = { 'posts': Post.objects.all().order_by('-time_posted'), 'actions': Action.objects.all(), 'dogs': Dog.objects.all() } return render(request, 'dog_log_app/home.html', context) def post(request): form_post = Log_Form(request.POST or None) form_action … -
How to use javascript libraries imported from NPM
Context For a long time I was using Bootstrap and other libraries by sources. I mean I was including it as below: - static - vendor - jquery - popper - bootstrap - ... But nowadays, I need to improve myself in managing my web dependencies. For some reasons : Less sources in repositories and a more efficient team project Greater support to choose version or test migrations Saving time for later projects with same dependencies I need to include a library which is only provided through NPM which is codemirror So I am currently trying to manage dependencies via NPM, in a django project. But I'm stuck at a very basic step I guess. I don't know where to continue after npm install --save jquery popper.js bootstrap. I'm disturbed by all examples which are for node.js application... Where I'm stuck I have an index.js at the same level of my main package.json. I thought I had to import my scripts in this file, then include this script in my page. So I tried require Jquery then bootstrap, but I get errors on bootstrap required because jquery is undefined. I don't have much code to show, the more I need … -
How can i use Base64FileField for save file as base 64?
I want to save file with pdf txt and png extensions as bas64 .how can i write this class that support all of extentions.in other site i found Class Base64ImageFile ,but this class support image only. -
Select a valid choice. That choice is not one of the available choices. Django Error
Hy, I am a beginner in django and I am trying to create an App like Quora. I want the user to answer based on the question selected which I get from list of items. I wrote both class based and function based views but I get the same error of "Select a valid choice. That choice is not one of the available choices." Models.py class Question(models.Model): current_user = models.ForeignKey(User,on_delete=models.CASCADE) question = models.TextField() question_date_pub = models.DateTimeField(auto_now_add=True) def __str__(self): return (self.question) def get_absolute_url(self): return reverse('questions') class Answer(models.Model): current_user = models.ForeignKey(User,on_delete=models.CASCADE) question = models.ForeignKey(Question,on_delete=models.CASCADE) answer = models.TextField() def __str__(self): return self.answer def get_absolute_url(self): return reverse('questions') Forms.py from django import forms from .models import Question,Answer # class AskQuestionForm(forms.ModelForm): class Meta: model = Question fields = ['current_user','question'] widgets = { 'current_user':forms.TextInput(attrs={'class':'form-control','id':"my_user_input","type":"hidden"}), 'question':forms.Textarea(attrs={'class':'form-control'}) } class AnswerQuestionForm(forms.ModelForm): class Meta: model = Answer fields = ['current_user','question','answer'] widgets = { 'current_user':forms.TextInput(attrs={'class':'form-control','id':"my_user_input","type":"hidden"}), 'question':forms.TextInput(attrs={'class':'form-control','id':"current_question"}), 'answer':forms.Textarea(attrs={'class':'form-control'}) } Views.py def AnswerQuestionView(request,pk): question = Question.objects.get(pk=pk) if request.method == "POST": form = AnswerQuestionForm(request.POST or None) if form.is_valid(): form.save() else: form = AnswerQuestionForm() return render(request,'answer_question.html',{'form':form,'question':question}) This is the class based view also giving the same error class AnswerQuestionView(CreateView): model = Answer form_class=AnswerQuestionForm template_name = "answer_question.html" def get_context_data(self,*args,**kwargs): context = super(AnswerQuestionView,self).get_context_data(*args,**kwargs) question = get_object_or_404(Question,id=self.kwargs['pk']) context['question'] = … -
Exception inside application: __init__() takes 1 positional argument When adding ASGI_APPLICATION in Django 3.1 for channels
I am getting the following error when adding channels in Django. Exception inside application: __init__() takes 1 positional argument but 2 were given Traceback (most recent call last): File "/home/dell/Desktop/s/s/s-env/lib/python3.6/site-packages/channels/staticfiles.py", line 44, in __call__ return await self.application(scope, receive, send) File "/home/dell/Desktop/s/s/s-env/lib/python3.6/site-packages/channels/routing.py", line 71, in __call__ return await application(scope, receive, send) File "/home/dell/Desktop/s/s/s-env/lib/python3.6/site-packages/channels/routing.py", line 160, in __call__ send, File "/home/dell/Desktop/s/s/s-env/lib/python3.6/site-packages/asgiref/compatibility.py", line 33, in new_application instance = application(scope) TypeError: __init__() takes 1 positional argument but 2 were give The application works fine on WSGI configuration.The above error only appears when ASGI_APPLICATION = 'app.routing.application' is added. Since it's showing error originating from static files, I have tried generating static files again but that doesn't help. -
Django cached_db creating multiple sessions for me
If I delete all entries in the django_session DB table, and put in settings.py (using Memcached): SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db' Then if I log in, log out, then log in again, then check the number of rows in django_session I see there are 2 rows. I was not expecting that because according to the docs: If the user logs out manually, Django deletes the row. Then I removed setting the SESSION_ENGINE from settings.py, so that it's the default db session engine, then cleared all rows in django_sessions, and deleted all browser cookies. Then logged in, then out, then in again, and this time there is only one row. It seems like there is something not quite right with cached_db? The reason I am investigating this is I have set my cache to keep refreshing with: # Set to 2 months of inactivity SESSION_COOKIE_AGE = 2 * 31 * 24 * 3600 # Refresh session timeout on every request SESSION_SAVE_EVERY_REQUEST = True SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db' However often when I return the next day (without loggin out), I need to log in again. It works fine while I am using the site for a (few hours?), I stay logged in. Here are my … -
How to iterate and display a list in Django template
I am working on a Django project and I would lke to render some data in my template from a view. However the data is not getting displayed. Here is my view def ReportForm(request): user = request.user username = request.user.username result = request.session.get('result') print(result) html = render_to_string('report-form.html',{'result': result,'user':user}) response = HttpResponse(content_type='application/pdf') response['Content-Disposition'] = 'filename=\" {} report form.pdf"'.format(username) print(result) weasyprint.HTML(string=html) \ .write_pdf(response,stylesheets=[]) return response The otpu of the result printed is [{"model": "results.result", "pk": 2, "fields": {"student": 3, "DataComm": 50.0, "TradeProject": 515.0, "WebDesign": 5.0, "ObjectOrinted": 55.0, "SystemAnalysis": 21.0, "Remarks": "Passed"}}] This is the data that I wish to render on a table in the teplate Here is my template {% for res in result %} {{res.DataComm}} {% endfor %} Can someone kindly assist me on how to iterate over and render the data in the template -
Can make user.pythonanywhere.com in DjangoGirls tutorial
Ive done all the work regarding DjangoGirls but user.pythonanywhere.com does not work I cannot make a website, only localhost works right for me and Im afraid if I do something with it the website might crash eventually and the problem I guess might be in settings.py file I have done all the things step-by-step, but at some point, some codes did not work and I had no hope to continue my work and I abandoned most of my djangogirls folders and created a so-called "test_djangogirls" folder which I also abandoned because if I did something with it, computer would have crashed I did all the Django installation on venv and it worked, but there is no work for user.pythonanywhere.com, I did everything like ls, cd,dir commands for directory and everything was in directory Before I did not have problems like that I cannot understand how can I get to user.pythonanywhere.com otherwise? -
Django: What are my options in speeding up load times when having to query large datasets for users from my postgres dB to my web-server?
I have an online dashboard that loads financial data for users through visual tables and graphs. Users can input a few values which will trigger POSTS to populate data (from my postgres db), tables, and graphs. Naturally load times tend to exponentially grow the more values inputted. My dashboard uses Plotly-Dash, here are some of the recommendations that they recommend. There are several ways to improve speed using client-side callbacks using Javascript. (not an option for me right now as I don't know JS). Download necessary and repeated data during page load. Implement caching though several ways (redis, flask_caching, etc...) Reduce the amount of @callbacks Apart from my web-server, I can always optimize my postgresql requests to improve speed, but how much would that really improve speed if I'm just pulling data (using SELECT, ROUNDS, CAST, but nothing heavy on calculations. Calculating the STD for one data parameter is as far as I go) My questions are the following: Would it be better to store one large dataframe on website load, in a dictionary of dataframes rather? For reference, users need to pull around 500-10,000 rows of data (that's only because I don't want to increase the limit for now, … -
How to make a one to many relationship in Djando/Mysql?
Hi, there. Can someone help me understand how to make a one to many relationship in Django/Mysql? Here is models.py (code below) class Flora2Estado(models.Model): estado = models.OneToOneField(Estados, models.DO_NOTHING, primary_key=True) especie = models.ForeignKey('Listaflor', models.DO_NOTHING) class Meta: managed = False db_table = 'flora2estado' unique_together = (('estado', 'especie'),) class Listaflor(models.Model): especie = models.OneToOneField(Flora2Estado, models.DO_NOTHING, primary_key=True) familia = models.ForeignKey(Familia, models.DO_NOTHING, blank=True, null=True) nome = models.CharField(db_column='especie', max_length=255, blank=True, null=True) # Field renamed because of name conflict. class Meta: managed = False db_table = 'listaflor' class Estados(models.Model): estado_id = models.AutoField(primary_key=True) estado_nome = models.CharField(max_length=100, blank=True, null=True) class Meta: managed = False db_table = 'estados Thanks a lot. -
ModelChoiceField Customization (django-forms)
I have the following setup: MODELS.PY class MeatMenu(models.Model): MEAT_CHOICES = ( ('chicken', 'Chicken'), ('beef', 'Beef'), ) meat_type = models.CharField(max_length=20, choices=MEAT_CHOICES) meat_price = models.DecimalField(max_digits=10, decimal_places=2) In the same model file, I use the MeatMenu model as a fk to allow users to buy the meat they want (can calc total cost using price [hence the need for a fk as opposed to direct model choices]) class BuyMeat(models.Model): client = models.ForeignKey(User, on_delete=models.CASCADE) meat_needed = models.ForeignKey(MeatMenu, on_delete=models.SET_NULL, blank=True, null=True) date_created = models.DateTimeField(default=timezone.now) class Meta: ordering = ('-date_created',) def __str__(self): return str(self.meat_needed) FORMS.PY In my form, I'm trying to have a user execute an order for the meat they want as follows: class BuyMeatForm(forms.ModelForm): meat_needed = forms.ModelChoiceField(queryset=None, to_field_name='service_name', widget=forms.RadioSelect, empty_label=None) class Meta: model = BuyMeat fields = '__all__' exclude = ('client', 'date_created') def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['service_needed'].queryset = MeatMenu.objects.all() VIEWS.PY def buy_meat(request): if request.method == 'POST': form = BuyMeatForm(request.POST) if form.is_valid(): new_purchase = form.save(commit=False) new_purchase.client = request.user new_purchase.date_created = timezone.now() new_purchase.save() else: form = BuyMeatForm() context = {'buy_form': form} .................... PROBLEM The problem comes in customizing my "meat_needed" field in the form. As you can see in my forms.py file, I would like to customize the foreignkey dropdown-select into radio buttons whereby … -
Calculate loss and profit based on expenses in Django
I am hoping someone can guide me. Basically , I would like to, using Django, to calculate either profit or loss based on expenses. For example, if I bought animal feed for 1 k and veterinary services cost another k, and there are other expenses within a month. After selling milk produce, I’d like to take the total amount received and deduct the expenses and return the margin. -
I cant solve this problem with python/django/oracle stored procedures
im working on a project with python, django and oracle db (with stored procedure as a requirement). Im new working with python and im trying to solve this problem, can you see what is the problem? this is the pythons function: The oracle PL/SQL stored procedure: And the "subtarea" table Can you please help me? -
Problems trying to get data
I am developing an application that sends data and represents it in a graph, the problem is that when I print the data it does it the way I want it, but when returning the data it only sends the first one, not the rest. This is my view. class DeveloperDatailView(DetailView): template_name = 'dates/dates.html' model = Developer def activities_porcentage(self): projects = Project.objects.filter(developer=self.kwargs['pk']) for project in projects: tasks = Task.objects.filter(project=project).filter(state=True) for task in tasks: activities = Activities.objects.filter(task=task).count() complete = Activities.objects.filter(task=task).filter(process=False).count() data = int((complete * 100) / activities) return data def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['projects'] = Project.objects.filter( developer=self.kwargs['pk']) context['quantity'] = Project.objects.filter( developer=self.kwargs['pk']).count() context['activities'] = self.activities_porcentage() return context -
static file serving with django/react/heroku
I have a small React/Django app deployed to Heroku, and I'm struggling to understand how static files are served. I've gotten as far as getting Django to serve the React entry point, but none of the images are showing up. The images are located in project-root/public/static, so that they will be copied to project-root/build/static when the project is built. (npm run build) For example https://ytterblog.herokuapp.com/build/static/photosquat-cropped.jpg returns a 404, despite the fact that the file is located in project-root/build/static/photosquat-cropped.jpg which becomes /app/build/static/photosquat-cropped.jpg when deployed to Heroku. I think I'm not configuring static file serving properly. I also don't really know what whitenoise is. Any help? Here's my settings.py file: """ Django settings for ytterblog_server project. Generated by 'django-admin startproject' using Django 3.1.3. For more information on this file, see https://docs.djangoproject.com/en/3.1/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.1/ref/settings/ """ from pathlib import Path import django_heroku import os # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'rn!n3atk9adpep08=e%xge16x@7e0s_%fvpx@e=hwxa2@lf8hk' # SECURITY WARNING: don't run with debug turned on in production! DEBUG … -
vue slider help pls click img datatbase
when the image is clicked, the images need to be changed I cannot retrieve images from the database in script I have a django backend part I can’t from the databases I can’t use this in vue function <script> export default { name: 'Single', props:['id','img1'], data() { return { mds: {}, } }, created() { this.loadShop() }, methods: { async loadShop() { this.mds = await fetch( `${this.$store.getters.getServerUrl}/mds/${this.id}` ).then(response => response.json()) console.log(this.mds) console.log(this.id) }, } } </script> my html I want to make a slider on and click like in a photo but not a magician <div class="col-md-12" style=""> <img :src="'http://127.0.0.1:8000'+mds.img1" class="img-responsive" /> </div> <div class="col-md-12" style="margin-top:10px;"> <div class="col-md-2"> <img :src="count" class="img-slider" @click="slid()"/> </div> <div class="col-md-2"> <img :src="'http://127.0.0.1:8000'+mds.img2" class="img-slider" @click="slid()"/> </div> <div class="col-md-2"> <img :src="'http://127.0.0.1:8000'+mds.img3" class="img-slider" @click="slid()"/> </div> <div class="col-md-2"> <img :src="'http://127.0.0.1:8000'+mds.img4" class="img-slider" @click="slid()"/> </div> <div class="col-md-2"> <img :src="'http://127.0.0.1:8000'+mds.img5" class="img-slider" @click="slid()"/> </div> <div class="col-md-2"> <img :src="'http://127.0.0.1:8000'+mds.img6" class="img-slider" @click="slid()"/> </div> </div> I want to make a slider on and click like in a photo, but I can't I want to make a slider on and click like in a photo, but I can't I want to make a slider on and click like in a photo, but I can't I want to … -
Django Whitnoise/Heroku:whitenoise.storage.MissingFileError
I have ran into thise problem that is preventing me from using heroku and whitenoise. I have checked the doc of Whitnoise, they mentioned this: WHITENOISE_MANIFEST_STRICT Default True Set to False to prevent Django throwing an error if you reference a static file which doesn’t exist. This works by setting the manifest_strict option on the underlying Django storage instance, as described in the Django documentation: If a file isn’t found in the staticfiles.json manifest at runtime, a ValueError is raised. This behavior can be disabled by subclassing ManifestStaticFilesStorage and setting the manifest_strict attribute to False – nonexistent paths will remain unchanged. Note, this setting is only effective if the WhiteNoise storage backend is being used. I have already set manifest_strict to false WHITENOISE_MANIFEST_STRICT=False But where in the setting file should I put it , and how to I subclass ManifestStaticFilesStorage? I am very thankful for any help, wish you all a good day. -
how send aes encrypted document as a response in django
I am making a web app using Django I want to send some encrypted file to the user when he tries to click on the button. I am using return FileResponse(open("media/book/a_enc.pdf" , 'rb')) but it is giving me an internal server error. how can I send an encrypted file to a user in django