Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to use Django db.sqlite3 database with React?
I want to use Django as backed with react and I have already integrated Django with react app. And my react app(blog in my case) is up and running with Django. I have made following changes to do so. Dir for templates inside settings.py: Dir for Static Files inside settings.py: In urls.py rendered template without using views.py: But now I want to use the Django's db.sqlite3 as my database for react app. Please tell me how to configure it ? What additional settings I need to configure to fetch data from db.sqlite3 database inside react app ? If more information about the settings are required then tell me I will edit my question accordingly. -
NoReverseMatch at /add_post Reverse for 'article-details' with arguments '('4', '0')' not found. 1 pattern(s) tried: ['blogpost/(?P<pk>[^/]+)$']
Getting this issue in my django blog project. Everything is specified neatly but I don't understand why it is crashing. urls.py : from django.urls import path from .views import Homeview, ArticleDetailView, AddPostView urlpatterns = [ path('', Homeview.as_view() , name="home"), path('blogpost/<str:pk>', ArticleDetailView.as_view(), name='article-details'), path('add_post', AddPostView.as_view( ), name="add_posts") ] models.py from django.db import models from django.contrib.auth.models import User from django.urls import reverse ''' class Post(models.Model): blog_title = models.CharField(max_length=200) author = models.ForeignKey(User, on_delete=models.CASCADE) body = models.TextField(default="") def __str__(self): return self.blog_title + '|' + str(self.author) def get_absolute_url(self): return reverse('article-details', args = str(self.id)) articledetails.html* {% extends 'home/base.html' %} {% block content %} <h1>{{post.blog_title}}</h1> </br> {{post.body}} {% endblock %} -
Error in Models raise TypeError('on_delete must be callable.')
when i run following command python manage.py makemigrations I have this error enter code here File "C:\Users\pc\Desktop\django\Chocolate\shop\migrations\0002_product.py", line 21, in Migration ('p_cat', models.ForeignKey(blank=True, null=True, on_delete='models.CASECADE', to='shop.category')), File "C:\Users\pc\Envs\test\lib\site-packages\django\db\models\fields\related.py", line 813, in __init__ raise TypeError('on_delete must be callable.') TypeError: on_delete must be callable``` [1]: https://i.stack.imgur.com/ujUkQ.png -
Why is my API data nt showing up on my django html page?
I am fairly new to coding in general so apologies for my dumb question. I created an API in Node. I put some filler data in the DB and tested the API. Works fine. I created a Django app that attempts to access the data in the API. I am using a CORS module so I can access the API on my local machine. When I load the home page, a GET request is sent to the API, and I can see that the API receives the request. I don't know if any data is being sent back. Nothing shows up in the table on the home page. -API routes- (all routes are starting with /questions) router.get('/', queryQuestions); router.post('/', addQuestion); router.delete('/:uid', deleteQuestion); router.get('/:uid', queryQuestion); router.patch('/:uid', updateQuestion); -Django view- from django.shortcuts import render from django.shortcuts import redirect from django.contrib import messages def home(request): import json import requests api_request = requests.get("http://localhost:3000/questions") try: api = json.loads(api_request.content) except Exception as e: api = "Error..." return render(request, 'frontend/home.html', {'api': api}) Django template 'home' (sample) <table class="table table-striped table-bordered table-hover"> <thead class="thead-dark"> <tr> <th scope="col">ID</th> <th scope="col">Question</th> <th scope="col">Category</th> </tr> </thead> <tbody> {% if api %} {% for list_item in api %} <tr> <td>{{ list_item.uid }}</td> … -
Send mail different email id's when user click Button in Django?
I make real-estate system project, i am try to when user see property and they interested so click "interested" Button then send email to seller register email id and message is " someone(interested email id) is interested in your property id. How to do this if you know so plz know me -
I am trying to convert a python project into exe file however I am getting an 'unexpected EOF while parsing' error
I am using Auto-py-to-exe to convert the python project to an executable file. I am trying to export a Django project to production. I need help to convert the project into exe for commercial use. I am currently stuck. I keep getting this error whenever I try to convert the project using Auto-py-to-exe. Here is the full error An error occurred while packaging Traceback (most recent call last): File "d:\anaconda\envs\deepface\lib\site-packages\auto_py_to_exe\packaging.py", line 131, in package run_pyinstaller() File "d:\anaconda\envs\deepface\lib\site-packages\PyInstaller\__main__.py", line 114, in run run_build(pyi_config, spec_file, **vars(args)) File "d:\anaconda\envs\deepface\lib\site-packages\PyInstaller\__main__.py", line 65, in run_build PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) File "d:\anaconda\envs\deepface\lib\site-packages\PyInstaller\building\build_main.py", line 720, in main build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build')) File "d:\anaconda\envs\deepface\lib\site-packages\PyInstaller\building\build_main.py", line 667, in build exec(code, spec_namespace) File "C:\Users\ASUSVI~1\AppData\Local\Temp\tmpk_w1xzg6\mask_detection.spec", line 17, in <module> noarchive=False) File "d:\anaconda\envs\deepface\lib\site-packages\PyInstaller\building\build_main.py", line 242, in __init__ self.__postinit__() File "d:\anaconda\envs\deepface\lib\site-packages\PyInstaller\building\datastruct.py", line 160, in __postinit__ self.assemble() File "d:\anaconda\envs\deepface\lib\site-packages\PyInstaller\building\build_main.py", line 419, in assemble self.graph.process_post_graph_hooks() File "d:\anaconda\envs\deepface\lib\site-packages\PyInstaller\depend\analysis.py", line 365, in process_post_graph_hooks module_hook.post_graph() File "d:\anaconda\envs\deepface\lib\site-packages\PyInstaller\depend\imphook.py", line 440, in post_graph self._load_hook_module() File "d:\anaconda\envs\deepface\lib\site-packages\PyInstaller\depend\imphook.py", line 407, in _load_hook_module self.hook_module_name, self.hook_filename) File "d:\anaconda\envs\deepface\lib\site-packages\PyInstaller\compat.py", line 588, in importlib_load_source return mod_loader.load_module() File "<frozen importlib._bootstrap_external>", line 399, in _check_name_wrapper File "<frozen importlib._bootstrap_external>", line 823, in load_module File "<frozen importlib._bootstrap_external>", line 682, in load_module File "<frozen importlib._bootstrap>", line 265, in _load_module_shim File "<frozen importlib._bootstrap>", … -
how to start celery periodic task at 9:30 to 12:30 every 30 seconds?
I want to run a celery task in Django from 09:30 to 12:30 for every 30 seconds. Is it possible to turn the interval on for 30 seconds and turn on the interval schedule only for a certain period of the day? -
Django Project and .net project with same database (Postgresql)
I have two project which is Django Project and .net Project with the same database (Postgres). what is the recommended way for them not to have a conflict? because there is a problem when I call a certain field of a table using foreignkey just like this in my views.py reports = TrEmployeeSuppliersFeedbackQuestionsSubmittedRecords.objects.filter( fmCustomerID__company_name__in=company.values_list('fmCustomerID__company_name')).order_by('-inputdate') for report in reports: writer.writerow([ smart_str(report.fmCustomerEmployeeSupplierID.lastname), smart_str(report.fmCustomerEmployeeSupplierID.firstname), smart_str(report.fmCustomerEmployeeSupplierID.middleInitial), ]) return response this is my models.py class TrEmployeeSuppliersFeedbackQuestionsSubmittedRecords(models.Model): fmCustomerEmployeeSupplierID = models.ForeignKey('FmCustomerEmployeeSupplier', related_name='+', on_delete=models.SET_NULL, null=True, blank=True, verbose_name="CustomerEmployeeSupplier") class FmCustomerEmployeeSupplier(models.Model): dateSubmitted = models.DateField(auto_now_add=True, null=True, blank=True) lastname = models.CharField(max_length=500, blank=True, null=True) firstname = models.CharField(max_length=500, blank=True, null=True) middleInitial = models.CharField(max_length=500, blank=True, null=True) bodyTemperature = models.FloatField(blank=True, null=True) def __str__(self): suser = '{0.lastname} {0.firstname} {0.middleInitial}' return suser.format(self) @property def is_past_due(self): return date.today() > self.modifyDate class Meta: verbose_name_plural = "50. Customer's List of Employees, Suppliers and visitors" -
Django run a function while exiting a view or navigating to a different URL from the current URL
In my django application, when I visit a particular URL ex:enter_database, a view function is called that adds database entries. Now when I visit a different URL, I want to clear the database entries. My question, is it possible to call a method while leaving a view/URL. Note: I can clear the entries by adding the logic in every other view, which is not the approach I want to do. I am looking for a way to call a method while exiting the current displayed view. -
Django profile image is incorrectly displaying the logged in user's image (on every profile)
Any assistance in this would be much appreciated. Problem: Logged in user image is displaying on every user's profile in Django 3.1 I extended the Django User model with a OneToOne relationship to another model called UserProfile, which contains an ImageField called profile_pic. Settings for root media folder are setup correctly in settings.py and referred to in root urls.py. Something is incorrect with the class-based view, a generic ListView to display a user's product posts, or I'm incorrectly referring to the profile_pic in the template. Any ideas on how to display each user's profile image on their associated userprofile? Currently, when a user is logged in, his/her image is displaying on every profile. models.py class UserProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) profile_pic = models.ImageField(default='default_profile_pic.jpg', upload_to='profile_pics') class Meta: verbose_name_plural = "User Profiles" def __str__(self): return f'{self.user.username} UserProfile' def save(self, *args, **kwargs): super().save(*args, **kwargs) views.py class ProfileListView(ListView): model = Product template_name = 'users/profile.html' context_object_name = 'products' paginate_by = 12 def get_queryset(self): user = get_object_or_404(User, username=self.kwargs.get('username')) # userprofile = UserProfile.objects.filter(user_id=userprofile) return Product.objects.filter(user=user).order_by('-creation_date') profile.html {% if user.userprofile.profile_pic %} <img class="rounded-circle" src="{{ user.userprofile.profile_pic.url }}" alt=""> {% else %} <img class="rounded-circle" src="media/default_profile_pic.jpg" alt=""> {% endif %} -
Limit Foreign Key Options in Django Select
I have a model for Supplier and another model for Product. Each Product must have a Supplier instance associated to it. Later on, in a separate model form for the Proforma model, the user has to select a Supplier and then a Product. What I'd like to see happen is the Product select options filter down to Products where the Supplier = the Supplier the user has selected. I am not finding much on how to handle this use case...could anyone point me in the right direction? Will this require the use of JS or can I do something to set this in the form directly? Or maybe pass a queryset from the view to this field? Anything even some resource on this would be helpful. models.py class Supplier(models.Model): supplierName = models.CharField(max_length=100) class Product(models.Model): code = models.CharField(max_length=100) supplier = models.ForeignKey(Supplier, null=False, blank=False) class Proforma(models.Model): ... supplier = models.ForeignKey(Supplier, null=False, blank=False, on_delete=models.CASCADE) code = models.ForeignKey(Product, null=True, blank=True, on_delete=models.CASCADE) -
Uploading image into ModelForm in Django?
I am having trouble uploading an image into with a form through Django. The file does not appear in my `templates/auctions' directory, nor does it render in my template (probably because it never uploaded). In my views.py: @login_required(login_url="login") def createListing(request): if request.method == "POST": filled_form = CreateListing(request.POST, request.FILES) if filled_form.is_valid(): user = User.objects.get(username=request.user) new_listing = filled_form.save(commit=False) new_listing.listed_by = user new_listing.save() return HttpResponseRedirect(reverse("index")) else: context = { "createlistingform": filled_form } else: context = { "createlistingform": CreateListing() } return render(request, "auctions/createlisting.html", context) I tried to replicate the approach in "Handing uploads with a file" and it's still not working. My AuctionListing model in models.py has this field: image = models.ImageField(blank=True, upload_to="images/") and my project file settings.py has this configuration: MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = '/media/' Is my commit=False in the views.py creating an issue? -
Django Chat Application using channels
I am trying to learn to setup a django chat using channels. I tried the Channels tutorial at https://channels.readthedocs.io/en/latest/index.html and got into some issues. My issue is as below. When 1st browser joins a room it works just fine. But the moment a new browser session joins the same room, the first session does not get the messages and 2 messages are sent to the latest browser session. If a third browser session joins the room, 1st and 2nd session don't get the messages and the third session gets all the 3 messages. I followed every step meticulously but not able to fix the issue. Can anyone guide me please. -
How to get a many to many field display in my select field form
FORM class Form_elegir_carrera(forms.Form): carrera_del_tutor= forms.ModelChoiceField(queryset=None,widget=forms.Select(attrs={'class': 'select is-normal'}),label='Tutor carrera',required=True) def __init__(self, *args, **kwargs): self.user = kwargs.pop('user', None) super(Form_elegir_carrera,self).__init__(*args, **kwargs) if self.user: self.fields["carrera_del_tutor"].queryset = Tutor.objects.filter(user_id=self.user).get().carrera else: self.fields['carrera_del_tutor'].queryset = Tutor.objects.none() def clean(self): carrera_del_tutor = self.cleaned_data.get("carrera_del_tutor") VIEWS @login_required def elegir_carrera(request, tutor_id): context = { 'tutor_id':tutor_id } if request.method == 'POST': form = Form_elegir_carrera(data=request.POST or None) if form.is_valid(): descripcion = form.cleaned_data.get('carrera_del_tutor', None) context = { 'form': form,'tutor_id':tutor_id } return HttpResponseRedirect(request.META.get('HTTP_REFERER')) else: context = { 'form': form, 'tutor_id':tutor_id } return render(request, "elegir_carrera.html", context) else: form = Form_elegir_carrera(user = tutor_id) context = { 'form': form,'tutor_id':tutor_id} return render(request, "elegir_carrera.html", context) context = { 'form': form, 'tutor_id':tutor_id } return render(request, "elegir_carrera.html", context) MODEL class Tutor(models.Model): user = models.OneToOneField( User, on_delete=models.CASCADE, primary_key=True) nombre = models.CharField(max_length=50, blank=False, null=True) apellido = models.CharField(max_length=50, blank=False, null=True) carrera = models.ManyToManyField(Carrera, blank=True) class Meta: verbose_name_plural = "Tutores" verbose_name = "Tutor" def __str__(self): return '%s %s' % (self.nombre, self.apellido) #return self.user.email I want to query all carreras that the user has, and display each of them in a dropdown to be selected. Until now it displays the carreras asociated to the user, but when I make a submit, it throws an error saying that is not one of the availables. -
Why is installing python-psycopg2 on my Docker image not preventing the subsequent "No module named 'psycopg2'" error?
I'm using docker-compose v 1.27.4 on Mac. I have this docker-compose.yml file -- two services, a PostGres DB and a Python/Django app ... services: postgres: image: postgres:10.5 ports: - 5105:5432 environment: POSTGRES_DB: directory_data POSTGRES_USER: chicommons POSTGRES_PASSWORD: password web: restart: always build: ./web ports: # to access the container from outside - "8000:8000" env_file: .env environment: DEBUG: 'true' command: /usr/local/bin/gunicorn directory.wsgi:application --reload -w 2 -b :8000 volumes: - ./web/:/app depends_on: - postgres This is the Dockerfile used to build the Python/Django container ... FROM python:3.8-slim RUN apt-get update && apt-get install RUN apt-get install -y dos2unix RUN apt-get install -y libpq-dev python-dev RUN apt-get install -y python-psycopg2 RUN apt-get install -y libmariadb-dev-compat libmariadb-dev RUN apt-get update \ && apt-get install -y --no-install-recommends gcc \ && rm -rf /var/lib/apt/lists/* RUN python -m pip install --upgrade pip WORKDIR /my-app/ COPY requirements.txt requirements.txt COPY entrypoint.sh entrypoint.sh RUN python -m pip install -r requirements.txt RUN dos2unix /my-app/entrypoint.sh ENTRYPOINT ["bash", "/my-app/entrypoint.sh"] However, when I start my application using "docker-compose up," I get the below errors web_1 | Traceback (most recent call last): web_1 | File "/usr/local/lib/python3.8/site-packages/django/db/backends/postgresql/base.py", line 25, in <module> web_1 | import psycopg2 as Database web_1 | ModuleNotFoundError: No module named 'psycopg2' web_1 | web_1 … -
How to set upload_handlers on a per-request basis using Django Rest Framework
I have a DRF view where I need to ensure that uploaded files land on the filesystem and not just in memory. DRF respects Django's FILE_UPLOAD_HANDLERS setting, but I don't want to change it for my whole app, just this one view. I know that in a regular Django view I could set request.upload_handlers to my desired value, but that doesn't seem to work in DRF. I've tried doing it from .initialize_request() in my viewset, like so: def initialize_request(self, request, *args, **kwargs): request.upload_handlers = ["django.core.files.uploadhandler.TemporaryFileUploadHandler"] return super().initialize_request(request, *args, **kwargs) but I'm getting: AttributeError: You cannot set the upload handlers after the upload has been processed. What is the correct way for me to set the upload handlers for a single DRF view (in particular, the create action of a generic viewset)? -
Source does not exist, Django templates
Although I set TEMPLATE_DIR and DIR in TEMPLATES in settings.py I can't receive my goal. www.rouznegasht.com Is my website. You can see the error now. the settings.py : TEMPLATE_DIRS = ( '/home2/rouznega/django-rn/staticsdir/', ) TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ '/home2/rouznega/django-rn/staticsdir/' ], 'APP_DIRS': False, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] this is my views.py : from django.shortcuts import render from django.http import HttpResponse def index(request): context={} return render(request,'index2.html',context=context) And I put my template in this folder. after that I call collectstatic in the shell. but I can't achieve the goal. The error : why the engine searchs here ? django.template.loaders.app_directories.Loader: /home2/rouznega/virtualenv/django-rn/3.7/lib/python3.7/site-packages/django/contrib/admin/templates/index2.html (Source does not exist) django.template.loaders.app_directories.Loader: /home2/rouznega/virtualenv/django-rn/3.7/lib/python3.7/site-packages/django/contrib/auth/templates/index2.html (Source does not exist) if this details helps you to help me look the end of settings.py : STATIC_URL = '/static/' STATIC_ROOT = '/home2/rouznega/public_html/assets/' STATICFILES_DIRS = [ ('/home2/rouznega/django-rn/staticsdir/') ] Thank you -
Detecting the no. of colors of an uploaded image in a Django project
I am working on a colour detection project and I am trying to link it to my Django Project, but I don't know where to start. In my Django project, I have a Post CreateView where users can upload images. Here is the function that I am trying to link the colours in the image to Post.colors but I don't know how to make it generated directly once the image is uploaded Here is the models.py: class Post(models.Model): title = models.TextField(max_length=100) design = models.ImageField( blank=False, null=True, upload_to='new designs') date_posted = models.DateTimeField(default=timezone.now) colors= models.TextField(max_length=10,blank=True, null=True) def __str__(self): return self.title def imagecolors(self, *args, **kwargs): img = Image.open(self.design) size = w, h = img.size data = img.load() colors = [] for x in range(w): for y in range(h): color = data[x, y] hex_color_lower = ''.join([hex(c)[2:].rjust(2, '0') for c in color]) hex_color = hex_color_lower.upper() colors.append(hex_color) total = w * h color_hex = [] color_count = [] color_percent = [] df = pd.DataFrame() for color, count in Counter(colors).items(): percent = count / total * \ 100 # Do not make it int. Majority of colors are < 1%, unless you want >= 1% if percent > 1: color_hex.append(color) color_count.append(count) color_percent.append(percent) Post.colors=color_hex print(Post.colors) with the above … -
Password protected link gives 404 in Django and Nginx
I want to password-protect a single page of my Django website (I don't want to use Django's authentication system, which I'm using already for other parts of my website; this is an unrelated one-off) by adding this to my nginx.conf: location /myprivatepage { auth_basic "Private page"; auth_basic_user_file /etc/nginx/.htpasswd; } And putting user and password in /etc/nginx/.htpasswd. When I point my browser to /myprivatepage the browser asks indeed for user and password. Once successfully authenticated, I get a 404 error: 404 Not Found nginx/1.14.2 If I comment the lines above I can reach the page as guest correctly. What am I doing wrong? -
Django render_to_string() got multiple values for argument 'context'
I am trying to pass the following argument to render to response syntax in Django but I keep getting the following error: render_to_string() got multiple values for argument 'context' def genarate_pdf_notes(request): response = HttpResponse(content_type='application/pdf') response['Content-Disposition'] = 'attachment; filename=filter' + \ str(datetime.datetime.now())+'.pdf' response['Content-Transfer-Encoding'] = 'binary' context = {} filtered_yp = YP_Filter( request.GET, queryset=YP_General_Information.objects.all() ) context['filtered_yp'] = filtered_yp html_string = render_to_string(request, 'filter/homepage.html', context=context) html = HTML(string=html_string) result = html.write_pdf() with tempfile.NamedTemporaryFile(delete=True) as output: output.write(result) output.flush() output.seek(0) # output = open(output.name, 'rb') they using this on a live server response.write(output.read()) return response -
Django: ConnectionResetError: [Errno 54]
This logs, quite repeatedly, every time my app loads on my computer. Exception happened during processing of request from ('127.0.0.1', 53597) Traceback (most recent call last): File "/usr/local/Cellar/python@3.8/3.8.6/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 650, in process_request_thread self.finish_request(request, client_address) File "/usr/local/Cellar/python@3.8/3.8.6/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 360, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/local/Cellar/python@3.8/3.8.6/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 720, in __init__ self.handle() File "/usr/local/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 174, in handle self.handle_one_request() File "/usr/local/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 182, in handle_one_request self.raw_requestline = self.rfile.readline(65537) File "/usr/local/Cellar/python@3.8/3.8.6/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socket.py", line 669, in readinto return self._sock.recv_into(b) ConnectionResetError: [Errno 54] Connection reset by peer I realize that this has been posted on extensively over the years, but it seems to me that the consensus on the answer is that it could be one of a few things: (a) Using a .png instead of an .ico in a favicon (b) Misusing {% static %} (c) Misusing event.preventDefault() Unfortunately for me, none of those things have happened in the last few weeks in my teams commits. So I ask, are there other solutions I may be missing? This is a result of me recently merging with a master development branch. -
start download and redirect at the same time
I have a view that hands back a file for download, but also some messages about the status - which I do not see, because of no redirect after the download started: class DownloadView(TemplateView): template_name = "TEST/listview.html" def get(self, request, *args, **kwargs): filepath = GET_FILE() if os.path.exists(filepath): with open(filepath, 'rb') as fh: response = HttpResponse(fh.read(), content_type="application/force-download") response['Content-Disposition'] = 'inline; filename=' + os.path.basename(filepath) messages.success(request, "download started ...") return response return redirect("index") except Exception as e: messages.error(request, e) return redirect("index") I do not necessarily need the redirect to index after the response, but I cannot see the messages until I reload the page - which is not nice if there was an error. How can I add a redirect after the download started? -
Expected json object in Django activity stream but show string in template
Here is settings.py configuration for the django-activity-stream. ACTSTREAM_SETTINGS = { 'MANAGER': 'actstream.managers.ActionManager', 'FETCH_RELATIONS': True, 'USE_PREFETCH': True, 'USE_JSONFIELD': True, 'GFK_FETCH_DEPTH': 1, } This is action. action.send(actor=actor, verb="Posted", target=target, data='some string') and template {% for action in stream %} <div>{{ action.data.data }}</div> {% endfor %} I expected that template will show some string, but not showing anything. If I change the tag like this {% for action in stream %} <div>{{ action.data }}</div> {% endfor %} It shows {"data": "some string"} -
Django Template Context in Flatpages
I'm using template inheritance with a base.html file that has a footer.html include: {% include 'footer.html' %} I've got context data in all pages (eg, index, DetailViews, ListViews, etc) except for the flatpages (of which there are many). All my templates inherit base.html, which includes footer.html (including my flatpages default.html). How can I get the context data (eg, from my other models) to show up in my flatpages? I suppose I can add context to a view if I could figure out how to override the Django flatpage view. The flatpage view in Django seems to only have the actual flatpage object as context. -
How to customize django admin panel
I am building an e-commerce website and I would like to customize my Django Admin Panel to look something like this: I would like to re-design the entire admin page and add graphs, tables images etc. the same way you would do on the front-end. I have been searching online for hours for a solution but I can't find anything useful. Does anyone have any solution to this problem?