Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Issue migrating on m1 mac: geos incompatible architecture
I have run through a setup and I'm having issues migrating my app (within my venv). When I run python manage.py migrate I recevie this error: OSError: dlopen(/opt/homebrew/opt/geos/lib/libgeos_c.dylib, 0x0006): tried: '/opt/homebrew/opt/geos/lib//libgeos_c.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/opt/homebrew/opt/geos/lib/libgeos_c.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/opt/homebrew/opt/geos/lib//libgeos_c.1.16.0.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/opt/homebrew/Cellar/geos/3.10.2/lib/libgeos_c.1.16.0.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')) I've tried the answers to this question (missing libgeos_c.so on OSX), but none of them are working for me. I've also tried adding export DYLD_LIBRARY_PATH=/opt/homebrew/opt/geos/lib/ to my ~/.bash_profile. The output of file /opt/homebrew/Cellar/geos/3.10.2/lib/libgeos.dylib = /opt/homebrew/Cellar/geos/3.10.2/lib/libgeos.dylib: Mach-O 64-bit dynamically linked shared library arm64 The output of file $(which python3) = /Users/danieljohnson/Documents/code/project/venv/bin/python3 (for architecture x86_64): Mach-O 64-bit executable x86_64 /Users/danieljohnson/Documents/code/project/venv/bin/python3 (for architecture arm64): Mach-O 64-bit executable arm64 I'm not sure where to go from here. -
Google Drive API, Python, Django
I have some csv files that I want to generate everytime I run the script and upload them directly to google drive. When you have the files locally, it is easy to upload them. But, when I want to upload them I can't do that. I got this error instead : TypeError: expected str, bytes or os.PathLike object, not _csv.writer I am using googleapiclient.MediaFileUpload to upload the files, and the method Create_Service from Google. Here is a snippet of my code: from datetime import datetime from googleapiclient.http import MediaFileUpload, MediaIoBaseUpload from .Google import Create_Service @api_view(['GET']) def uploadFile(request): current_date = datetime.today().strftime("%d-%m-%y") content_disposition = 'attachment; filename=' + \ 'solde_quotidien_' + str(current_date) + '.csv' response = HttpResponse() response['Content-Disposition'] = content_disposition writer = csv.writer(response) writer.writerow(['Date', 'Compte', 'Nom du client', 'Solde', 'Hold Balance', 'Type client']) client = ['2022', '34995277', 'Mehfoud', '1000000', '500'] writer.writerow(client) # Upload a file # Le nom sur le cloud file_metadata = { 'name': 'test.csv', 'parents': ['1QXu_mk5lWbNQyk-EiBnRSIQYmXqNmAdm'] } media_content = MediaFileUpload(writer, mimetype='text/csv') file = service.files().create( body=file_metadata, media_body=media_content ).execute() print(file) return response Apparently, the problem is with MediaFileUpload. What should I do in this situation? Thanks in advence. -
Error - type object '' has no attribute '' when calling class method
So I'm having a pretty weird issue with my Django app. I have a model called acsUser with a class method called getAcsMgr that should return a list of managers who have employees with access to the system. When running the app using the runserver management command this works just fine, but when running the server using Gunicorn and Nginx and navigating to the view being served the list as context I get type object 'acsUser' has no attribute 'getAcsMgr'.I'm not sure why this works locally but not when running it on the server. Please see the model and information below. Model: class acsUser(models.Model): # Everything but the adAcct field is information pulled directly from ACS using it's API call description = models.CharField(max_length=200, null=True) acsId = models.CharField(max_length=20, null=True) identityGroupName = models.CharField(max_length=200, null=True) acsName = models.CharField(max_length=20, null=True) fullName = models.CharField(max_length=200, null=True) jobTitle = models.CharField(max_length=200, null=True) supervisor = models.CharField(max_length=200, null=True) location = models.CharField(max_length=200, null=True) userDefEmail = models.CharField(max_length=200, null=True) userDefManagerId = models.CharField(max_length=200, null=True) legacySystem = models.CharField(max_length=20, null=True) created = models.CharField(max_length=200, null=True) email = models.CharField(max_length=200, null=True) enabled = models.CharField(max_length=20, null=True) lastModified = models.CharField(max_length=200, null=True) maxFailureEnabled = models.CharField(max_length=20, null=True) adAcct = models.ForeignKey('employee', null=True, blank=True, on_delete=models.CASCADE, related_name='ACSadAccount') # What to return when an instance is called … -
Why can't find or install home module in Django?
I am new to Django and is learning it from a youtube video. In the video the tutor does this from home import views. Now when i try to do the same thing i get an error saying "Unresolved reference home". So i tried installing home using pip installer but is constantly getting the following error:- Collecting uwsgi>=2.0 Using cached uwsgi-2.0.20.tar.gz (804 kB) Preparing metadata (setup.py) ... error error: subprocess-exited-with-error × python setup.py egg_info did not run successfully. │ exit code: 1 ╰─> [8 lines of output] Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 34, in <module> File "C:\Users\clash\AppData\Local\Temp\pip-install-gpajfqiw\uwsgi_5085974451e542118156b6196d19b2cf\setup.py", line 3, in <module> import uwsgiconfig as uc File "C:\Users\clash\AppData\Local\Temp\pip-install-gpajfqiw\uwsgi_5085974451e542118156b6196d19b2cf\uwsgiconfig.py", line 8, in <module> uwsgi_os = os.uname()[0] AttributeError: module 'os' has no attribute 'uname'. Did you mean: 'name'? [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details. Can somebody please tell me why this is happening and what is the solution to this error. … -
Python got error "NameError: name '_mysql' is not defined"
With Python 3.7.9, Django 3 and MariaDB, the application always fails with the error "NameError: name '_mysql' is not defined". Please see the exception trace and pip package list attached in the Details section below, and let me know if you need to see the yum package information. We highly appreciate your help. Details: 1. The full exception trace: Exception in thread django-main-thread: Traceback (most recent call last): File "/data/app/venv3.7/lib/python3.7/site-packages/MySQLdb/__init__.py", line 18, in <module> from . import _mysql ImportError: libperconaserverclient.so.21: cannot open shared object file: No such file or directory During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner self.run() File "/usr/local/lib/python3.7/threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "/data/app/venv3.7/lib/python3.7/site-packages/django/utils/autoreload.py", line 53, in wrapper fn(*args, **kwargs) File "/data/app/venv3.7/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 110, in inner_run autoreload.raise_last_exception() File "/data/app/venv3.7/lib/python3.7/site-packages/django/utils/autoreload.py", line 76, in raise_last_exception raise _exception[1] File "/data/app/venv3.7/lib/python3.7/site-packages/django/core/management/__init__.py", line 357, in execute autoreload.check_errors(django.setup)() File "/data/app/venv3.7/lib/python3.7/site-packages/django/utils/autoreload.py", line 53, in wrapper fn(*args, **kwargs) File "/data/app/venv3.7/lib/python3.7/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/data/app/venv3.7/lib/python3.7/site-packages/django/apps/registry.py", line 114, in populate app_config.import_models() File "/data/app/venv3.7/lib/python3.7/site-packages/django/apps/config.py", line 211, in import_models self.models_module = import_module(models_module_name) 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>", … -
How to make static directory in Django
I created static directory which included css and image files in my Django project. When I run my project the css do display("GET /static/website/barber.css HTTP/1.1" 200 69) but the images do not("GET /static/website/images/balloons.gif HTTP/1.1" 404 1840), -
Uploading story to user story field without creating new story object ,but rather add to already upload stories of that user
Okay I have been stack in trying to have user create stories and add to their already uploaded stories in the backend database, but my current challenge is each time that a user uploads a story it doesn't add the story to the already existing field for that user, but rather create a new story object for that user! Is there a way that i could let users upload their new stories to add to already uploaded stories of that user ? My view for creating stories. def create_story(request): if request.method == "POST": form = StoryImageForm(request.POST, request.FILES) videos =request.FILES.getlist('video') images = request.FILES.getlist('image') title = request.POST['title'] # slug = str(title).lower().replace(" ", "-") story_data = Story(user=request.user,title=title) story_data.save() if form.is_valid(): data = form.save(commit=False) for image in images: data = StoryImage(post=story_data,user=request.user,images=image) data.save() return redirect('feed:feed') return render(request,"story/create_story.html") -
django admin panel healthcheck
I want to create a healthcheck endpoint for my django admin panel. I want to register it via admin.site.register_view (I am using the adminplus package) but I can't figure out how to made it accessible to the public, without the need to authenticate first. Any ideas? -
DRF Serialize subset of fields on nested serializer based on URL parameters
I am trying to allow the user to choose a subset of the fields in DataSerializer to be serialized instead of all fields. The serializers are as followes and the two models have a OnetoOne relation. class DataSerializer(serializers.ModelSerializer): class Meta: model = MeasurementsBasic fields = ['temp', 'hum', 'pres', 'co', 'no2', 'o3', 'so2'] def to_representation(self, instance): representation = super().to_representation(instance) return {'timestamp': instance.time_taken, **representation} return representation class NameSerializer(serializers.ModelSerializer): measurements = DataSerializer(source='measurements_basic', read_only=True) class Meta: model = Microcontrollers fields = ['measurements'] def to_representation(self, instance): representation = super().to_representation(instance) return {'station': instance.name, **representation} return representation From what i understand the way the serializers are now i have a field "measurements" instead of each individual field of DataSerializer. I want to know whether i am wrong and if i am how i could go about allowing the user to choose only certain of those fields to appear in the response. -
Django: 'Method \"PATCH\" not allowed.' 405 after adding a foreign key
I am doing a project for uni and it decided to make it in Django to learn something new. I start to regret that... and I hope that you can help. I am creating a simple API that performed well previously, but after adding the related class into a model, it allows me only to perform GET & POST operations, and I don't know why it happens and how to fix that - I have specified http methods in viewsets. I want to perform PUT, PATCH & DELETE operations as well. models.py: from django.db import models class Author(models.Model): id = models.AutoField(primary_key=True) first_name = models.CharField(max_length=60,blank=True,null=True) last_name = models.CharField(max_length=60,blank=True,null=True) description = models.CharField(max_length=1000,blank=True,null=True) def __str__(self): return "%s %s" % (self.first_name, self.last_name) class Quote(models.Model): id = models.AutoField(primary_key=True) content = models.CharField(max_length=1000) author = models.ForeignKey(Author, on_delete=models.SET_NULL,related_name='quotes',null=True) source = models.CharField(max_length=60,blank=True,null=True) context = models.CharField(max_length=1000,blank=True,null=True) year = models.IntegerField(blank=True,null=True) def __str__(self): return self.content serializers.py: from rest_framework import serializers from .models import Quote, Author class QuoteSerializer(serializers.ModelSerializer): class Meta: model = Quote fields = ('id','content','author','source','year','context') lookup_field = 'author' class AuthorSerializer(serializers.HyperlinkedModelSerializer): quotes = QuoteSerializer(many=True, read_only=True) class Meta: model = Author fields = ('id','first_name','last_name','description','quotes') urls.py: from django.urls import include, path from rest_framework import routers from . import views router = routers.DefaultRouter() router.register(r'authors', views.AuthorViewSet,basename='authors') router.register(r'quotes', … -
Open the Client's Desktop Application using a button Click from Browser - Python/HTML
I want to open the desktop application(For eg: Notepad/Powerpoint/Putty). Attaching an image of how it works on sharepoint. Example image of how Microsoft Teams gets opened on the Click of the button is attached. I need this exact replica. On Clicking Open Microsoft Teams. Teams opens the meeting. Similarly I want to open an already installed desktop app on client's System. Similarly, I also want to open the Desktop Application of my company which is already installed. I used Os.Popen module of Python which works locally but, when hosted does not work. Note: OS and webbrowser module were tried. -
Spatial join in Django
I am trying to do a spatial join (as explaind here) using PostGIS within Django. The Django spatial lookups do not help. My best clue is to use custom SQL but I would really prefer to keep using a QuerySet query. In plain english my query would be: Select all estates which contains at least one building with type "heavy" Here are my two models: class Building(models.Model): type = models.CharField(max_length=255, null=True, db_index=True) footprint = models.IntegerField(null=True, blank=True) perimeter = models.PolygonField(null=True, spatial_index=True) class Estate(models.Model): city = models.ForeignKey(City, on_delete=models.CASCADE) area = models.IntegerField(null=True, validators=[MinValueValidator(1)]) perimeter = models.PolygonField(null=True, validators=[estate_val.perimeter], spatial_index=True) Is there any way to do something like: estates = Estate.objects.filter(CUSTOM_JOIN_FILTER) -
Django set User for ForeignKey field in another model
I have a model like this: class File(models.Model): id = models.UUIDField(primary_key = True, default = uuid.uuid4, editable = False, unique=True) name = models.CharField(max_length=500) created_at = models.DateTimeField(auto_now_add=True) size = models.IntegerField(default=0) user = models.ForeignKey(User, on_delete=models.CASCADE) I'm using Django rest framework so, I created a view for this model: class FileCreate(CreateAPIView): def get_queryset(self): return File.objects.all() serializer_class = FileSerializer and I need to set user automatically for File object in view or serializer, but I don't know how... I want, when one user sends a request to create a file, "user" field in the file object automatically add request.user. -
I have this issue when registering user FileNotFoundError at /register/ [Errno 2] No such file or directory: '/media/default.jpg' on ubuntu linux serv
Please any help on how to solve this i know sure this is where the issue comes when i go directly to the url path http://ip:8000/media/default.jpg i can see the image. class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) image = models.ImageField(default='default.jpg', upload_to='profile_pics') def __str__(self): return f'{self.user.username} Profile' #resize the image after been save() def save(self, *args, **kwargs): super().save(*args, **kwargs) img = Image.open(self.image.url) if img.height > 300 or img.width > 300: output_size = (300, 300) img.thumbnail(output_size) img.save(self.image.url) -
What is the difference between objects.create() and instance.save()?
Is there any difference in making new record in database between MyModel.objects.create() and MyModel().save()? -
How can I save created pdf from pdfkit in django model?
Here I render my template to string and use the pdfkit to convert to pdf 'myPdf'. How can I save this created pdf to model? I tried this but it doesn't work. html = render_to_string('somehtmlfile.html',context=context) pdfkit.from_string(html, 'myPdf.pdf') f = open('myPdf.pdf') pdf = File(f) if pdf: data = {'upload': pdf} consent_serializer = CreatePdfSerializer(data=data) if CreatePdfSerializer.is_valid(raise_exception=True): CreatePdfSerializer.save() Here is model class CreatePdf(models.Model): upload = models.FileField('file_path',upload_to='upload_directory' max_length=1023) Serializer class CreatePdfSerializer(ModelSerializer): class Meta: model = models.CreatePdf fields = '__all__' -
Is possible add a subquery with anothers relationships in django orm annotate
I have a View to show my total stock by "point of sale". My problem is a new table added and I have put a more field in my View (counting total of reserved products). My actual scenario: Tables class SalePoint(models.Model): location = models.CharField(max_length=200, verbose_name='Local') [...] class Box(models.Model): sale_point = models.ForeignKey( [...] related_name='boxes', [...] ) product = models.ForeignKey( [...] related_name='boxes', [...] ) amount = models.PositiveSmallIntegerField() capacity = models.PositiveSmallIntegerField() class Product(models.Model): name = models.CharField() sku = models.CharField() View SalePointStockViewSet(viewsets.ModelViewSet): def list(self, request): queryset = ( SalePoint.objects.values( 'location', 'boxes__product__name' ).annotate( total_amount=Sum('boxes__amount'), total_capacity=Sum('boxes__capacity'), ) .order_by('location', 'total_amount') ) return Response(queryset) As I had said, my view works fine. I need to include a new field "reserved" in my queryset. Reserved is a sum of total ordered products with status "waiting" from this table: class Order(models.Model): WAITING = 'WAIT' DELIVERED = 'DELI' STATUS_CHOICES = [ (WAITING, 'Waiting'), (DELIVERED, 'Delivered'), ] sale_point = models.ForeignKey( [...] related_name='orders', [...] ) product_sku = models.CharField() status = models.CharField( [...] choices=STATUS_CHOICES, ) What am I thinking I'm thinking if it's possible to add the "reserved" field and fill it with a "subquery". The problem is that I have to filter the product by "sku". I don't know if this would be … -
Django admin filter is not working toexclude after filtering (Help Needed)
Hi with this code i can not exclue after filtering can any one help me def formfield_for_manytomany(self, db_field, request, **kwargs): if db_field.name == "company_names_uuids": kwargs["queryset"] = models.CompanyName.objects.filter(country_code== request._user_country) and models.CompanyName.filter((company_names__exists, country_code__exists) == None).exclue() return super().formfield_for_foreignkey(db_field, request, **kwargs) -
how to take views.py file from app to project/urls.py file
I created a project in django.in that from app/views.py i have to call the functions to mention in the project/urls.py .But its not accepting. mentioning the names from app/views.py to project/urls.py -
What is the difference between POST.get("..") and POST[".."] in django
I am beginner to django and i would like to know the difference between POST.get("..") and POST[".."]. def home(request): username=request.POST.get("username") return render(request,{"username":username}) ############ def home(request): username=request.POST["username"] return render(request,{"username":username}) -
Django - JWT + Brute force protection
Does anyone have boiler plate code for djangorestframework-simplejwt with brute force protection? I see they created 'django-defender' package (same author) but with custom setup path('login/', jwt_views.TokenObtainPairView.as_view(serializer_class=views.CustomTokenObtainSerializer)), it doesnt work, does anyone have minimal setup code with custom token obtainer? thank you -
field app.Vendor.created_by was declared with a lazy reference to 'auth.abstractbaseuser', but app 'auth' doesn't provide model 'abstractbaseuser'
hello i recently changed my user model to abstract base user and now i cant add any kind of OneToOneField models iam getting two different errors the other error : vendor.NewUser.created_by: (fields.E300) Field defines a relation with model 'AbstractBaseUser', which is either not installed, or is abstract. this are my models models.py from os import name from django.db import models from django.utils import timezone from django.utils.translation import gettext_lazy as _ from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, BaseUserManager class CustomAccountManager(BaseUserManager): def create_superuser(self, email, user_name, first_name, password, **other_fields): other_fields.setdefault('is_staff', True) other_fields.setdefault('is_superuser', True) other_fields.setdefault('is_active', True) if other_fields.get('is_staff') is not True: raise ValueError( 'Superuser must be assigned to is_staff=True.') if other_fields.get('is_superuser') is not True: raise ValueError( 'Superuser must be assigned to is_superuser=True.') return self.create_user(email, user_name, first_name, password, **other_fields) def create_user(self, email, user_name, first_name, password, **other_fields): if not email: raise ValueError(_('لطفا یک ادرس ایمیل بدهید')) email = self.normalize_email(email) user = self.model(email=email, user_name=user_name, first_name=first_name, **other_fields) user.set_password(password) user.save() return user def get_profile_image_filepath(self,filename): return f'uploads/{self.pk}/{"profile.png"}' def get_default_profile_image(): return "uploads/profiled.png" class NewUser(AbstractBaseUser, PermissionsMixin): email = models.CharField(_('ایمیل'),max_length=255 ,unique=True) user_name= models.CharField(_('نام کاربری'),max_length=255,unique=True) first_name = models.CharField(_('نام مسکن'),max_length=255 , blank=True) phone = models.CharField(_('شماره همراه'),max_length=50, blank=True) تاریخ_ثبت_نام = models.DateTimeField(verbose_name='تاریخ_ثبت_نام', auto_now_add=True) اخرین_ورود = models.DateTimeField(verbose_name='اخرین_ورود', auto_now=True) about = models.TextField(_( 'درباره شما'), max_length=500, blank=True) created_by = models.OneToOneField(AbstractBaseUser, blank=True,related_name="vendor",on_delete=models.CASCADE) … -
i am trying to fetch top performing city in django through foreign key - Django
here i am trying to fetch top performing city from sql where they are connected through forienkey. Models class Orders(models.Model): id = models.AutoField(primary_key=True) customer = models.ForeignKey(Customers , on_delete=models.DO_NOTHING , blank = True , null = True) product = models.ForeignKey('Products' , on_delete=models.DO_NOTHING ) class Customers(models.Model): id = models.AutoField(primary_key=True) username = models.CharField(max_length =100 , blank=True) date_created_gmt = models.DateField(blank=True) city = models.CharField(max_length=50 ,blank=True) so basically orders table have multiple orders with product_id and customer_id as foriegnkey. customer table have each customers address with city , pincode etc. so from this i need top performing city. city names which have highest orders in descending order. your help will appriciate. thank you -
Inclusion_tag doesn't display data in other models on template
I was follow to a old courses Udemy and I try create a project had 2 app( group & posts) and just found out that you can use: from django import template register = template.Library() To allow link models app to another app. In the old courses it just add in models.py and create tag in post_list.html to show what group you join and all group but don't create templatetags folder and how it work. Even when I check the sample it don't had any thing. So I was search gg try build it by myself, but it doesn't show anything. Can you check it. Thank App groups models.py: class Group(models.Model): name = models.CharField(max_length=235, unique=True) slug = models.SlugField(allow_unicode=True,unique=True) descripsion = models.TextField(blank=True,default='') descripsion_html = models.TextField(editable=False,default='',blank=True) member = models.ManyToManyField(User,through='GroupMember') def __str__(self): return self.name def save(self,*args, **kwargs): self.slug =slugify(self.name) self.descripsion_html = misaka.html(self.descripsion) super().save(*args, **kwargs) def get_absolute_url(self): return reverse("groups:single", kwargs={"slug": self.slug}) class GroupMember(models.Model): group = models.ForeignKey(Group,related_name='memberships',on_delete=models.CASCADE) user = models.ForeignKey(User, related_name='user_groups',on_delete=models.CASCADE) def __str__(self): return self.user.username In templatetags group_tags.py: from django import template from ..models import Group,GroupMember register = template.Library() @register.inclusion_tag('clonemedia/posts/templates/posts/post_list.html') def get_other_group(): group_members = GroupMember.objects.all() other_groups = Group.objects.all() return {'other_group':other_groups, 'group_member':group_members } In template post_list.html: {% load group_tags %} <h5 class='title'> Your Groups</h5> <ul class='list-unstyled'> … -
django next url parameter
I am using a custom Login View and a custom login page. What I am struggling with is the next parameter that I want to use so if there is the next parameter in the url then the user is being redirected to the previous page. As you can see in the code below I am using django-crispy-forms and django-axes. The problem is that I am able to successfully redirect users to the homepage but I cannot access any data that is visible for logged-in users (all views are restricted for logged-in users) such as user email, and content. Moreover, when I try to click on any hyperlink Django is automatically redirecting to the login page. When I try to access a page manually, for instance, http://127.0.0.1:8000/articles it redirects me to http://127.0.0.1:8000/accounts/login/?next=/articles/ which gives me Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/accounts/login/?next=/articles/ views.py class UpdatedLoginView(LoginView): form_class = LoginForm template_name = 'user/login.html' redirect_field_name='main/homepage.html' def post(self, request, *args, **kwargs): form = self.form_class(request.POST) if form.is_valid(): if 'next' in request.POST: return redirect(request.POST.get('next')) else: return(redirect('homepage')) else: return render(request, self.redirect_field_name, {'form': form}) class ArticleListView(LoginRequiredMixin, ListView): template_name = 'articles/ArticleListView.html' model = Article paginate_by = 6 queryset = Article.objects.filter(status=1) def get_context_data(self, **kwargs): context = super(ArticleListView, …