Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
DoesNotExist at /admin Category matching query does not exist
I get errors when going to admin panel. Django shows me the error associated with the categories in the product list. I do not understand why the admin panel is waiting for the category? How is this interrelated? Help me please The error looks like this Category matching query does not exist. DoesNotExist at /admin ./shop/views.py in product_list category = Category.objects.get(slug=category) urls.py from django.conf.urls import url, include from django.conf import settings from django.contrib import admin urlpatterns = [ url(r'', include('orders.urls')), url(r'', include('cart.urls')), url(r'', include('shop.urls')), url(r'^admin/&', admin.site.urls), ] shop urls.py app_name = 'shop' urlpatterns = [ url(r'^$', views.product_list, name='product_list'), url(r'^show/(?P<slug>[-\w]+)$', views.product_show, name='product_show'), url(r'^(?P<category>[-\w]+)$', views.product_list, name='lst_by_ctgry'), url(r'^(?P<category>[-\w]+)/(?P<subcategory>[-\w]+)$', views.product_list, name='lst_by_subctgry'), url(r'^(?P<category>[-\w]+)/(?P<subcategory>[-\w]+)/(?P<kind>[-\w]+)$', views.product_list, name='lst_by_knds'), ] settings.py # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django_extensions', 'shop', 'cart', 'orders', ] product_list - views def product_list(request, category=None, subcategory=None, kind=None): if category: categories = Category.objects.all() category = Category.objects.get(slug=category) subcategories = Subcategory.objects.filter(category=category) products = Product.objects.filter(category=category, available=True) products_quantity = len(Product.objects.filter(category=category, available=True)) kinds = None; kind_last = None if subcategory: subcategory = Subcategory.objects.get(slug=subcategory) kinds = Kind.objects.filter(kind=subcategory) products = Product.objects.filter(category=category, subcategory=subcategory, available=True) if kind: kind = Kind.objects.filter(slug=kind) products = Product.objects.filter(category=category, subcategory=subcategory, kind__in=kind, available=True) kind_last = kind.last() if products: paginator = Paginator(products, 8) page = request.GET.get('page') products = … -
In Django, how to find out what URL pattern matched for a request?
I'm working on an old Django project with a lot of URL patterns. Sometimes, it's not clear for me which view was run by the dispatcher. Is there any way to see what URL pattern matched for a particular request in Django? -
How filter manytoManyfield before pre choice
I have 2 fields team=models.ForeignKey(Team) players=models.ManytoManyField(Player) when creating a match, when I select a team I want to list the players of that team so that I can choose which players will play in the match. (I want to filter because there are hundreds of maybe thousands of players. I don't want to see the players of other teams.) like this; players=models.ManytoManyfield(players,filter=xxx.team.players) -
How I can add a button to django-tables2 to trigger a modal for deleting entries?
So I made a view with django-tables2 to view user entries and I wanted to show a columns of actions So I thought i could use TemplateColumn to add the buton for triggering the modal however it doesn't trigger when i click the button. Tables.py import django_tables2 as tables from django_tables2.columns import TemplateColumn from .models import Patient,UploadedImages from django_tables2.utils import A # alias for Accessor class PatientTable(tables.Table): FirstName = tables.Column(linkify=("patients:patient_detail", {"pk": tables.A("pk")})) LastName = tables.Column(linkify=("patients:patient_detail", {"pk": tables.A("pk")})) Telephone_no = tables.Column(linkify=("patients:patient_detail", {"pk": tables.A("pk")})) edit = tables.LinkColumn('patients:patient_update',text='Edit', args=[A('pk')], attrs={ 'a': {'class': 'btn btn-primary'} }) # delete = tables.LinkColumn('patients:patient_delete', text='Delete', args=[A('pk')], attrs={ # 'a': {'class': 'btn btn-danger'} # }) delete = TemplateColumn('<a class="btn btn-danger" data-toggle="modal" data-target="#modalDelete" >Edit</a>') class Meta: model = Patient attrs = {'class': 'table table-striped table-hover'} exclude = ("user", "Notes", "Adress") template_name = 'django_tables2/bootstrap4.html' views.py @login_required def Patients_list(request): patients = Patient.objects.all() table = PatientTable(patients.filter(user=request.user)) RequestConfig(request).configure(table) return render(request, 'patients/patients_list.html',{ 'table' : table, 'patients':patients, }) and here's the template {% extends 'base.html' %} {% load render_table from django_tables2 %} {% block content %} <div id="content"> {% if user.is_authenticated %} <h1> Patients list: </h1> <br> <a href="{%url 'patients:patient_create'%}" class="btn btn-info" role="button">Add Patient</a> <br> <br> {% render_table table %} {% else %} <h2>please login</h2> {% … -
how to tell which ini file the current uwsgi process is using?
In an operating website with Nginx, Uwsgi and Django. and it has tons of venv and django projects. Is it any way I can tell with .ini file the uwsgi loaded? -
How to let existing entries empty when using auto_now_add?
I added a field to my existing model : creation_date = models.DateTimeField( auto_now_add=True, blank=True, null=True) When applying the migration, auto_now_add is applied to all existing entries. How to avoid that ? creation_date must remain null for all data recorded before the migration is applied. -
How i can calculate sum of n based on id?
I have a QuerySet like this. I want sum of "n" based on "id". this is my queryset: <QuerySet [{'id': 1, 'n': 0}, {'id': 2, 'n': 0}, {'id': 2, 'n': 1}, {'id': 3, 'n': 2}, {'id': 4, 'n': 0}, {'id': 5, 'n': 1}, {'id': 5, 'n': 0}]> and this is my code: drivers = Driver.objects.values('id').annotate( travel_time=Sum(Case( When(car__ride__pickup_time__isnull=False, then=(F('car__ride__dropoff_time') - F('car__ride__pickup_time'))), default=0 )), ).annotate( n=Case( When(Q(travel_time__gt=t) & Q(car__model__gte=n), then=Count('car__ride')), output_field=IntegerField(), default=0 ) ).values('id', 'n') i dont know how to make a group by based on id :( -
Bookmarklets and Django authentication
I have developed 2 bookmarklets for accessing 2 different web services through a sort of "gateway" or "proxy". Since they are addressed to registered users of a learning platform based on Django, I try to limit the access to users that authenticated to said platform and click on the bookmarklets from a tab of the same browser window. In the first of the 2 bookmarklets, which sends a GET request, this trick works, while in the other one, which sends a POST request, it fails. Bookmarklet 1. (inspired from the xAPI Bookmarklet) In the simplest case the user, while navigating the web, wants to declare that it has seen (and found interesting) a web page. When s/he clicks on the bookmarklet button, the javascript code collects some info and sends it to a "view" of the Django platform as URL-encoded data inside the querystring of a GET HTTP request. Django verifies that the user is authenticated and sends an xAPI statement to an xAPI LRS (learning record store) of which it owns the credentials. Bookmarklet 2. The user, while navigating the web, wants to ask a specialized web application to perform some text analysis of the content of a web … -
New field in annotation destroys all field types django
I need to load all stats one by one for each user's account. I used annotate() to connect and calculate other related models fields, but one of the field, while added - destroys all types and multiplies integer by 10 somehow in previous fields in queryset. I have 3 models: AdvertisingAccount, Campaign, UserProfile. I've tried casting for all the fields, but it didn't changed the picture: I need integers to be integers, and decimals to be decimals with 2 decimal places (as set in models). expected: ads_direct 313 303 31.12 2165.18 but recieved: ads_direct 3443 3333 342.320000000000 8441.80000000000 code in views: (I need these fields be calculated) accounts = user.userprofile.advertising_accounts.annotate( clicks=Cast(Sum('campaigns__clicks', filter = Q(campaigns__userprofile = userprofile)), IntegerField()), views=Cast(Sum('campaigns__views', filter = Q(campaigns__userprofile = userprofile)),IntegerField()), ad_spent=Cast(Sum('campaigns__ad_spent', filter = Q(campaigns__userprofile = userprofile)),DecimalField(decimal_places=2)), money_left = Sum('budgetings__deposited', filter = Q(budgetings__userprofile = userprofile)) - (Sum('campaigns__ad_spent', filter = Q(campaigns__userprofile = userprofile))), ) Note If I comment out money_left, all annotations calculates and presents OK (except decimal place: it takes 12 places, instead of 2). I've tried this, but it didnt change situation: accounts = user.userprofile.advertising_accounts.annotate( clicks=Cast(Sum('campaigns__clicks', filter = Q(campaigns__userprofile = userprofile)), IntegerField()), views=Cast(Sum('campaigns__views', filter = Q(campaigns__userprofile = userprofile)),IntegerField()), ad_spent=Cast(Sum('campaigns__ad_spent', filter = Q(campaigns__userprofile = userprofile)),DecimalField(decimal_places=2)), money_left = Cast((Sum('budgetings__deposited', … -
how to send data from the view to the header or the navigationBar
i have django website that have a navigation bar where i need to display the user and the group that belong to it in the navigation bar in order to make it visible on all pages. until now i am bale to send these data to a specific page and not to the header. views.py def home(request): #print(User.groups.get()) print(request.session.keys()) if request.session.has_key('theUser'): authed=request.session['theUser'] if request.session.has_key('group'): sections=request.session['group'] return render(request,'./mainpage.html',{'sections':sections,'authed':authed}) else: authed=None else: authed=None return render(request,'./Login.html',{'authed':authed}) where i am sending {'sections':sections,'authed':authed} to mainpage.html mainpage.html <div id='left-column-Input' class="formInput" include="select()"> {{user.get_username}}|{{sections}} what i need is to send the data to the header or the base file. base.html <!DOCTYPE html> {% load static %} <html> <head> <script type="text/javascript" src="{% static '/js/jquery-3.1.1.min.js' %}"></script> <link rel= "icon" type= "image/png" href="{% static 'img/logo_title/icon-AddressBar.png'%}"> <link rel="stylesheet" type="text/css" href="{% static '/css/search.css'%}"> <link rel="stylesheet" type="text/css" href="{% static '/css/style.css'%}"> </head> <body> <img class="logoMM" src="{% static 'img/logoMM.png' %}" alt="Smiley face" /> <!-- <div class="wrap"> --> <div class="wrap search Horizontal-scale"> <!-- <div class="Horizontal-scale"> --> <button type="submit" class="searchButton"> <svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="search" role="img" viewBox="0 -20 530 530"><path fill="currentColor" d="M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 … -
Updating model on save vs count objects in the ListView - what's better performance-wise?
I'm creating a forum script. Currently I'm trying to optimize things and looking for answer from more experienced developers. For example - let's assume we are working on ListView of Category, which should list all threads within the same forum category. For every thread in category we are listing fields such as: Thread name Thread author Number of posts Number of views Last post details (a uthor, date) What is the best performance approach to calculate number of posts? Currently I'm thinking about 3 of them. Use annotate() on queryset add IntegerField posts_number to Thread model. Increment the value on save() in Post model and decrement on delete() Use memcache to cache read-only SQL queries and force cache refresh on every save() in Post model. I'm aware this is not an issue with low traffic forums, but I would love to know what's the best approach -
How to change file system encoding in django on centOS
Filesystem encoding (sys.getfilesystemencoding()) in Django returns "ascii", although in centOS system the returning value is "utf-8" As a result of the invalid encoding I get the UnicodeError during the uploading files with Cyrillic name. I've tried: sys.getfilesystemencoding = lambda: 'UTF8' set Django DEFAULT_ENCODING as 'UTF8' In interpreter on CentOS: >>> sys.getfilesystemencoding() 'utf-8' Then I added this code in views.py: loc_info = "fs_encoding: " + str(sys.getfilesystemencoding()) return django.http.HttpResponse(loc_info) And I got: fs_encoding: ascii I want to get the value "UTF8" as the result of the function sys.getfilesystemencoding() in Django -
router.register(), AttributeError: module 'rest_framework.views' has no attribute
I don't know what I am doing wrong. I have been battling with this error for hours. I have opened all the suggestions I saw and implemented what they suggested but still, the error is pending router.register(r'^hmos/$', views.HMOList), AttributeError: module 'rest_framework.views' has no attribute 'HMOList' This is "core/urls.py" from django.conf.urls import url from .views import * from django.urls import path from rest_framework.urlpatterns import format_suffix_patterns from rest_framework_jwt.views import obtain_jwt_token,refresh_jwt_token from rest_framework.routers import DefaultRouter router = DefaultRouter() router.register('hmos', views.HMOList) urlpatterns = format_suffix_patterns(urlpatterns) This is "core/views.py" from django.shortcuts import render_to_response import json from rest_framework.parsers import MultiPartParser, FileUploadParser, FormParser from django.db.models import Q from rest_framework import permissions from django.contrib.auth import authenticate, login,logout from rest_framework import generics, status, views from rest_framework.permissions import IsAuthenticated from .models import * from .serializers import * from rest_framework.response import Response from rest_framework_jwt.authentication import JSONWebTokenAuthentication from rest_framework.permissions import IsAuthenticated from .utils import generate_responder_serial from rest_framework.parsers import MultiPartParser, FileUploadParser, FormParser from django.conf import settings import os from django.db.models import Q #from rest_framework.authentication import (BaseJSONWebTokenAuthentication) from rest_framework import viewsets def jwt_response_payload_handler(token, user=None, request=None): return { 'token': token, 'user': SystemUserSerializer(user).data } def create(self, request, *args, **kwargs): new_data = {'name': request.data['name'].strip(), 'address': request.data['address'], 'state': request.data['state'], 'mobile1': request.data['mobile1'], 'mobile2': request.data['mobile2'], } if HMO.objects.filter(name = request.data['name'].strip()): raise … -
Change Boolean value inside template?
In Django I am creating registration form for multiple user types. I have set in models Boolean field which is set to false. My form file has registration fields where Boolean equal to false. I have registration view. Is there any possibility to change Boolean value inside template? I need that after registration in created user Boolean field has become true. I do not need to print Boolean at all. -
How to get Custom made Django Model Form's id in html Template
I want to get the Form id if is possible from the templates using django : my form.py class Post_Votes_form(forms.ModelForm): class Meta: model = Post_votes fields = ['vote',] my models.py class Post_votes(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE,) post_id = models.ForeignKey(Post, on_delete=models.CASCADE,) vote = models.BooleanField() In my html i tried something like this to get this forms's id "{{vote_form.auto_id}}" but with this i am getting in the template this "id_%s" : {% if vote_form %} <form method="post" id="{{vote_form.auto_id}}" > {% csrf_token %} {{ vote_form.vote }} {% endif %} </form> I know i can add by myself any id name for this form id, but i wanted to know if there is any other way to get id for the whole form like we have for the form.fields id with this code : form.field.auto_id. -
How to take only the integer items and calculate sum from the list? [duplicate]
This question already has an answer here: Understanding slice notation 31 answers Filter a list in python get integers 4 answers Here i have list with product name and product price but i want to take only the products price from the list and calculate the total price of all products. How can i do it ? For example i have a list: all_products = ['food',1000,'pasta',500,'beer',400] how can i do : 1000+500+400 = 1900 -
How to fill user field in any QuerySet from template by pressing button - Django?
In models: class Match(models.Model): user = models.ManyToManyField(User, blank=True) player_name = models.CharField(max_length=30, null=True, blank=True) player_credit = models.IntegerField(null=True, blank=True) hot_league = models.ManyToManyField('HotLeague', blank=True) class HotLeague(models.Model): user = models.ManyToManyField(User, blank=True) price_pool = models.IntegerField() winner = models.IntegerField() entry = models.IntegerField() In views: def hot_league_details(request, match_id, hot_league_id): match = get_object_or_404(Match, pk=match_id) hot_league = get_object_or_404(match.hot_league, pk=hot_league_id) context = { 'match': match, 'hot_league': hot_league, } return render(request, 'main/hot_league_details.html', context=context) In templates: <div class="col"> Price Pool <h4 style="color:red;" class="pt-1">TK. {{ hot_league.price_pool }}</h4> </div> <div class="col text-center" style="font-size: 12px; padding-top: 5px;"> <div>{{ hot_league.winner }} Winners</div> <div class="d-flex justify-content-end"> <button type="button" class="btn btn-danger btn-sm">TK. {{ hot_league.entry }}</button> </div> </div> In admin site, I put the value for Match and HotLeague model without filling user field. user field is now empty. It will be filled by user. In template, when any logged in user press the button then in my Match and HotLeague model's QuerySet(specifically the user field) will update with this logged in user automatically..That means, now user field is not be empty. It is now filled by user and other fields remain same.... Like, in any online market place when user add any product in cart, then all the information of that product can be accessed by this user … -
Create object when created another object in Django
Is it possible to create object when I created another object in Django? I have code like this and I would like to create AnotherModel instance firstly and then Model instance (when creating AnotherModel). class Model(models.Model): name = models.CharFiled(max_length=50) class AnotherModel(models.Model): model = models.ForeignKey(Model, on_delete=models.CASCADE) description = models.TextField() I tried use Django signals - pre_save. @receiver(pre_save, sender=AnotherModel) def save_model(sender, **kwargs): # some code But I have exception like this: ValueError: Cannot assign "u'Test": "AnotherModel.resource" must be a "Model" instance. -
How to prepare django app for deploying on server?
I followed a tutorial from a site and I deployed my django app on pythonanywhere.com.For this purpose I had to use git to upload codes.As a result my settings.py file was accessible by anybody.so any one could see my secret key on settings.py .It is not good right? I also left DEBUG = True later I found it is not secure.Then I set DEBUG = False on my local machine and it showed it need allowed hosts.What are those things? what should I do? Where can I learn about these? -
Can't restart nginx in django deployment app
I'm trying to follow this tutorial for deployment a django app in my droplet, but in the step four, when said: Now restart NGINX with the command below and you should be set: I have to run the follow command: sudo service nginx restart but I got this error: Failed to restart ngnix.service: Unit ngnix.service not found. I know that I need the file nginx.service but I didn't find a question about this... How can I fix it? -
Difference between debugger output and console output on Post return
I have a page with a table where the user selects records that they want to view using tags. When they hit submit I get the request.POST response that I am expecting. In the Pycharm debugger I can see all the responses that the user selected <QueryDict: {'csrfmiddlewaretoken': ['bkyQPyYtqh8ewWMPKIx34Lm9RPcBXq12FfYaidlbPQkotFxMi6vwWXhCqZjk48pA'], 'record': ['employer_addr_id=32003931&employer_trd_id=32004927&employer_reg_id=None', 'employer_addr_id=32005506&employer_trd_id=32006550&employer_reg_id=None', 'employer_addr_id=32006030&employer_trd_id=32007075&employer_reg_id=None', 'employer_addr_id=32006957&employer_trd_id=32008002&employer_reg_id=None']}> However, in the code and when I am using the console debugger if I type request.POST['record'] I only get the last record 'employer_addr_id=32006957&employer_trd_id=32008002&employer_reg_id=None' Any suggestions on what is going on here? -
change function based view in Class Based View for Form "request" handling
I am following a tutorial where a Cart is made for Products handling. the is a function to add the items in the cart as @require_POSTdef cart_add(request, product_id): cart = Cart(request) product = get_object_or_404(Product, id=product_id) form = CartAddProductForm(request.POST) if form.is_valid(): cd = form.cleaned_data cart.add(product=product, quantity=cd['quantity'], update_quantity=cd['update']) return redirect('cart:cart_detail') and the second one is def product_detail(request, id, slug): product = get_object_or_404(Product, id=id, slug=slug, available=True)cart_product_form = CartAddProductForm() return render(request,'shop/product/detail.html',{'product':product,'cart_product_form': cart_product_form}) How can I change these two codes into ClassBasedViews? What will be better? using thesamefunction based views or the ClasBased? from django import formsPRODUCT_QUANTITY_CHOICES = [(i, str(i)) for i in range(1, 21)]class CartAddProductForm(forms.Form): quantity = forms.TypedChoiceField( choices=PRODUCT_QUANTITY_CHOICES, coerce=int) update = forms.BooleanField(required=False, initial=False, widget=forms.HiddenInput) this is forms.py in CartApp. The cart has a class called Cart which requires request,Product from the form. How can I pass that information to cart using CBV? -
How can I do to filter on the dates
I am programming using django and I have this variable : a = '2019-08-03' And I have a database with two columns start and end like this : start = 2019-08-01 00:00:00.000000 end = 2019-08-15 00:00:00.000000 Obviously start and end have many values. I would like to get the rows which a is between start and end. How can I do ? I thought to something like this : c = myObject.objects.filter(mycondition) but I guess I have to do a conversion right and then something like between... Could you help me please ? I precise I can modify a like thisa = 2019-08-03 00:00:00.000000 -
How to migrate HUE 4.2 to HUE 4.4 on EMR cluster
I'm currently running an EMR 5.17.0 cluster with HUE 4.2, now I'm planning to upgrade my EMR to 5.24 and migrate the HUE from 4.2 to 4.4. I've followed the instruction from AWS "How to migrate a Hue database from an existing Amazon EMR cluster" But I got below exception when I try to import the hue-mysql.json from my new cluster! seems the schedule not be supported on HUE 4.4, does anyone have any good suggestions on how to fix this? [hadoop@ip-172-31-21-127 ~]$ sudo /usr/lib/hue/build/env/bin/hue loaddata hue-mysql.json Traceback (most recent call last): File "/usr/lib/hue/build/env/bin/hue", line 14, in <module> load_entry_point('desktop', 'console_scripts', 'hue')() File "/usr/lib/hue/desktop/core/src/desktop/manage_entry.py", line 216, in entry execute_from_command_line(sys.argv) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11.20-py2.7.egg/django/core/management/__init__.py", line 364, in execute_from_command_line utility.execute() File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11.20-py2.7.egg/django/core/management/__init__.py", line 356, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11.20-py2.7.egg/django/core/management/base.py", line 283, in run_from_argv self.execute(*args, **cmd_options) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11.20-py2.7.egg/django/core/management/base.py", line 330, in execute output = self.handle(*args, **options) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11.20-py2.7.egg/django/core/management/commands/loaddata.py", line 69, in handle self.loaddata(fixture_labels) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11.20-py2.7.egg/django/core/management/commands/loaddata.py", line 109, in loaddata self.load_label(fixture_label) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11.20-py2.7.egg/django/core/management/commands/loaddata.py", line 166, in load_label for obj in objects: File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11.20-py2.7.egg/django/core/serializers/json.py", line 88, in Deserializer six.reraise(DeserializationError, DeserializationError(e), sys.exc_info()[2]) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11.20-py2.7.egg/django/core/serializers/json.py", line 82, in Deserializer for obj in PythonDeserializer(objects, **options): File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11.20-py2.7.egg/django/core/serializers/python.py", line 129, in Deserializer field = Model._meta.get_field(field_name) File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11.20-py2.7.egg/django/db/models/options.py", line 619, in get_field raise … -
Is there any downside to Django proxy models?
I'm getting rather tired of paging through lots of irrelevant little fiddly properties while looking for the actual database structure of my models. Would it be a bad thing to use proxy models universally just to keep my code better organized / more readable? I.e. class Foo_Base( models.Model): title = models.CharField( ...) # other DB fields. As little as possible anything else. class Bar_Base( models.Model): foo = models.ForeignKey( Foo_Base, ... ) etc. not many more lines than there are columns in the DB tables. Then at the bottom or elsewhere, class Foo( Foo_Base): class Meta: proxy=True @property def some_pseudo_field(self): # compute something based on the DB fields in Foo_Base return result @property # etc. pages of etc. The fact that makemigrations and migrate tracks proxy models makes me slightly concerned, although this usage seems to be exactly what the Django documentation says they are for (wrapping extra functionality around the same database table). Or is there another way to organize my code that accomplishes the same (keeping fundamental stuff and fiddly little support bits apart). (About the only thing I dislike about Python, is that it does not have include functionality for reading in a heap of code from another …