Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Prefix url Django
I am trying to make a customized prefix in urls for language without using i18n. The following code is in the root url file. urlpatterns = [ url(r'^[a-z]{2}/', include('landing_page.urls')), ] And the following code in landing_page.urls file; urlpatterns = [ url(r'^$', views.LandingView, name='landing'), ] Whenever I use; <a href="{% url 'landing' %}"></a> The following is displayed: <a href="/aa/"></a> How can I change "/aa/" automatically to the prefix for the current language (e.g. "/en/")? Without doing the following, since that gives many other problems in my setup. urlpatterns = [ url(r'^(?P<var>[a-z]{2})/', include('landing_page.urls')), ] Thanks! -
django-sass-processor is changing the order of the css rules
The following main.scss: @import "./boostrap-custom"; @import "./custom_styles"; Accompanied with the html: <link rel="stylesheet" type="text/css" href="{% sass_src 'scss/main.scss' %}"> Compiles to the following css rules: However if I reference aforementioned scss files separately, I get different css: <link rel="stylesheet" type="text/css" href="{% sass_src 'scss/boostrap-custom.scss' %}"> <link rel="stylesheet" type="text/css" href="{% sass_src 'scss/custom_styles.scss' %}"> Note that _spacing.scss and essentials.css swap around places. Hence it seems that django-sass-processor plugin is using some internal logic which doesn't work very well in my case. Any ideas how I may resolve this? -
Django generic FormView not showing when included in other template
First, what is currently working: I have a form defined in forms.py: class EnrollForm(forms.Form): course_id = forms.IntegerField(required=True) def enroll(self): print(self.cleaned_data) I build said form in a view in views.py: class EnrollView(FormView): template_name = 'core/enroll.html' form_class = EnrollForm success_url='' def form_valid(self, form): form.enroll() return super().form_valid(form) I display it in enroll.html: <form action="." method="post"> {% csrf_token %} {{ form }} <input type="submit" value="Enroll" /> </form> So, when I visit localhost:8000/core/enroll/, I see the form in all its might: However, when I attempt to include this file in another file using {% include "core/enroll.html" %} in another html file, that only displays the button while the {{ form }} tag in enroll.htmldoesn't resolve to anything and just silently fails, showing: -
jQuery - load div, and store checkbox
In one file (content.html) I have dynamically generated table (by Django). In one of seven columns I have checkbox - one checkbox for each row. I import div, which contain this table to index.html using jQuery load() - the table refreshing every 10 seconds. I need to store checked checkbox between refreshings because this is value for form and submit. How I can do this? Regards! -
Recurring payments using Stripe and Django
I'm still pretty new to Django and am trying to set up recurring payments via Stripe. I'm using Django 2.0 and have successfully set up a single charge test case. However, I'm unfamiliar with how to create recurring payments, and require it for the project I'm working on. For the single payment, I have the following: Views stripe.api_key = settings.STRIPE_SECRET_KEY def checkout(request): """Stripe check out""" new_tier = models.PaymentTier( level = "Tier 3", year = 2018 ) if request.method == "POST": token = request.POST.get("stripeToken") try: charge = stripe.Charge.create( amount = 2000, currency = "usd", source = token, description = "Tier 3 subscription for Elite Fitness" ) new_tier.charge_id = charge.id except stripe.error.CardError as ce: return False, ce else: new_tier.save() return redirect("thank_you_page") def payment_form(request): """Render stripe payment form template""" context = {"stripe_key": settings.STRIPE_PUBLIC_KEY} return render(request, "stripe-template.html", context) def thank_you_page(request): """Successful payment processed""" return render(request,'thank_you_page.html') stripe-template.html <form action="checkout/" method="POST"> {% csrf_token %} <script src="https://checkout.stripe.com/checkout.js" class="stripe-button" data-key={{stripe_key}} # Make sure to wrap the variable name with double {} data-amount="2000" data-name="company name here" data-description="Elite Fitness Subscription" data-image="picture.png" data-currency="usd"> </script> </form> I've had a difficult time finding anything online which covers recurring payments specifically. If anybody knows how to set them up (even through dj-stripe or pinax) … -
How to add if statement in filter?
I have 4 parameters: city, province, strtype, direction, when the parameter is not empty I want to use it in filter, when it is empty, do not set it as filter keyword. The part of current code I use is as below: if (direction == '') & (strtype == '') & (city == '') & (province == ''): queryset = address.objects.filter(addline__startswith=keyword)[:10] if not queryset.exists(): queryset = address.objects.filter(strname__startswith=keyword)[:10] return queryset else: return queryset if (direction != '') & (strtype == '') & (city == '') & (province == ''): queryset = address.objects.filter(addline__startswith=keyword, strdir=direction)[:10] if not queryset.exists(): queryset = address.objects.filter(strname__startswith=keyword, strdir=direction)[:10] return queryset else: return queryset There are 16 posibilities, it means i need to write 16 if statements! This is too many codes and ungraceful, is there a terse solution? -
Django count queryset:int() argument must be a string, a bytes-like object or a number, not 'builtin_function_or_method'
I am stuck up with my efforts to count files uploaded by my user models.py class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) class Document(models.Model): docfile = models.FileField(upload_to='documents/%Y/%m/%d') uploaded_by = models.ForeignKey(Profile,on_delete=models.CASCADE) date_uploaded = models.DateTimeField(auto_now_add=True) class UploadDetail(models.Model): profile = models.ForeignKey(Profile,on_delete=models.CASCADE) document = models.ForeignKey(Document,on_delete=models.CASCADE) amount = models.IntegerField(default=0) views upload function @login_required def upload(request): # Handle file upload user = request.user if request.method == 'POST': form = DocumentForm(request.POST, request.FILES) if form.is_valid(): newdoc = Document(docfile=request.FILES['docfile']) newdoc.uploaded_by = request.user.profile newdoc.save() # Redirect to the document list after POST return HttpResponseRedirect(reverse('upload')) else: form = DocumentForm() # A empty, unbound form # Load documents for the upload page documents = Document.objects.all() current_up = Document.objects.filter(uploaddetail=id).count() I got int() argument must be a string, a bytes-like object or a number, not 'builtin_function_or_method' Django refers to which builtin function? How to fix this? -
Django Haystack creates fields with wrong types
Django Haystack seems to be unable to create fields with correct types. I'm using Django 1.10.7, Django Haystask 2.7.1.dev5+gc6616d1 (previously tried older versions, but there were some compatibility issues), pysolr 3.6.0, Solr 7.3.1. The home directory of Solr is /var/solr/, so I put the schema.xml and solrconfig.xml files generated by Haystack with the following command: ./manage.py build_solr_schema -c /var/solr/data/{project_name]/conf After generating the files, I reloaded the core, then executed the following command: ./manage.py rebuild_index The following is just one of the fields defined in Django: date_created = indexes.DateTimeField(model_attr='date_created') It appears in the schema.xml file as: <field name="date_created" type="date" indexed="true" stored="true" multiValued="false" /> Still, it can be seen from the Solr admin panel that the field is of type "text_general". And all of the fields are of this type. Also, I tried to move the schema.xml and solrconfig.xml files to /var/solr/data/{project_name}, but it didn't help either. What am I missing here? -
Django strange behaviour of aggregation over custom ManyToMany field
I've encountered some unexpected (for me) behavior of aggregation over ManyToMany field in django. I have the following schema: class ContestTaskRelationship(models.Model): contest = models.ForeignKey('Contest', on_delete=models.CASCADE) task = models.ForeignKey('Task', on_delete=models.CASCADE) solved = models.ManyToManyField('User', related_name='contests_tasks_solved', blank=True) cost = models.IntegerField(default=0) class Contest(models.Model): tasks = models.ManyToManyField('Task', related_name='contests', blank=True, through='ContestTaskRelationship') class Task(models.Model): pass Then I have one task and two contests, connected to that task. If I try to annotate count of ContestTaskRelationship models like that (assuming contest is one of the contests): task = contest.tasks.annotate(number_solved=Count('contesttaskrelationship')).first() I get task.number_solved == 1, but when I try like that: task = Task.objects.get(id=1).annotate(number_solved=Count('contesttaskrelationship')).first() I get the expected result task.number_solved == 2. Why is that? Isn't it the same object and the same field? -
Django getting error :send_mail() got an unexpected keyword argument 'fail_silently' on sending mails
I am new to django and trying to use django emailer. I have provided the following settings for mail in settings.py : EMAIL_USE_TLS = True EMAIL_HOST='smtp.gmail.com' EMAIL_HOST_USER='ant@a.com' EMAIL_HOST_PASSWORD='******' EMAIL_PORT = 587 I have defined one view in my views.py as following: def testemail(request) : subject="test email" message="hello sid" reply_to_list=['abc@gmail.com','def@gmail.com'] send_mail(subject,message,'ant@a.com',reply_to_list,fail_silently=True) I have registered this view in url.py as `url(r'^testemail/',email_views.testemail,name="testemail") But after hitting the url i am getting the error as : send_mail() got an unexpected keyword argument 'fail_silently' Any suggestions or solutions ,as why this error is coming? -
python-home option fails when attempting to configure Django/mod_wsgi application in daemon mode on CentOS
I have a Django application running on Centos 7.5 with Apache 2.4 and mod_wsgi 4.6.4. I'm having a hard time getting mod_wsgi to use the virtual environment I want it to use. I installed Python 3.6 via yum and used it to create a virtual environment. I compiled mod_wsgi from source, using the with-python option to point it to the correct Python binary. The (approximate) Apache configuration I expected to work, but which does not work, is the following: # Required because of some third-party packages that use the # simplified GIL state API WSGIApplicationGroup %{GLOBAL} <VirtualHost *:80> WSGIDaemonProcess myapp python-home=/path/to/venv python-path=/path/to/my/app WSGIProcessGroup myapp WSGIScriptAlias / /path/to/my/app/wsgi.py </VirtualHost> <VirtualHost *:443> WSGIProcessGroup myapp WSGIScriptAlias / /path/to/my/app/wsgi.py </VirtualHost> This configuration can't find any of the packages installed in the virtual environment. Dumping sys.path shows that the path doesn't contain /path/to/venv/lib/python3.6/site-packages as expected, but rather /lib/python3.6/site-packages (i.e. the system directory). The only way I've been able to get my app to run is by changing the WSGIDaemonProcess directive to: WSGIDaemonProcess myapp python-path=/path/to/my/app:/path/to/venv/lib/python3.6/site-packages The first configuration (using python-home as recommended) does work for me on macOS 10.12 with Python 3.6 and mod_wsgi 4.5.24. A big difference between the two environments is the fact that … -
difference between ng serve and ng build. when pushed to heroku. Heroku shows old version
I am using django heroku and angular. My current source code has many changes to it. When I run ng serve I see the changes in my local server. But when I run ng build add the code to my django project and push to heroku, I get the source code several commits behind my site version. I have pushed my current to my repo. This just started happening, the build not reflecting the current source. I have no idea why. I am actively researching this and will add to this question as I have more info. it seems ng build --prod might give a fresh reload of the current source but still looking into it. I am getting this warning in my terminal when I run a cli command: Your global Angular CLI version (6.1.0-rc.0) is greater than your local version (6.0.0-rc.4). The local Angular CLI version is used. To disable this warning use "ng config -g cli.warnings.versionMismatch false". but that shouldn't matter. I ran ng build -prod and got several errors I was not getting with ng serve. I am fixing them. The hypothesis is this is what is causing the difference. Of course this is best guess … -
django annotate and aggragate
I have some models: class User(models.Model): username = models.CharField(max_lenght=50) class Order(models.Model): price = models.IntegerField() user = models.ForeignKey(User, related_name='orders') created_at = models.DateTimeField(auto_now_add=True) And when I want add all prices to users query I do this query: User.objects.annotate(all_prices=Sum('orders__price')) But when I want to add not all prices(only those which created one year ago and early): I think, it would be like so: orders = Order.objects.filter( user_id=OuterRef('id), created_at__gte=timezone.now() - timezone.timedelta(days=365) ) User.objects.annotate(all_prices=Sum(orders.values_list('price')) but error was like so: FieldError: Cannot resolve expression type, unknown output_field How can I do this query? -
"Uncaught SyntaxError: Unexpected token <" using Gunicorn and Apache for Django/React app
I'm very inexperienced when it comes to setting up web servers. The server I am working on has Apache and reverse proxy to Nginx. That is the current setup for the currently application. We are replacing the current application with a React/Django app. Using Gunicorn seems like the easiest solution using it as a proxy; having Apache ProxyPass to the Gunicorn local IP: http://127.0.0.1:8000 that is running. https://docs.djangoproject.com/en/dev/howto/deployment/wsgi//gunicorn/ So, I'm pretty sure Apache is setup correctly. You obviously shouldn't do this in a production environment, but I ran python manage.py runserver 127.0.0.1:8000, and was able to access the web application on the server by going to URL (test.example.com). Just for testing purposes. So I at least know that the Apache ProxyPassseems to be working properly, and I can communicate with the application. Config for Apache: ProxyPreserveHost On ProxyPass / http://127.0.0.1:8000/ retry=5 ProxyPassReverse / http://127.0.0.1:8000/ <Proxy *> Order deny,allow Allow from all </Proxy> So trying to implement Gunicorn as the proxy which seems like it should be almost as straight forward. The process I'm following, after I have pip install gunicorn is to: 1) npm start to compile the app.js, manifest.js, vendor.js, and other assets into /bundle 2) python manage.py collectstatic … -
Heroku deploy for my django app does not work properly
I am new in heroku and developed a simple django app locally. Now I am trying to put it into heroku. My first deployment was successful and I can see the web screen at heroku. But these days I found some of my code change did not transfer to the source in heroku. It seems this problem happen after "pipenv" was installed. Please refer to followings, (estimate) C:\dev\estimate\src>git commit -i estimate/settings/base.py -m "base.py" [master 42eede1] base.py 1 file changed, 1 insertion(+), 1 deletion(-) (estimate) C:\dev\estimate\src>git push heroku master Counting objects: 5, done. Delta compression using up to 4 threads. Compressing objects: 100% (5/5), done. Writing objects: 100% (5/5), 409 bytes | 0 bytes/s, done. Total 5 (delta 4), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Python app detected remote: ! No 'Pipfile.lock' found! We recommend you commit this into your repository. remote: ! The latest version of Python 3 is python-3.6.5 (you are using python-3.6.4, which is unsupported). remote: ! We recommend upgrading by specifying the latest version (python-3.6.5). remote: Learn More: https://devcenter.heroku.com/articles/python-runtimes remote: -----> Installing pip remote: -----> Installing dependencies with Pipenv 11.8.2… remote: Installing dependencies from Pipfile… remote: -----> Discovering … -
django, 'some_field' attribute has no file associated with it
views.py if request.is_ajax(): testpic = TestPic.objects.get(pk=1) form = TestPicForm(request.POST, request.FILES, instance=testpic) if form.is_valid(): form.save() forms.py class TestPicForm(forms.ModelForm): class Meta: from .models import TestPic model = TestPic fields = ('file', 'file_50',) def save(self): test_photo = super(TestPicForm, self).save() file = user_photo.file image = Image.open(file) rotated_image = image.rotate(90, expand=True) cropped_image = rotated_image.resize((300, 300), Image.ANTIALIAS) cropped_50_image = rotated_image.resize((50, 50), Image.ANTIALIAS) cropped_image.save(test_photo.file.path) file.seek(0) cropped_50_image.save(test_photo.file_50.path) return user_photo models.py class TestPic(models.Model): file = models.ImageField(null=True, blank=True, default=None, upload_to="photo/%Y/%m/%d") file_50 = models.ImageField(null=True, blank=True, default=None, upload_to="photo/%Y/%m/%d") This code is to upload a image file, to resize of it by two different size and to save it. Sadly, It works only when there is any file on field file_50. In other words, if there is file some_file_50.jpeg on file_50 field, image file uploading does works, but in django-admin, there cannot see change of file name on file_50 field.(file name of file field is changed.) However content of some_file_50.jpeg is changed. Only name of file, some_file_50.jpeg is unchangeable. When file_50 field has no file on it, it throws the error: The 'file_50' attribute has no file associated with it. Question: How can I fix it? -
Django vs Flask - Argument-based or global-import request object
I am comparing Django and Flask in the ways of how they expose request objects: Django: When a page is requested, Django creates an HttpRequest object that contains metadata about the request. Then Django loads the appropriate view, passing the HttpRequest as the first argument to the view function. (Reference) def index(request): print(request.method) Flask: For web applications it’s crucial to react to the data a client sends to the server. In Flask this information is provided by the global request object. (Reference) from flask import request @app.route('/') def index(): print(request.method) I know Flask request is not actually global, it is threadsafe/context local. I have heard that Flask's way is a more "pythonic" way of doing it, but it seems to me that "argument" is a better scope for a request. Is there any reason we would like to use one over another? Is there any reason behind the design decision? (Some discussions on Hacker News but I still cannot come up with an answer) -
error regexp django urls
my urls.py from django.urls import path from home.views import homePageView, activateUser urlpatterns = [ path('',homePageView.as_view(),name='home'), path('activate/([a-zA-Z0-9]{15})/$', activateUser.activate, name='activate') ] the url on the browser: http://127.0.0.1:8000/activate/9Eri2DOMYpwI5p8/ error: Using the URLconf defined in cryptoassistant.urls, Django tried these URL patterns, in this order: admin/ [name='home'] activate/([a-zA-Z0-9]{15})/$ [name='activate'] activate/([a-zA-Z0-9]{15})/$ [name='activate'] The current path, activate/9Eri2DOMYpwI5p8/, didn't match any of these. django generate this error..some one suggest !! -
Verify JWT in Django using Cognito to allow access
Using: https://github.com/LabD/django-cognito-jwt I managed to to authenticate against cognito and have a token returned. What I don't get from the docs is how to validate the token so as to restrict URL paths. How would I validate the tokens ? Thanks. -
My Django refuses to let me use keywords in a URL
I am trying to use keywords in my Django URl but it will not allow me. I have tried the syntax of about 7-8 peoples projects and none of them have worked... So basically I have a class with user info and one of the attributes it contains is "first_name", obviously representing the first name of the users in the database. So basically, according to my app, userData/index : brings up a list of all users userData/1 : brings up the info of the user with the ID of 1 The code for this is... urlpatterns = [ path('admin/', admin.site.urls), path('', welcome), path('userData/', include('userData.urls')), ] This is the code from my project url folder^ from django.conf.urls import url from .views import admins, index, ratings urlpatterns = [ url('admins', admins, name='admins'), url('index/', index, name='index'), url('user_id', ratings, name='rating') ] Now here is where the problem is, the keyword user_id simply prints literally the characters user_id as a string in the url bar when I want it to print the user id. I just dont know what to write in place of 'user_id'.. Any help is appreciated, thank you! -
Why is ASCII encoding set as default on my Django2.0 project? How to change it?
After pushing to a server, my Django application started to raise UnicodeEncodeError in various locations of the code (e.g. in printing, handling request in views): > UnicodeEncodeError: 'ascii' codec can't encode characters in position > 165-168: ordinal not in range(128) ASCII codec? I use Django2.0 and Python 3.6, which both use UTF-8 as default. Also, for configuration I still use SQLite, which always utilizes UTF-8 for internal encoding, so it’s not an issue with database. I don’t have any additional settings for encoding (I use things like LANGUAGE_CODE, USE_I18N, USE_L10N, but I don’t see how this could be relevant), especially I didn’t set DEFAULT_CHARSET or LC_CTYPE. On my local machine my application runs fine, so I checked an environment bin/activate file on the server, but found nothing suspicious there. I even tried to set the encoding explicitly by adding # -*- coding: utf-8 -*- on top, but without noticeable effect. What could be source of this problem? What settings on server order application to try to encode non-ascii characters with an ASCII codec? How to change it? -
Django Rest framework: custom API response
I have Char objects with ManyToMany relationships to Source objects. Because a Char can appear in many Sources and many Sources can contain multiple Chars. The MtM relationship goes through a through table which also contains page number. In my API response, which I built using the Django REST framework I want to avoid resolving the full Source title, author etc. for every Char. Rather, in order to reduce the size of the JSON response, I want to refer it by id and include a sources section so the client can look it up. I.e. a client visiting /api/char/26 should get the following response: "chars": [ { "id": 26, "name": "龜", "locations": [ { "page": 136, "source": 1 }, { "page": 162, "source": 1 } ] } ], "sources": [ { "id": 1, "title": "Bruksanvisning Foamglass", "author": "Bluppfisk" } ] Here's the API view: class CharAPIView(generics.RetrieveAPIView): queryset = Char.objects.all() serializer_class = CharSerializer and the Serializers: class CharSerializer(serializers.ModelSerializer): locations = serializers.SerializerMethodField() class Meta: model = Char fields = ('id', 'name', 'locations',) depth = 1 def get_locations(self, obj): qset = CharInSource.objects.filter(char=obj) return [CharInSourceSerializer(m).data for m in qset] class CharInSourceSerializer(serializers.ModelSerializer): class Meta: model = CharInSource fields = ('page', 'source',) The problem is I … -
Adding a user to a group using django rest framework programmatically
I want to be able to attach a user to a group upon creation. Here is the result of select * from auth_group: image screenshoot Here is the my serializer.py file: from rest_framework import serializers from .models import User class UserSerializer(serializers.ModelSerializer): class Meta(object): model = User fields = ('id', 'email', 'first_name', 'last_name', 'phone', 'address', 'is_active', 'is_staff', 'is_superuser', 'date_joined', 'password',) extra_kwargs = {'password': {'write_only': True}} Here is my model.py file: from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager from django.contrib.auth.models import PermissionsMixin, UserManager, Group from django.db import models, transaction # Create your models here. from django.utils import timezone class UserManager(BaseUserManager): def _create_user(self, email, password, **extra_fields): """ Creates and saves a User with the given email,and password. """ if not email: raise ValueError('User must have an email address') email = self.normalize_email(email) if not extra_fields["group_id"]: raise ValueError('User must have group id') try: with transaction.atomic(): user = self.model(email=email, **extra_fields) group = Group.objects.get(extra_fields["group_id"]) group.user_set.add(user) user.set_password(password) user.save(using=self._db) return user except: raise def create_user(self, email, password=None, **extra_fields): extra_fields.setdefault('is_staff', False) extra_fields.setdefault('is_superuser', False) return self._create_user(email, password, **extra_fields) def create_superuser(self, email, password, **extra_fields): extra_fields.setdefault('is_staff', True) extra_fields.setdefault('is_superuser', True) return self._create_user(email, password=password, **extra_fields) class User(AbstractBaseUser, PermissionsMixin): """ An abstract base class implementing a fully featured User model with admin-compliant permissions. """ email = models.EmailField(max_length=40, unique=True) … -
from openpyxl.chart.title import Title - AttributeError: 'list' object has no attribute
Question No changes to this module that I am aware of. Another separate custom program was installed on the same computer then the errors below started. Suggestions would be appreciated. Errors 3 Traceback (most recent call last): File "log.py", line 100, in error_catcher response = func() File "models.py", line 852, in func instance.main() File "models.py", line 1061, in main data_obj = report.Main(*self.args) File "report.py", line 95, in init self.data_manager() File "report.py", line 113, in data_manager self.equivdod_report('DoD Equiv') File "report.py", line 328, in equivdod_report datas) File "scriptexcel.py", line 230, in equivdod_report ytitle=r'Design Usage (%)' File "excelcreator.py", line 376, in hist__init__ self.title_params(bc.title) File "excelcreator.py", line 767, in title_params baseline=1000 AttributeError: 'list' object has no attribute 'rPr' excelcreator.py (Segments from this module) from openpyxl import Workbook from openpyxl import load_workbook from openpyxl.chart.title import Title import openpyxl.drawing.text as oxldt import os import re import openpyxl import numpy as np import datetime class Excel(): def hist__init__(self, sheet_name, mincol=None, maxcol=None, minrow=None, maxrow=None, bc=None, title=None, ytitle=None, xtitle=None): if bc is None: bc = BarChart() bc.title = title bc.y_axis.title = ytitle bc.legend.position = 't' self.title_params(bc.title) self.title_params(bc.y_axis.title) xval = Reference( self.wb[sheet_name], min_col=mincol-1, min_row=2, max_row=maxrow) data = Reference( self.wb[sheet_name], min_col=mincol, max_col=maxcol, min_row=minrow, max_row=maxrow) return bc, xval, data def title_params(self, title): … -
Grant complex bundled permissions to Django Groups
Django makes it straightforward to grant permissions to a Group of Users, by using its out-of-the-box authentification system. Now, we would like to model more complex permissions structures, whereby permissions can be inherited across multiple Django models. We would like to assign Packackes to each group, whereby each package again activates a set of permissions. As a result, a Group's total permissions would derive from it's own permissions, as well as its assigned Packages. This seems similar to how a User's total permissions derive from her own permissions, as well as her groups' permissions. It can be desirable to model even more complex permission structures, i.e. there could be different PackageTypes (describing sets of permissions), or perhaps Groups could also be assigned additional permissions via relationships to other models (e.g. Subscriptions in addition to Packages). Finally, some of these permissions may be object-level, such that it would make sense to use some of the well-tested object-permission Django packages, such as Django-Guardian , Rules, or Django-Permissions. Now my question is: Are these kinds of structured/complex permission set-ups natively covered in Django? OR, are they supported by some of the Django permission packages? With which Django object-permission libraries do they play well …