Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
When launching django-app from herroku, it says "application error", but the logs doesn't show any error
I am working at a django app (noob) in PyCharm and back it up on GitHub. I want to run the app from heroku and I created an workspace and deployed the app from the Git link. In logs it says that the app is launching, but when I am trying to acces the page, it says "application error! An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details." This is the log: -----> Python app detected -----> Installing pip -----> Installing requirements with pip -----> $ python manage.py collectstatic --noinput 94 static files copied to '/tmp/build_92826bd11c22ebfaffc04da632fb123d/USR/static'. -----> Discovering process types Procfile declares types -> (none) -----> Compressing... Done: 49.6M -----> Launching... Released v12 https://backend-educational.herokuapp.com/ deployed to Heroku Any idea about what am I missing? -
django aws ses boto3 - why different IAM credentials are used for verify_email_identity
I am trying to use django boto3 aws ses to to send email. I notice verify_email_identity uses a different IAM credentials, where is this set actually ? i didnt set it in my django app. client = boto3.client('ses', region_name='us-east-1') client.verify_email_identity(EmailAddress="bounce@example.com") -> IAM user B conn = mail.get_connection('django_amazon_ses.EmailBackend') -> IAM user A email = EmailMessage( 'Subject', 'Content', 'bounce@example.com', ['to@example.com'], headers={'From': 'from@example.com'}, ) self.assertGreater(conn.send_messages([email]), 0) -> IAM user A IAM user A has all the permission (like below), but IAM user B doesnt have. to me its strange why it is using IAM user B, how can that be possible ? i checked all my code there is no such settings for IAM user B { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ses:SendEmail", "ses:SendRawEmail", "ses:VerifyEmailIdentity" ], "Resource": "*" } ] } In settings.py, this is IAM user A credentials, i didnt not set IAM user B in anywhere in the app, maybe somewhere else in the mac pc, but im not sure. AWS_ACCESS_KEY_ID = config('AWS_ACCESS_KEY_ID') AWS_SECRET_ACCESS_KEY = config('AWS_SECRET_ACCESS_KEY') The question is client = boto3.client and verify_email_identity sets the aws credentials -
How to add image in Django RadioSelect choices individually?
forms.py from django import forms BINDING = ( ('1','Coil Bound Paperback'), ('2','Perfect Bound Paperback'), ('3','Saddle Stitch Paperback'), ) class BindingForm(forms.Form): my_binding_choice = forms.ChoiceField(choices=BINDING,widget =forms.RadioSelect()) views.py from django.shortcuts import render,render_to_response from .forms import MyForm,BindingForm def my_binding_view(request): form = BindingForm() return render(request,'base.html',{'binding_form':form}) template.html {% for radio in binding_form %} <div class="myradio"> {{ radio }} </div> {% endfor %} '''But i want to add images to my choices so it would be shown in radioselect list,or that can be achieved in else method?''' -
How to show multiple category in detail view django?
I'm working on a Django blog, and having implemented category for detail page. I've stumbled upon an issue. I want to display some categories of a product by using many to many field, I use the following code. This my model.py file from django.db import models from django.urls import reverse # Create your models here. class Category(models.Model): name = models.CharField(max_length=200) slug = models.SlugField(max_length=200, unique=True) is_active = models.BooleanField(default=True) def __str__(self): return self.name def get_absolute_url(self): return reverse('myshop:product_list_by_category', args=[self.slug]) class Product(models.Model): category = models.ManyToManyField(Category) name = models.CharField(max_length=200) slug = models.SlugField(max_length=200) image = models.ImageField(upload_to='products/%Y/%m/%d', blank=True) description = models.TextField(blank=True) price = models.DecimalField(max_digits=10, decimal_places=2) stock = models.PositiveIntegerField() available = models.BooleanField(default=True) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) def __str__(self): return self.name def get_absolute_url(self): return reverse('myshop:product_detail', args=[self.slug]) This is views.py file from django.shortcuts import render, get_object_or_404 from .models import Category, Product # Create your views here. def product_list(request, category_slug=None): category = None categories = Category.objects.all() products = Product.objects.filter(available=True) if category_slug: category = get_object_or_404(Category, slug=category_slug) products = products.filter(category=category) return render(request, 'shop/product/list.html', {'category': category, 'categories': categories, 'products': products}) def product_detail(request, product_slug): product = get_object_or_404(Product, slug=product_slug, available=True) category = product.category.filter(is_active=True) return render(request, 'shop/product/detail.html', {'product': product}, {'category': category}) and this is for detail.html page file {% extends "shop/base.html" %} {% load static … -
Facebook redirection with Django and python-social-auth
To locally test the ability to login in my django app with Facebook through python-social-auth, I have followed these steps: define a mapping from 127.0.0.1 to www.florian.com in /etc/hosts add http://www.florian.com:8000/login/facebook and http://www.florian.com:8000/complete/facebook in the field OAuth valid URI redirect in Facebook Login --> settings run python manage.py runserver www.florian.com:8000 However, when accessing http://www.florian.com:8000/login/facebook, I get the following error: Can't Load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and subdomains of your app to the App Domains field in your app settings. However when I check the validity of this URL with the field available in the Facebook Login --> settings, it is OK. Here are my Django files: urls.py: from django.conf.urls import url, include from django.contrib import admin from rest_framework import routers from backend import views from webapp import views as webapp_views from django.contrib.auth import views as auth_views router = routers.SimpleRouter() router.register(r'users', views.UserViewSet, 'User') router.register(r'games', views.GameViewSet, 'Game') urlpatterns = [ url(r'^$', webapp_views.home, name='home'), url('', include('social_django.urls', namespace='social')), # FACEBOOK login/registration from Web url(r'^login/$', auth_views.login, name='login'), url(r'^logout/$', auth_views.logout, name='logout'), url('', include('social_django.urls', namespace='social')), url(r'^test/', webapp_views.test), url(r'^admin/', admin.site.urls), url(r'^connect/', views.CustomObtainAuthToken.as_view()), url(r'^membership_create/', views.MembershipCreate.as_view()), # Facebook login/registration from REST API … -
Error on Django Stripe: Request req_rbqdcpSrevU8AD: Must provide source or customer
I'm getting the following error on my Stripe payment view: InvalidRequestError at /advertise/post/ Request req_rbwdcpSrc9U8AD: Must provide source or customer. I've simply copied the code from the Stripe (Python) tutorial so I'm not sure why it's not working.: def pay(request, context): ad = get_object_or_404(AdvertisePost, hash=context['hash']) amount = ad.total_price * 100 # Set your secret key: remember to change this to your live secret key in production # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = "sk_test_exhH9odKfkT4mxzbtVxuJOBZ" # Token is created using Checkout or Elements! # Get the payment token ID submitted by the form: if request.method == "POST": token = request.POST.get('stripeToken') print('Token:', token) #prints None charge = stripe.Charge.create( amount=amount, currency='aud', description='Boosted Post', source=token, ) context = { 'amount': amount, 'ad': ad } return render(request, 'advertising/pay.html', context) and here's the form in my html: <form action="" method="POST"> <script src="https://checkout.stripe.com/checkout.js" class="stripe-button" data-key="pk_test_8rSK99eA02ntvemImQCeV6su" data-amount="{{ amount }}" data-name="My name" data-description="Example charge" data-image="https://stripe.com/img/documentation/checkout/marketplace.png" data-locale="auto" data-currency="aud"> </script> </form> Any idea what the problem is? PS: I'm using this for one-time payments. Not saving customers or anything like that. -
django form post object like php
can i post a object to views like php? If not, how can i do the same result? thank you so much. Like the below form <form method="post"> {% csrf_token %} <div> <input name="category[0]['name']" type="text" required /> <input name="category[0]['desc']" type="text" required /> </div> <div> <input name="category[1]['name']" type="text" required /> <input name="category[1]['desc']" type="text" required /> </div> <button type="submit" class="btn btn-primary">Submit</button> </form> -
In the early morning my django application shows page is not working
But after restart apache in my google cloud then my application works.How to solve this issue. -
How to reset variable in image source?
My problem is that I can't figure out how to reset a part of <img src='' which is a value from AJAX. Every time a javascript function is called this ajax_value is added so I ran in to a problem that it keeps adding this value without removieng it first. Looks like this: Problem: /static/lpr_images/2018_04_14_08_00.png2018_04_14_08_01.png Situation: <img src="{% static 'lpr_images/' %}" + ajax_value /> Things I tried but they didn't work: $("#lcp_img").reset(); raises error Uncaught TypeError: $(...).reset is not a function Tried .remove() but that removes img tag. base.html ... <div class="modal-body"> {% csrf_token %} <img id="lcp_img" src="{% static 'lpr_images/' %}" alt="My image"/> {{ form.as_p }} <br> </div> .... <script type="text/javascript"> function get_task_info(data) { $.ajax({ ... document.getElementById('lcp_img').src += data.result.imageName; $("#exampleModal").modal('show'); }; function reset_img_src() { $('#lcp_img').reset(); }; </script> -
Wagtail | ChoiceField not displayed
I am facing some kind of incomprehensible behavior working with "StructBlock" and "ChoiceBlock". For some reasons the ChoiceBlock dont show up in admin-menu if designed via class-notation. Like that no choiceblock is shown at admin-menu. Only the textblock. class CodeBlock(blocks.StructBlock): code = blocks.TextBlock(required=True) type = blocks.ChoiceBlock(choices=[ ('markup', 'markup'), ('css', 'css') ], required=True), class Meta: template = 'home/blocks/code.html' class HomePageIndex(Page): body = StreamField([('code', CodeBlock())]) content_panels = Page.content_panels + [ StreamFieldPanel('body'), ] The following solution is in my opinion pretty much equal, but works well. I do not get why... Due the fact i need the Struct-Field more often i prefer the the class-notation. class HomePageIndex(Page): body = StreamField([ ('code', blocks.StructBlock([ ('code', blocks.TextBlock(required=True)), ('type', blocks.ChoiceBlock(choices=[ ('markup', 'markup'), ('css', 'css') ], template='home/blocks/code.html')) ]) content_panels = Page.content_panels + [ StreamFieldPanel('body'), Not get me wrong, i could make it work (using the bad-way). I wonder why that happens. Ty in advance -
TypeError: get() takes 2 positional arguments but 3 were given
I am trying to get an input to appear on my page, and have been following Max Goodridge's walkthrough ep.45, but seem to have gotten myself stuck on this particular section. If anyone could assist this would be a massive help. My urls.py: url(r'^bandlist/$', polls_views.bandlist, name='bandlist'), url(r'^bandlist/(\d+)/$', polls_views.BandView.as_view(), name='bandview'), My views.py def bandlist(request): query = Band.objects.order_by('bandname') args = {'query': query} return render(request, 'bandlist.html', args) class BandView(TemplateView): template_name = 'bandview.html' def get(self, request): form = BandForm() return render(request, self.template_name, {'form': form}) My forms.py class BandForm(forms.Form): post = forms.CharField() And the template (band.html) {% extends 'bbase.html' %} {% block content %} <h1>{{ band.bandname }}</h1> <h5>Total Ratings: {{ band.totalrating }}</h5> <h5>How many times have {{band.bandname}} been rated: {{ band.totalrated }}</h5> <h5>Average rating (Out of 5): </h5> <form method="post"> {{ form.as_p }} <input type="submit" value="Score" /> </form> {% endblock %} After this, I will then be attempting to implement a rating and review system for each band. If anyone could give advice on that as well that would be very much appreciated. -
Django Rest Framework regroup queryset by a category
In the current project that i'm working on, i need to regroup (group) a queryset by category and put contents with same category in a list all provided together. I have the following model structure: class Category(models.Model): title = models.CharField(max_length=255) class Item(models.Model): title = models.CharField(max_length=255) category = category = models.ForeignKey(to="Category", verbose_name=_('category'), related_name='items', on_delete=models.SET_NULL, null=True, blank=True) I would like the output serialized result to be like: { "category_title_1":[ { "id": 1, "title" : "something", }, { "id": 2, "title": "something else", } ], "category_title_2": [ { "id": 3, "title": "another string", }, { "id": 4, "title": "and yet another title", } ] } I know i can always iterate over the queryset and group them manually, i'm wondering if there is a native efficient way to do this. Thanks -
Add local python module to the classpath in IntelliJ
I am trying to run/debug my python project from IntelliJ Ultimate 2018.1. I have defined a python SDK, a Django local server (as the project uses Django as a template language), the PYTHONPATH is properly defined, etc. If I execute python manage.py runserver from my MacOS terminal, the server starts normally. When I am trying to run my IntelliJ configuration, it fails, with message: /usr/bin/python2.7 -d /Users/my_user/dev/github/my_project/manage.py runserver 8000 Traceback (most recent call last): File "/Users/my_user/dev/github/my_project/manage.py", line 19, in <module> paths = importlib.import_module('settings.' + server + '.paths') File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/Users/my_user/dev/github/my_project/settings/__init__.py", line 11, in <module> paths = importlib.import_module('my_project.settings.' + server + '.paths') File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) ImportError: No module named my_project.settings.local.paths The settings.local folder does contains the __init__.py file, and also settings folder and the root folder of my project. Doing a few hours of research over the internet I have realised that the main problem is to include local modules on the classpath, so they are available for server startup. For PyCharm, this is totally clear explained here. However, when trying to do the same thing in IntelliJ, this never works. Some people write about it here for example, but that … -
How to give 2 ChoiceField in Django Rest Framework
I want to know how to give two ChoiceField function in Serializer.py if i pass to def function it throws error like "Cannot assign "{'type': '1'}": "Product.type_units" must be a "Units" instance." so please help me to do this models.py class State(models.Model): statename= models.CharField(max_length=25) class District(models.Model): district_name= models.CharField(max_length=25) class Detail(models.Model): name = models.CharField(max_length=25) district = models.ForeignKey(District,on_delete=models.CASCADE) state = models.CharField(State,on_delete=models.CASCADE) Serializer.py class StateSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = Units fields = ('id','statename') class DistrictSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = Category fields = ('id','district_name') class DetailSerializer(serializers.HyperlinkedModelSerializer): state= serializers.CharField(source='state.statename') district= serializers.CharField(source='district.district_name') class Meta: model = Product fields = ('id','name','district','state') def create(self, validated_data): district= validated_data.pop('district') validated_data.update({'district_id': district['district_name']}) detail= Detail.objects.create(**validated_data) return detail -
Filtering foreign key data by created_by field using Class-Based-View
This is my models.py class InvoiceLine(AbstractSaleLine): invoice = models.ForeignKey('books.Invoice', related_name="lines") name = models.ForeignKey('books.Item') tax_rate = models.ForeignKey('books.TaxRate') class Meta: pass class Item(models.Model): item = models.CharField(max_length=255) created_by = models.ForeignKey(User, on_delete=models.CASCADE, related_name="Item", default=1) views.py class InvoiceCreateView(generic.CreateView): template_name = "books/invoice_create_or_update.html" model = Invoice form_class = InvoiceForm formset_class = InvoiceLineFormSet success_url = reverse_lazy("books:invoice-list") forms.py class InvoiceLineForm(RestrictLineFormToOrganizationMixin, ModelForm): class Meta: model = InvoiceLine fields = ( "name", "tax_rate", "item_id" ) How do i filter Item the foreign key by field created_by using CBV? I am using CreateView. -
When deploying Django into AWS Fargate how do you add the local ip into ALLOWED_HOSTS
I am testing out deploying my Django application into AWS's Fargate Service. Everything seems to run, but I am getting Health Check errors as the Application Load Balancer is sending requests to my Django application using the Local Ip of the host. This give me an Allowed Host error in the logs. Invalid HTTP_HOST header: '172.31.86.159:8000'. You may need to add '172.31.86.159' to ALLOWED_HOSTS I have tried getting the Local ip at task start up time and appending it to my ALLOWED_HOSTS, but this fails under Fargate: import requests EC2_PRIVATE_IP = None try: EC2_PRIVATE_IP = requests.get('http://169.254.169.254/latest/meta-data/local-ipv4', timeout = 0.01).text except requests.exceptions.RequestException: pass if EC2_PRIVATE_IP: ALLOWED_HOSTS.append(EC2_PRIVATE_IP) Is there a way to get the ENI IP Address so I can append it to ALLOWED_HOSTS? -
Django HttpResponse to raw Html
I want to start of by asking if what I'm doing is considered bad practice. I have a page where users can make comments. Once a user makes a comment, I want to reload the entire comment section using ajax and display it anew. My solution to this was to create a separate view that displays only the comments. Then, I can make web requests to this view, grab the response, and place the unaltered html response from it directly into my page. Is this a bad idea? What I've gotten stuck on is that there doesn't seem to be a way to get the direct html from an HttpResponse. I have a template that generates the page of only comments: {% for comment in comments %} {{ comment.text }} <br/> {% endfor %} And I display this response using {% autoescape off %}{{ comments_html.content }}{% endautoescape %} in the main template that has the comment section. However, my output has lots of extraneous things: b'\n COMMENT TEXT\n \n\n COMMENT TEXT\n \n\n COMMENT TEXT\n \n' Is there a way I can strip these values using only javascript? Should I even need to do that - why are they there in … -
Django serializers: What does is_valid actually do?
git repo: django tutorial I've been following the above django project that looks at creating at person to person chat. I've come across this part: def message_list(request, sender=None, receiver=None): ... elif request.method == 'POST': print('posting') data = JSONParser().parse(request) print(data) serializer = MessageSerializer(data=data) print(serializer) if serializer.is_valid(): serializer.save() return JsonResponse(serializer.data, status=201) What does "if serializer.is_valid():" actually do? Is it checking that the data in the message matches the data in the user profile? I've never used serializers before and could use an explanation of it. Thanks -
Django not filtering with user object
I'm using Django 2.0 In my view.py file def form_valid(self, form): email = self.request.POST.get('email') try: user = User.objects.get(email=email) except ObjectDoesNotExist: user = None already_shared = Shared.objects.already_shared(note, user, email) and in models.py class SharedQuerySet(models.query.QuerySet): pass class SharedManager(models.Manager): def get_queryset(self): return SharedQuerySet(self.model, using=self._db) def already_shared(self, note, user, email): if user is not None: print(user) # this line prints the username shared_note = self.get_queryset().filter(note=note, user=user).first() else: shared_note = self.get_queryset().filter(note=note, email=email).first() return shared_note class Shared(models.Model): note = models.ForeignKey(Note, on_delete=models.CASCADE) user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True, null=True) email = models.CharField(max_length=100, blank=True, null=True) for each record there could be either email or user set in the database. When I return email string, it works fine and record is filtered as well. But on passing user object from view, it returns None. I even tried with passing .filter(note=note, user=user.pk) but it is also not working. Printing print(user) prints username and other fields are also accessible via user.email, user.pk, etc. -
Django - how to make efficient use of django-mptt using DRY
I have a django blog project and am making use of Django-MPTT. I have two parent categories for my blog, "Travelling" and "Programming". The user is presented with all "Travelling" posts when they hit the home page, and I want to start writing posts in my "Programming" section too, which accessed via a nav bar. I am keen to make this as DRY as possible, but am not sure on the best way. The relevant structure is : views.py def getPosts(request): latest_posts = Post.objects.all().order_by('-pub_date') Travelling = Category.objects.filter(name="Travelling") childCats = Category.objects.filter(parent=Travelling) context = { 'latest_posts':latest_posts, 'childCats':childCats, } return render(request, 'posts/getPosts.html', context) def getPost(request, parentSlug, catSlug, postSlug): parent = Category.objects.root_nodes() childCats = Category.objects.filter(parentSlug=parentSlug) childCat = childCats.get(catSlug=catSlug) post = Post.objects.get(postSlug=postSlug) try: nextPostSlug = post.get_next_by_pub_date().postSlug except: nextPostSlug = None try: previousPostSlug = post.get_previous_by_pub_date().postSlug except: previousPostSlug = None context = { 'parent':parent, 'childCat':childCat, 'childCats':childCats, 'post':post, 'nextPostSlug':nextPostSlug, 'previousPostSlug':previousPostSlug, } return render(request, 'posts/getPost.html', context) posts.urls.py urlpatterns = [ url(r'^$', views.getPosts, name='getPosts'), url(r'^(?P<parentSlug>[\w\-]+)/(?P<catSlug>[\w\-]+)/$', views.getCategory, name='getCategory'), url(r'^(?P<parentSlug>[\w\-]+)/(?P<catSlug>[\w\-]+)/(?P<postSlug>[\w\-]+)/$', views.getPost, name='getPost'), url(r'privacypolicy$', views.privacypolicy, name='privacypolicy'), ] getPosts.html ... {% for post in latest_posts %} {% if post.show_in_posts %} <a href="{% url 'getPost' parentSlug=post.category.parentSlug catSlug=post.category.catSlug postSlug=post.postSlug %}"> </a> ... My question is, in applying DRY, does this mean that instead of duplicating templates … -
How to upload multiple images from a single "Choose Files" selector in django admin
I'm doing this little project simulating a clothing ordering system to brush up my django skills. I have to add several pictures of a certain item(not a fixed number). So, using a fixed number of image fields in Item model is not ideal. So, I thought of another model consisting only of images connected to the model 'items' by a key. Now I know that django has the inline option for adding model objects one by one as per requirement. But that seems a bit of a sucker as you have to open that dialog box and select the images one by one. Is it possible that there be a selector via which we could choose multiple files at once and they be added to the model?? -
Remove every character before the website name in a URL
For example if I have https://stackoverflow.com/questions/ask I'd like to cut it to stackoverflow.com/questions/ask or if I have http://www.samsung.com/au/ I'd like to cut it to samsung.com/au/. I want to make a template tag for this but not sure what to return: def clean_url(url): return ? template {{ url|clean_url }} Any idea? -
Django, comments cannot get the name of the post they are on
I'm having an issue with Python Django. It has to do with foreign keys and models. I have been told before that my questions are often incredibly mediocre, so please bear with me on this. I am trying to configure comments for a social network I'm working on and I've just got comments working, kind of. The issue is that, although I can input a comment and the database will log it and the person who wrote it, it won't log the post it is on. It always returns null. This is really the full extent of what I can say, as I REALLY don't understand what is happening. Here are a number of different code snippets and image that should hopefully be able to elaborate on the issue without requiring my interjection. 1: The models of the post-app https://pastebin.com/XXNsCa5g The important model being: class Comment(models.Model): 2: The reply template: https://pastebin.com/GsLUQqYp 3: The reply view: class PostReplyView(CreateView): model = models.Comment template_name = 'post_reply.html' fields = ['comment'] def form_valid(self, form): form.instance.author = self.request.user return super().form_valid(form) Finally, a visual representation of what is missing from a comment when it is posted: enter image description here -
django form pagination save in local storage
I have a form pagination that I want to save user's input in local storage. I have managed to get this variable in my jquery script: var fields = [<django.forms.boundfield.BoundField object at 0x000000000E415D30>, <django.forms.boundfield.BoundField object at 0x000000000E415400>, <django.forms.boundfield.BoundField object at 0x000000000E415390>, <django.forms.boundfield.BoundField object at 0x000000000E415AC8>, <django.forms.boundfield.BoundField object at 0x000000000E415BE0>, <django.forms.boundfield.BoundField object at 0x000000000E415208>, <django.forms.boundfield.BoundField object at 0x000000000E4158D0>, <django.forms.boundfield.BoundField object at 0x000000000E4154E0>, <django.forms.boundfield.BoundField object at 0x000000000E415860>, <django.forms.boundfield.BoundField object at 0x000000000E80DEF0>] My problem is I do not know how to save this field objects' key/value into local storage. There are large number of pages so this is generic and I should not use field names to access field values, just this field objects. Would you please give me a pointer how to acheive this. Thanks -
Django "ValueError: Can't bulk create a multi-table inherited model"
Problem I am using the django-model-utils InheritanceManager. I have a super Notification(models.Model) class which I use to create many notification subclasses such as PostNotification(Notification), CommentNotification(Notification), etc., and when trying to run CommentNotification.objects.bulk_create(list_of_comment_notification_objects), i get the following traceback: File "/home/me/.virtualenvs/project/local/lib/python2.7/site-packages/django/db/models/query.py", line 429, in bulk_create raise ValueError("Can't bulk create a multi-table inherited model") ValueError: Can't bulk create a multi-table inherited model and upon inspecting the query.py file, we get this causes the error: for parent in self.model._meta.get_parent_list(): if parent._meta.concrete_model is not self.model._meta.concrete_model: raise ValueError("Can't bulk create a multi-table inherited model") Environment Django Model Utils version: 3.1.1 Django version: 1.11.7 Python version: 2.7.3 Example PostNotification.objects.bulk_create( [PostNotification(related_user=user, post=instance) for user in users] ) throws the above exception What I have tried and though was a success originally: I though that simply running: BaseClass.objects.bulk_create(list_of_SubClass_objects) instead of SubClass.objects.bulk_create(list_of_SubClass_objects) would work and return a list of SubClass values, but running SubClass.objects.all() would return an empty result. The bulk_create() would only create a Notification base class object for each item in the list.