Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Field Error When Using choices in a Django Model field
After adding one of the model fields to select an option from a list, I get a field error. What could possibly be the cause and the solution to this ERROR: File "/home/chrisdev/code/work/cw-full/lib/python3.8/site-packages/django/db/models/sql/query.py", line 1481, in names_to_path raise FieldError("Cannot resolve keyword '%s' into field. " django.core.exceptions.FieldError: Cannot resolve keyword 'status' into field. Choices are: description, id, image, name, slug MODEL: from django.db import models from django.contrib.auth.models import User # News Model class News(models.Model): DRAFT = 'DRT' PUBLISHED = 'PUB' article_publication_choices = [ (DRAFT, 'Draft'), (PUBLISHED, 'Published'), ] title = models.CharField('News Title', max_length=200, unique=True, help_text='News Heading') slug = models.SlugField(max_length=200, unique=True) author = models.ForeignKey(User, on_delete= models.SET_NULL, related_name='news', null=True) updated_on = models.DateTimeField(auto_now= True) news_summary = models.CharField('News Summary', max_length=200) content = models.TextField('News Content') created_on = models.DateTimeField(auto_now_add=True) article_publication = models.CharField(max_length=2, choices=article_publication_choices, default=PUBLISHED, ) class Meta: verbose_name = 'News Updates' verbose_name_plural = verbose_name ordering = ['-created_on'] def __str__(self): return self.title -
Performance issue in downloading Static files and assets in django
I have published an app based on Django & react and I'm serving static files from the same server whitenoise take care of that's in my localhost 127.0.0.1:8000 everything work as expected nothing to improve In a production server, I have a lot of loading for images and other static files. I have a mistake or something I missing to implement it? or I need to move all static files to another web server like amazon? I do not know if this question is based on opinions or not, but I really do confusing -
Systemd service file for running django app using docker
I have a Django application running using the docker containers on my local system. I want to start the application on system reboot. So, I decided to write a systemd service file. [Unit] Description=docker_container service [Service] WorkingDirectory=/home/sree/Documents/code/solutions_new/solutions/ ExecStart=/usr/bin/docker /usr/bin/docker-compose -f docker-compose_dev.yml up Restart=always RestartSec=60 [Install] WantedBy=multi.user.target On my system, I usually run the Django app in a virtual environment.Am getting the below error when trying to start the service file docker_container.service - docker_container service Loaded: loaded (/etc/systemd/system/docker_container.service; enabled; vendor preset: enabled) Active: activating (auto-restart) (Result: exit-code) since Sun 2021- 01-24 09:33:49 PST; 9s ago Process: 21241 ExecStart=/usr/bin/docker /usr/bin/docker-compose -f docker-compose_dev.yml up (code=exited, status=125) Main PID: 21241 (code=exited, status=125) -
Trying to make an availability table with multiple inputs in a column
I want to create a table where users register their available hours, but when I click on two or more boxes in the same column the data is overwritten by the latest time. I want to store the values in the database as a list of strings. Is my approach totally wrong? because I believe this is the best and easiest way to do what I want to do. views.py def availability(request): start = datetime(year=1, month=1, day=1, hour=8, minute=00, second=00) time_slots = [] for x in range (0, 29): time_slots.append(str(start.strftime('%-I:%M %p'))) start += timedelta(minutes = 30) x += 1 if request.method == 'POST': sunday = request.POST['sunday'+str(x)] monday = request.POST['monday'] tuesday = request.POST['tuesday'] wednesday = request.POST['wednesday'] thursday = request.POST['thursday'] friday = request.POST['friday'] saturday = request.POST['saturday'] context = { 'if_tutor': UsersUpdated.objects.get(user_id=request.user.pk), 'time_slots': time_slots, } return render(request, 'user/tutor_availability.html', context) HTML {% extends "user/base.html" %} {% csrf_token %} {% block title %}Dashboard{% endblock %} {% block content %} <div class="content"> <div class="inner_content"> <h2 class="title">Availability</h2> <div class="top_line"></div> <form method="POST"> {% csrf_token %} <table> <tr> <th></th> <th>Sunday</th> <th>Monday</th> <th>Tuesday</th> <th>Wednesday</th> <th>Thursday</th> <th>Friday</th> <th>Saturday</th> </tr> {% for time_slot in time_slots %} <tr> <td>{{ time_slot }}</td> <td><input type="checkbox" value="{{ time_slot }}" name="sunday"></td> <td><input type="checkbox" value="{{ time_slot }}" name="monday"></td> … -
Django and React authentications system
I am intermediate Django web developer. I am trying my hands on working with both Django and react at the same time. It's all good if you are using the rest framework, but I am stuck with the authentication system. I love Django built-in UserCreationForm but the solutions(JWT) I find don't seem to utilize Django forms. I tried Django Djoser and Knox; my problem Djoser throw parse error when the password is complex, i.e. include symbols, and both don't utilize Django forms. Note: It's okay if your solution does utilize Django forms, but it's better if it does. I should be able to login to Django admin panel too. I should be able to upload images(profile pic) while registering user. And that's it any help is really appreciated and also English is not my first language, so forgive me if I made any mistake. Thanks -
How to properly do monkey Patching on Django 3.1
i'm currently coding a web application with django 3.0 and trying to override some functions of an installed django apps (Python social auth module). I want to do it because i want to change the default behavior. I have found some method to perform overriding of a module (monkey patching) and try to implement it but i the following errors when i try to implement it : File "/Users/***********/code/recrutlocataire/recrutlocataire/core/__init__.py", line 1, in <module> import core.monkey File "/Users/***********/code/recrutlocataire/recrutlocataire/core/monkey.py", line 6, in <module> from django.contrib.sessions.models import Session File "/usr/local/lib/python3.8/site-packages/django/contrib/sessions/models.py", line 1, in <module> from django.contrib.sessions.base_session import ( File "/usr/local/lib/python3.8/site-packages/django/contrib/sessions/base_session.py", line 26, in <module> class AbstractBaseSession(models.Model): File "/usr/local/lib/python3.8/site-packages/django/db/models/base.py", line 107, in __new__ app_config = apps.get_containing_app_config(module) File "/usr/local/lib/python3.8/site-packages/django/apps/registry.py", line 252, in get_containing_app_config self.check_apps_ready() File "/usr/local/lib/python3.8/site-packages/django/apps/registry.py", line 135, in check_apps_ready raise AppRegistryNotReady("Apps aren't loaded yet.") django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. Create my patch in the monkey.py file in my application directory: core/monkey.py from social_core import utils from social_core.exceptions import InvalidEmail from django.core import signing from django.core.signing import BadSignature from django.contrib.sessions.models import Session from django.conf import settings def partial_pipeline_data(backend, user=None, *args, **kwargs): pass Import the monkey file in the init file located in my application directory : core/init.py import core.monkey It seems that I have this … -
HTML video Tag range not working propery in Django
Am creating a small website, where Django returns a movie and the video Tags handles and play the movie. The video Tag plays the movie but the video tag range or slider doesn't work. When i try to move it, it immediately goes back to 0 and the movie restarts. I don't want that, all i want is to move the range and the movie skips according to the range or slider values. I tried this before in Flask it worked fine, but with Django it isn't. Here is are my models class Movies(models.Model): genre = models.ForeignKey(Genres, on_delete=models.CASCADE, null=True, related_name="movie_genre") name = models.CharField(max_length=200) movie_image = models.ImageField(upload_to="movie_images", blank=True) movie_path = models.FileField(upload_to="movie_path", blank=True) description = models.TextField(null=True) author = models.CharField(max_length=200) date_released = models.DateTimeField(default=timezone.now) likes = models.ManyToManyField(User, related_name="movie_like", blank=True) favorites = models.ManyToManyField(User, related_name="movie_favorites", blank=True) def __str__(self): return f"Movies('{self.genre.name}, {self.name}','{self.author}', '{self.date_released}')" def total_likes(self): return self.likes.count() def total_favorites(self): return self.favorites.count() def get_absolute_url(self): return reverse('home') Here are my views @login_required def show_movie_data(request, id): movie = get_object_or_404(Movies, id=id) if movie: stuff = get_object_or_404(Movies, id=id) total_likes = stuff.total_likes() liked = False is_favorite = False if stuff.favorites.filter(id=request.user.id).exists(): is_favorite = True if stuff.likes.filter(id=request.user.id).exists(): liked = True context = { 'movie':movie, 'total_likes':total_likes, 'liked': liked, 'is_favorite': is_favorite, } return render(request, 'main/show_movie_data.html', context) else: … -
Django client get: TypeError: __init__() takes 1 positional argument but 2 were given
I have following easy test: class DeviceListTests(APITestCase): def test_devices_list(self): self.user = UserFactory() self.device = DeviceFactory(name="SoundTalks_device") self.client.force_login(self.user) response = self.client.get( reverse("device-list") ) Python/Django is returning an error on: response = self.client.get( reverse("device-list") ) However this is an easy request, I get following error: Traceback (most recent call last): File "/opt/project/integrator_api/devices/tests/test_get_devices.py", line 15, in test_devices_list reverse("device-list") File "/usr/local/lib/python3.6/site-packages/rest_framework/test.py", line 286, in get response = super().get(path, data=data, **extra) File "/usr/local/lib/python3.6/site-packages/rest_framework/test.py", line 203, in get return self.generic('GET', path, **r) File "/usr/local/lib/python3.6/site-packages/rest_framework/test.py", line 232, in generic method, path, data, content_type, secure, **extra) File "/usr/local/lib/python3.6/site-packages/django/test/client.py", line 422, in generic return self.request(**r) File "/usr/local/lib/python3.6/site-packages/rest_framework/test.py", line 283, in request return super().request(**kwargs) File "/usr/local/lib/python3.6/site-packages/rest_framework/test.py", line 235, in request request = super().request(**kwargs) File "/usr/local/lib/python3.6/site-packages/django/test/client.py", line 503, in request raise exc_value File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) TypeError: __init__() takes 1 positional argument but 2 were given app_1 | app_1 | Aborting on container exit... Stopping integrator-api_app_1 ... Stopping integrator-api_app_1 ... done Process finished with exit code 1 devices/urls.py from django.conf.urls import url from rest_framework.urlpatterns import format_suffix_patterns from integrator_api.devices.views.device_list_view import DeviceListView urlpatterns = format_suffix_patterns( [ url(r"^$", DeviceListView, … -
'QuerySet' object has no attribute 'view_count'
Meanwhile using "view count" in my ecommerce project showing this error ('QuerySet' object has no attribute 'view_count') views.py class ProductDetailView(TemplateView): template_name = 'product-detail-view.html' def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) slug_url = self.kwargs['slug'] product = Product.objects.filter(slug=slug_url) product.view_count += 1 product.save() context["products"] = product return context models.py class Product(models.Model): title = models.CharField(max_length=200) slug = models.SlugField(unique=True) category = models.ForeignKey(Category, on_delete=models.CASCADE) image = models.ImageField(upload_to='products_img') wholesale_rate = models.PositiveIntegerField() amazon_rate = models.PositiveIntegerField() description = models.TextField() warranty = models.CharField(max_length=200, null=True, blank=True) return_policy = models.CharField(max_length=200, null=True, blank=True) view_count = models.PositiveIntegerField(default=0) -
Django ModelAdmin get_form 'NoneType' object is not callable
I am trying to add a new field to ModelAdmin, but get an error: @admin.register(FilmWork) class FilmworkAdmin(admin.ModelAdmin): fields = ('title', 'plot', 'ratings', 'film_creation_date', 'age_limit', 'link') def get_form(self, request, obj=None, **kwargs): form_factory = super(FilmworkAdmin, self).get_form(request, obj, **kwargs) form_factory.base_fields['Actors'] = forms.CharField(widget=forms.Textarea(), required=False) The error says: form = ModelForm(initial=initial) TypeError: 'NoneType' object is not callable I do not initialise any modelform anywhere. What am I doing wrong? -
django drf testing social oauth2 with google
I'm trying to test drf-social-oauth2's integration with Google via python manage.py test with the following test class: class DRFSocialOAuthIntegrationTest(TestCase): def setUp(self): self.test_user = UserModel.objects.create_user("test_user", "test@user.com", TEST_USER_PASSWORD) self.application = Application( name="Test Application", redirect_uris="", user=self.test_user, client_type=Application.CLIENT_CONFIDENTIAL, authorization_grant_type=Application.GRANT_PASSWORD, # https://github.com/jazzband/django-oauth-toolkit/blob/master/oauth2_provider/models.py ) self.application.save() # Every test needs a client. self.client = Client() def tearDown(self): self.application.delete() self.test_user.delete() def test_drf_social_oauth2_integration(self): '''Following testing steps found at curl -X POST -d "grant_type=convert_token&client_id=<django-oauth-generated-client_id>&client_secret=<django-oauth-generated-client_secret>&backend=google-oauth2&token=<google_token>" http://localhost:8000/auth/convert-token''' def convert_google_token(self): ''' Convert Google token to our access token curl -X POST -d "grant_type=convert_token&client_id=<client_id>&client_secret=<client_secret>&backend=google-oauth2&token=<google_token>" http://localhost:8000/auth/convert-token ''' return self.client.post( '/auth/convert-token', { 'grant_type': 'convert_token', 'client_id': self.application.client_id, 'client_secret': self.application.client_secret, 'backend': 'google-oauth2', 'token': <google_token> } ) That seems to work fine, but I have to keep feeding it the google_token by manually navigating to https://developers.google.com/oauthplayground/?code=<my_code>&scope=email+profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+openid&authuser=0&prompt=consent#: Once there, I click on the 'Exchange authorization code for tokens' button, get the access token, and paste that access token into the tokenparameter of the request inside convert_google_token(). This doesn't feel very automated. I'm not sure if I should just click the checkbox so that the access token is refreshed automatically and therefore never have to edit it in convert_google_token(). Or maybe I'm supposed to get that access token programmatically. But I believe that would entail getting the authorization code first, which … -
How to use async function based views in DRF?
Since Django now supports async views, I'm trying to change my code base which contains a lot of function based views to be async but for some reason its not working. @api_view(["GET"]) async def test_async_view(request): ... data = await get_data() return Response(data) When I send a request to this endpoint, I get an error saying: AssertionError: Expected a Response, HttpResponse or HttpStreamingResponse to be returned from the view, but received a <class 'coroutine'> Does DRF not support async views yet? Is there an alternative I can do to get this working? -
How to solve this error of django project?
Using the URLconf defined in personal_portfolio.urls, Django tried these URL patterns, in this order: admin/ ^media/(?P.*)$ The empty path didn't match any of these. from django.contrib import admin from django.urls import path from django.conf.urls.static import static from django.conf import settings urlpatterns = [ path('admin/', admin.site.urls), ] urlpatterns += static(settings.MEDIA_URL , document_root=settings.MEDIA_ROOT) -
'core' is not a registered namespace Django
It is the first time i get this error while trying to create a slug. Can't seem to find out why and there's no other answer in here. Here is the models.py: from django.db import models from django.conf import settings from django.shortcuts import reverse class Item(models.Model): title = models.CharField(max_length=100) price = models.FloatField() category = models.CharField(choices=CATEGORY_CHOICES, max_length=2, default="Sport") slug = models.SlugField(default="") def __str__(self): return self.title def get_absolute_url(self): return reverse("core:productpage", kwargs={ 'slug': self.slug }) Here is the views.py: from django.shortcuts import render from django.contrib import admin from .models import * from django.views.generic import ListView, DetailView def index(request): context = {'items': Item.objects.all()} return render(request, 'ecommerceapp/index.html', context) #returns the index.html template def shop(request): context = {'items': Item.objects.all()} return render(request, 'ecommerceapp/shop.html', context) def about(request): return render(request, 'ecommerceapp/about.html') def blog(request): return render(request, 'ecommerceapp/blog.html') def contact(request): return render(request, 'ecommerceapp/contact.html') def productpage(request): return render(request, 'ecommerceapp/product-single.html') -
Django ability to build management systems
Good day! I would like to ask if Django is suitable to build full systems like "Library management systems", "Booking systems", "client management system", etc. is it going to be sufficient to build such systems with Django or PHP would be a more suitable choice? and what would be the differences between the two choices with regard to such systems? -
How to link page from one app to another app
I'm new to django and I'm building a project "myblog" which has "blog" app in which I have created a base.html file which contain nav bar list of About and contact.I also created a "sendemail" app in same "myblog" project and I placed "email.html" contact file in templates directory of "sendemail" app, then what should be the href link in base.html file of "blog" app to access email.html file in "sendemail" app. This is base.html file in blog app of templates directory. {% load static %} <!DOCTYPE html> <html> <head> <title>Stand For Christ</title> <link rel="stylesheet" href="{% static 'css/base.css' %}"> <link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet"> <meta name="google" content="notranslate" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous" /> </head> <body> <style> body { font-family: "Roboto", sans-serif; font-size: 17px; background-color: #fdfdfd; } .shadow{ box-shadow: 0 4px 2px -2px rgba(0,0,0,0.1); } .btn-danger { color: #fff; background-color: #1d2671; border-color: #1d2671; } .masthead { background: #1d2671; height: auto; padding-bottom: 15px; box-shadow: 0 16px 48px #E3E7EB; padding-top: 10px; } </style> <!-- Navigation --> <nav class="navbar navbar-expand-lg navbar-light bg-light shadow" id="mainNav"> <div class="container-fluid"> <a class="navbar-brand" href="{% url 'home' %}" style="color:#1d2671;font-size:25px" >Stand For Christ Ministries</a> <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation" > <span class="navbar-toggler-icon"></span> … -
change_view() missing 1 required positional argument: 'object_id'
I am new in Django Framework and currently working on first project. I made a simple contact form it takes data from users and save it into database. Everything is working right. But when I login into my admin panel and go into the Contacts and click on the data that I received. I am getting error "change_view() missing 1 required positional argument: 'object_id'". my admin.py from home.views import contact from django.contrib import admin from home.models import Contact # Register your models here. admin.site.register(Contact) my models.py from django.db import models # Create your models here. class Contact(models.Model): name = models.CharField(max_length=30) email = models.EmailField() phone = models.CharField(max_length=10) desc = models.TextField() my views.py from home.models import Contact from django.shortcuts import render, HttpResponse from home.models import models # Create your views here. def home(request): # return HttpResponse("This is My Homepage") context = {"Name": "Harry", "Course" : "Django"} return render(request, 'home.html') def about(request): # return HttpResponse("This is My About page") return render(request, 'about.html') def projects(request): # return HttpResponse("This is My Projects") return render(request, 'projects.html') def contact(request): if request.method=='POST': print('This is POST') name = request.POST['name'] email = request.POST['email'] phone = request.POST['phone'] desc = request.POST['desc'] # print(name, email, phone, desc) contact = Contact(name=name, email=email, phone=phone, desc=desc) … -
Django: redirect is still available even after deleting it
django newbie here. I applied redirect locally from /aboutt page to an /about page as a test example. I did it via /admin interface after adding all the required things into settings.py as listed here. Redirect worked, but after deleting it from /admin interface it's still available. I've also deleted the redirect using Python API via shell, but for some reason it's still redirecting. What could be the cause? Any ideas? -
Django - Reverse for 'saleitems' with arguments '('',)' not found. 1 pattern(s) tried: ['(?P<pk>[0-9]+)/$']
I know this question asked already many time but really i cant get any answer for this. Project is about saving invoice application where try to save SellInvoice and reverse SellItems path for adding items to invoice but not success: view.py class SellView(generic.View): template_name = "webapp/sellinovice.html" def post(self, request): try: data ={ 'type': "fa", 'totalprice':0, 'date': request.POST.get("factor_date"), } except: pass else: sellinovice = Sellinvoice(**data) sellinovice.save() return HttpResponseRedirect( reverse('webapp:sellitems' , args=(sellinovice.id ,)) ) models.py class Sellinvoice(models.Model): id = models.BigAutoField(db_column='Id', primary_key=True) # Field name made lowercase. type = models.TextField(db_column='Type', blank=True, null=True) # Field name made lowercase. totalprice = models.DecimalField(db_column='TotalPrice', max_digits=18, decimal_places=2) # Field name made lowercase. date = models.DateTimeField(db_column='Date') # Field name made lowercase. class Meta: managed = False db_table = 'SellInvoice' urls.py path('sellinvoice', views.SellView.as_view(), name='sellinvoice'), path('<int:pk>/', views.SellItemsView.as_view(), name='sellitems'), in html When i pass argument sellinovice.id like: <a class="nav-link active" href="{% url 'webapp:sellitems' sellinovice.id %}"> foo </a> faced this erorr: Reverse for 'sellitems' with arguments '('',)' not found. 1 pattern(s) tried: ['(?P[0-9]+)/$'] and if use sellinvoice primary key (for example 1967) as argument like : <a class="nav-link active" href="{% url 'webapp:sellitems' 1967 %}"> foo </a> it reversed to 'webapp:sellitems' and working perfect. What is wrong here? i was checking many question look … -
Blueprints in Flask vs Apps in Django
I am new to Flask and noticed something called Blueprint in Flask. I searched it and now I am using it in my Flask project. I had already worked in Django and I guess Blueprints are the Flask's equivalent of Apps in Django. Is my thinking and approach right? -
Why i get this error TemplateSyntaxError at / Invalid block tag on line 15: 'provider_login_js'. Did you forget to register or load this tag?
I want to connect login system with Facebook and Google . But i face this error my code is: {% load socialaccount %} {% providers_media_js %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <div class="container" style="margin-top: 20px"> <button><a href="#">Google Login</a></button> <button><a href="{% provider_login_js "facbook" method="oauth2" %}">Facebook Login</a> </button> </div> </body> </html> -
I am working on django.The first code i am running only "Hello world" printing but it is not printing.The following problem ocurring
I am working on django.The first code i am running only "Hello world" printing but it is not printing.The following problem ocurring. -
Django Select ForeignKey filed for Admin using a condition
I'm working on a project using Python(3.7) and Django(3) in which I have implemented a few models. One of them is ReportsModel which has ForeignKey field to other models. Now I want to display other models data in ReportsModel admin. Here what I have tried so far: From models.py: class ReportsModel(models.Model): cdr_report = models.ForeignKey(CurrencyDistributionModel, on_delete=models.CASCADE, null=True, default=None) cme_report = models.ForeignKey(CurrencyManagementExpenditureModel, on_delete=models.CASCADE, null=True, default=None) cps_report = models.ForeignKey(CurrencyProcessingStorageModel, on_delete=models.CASCADE, null=True, default=None) cma_report = models.ForeignKey(CurrencyManagementAssetsModel, on_delete=models.CASCADE, null=True, default=None) def __str__(self): if self.cdr_report is not None: return self.cdr_report.RequestId elif self.cme_report is not None: return self.cme_report.RequestId elif self.cps_report is not None: return self.cps_report.RequestId elif self.cma_report is not None: return self.cma_report.RequestId To display the ForeignKey field in admin I'm using the django_reverse_admin package, here how I did that: From admin.py: class ReportAdmin(ReverseModelAdmin): report = None if ReportsModel.cdr_report is not None: report = 'cdr_report' elif ReportsModel.cme_report is not None: report = 'cme_report' elif ReportsModel.cps_report is not None: report = 'cps_report' elif ReportsModel.cma_report is not None: report = 'cma_report' search_fields = ['name'] inline_reverse = [report] inline_type = 'stacked' admin.site.register(ReportsModel, ReportAdmin) now in the admin, it only works for the cdr_report, when I add a report of type cme_report, I'm getting the RequestField correctly, but the cme_report field is … -
TypeError: data.allEmployers.map is not a function
I am getting this error when i try fetching data to React Frontend using GraphQL from Django Backend Error enter image description here This is the react code to fetch in the React frontend side enter image description here -
Django Messages do not disappear
I'm facing the issue that on some browsers my Django messages do not dissapear, for example If a new post gets created the side indicates with a message that the new post has been successfully created. If I reload the page the message doesn't disappear and keep showing up, why that? The issue goes so far that messages are stacking after using the side for a while you only see messages xD ... Can smb help with this? Is this just because of the browser that being used? This is how I display my messages: <div class="messages"> {% if messages %} {% for message in messages %} <span><li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li></span> {% endfor %} {% endif %} </div> Thanks in advance