Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Use Polymer3 with django
How to import basic polymer 3 components like paper-elements and iron elements in django. Polymer1 components(html pages) can be imported using materialdjango, but it does not support polymer3. see documentation:-documentation of material django -
What do I use the Serializer create method for?
I am trying to implement a simple flow where the a user POSTs a secret code to an api endpoint. By doing so the user creates a foreign key relationship with another model. I achieved the desired behaviour on the serializer by overwriting the create method like so: class RegisterUserToCustomerSerializer(serializers.Serializer): company_code = serializers.CharField(allow_blank=False) def create(self, validated_data): user = validated_data['user'] try: customer = Customer.objects.get(company_code=validated_data['company_code']) except Customer.DoesNotExist: return HttpResponse(status=404) user.related_customer = customer user.save() return customer In normal Django I would have implemented the behaviour on the forms save(commit=False) method. Since DRF does not have this function I feel stuck with the create() and update(). Two things really bug me about my solution: I have to return the customer from create method eventhough the user was edited. But since the 'company_code' variable does not exist on the user DRF will through an error if I return the user I am overwriting the create() method but I am not really creating anything. Sure, I could use update but in terms of design, this makes it even worse I fear. Everything about using the create() method feels weird about this. From accessing the user to the return statement. Do you guys see ways to avoid … -
Which field is concerned by : 'a bytes-like object is required, not ....'
I have on two django models the error a bytes-like object is required, not 'NoneType'. But I have no clue which field is concerned. Is there a general tip to identify the problematic field ? Django is great but error messages tends to be too broad. Here is the specific problem class Device(models.Model, IndexedModelMixin): class Meta: ordering = ("device_name",) device_id = models.UUIDField(primary_key=True, default=uuid.uuid4, blank=True, editable=False) device_reference = models.CharField(db_index=True, blank=True, max_length=128, unique=True) device_name = models.CharField(default="", blank=True, max_length=64) device_address = models.CharField(default="", blank=True, max_length=128) device_position = models.CharField(default="", blank=True, max_length=64) device_description = models.CharField(default="", blank=True, max_length=256) groups = models.ManyToManyField(Group, related_name="devices") then in unit-tests device = Device(device_name='toy'); device.save() # here is the bug : a bytes-like object is required, not 'NoneType' -
How do I get comment count of each blog post in ListView via Get_context_data? Filtering by self.id/self.object.id/self does not work
from django.shortcuts import render from django.views.generic.list import ListView from django.views.generic.detail import DetailView from journal.models import Post, Corrections, Comments class PostListView(ListView): model = Post def get_context_data(self, **kwargs): context = super(PostListView, self).get_context_data(**kwargs) context['comment_count'] = Comments.objects.filter(post_id=self.id).count() return context This is the offending line of code: context['comment_count'] = Comments.objects.filter(post_id=self.id).count() If I manually replace self.id with a number, then it will correctly grab the comment count of the post. Which brings me to my question: How do I get the post.id if I am in a ListView? edit: from django.urls import path from journal.views import PostListView, PostDetailView urlpatterns = [ path('', PostListView.as_view(), name='post-list'), path('<int:pk>/', PostDetailView.as_view(), name='post-detail'), ] -
Unable to execute skew correction executable from django deployed in IIS service
I have deplyed a django application in windows server IIS8.Within my django app I am running an executable using command line subprocess.popen.I am able access the executable and run the command line operation but after execution , it stops after sometime and my request stops executing further. But the same executable runs without problem when I run my application using django development server -
Django can't migrate cause type "geography" does not exist
When I trying migrate django throws this django.db.utils.ProgrammingError: type "geography" does not exist LINE 1: ...otment" ("id" bigint NOT NULL PRIMARY KEY, "geom" geography( Postgis was be created in postgresql after that first migrates were created. I can fix it without migration to the new emptry DB? My model.py example: from renter.models import * from classification_list.models import* from django.contrib.gis.db import models class ForestryKeys(models.Model): id = models.IntegerField(primary_key=True) df_forestry = models.TextField(blank=True, null=True), geom = models.PolygonField(geography=True, null=True, blank=True, verbose_name='geomet') class Meta: managed = True verbose_name = 'frst' verbose_name_plural = 'frstes' -
Django 1.11.20 get count of rows per ISO week and year
I need to get the count of items per ISO week and year. I tried the following from django.db.models.functions import ExtractWeek, ExtractYear from django.db.models.aggregates import Count count = myModel.objects.annotate(year=ExtractYear('created_at')) \ .annotate(week=ExtractWeek('created_at')) \ .values('year','week') \ .annotate(count=Count('week')) But my result is <QuerySet [{'year': 2019, 'week': 7, 'count': 1}, {'year': 2019, 'week': 7, 'count': 1}, {'year': 2019, 'week': 7, 'count': 1}, {'year': 2019, 'week': 7, 'count': 1}....... How can I get change it so my result is: Thanks in advance -
Django Heroku Debug = False, Static files cause Internal Server Error
I am currently trying to deploy a django app with Heroku. When I try to deploy with Debug=False however, I get an Internal Server Error, because the server cannot find the main.css style sheet. Note that when Debug=True everything works fine. When I try python manage.py findstatic --verbosity 2 main.css in the commandline, I get the error message "No matching file found for 'main.css'. Looking in the following locations: /Users/Kyle/.local/share/virtualenvs/hostable-Ij2AFM0k/lib/python3.6/site-packages/django/contrib/admin/static", but I have no clue why it's looking in here. Below I've provided my settings.py file. My file hierarchy is a mess, because doing collectstatic generated a whole bunch of static files into a staticfiles folder, but I don't know where they came from or what their purpose is. I have the style sheet in a static folder, but this doesn't seem to be being called anymore. What I would like to know is this: what am I supposed to change either in my settings or in my file hierarchy so that main.css is found? # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False ALLOWED_HOSTS = ['*'] # Application definition INSTALLED_APPS = [ 'crispy_forms', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'menus.apps.MenusConfig', 'events.apps.EventsConfig', 'users.apps.UsersConfig', ] MIDDLEWARE … -
Adding linebreaks to string and then rendering linebreaks
I'm attempting to build a linebreak into a string and then render that string in a template with the linebreaks. I'm saving the following string to a model field: usercart.other_tax_regnum = "State tax reg number" + "/n" + "Second State tax reg number" usercart.save() Then, within my view, I render thefield {{ usercart.other_tax_regnum|linebreaks }} Rather than showing a line break, this is what gets rendered: State tax reg number/nSecond State tax reg number Any thoughts on how I can do this? Thank you! -
Populate template with data on page load
I am trying to populate a html page with user's profile details on page load. Django document has this get_context_data() method in TemplateView, when I am using the same to display data to html page I get the following exception TemplateDoesNotExist(', '.join(template_name_list), chain=chain) django.template.exceptions.TemplateDoesNotExist: app/profile.html Here is my code: urls.py url(r'^profile/', views.ProfileDetailView.as_view(), name='profile'), views.py class ProfileDetailView(TemplateView): template_name = "appName/profile.html" def get_context_data(self, **kwargs): if 'user_name' in self.request.session: username = self.request.session['user_name'] return render_to_response('appName:profile', {'username': username}) This is how am using in the html page profile.html <input type="text" class="form-control" placeholder="User name" id="usernameDisplay" name="usernameDisplay" readonly value="{{ username }}"> Where am I going wrong? -
Python using Django Framework and Postgres Problems Connecting to Heroku Missing Modules
I am having issues with an older project written with Django, now trying to push it to Heroku with issues. This was set up years ago with the same files by someone else in well under an hour. When I did it all day today, I originally got an error when launching and when running the logs I get: bash: heroku: command not found I hired 3 guys to help me that were "well-versed" in these areas. The first person knew quite a bit but came short on pip (pip freeze) and stated that the requirements.txt file was missing the required modules and he couldn't find which ones to include. So I set up a project on a freelance site specifically for someone to help me find modules and fix what's missing. I found a high rated vet with a great reputation specifically in Py/Django/Heroku who said he could help. I shared the exact same git repo I had and within 15 minutes he fixed the problem and shared with me on his localhost. In hindsight I am wondering if he just so happened to have all the modules installed already, being a fulltime Django developer for 6 years? Once … -
Unable to pass context to the home view
I've been trying to add a like button that changes to unlike when the User clicks on it, however the button isn't changing because I am unable to pass the context to the home.html file. I know the logic i used will throw an error as the get_object_or_404() will not receive an id from the server however if I pass an argument id to the home() function it will also throw an error as the server doesn't provide an id to the page. I'm sorry for asking a question related to logic and not concepts but I haven't been able to understand which concept could i use here views.py from django.shortcuts import render,get_object_or_404 from django.views.generic import ListView from .models import Blog from django.http import HttpResponseRedirect def home(request): post=get_object_or_404(Blog,id=id) context={ 'posts':Blog.objects.all(), 'is_liked':post.likes.filter(id=request.user.id).exists() } return render(request,'blog-home',context) def like_post(request, blog_id): post = get_object_or_404(Blog, id=blog_id) is_liked=False if post.likes.filter(id=request.user.id).exists(): post.likes.remove(request.user) is_liked=False else: post.likes.add(request.user) is_liked=True context={ 'is_liked':is_liked } return HttpResponseRedirect(Blog.get_absolute_url(blog_id)) def post_detail(request, id): post=get_object_or_404(Blog, id=id) context={ 'post':post, 'is_liked': post.likes.filter(id=request.user.id).exists(), } return render(request, 'blog/post_detail.html',context) def check_liked(request): post = get_object_or_404(Blog, id=blog_id) is_liked=False if post.likes.filter(id=request.User.id).exists(): is_liked=True else: is_liked=False context={ 'is_liked':is_liked } return render(request, 'blog/post_detail.html',context) models.py from django.db import models from django.utils import timezone from django.contrib.auth.models import User from django.urls … -
'Unexpected token' on JSX for Django React Tutorial
I'm following this tutorial and cant for the life of me figure out why webpack isn't recognizing JSX? Would love someone to point out the silly thing that i'm missing :) my full code here https://github.com/dukarc/django-react-app Error: \django-react-app\leadmanager\frontend\src\components\App.js: Unexpected token (6:11) 4 | class App extends Component { 5 | render() { > 6 | return <h1>React App</h1>; | ^ 7 | } 8 | } Things I have Tried rm -rf node_modules && rm -f package-lock.json && npm install refered back to the tutorial github and double checked that i'm in sync Versions (will output more if requested ... this was just off top of my head): node: 10.15.1 npm: 6.8.0 package.json { "name": "lead_manager_react_django", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "dev": "webpack --mode development ./leadmanager/frontend/src/index.js --output ./leadmanager/frontend/static/frontend/main.js", "build": "webpack --mode production ./leadmanager/frontend/src/index.js --output ./leadmanager/frontend/static/frontend/main.js" }, "keywords": [], "author": "", "license": "ISC", "devDependencies": { "@babel/core": "^7.2.2", "@babel/preset-env": "^7.3.1", "@babel/preset-react": "^7.0.0", "babel-loader": "^8.0.5", "babel-plugin-transform-class-properties": "^6.24.1", "webpack": "^4.29.0", "webpack-cli": "^3.2.1" }, "dependencies": { "prop-types": "^15.6.2", "react": "^16.7.0", "react-dom": "^16.7.0" } } webpack.config.js module.exports = { module: { rules: [ { test: /\.(js|jsx)$/, exclude: /node_modules/, use: { loader: "babel-loader" } } ] } }; .babelrc { "presets": ["@babel/preset-env", "@babel/preset-react"], "plugins": … -
Is it possible to reset django migrations on an application deployed on heroku?
I have deployed a django application to heroku but I need to reset those migrations. Is that possible without deleting the entire project and redeploying it? I have some test data in that database that I would prefer not to have to enter all over again. -
django admin move auth models to another section
I'm using Django 2.x I have created a custom user model by extending the AbstractModel in authentication application class User(AbstractUser): pass and updated in settings AUTH_USER_MODEL = 'authentication.User' This has resulted in two sections in the admin panel. One section authentication contains User model while default Authentication and Authorization contain only Group model. I want to move either User to Authentication and Authorization or Group to Authentication so that both models could be together in a section. For that, I have added this in the authentication.admin.py apps.get_model('auth.Group')._meta.app_label = 'authentication' To move Group to Authentication. After running python manage.py makemigrations It generates migration in the auth app of django Migrations for 'auth': /Users/anuj/.local/share/virtualenvs/originor_py-Vd6fDdN7/lib/python3.6/site-packages/django/contrib/auth/migrations/0010_auto_20190220_0238.py - Remove field permissions from group - Alter field groups on user - Delete model Group And on migrating the migrations ./manage.py migrate, it gives error as ValueError: The field auth.User.groups was declared with a lazy reference to 'authentication.group', but app 'authentication' doesn't provide model 'group'. How can I move Group model to another section in the Django admin? Do I need to create custom Group model? -
connection from python code to rds error "SSL connection has been closed unexpectedly"
I do have code running in python+django in an aws server, at times very rarely i get an error of "SSL connection has been closed unexpectedly" when trying to connect to the aws rds instance . -
How should I structure requests with side effects when using Django Rest Framework?
I'm using Django Rest Framework and it's integrated with an external service. I'm using an endpoint to receive a callback from a webhook whenever a new task is created in the external service. When the callback request comes in, my code needs to create at least one object. But it's possible that multiple objects will need to be created from multiple different models. For example, if a new task is created it's possible that it was created by a new user, in which I also need to create a new user object to reflect this. In total, there could be up to 5 additional objects made as side effects. I'm aware of multiple different places that this logic could be added (e.g. service layers, serializers, models, managers, views). But there seem to be issues with all of these. Has anyone dealt with this issue before? If so, how did you solve it? -
How do I tell Django to never use (and totally ignore) SqlLite?
I'm tryign to get a Django application with Python 3.7 working with CentOS 7 and Apache (Mod WSGI). I have a project with a virtual environment set up. How do I turn off SqlLite? I'm not and don't intend to ever use it. I tried running (dentalenv) [root@server Python-3.7.2]# sudo yum install libsqlite3-dev Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.us-midwest-1.nexcess.net * epel: mirror.steadfastnet.com * extras: mirror.us-midwest-1.nexcess.net * updates: mirror.us-midwest-1.nexcess.net No package libsqlite3-dev available. Error: Nothing to do to install it and then restarting my Apache server. I even rebuilt Python, but I still get the below error, "ModuleNotFoundError: No module named '_sqlite3'" [Wed Feb 20 04:03:06.627020 2019] [wsgi:error] [pid 11885] Traceback (most recent call last): [Wed Feb 20 04:03:06.627285 2019] [wsgi:error] [pid 11885] File "/var/www/html/dental/wsgi.py", line 25, in <module> [Wed Feb 20 04:03:06.627323 2019] [wsgi:error] [pid 11885] application = get_wsgi_application() [Wed Feb 20 04:03:06.627353 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application [Wed Feb 20 04:03:06.627378 2019] [wsgi:error] [pid 11885] django.setup(set_prefix=False) [Wed Feb 20 04:03:06.627405 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/__init__.py", line 24, in setup [Wed Feb 20 04:03:06.627429 2019] [wsgi:error] [pid 11885] apps.populate(settings.INSTALLED_APPS) [Wed Feb 20 04:03:06.627467 2019] [wsgi:error] [pid 11885] File … -
Receiving form error invalid date, no matter the input
I have a form with a DateTimeField that keeps throwing an invalid date/time error. I have written the date in each format I can think of, but keep receiving this error and wondering what the reason for it could be. I would greatly appreciate any help. models.py class Lesson(models.Model): user = models.ForeignKey(User, null=True, default=None, related_name='lessons', on_delete=models.CASCADE) lesson_instrument = models.CharField(max_length=255, choices=instrument_list, blank=True) lesson_level = models.CharField(max_length=255, choices=level_list, blank=True) lesson_length = models.CharField(max_length=255, choices=length_list, blank=True) lesson_date_time = models.DateTimeField(default=timezone.now) lesson_weekly = models.BooleanField(default=False, blank=True) def __str__(self): return self.lessons @receiver(post_save, sender=User) def create_user_lessons(sender, instance, created, **kwargs): if created: Lesson.objects.create(user=instance) @receiver(post_save, sender=User) def save_user_lessons(sender, instance, **kwargs): for lesson in instance.lessons.all(): lesson.save() views.py def new_lesson(request): if request.method == 'POST': form = LessonForm(request.POST) if form.is_valid(): lessons = form.save(commit=False) lessons.user = request.user lessons.save() messages.success(request,'Lesson successfully created') return redirect('/teacher/schedule') else: messages.error(request, 'Information entered was invalid') else: form = LessonForm() lessons = Lesson.objects.filter(user=request.user) context = {'form' : form, 'lessons': lessons} return render(request, 'teacher/new_lesson.html', context) forms.py class LessonForm(forms.ModelForm): lesson_instrument = forms.ChoiceField(choices=instrument_list, widget=forms.Select(attrs={'class' : 'form-control', 'required' : 'True'})) lesson_level = forms.ChoiceField(choices=level_list, widget=forms.Select(attrs={'class' : 'form-control', 'required' : 'True'})) lesson_length = forms.ChoiceField(choices=length_list, widget=forms.Select(attrs={'class' : 'form-control', 'required' : 'True'})) lesson_date_time = forms.DateTimeField(widget=forms.DateTimeInput(attrs={'class': 'form-control', 'type':'datetime-local'})) lesson_weekly = forms.BooleanField(required=False) class Meta: model = Lesson fields = ('lesson_instrument', 'lesson_level', 'lesson_length', 'lesson_date_time', … -
Django 2.1.7 migrations on linux Mint
I have django 2.1.7 and python 3.7. My development machine used to be Windows 7 until a couple of weeks ago. It is now running linux Mint 19.1. I had a django project on the Windows box that is now on Mint. I have just returned to this project and there is a very strange interaction. I have the "requirements.txt" file from the old PC and installed all the packages in there with pip. I entered the project folder that containes the django manage.py file and typed: $ python manage.py makemigrations Members Billing Manager Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/home/me/PycharmProjects/MyProject/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute() File "/home/me/PycharmProjects/MyProject/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 357, in execute django.setup() File "/home/me/PycharmProjects/MyProject/venv/lib/python3.7/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/home/me/PycharmProjects/MyProject/venv/lib/python3.7/site-packages/django/apps/registry.py", line 89, in populate app_config = AppConfig.create(entry) File "/home/me/PycharmProjects/MyProject/venv/lib/python3.7/site-packages/django/apps/config.py", line 116, in create mod = import_module(mod_path) File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 728, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/home/me/PycharmProjects/MyProject/venv/lib/python3.7/site-packages/django/contrib/contenttypes/apps.py", line … -
how to edit (remove) entries from a django formset
Intro: I have a post which can have multiple images I achieving this with the help of 2 models namely. Post and Prep. The post model has a user, title, a message and a post_image class Post(models.Model): user = models.ForeignKey(User, related_name='posts') title = models.CharField(max_length=250, unique=True) message = models.TextField() post_image = models.ImageField(upload_to='post_images/') I am using another model to get additional images called Prep This can have multiple images. class Prep (models.Model): #(Images) post = models.ForeignKey(Post, on_delete=models.CASCADE, related_name='post_prep') image = models.ImageField(upload_to='post_prep_images/', blank=True, null=True) image_title = models.CharField(max_length=100) image_description = models.CharField(max_length=250) However unlike before each of the images from the prep model has a image_title and a image_description The Issue: I am able to create a post successfully and also almost edit the post with one exception I cannot reduce the number of images. If I have 3 Prep images I can add more images up to the max allowed I can edit existing images I cannot reduce the number of prep images How do I fix this error my post_edit view def post_edit(request, slug): post = get_object_or_404(Post, slug=slug) ImageFormSet = modelformset_factory(Prep, fields=('image', 'image_title', 'image_description'), extra=7, max_num=7, min_num=2) if post.user != request.user: raise Http404() if request.method == "POST": form = PostEditForm(request.POST or None, request.FILES … -
Django multiple annotations returns wrong results
I am trying to create an annotation in a django queryset. The annotation is a Count of reverse foreign key based on a condition. The issue I am having is that when I do the count for one reverse foreign key with a condition I get the right data, but when I do two annotations, one for each reverse foreign key. Here is the queryset with Count annotation for one reverse foreign key: ExamResponse.objects.filter( course_class__course=course, exam__exam_type=Exam.PRACTICE, user__is_demo=False, ended__isnull=False, id=125752 ).order_by( 'user_id', 'started' ).annotate( total_ecq_count=Sum( Case( When( choice_questions__response_time__gte=ENGAGEMENT_THRESHOLD, choice_questions__id__isnull=False, then=1 ), default=0, output_field=IntegerField() ), distinct=True ), ).values('total_ecq_count') Results (Correct Result): <QuerySet [{'total_ecq_count': 1}]> The query with two Count annotations ExamResponse.objects.filter( course_class__course=course, exam__exam_type=Exam.PRACTICE, user__is_demo=False, ended__isnull=False, id=125752 ).order_by( 'user_id', 'started' ).annotate( total_ecq_count=Sum( Case( When( choice_questions__response_time__gte=ENGAGEMENT_THRESHOLD, choice_questions__id__isnull=False, then=1 ), default=0, output_field=IntegerField() ), distinct=True ), total_etq_count=Sum( Case( When( text_questions__response_time__gte=ENGAGEMENT_THRESHOLD, text_questions__id__isnull=False, then=1 ), default=0, output_field=IntegerField() ), distinct=True ), ).values('total_ecq_count', 'total_etq_count') Results: (The total_ecq_count went from 1 to 3!!!) <QuerySet [{'total_ecq_count': 3, 'total_etq_count': 4}]> -
Handle Django Util Timezone Ambiguous Time Error without directly modifying the Django Package
I know to fix make_aware I can intercept the exception and set it forward an hour, however the issue is that Django is running the make_aware on dates as they're being discovered in a queryset, I am not calling the function in the code, is it happening in Django library code, which I can't edit without having to include the modified version in every version of the codebase. Is there a work around for this? -
Pre-Flight OPTIONS requests are canceled in Chrome (CORS already supported)
I'm working on a project that use Angular + Django(Django Rest Framework). During the development, the CORS support is done by using django-cors-headers, with CORS_ORIGIN_ALLOW_ALL = True and CORS_ALLOW_CREDENTIALS = True. When I'm trying to send POST requests to create some resources in frontend (Angular), some pre-flight OPTIONS requests are sent by Chrome and responded successfully by backend server (python manage.py runserver), but others are not. These requests are canceled due to unknown reason, backend server logs indicate that requests are received and accepted by server, details are shown in fig below. The headers of failed requests are shown below. However, if a copy the content of the headers and try sending it with curl, it works as expected. $ curl -v -X OPTIONS -H "Access-Control-Request-Headers: authorization,content-type" -H "Access-Control-Request-Method: POST" -H "DNS: 1" -H "Origin: http://localhost:4200" -H "Referer: http://localhost:4200" -H "User-Agent: Mozilla/5.0" http:/localhost:8000/api/user-permissions/ * Unwillingly accepted illegal URL using 1 slash! * Trying ::1... * TCP_NODELAY set * Connection failed * connect to ::1 port 8000 failed: Connection refused * Trying 127.0.0.1... * TCP_NODELAY set * Connected to localhost (127.0.0.1) port 8000 (#0) > OPTIONS /api/user-permissions/ HTTP/1.1 > Host: localhost:8000 > Accept: */* > Access-Control-Request-Headers: authorization,content-type > Access-Control-Request-Method: POST > … -
django-tables2 multiple classes for table
Is there a way to specify more than one class to a table that's generated using django-tables2. class SimpleTable(tables.Table): id = tables.Column() age = tables.Column() class Meta: attrs = {'class': 'mytable'} I want my table to have additional classes to 'mytable'. Is this achievable?