Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django template - set checkbox checked if object.val == true
I'm junior backend dev. I don't know how to use JS. I can't set <input type="checkbox" name="player_check"> true... or reverse i can't set <input type="checkbox" name="player_check" checked> false. My code: <table id="some_table"> <thead> <tr> <th>Prepared</th> </tr> </thead> <tbody> {% for player in players %} <tr> <td> <input type="checkbox" name="player_check"> </td> </tr> {% endfor %} </tbody> </table> Let's say in 'players' I have 5 players, each player has a value "player_check". Two of them have: player.player_check = True Rest: player.player_check = False I'm trying to initiate checkbox in my table with these values using {{}} or {% %} I've tried: <input type="checkbox" name="player_check" value=1> <input type="checkbox" name="player_check" value="1"> <input type="checkbox" name="player_check" value="True"> <input type="checkbox" name="player_check" value=True> <input type="checkbox" name="player_check" value="checked"> Nothing works... Then i found that checkbox has a parametr checked so: <input type="checkbox" name="player_check" checked> That was ok BUT... now i cant turn it off: <input type="checkbox" name="player_check" checked="false"> <input type="checkbox" name="player_check" checked="0"> <input type="checkbox" name="player_check" checked=0> <input type="checkbox" name="player_check" checked="unchecked"> So i decided to use django templpates + change in python code: Now player.player_check equals checked or unchecked It still doesn't work! Now i can't put {{ }} without name like "something"={{ foo }} Now i have 0 ideas … -
How to create a search model in django
I want to create a search panel. There will be many fields to fill out and if user doesn't fill out something I want to select all records from database for this parameter. And I am wondering how to do this in django model ? In raw MySQL that'd be ease, but I don't now how to set up conditions, for example , if user filled out field Name select only this choice, if not, select all Are there best practices for this kind of problem ? Thanks in advance, -
Automatically populate Django model database tables with unreal data
I'm working on a template inside one of my apps and I need to have a lot of records in a table to see how it looks like (and several other behaviors) in the template. I don't want to waste my time inserting over 30 records one by one. I'm trying to do a bulk insert but I have no previously dumped data or such to populate using it. The correctness of data is not important to me. the quantity is important. Does that do anything with mocking? I'm not trying to unit test anything. -
Django-cms | Django-Template (Key Error at /) | DuplicatePlaceholderWarning
This is what I'm getting whenever I'm adding child ImageUpload plugin and viewing it And Please guide me how to render parent and child plugin in templates and is there any issues with placeholder thing while rendering(I mean do we need to assign different names to placeholder while rendering it?) /Users/Sayan/Library/Python/2.7/lib/python/site-packages/cms/utils/placeholder.py:251: DuplicatePlaceholderWarning: Duplicate{% placeholder "content" %} in template fullwidth.html. DuplicatePlaceholderWarning) My models.py file for this plugin: class ImageUpload(CMSPlugin): image_file_1 = models.ImageField() pdf_doc_1 = models.FileField() pdf_doc_text_1 = models.CharField(max_length=20) input_text_1 = models.CharField(max_length=1000) button_class = models.CharField(max_length=20) My cms_plugins.py file: class ImageUploadParentPlugin(CMSPluginBase): model = CMSPlugin render_template = "image_upload_parent.html" allow_children = True class ImageUploadChildPlugin(CMSPluginBase): model = ImageUpload require_parent = True parent_classes = ['ImageUploadParentPlugin'] render_template = "image_upload_child.html" cache = False def render(self, context, instance, placeholder): context = super(ImageUploadChildPlugin, self).render(context, instance, placeholder) return context My image_upload_parent.html file {% load cms_tags %} <div class="intro"> <div class="row"> {% for plugin in instance.child_plugin_instances %} {% render_plugin plugin %} {% endfor %} </div> My image_upload_child.html file <div class="ttfeast col-sm-6 col-xs-12"> <img class="img-responsive" src="{{instance.image_file_1.url}}"> <div class="south-txt"> {{instance.input_text_1}} </div> <div> <a href="{{instance.pdf_doc_1.url}}" target="_blank"> <div class="{{instance.button_class}}"> {{instance.pdf_doc_text_1}} </div> </a> </div> -
How I can post my four kind of post with prioritizing it.
I'm working on a project, using Django 2.06. I have four model to maintain four kinds of posts from users and have to show it on one page. class QuickWordView(ListView): template_name = "index.html" queryset = QuickWord.objects.all() context_object_name = 'quickword' def get_context_data(self, **Kwargs): context = super(QuickWordView, self).get_context_data(**Kwargs) thought = QuickWord.objects.all() add_product = AddProduct.objects.all() article = Article.objects.all() official_letter = OfficalLetter.objects.all() context['addproduct'] = add_product context['article_view'] = article context['official_letter'] = official_letter return context Ps: sorry for spacing at the template section, I used four For tags to show the user post. Now, i want to show with priority such as I have add product, article, letter model. if I post an article it loop through at the article section to the template. such as shohan Ceo Article General It Is Unclear Whether The federal government has quietly revived its investigation into the murder of Emmett Till, the 14-year-old African-American boy whose abduction and ... Keep it 2 hours ago shohan Ceo Article General It Is Unclear Whether The federal government has quietly revived its investigation into the murder of Emmett Till, the 14-year-old African-American boy whose abduction and ... Keep it 2 hours ago shohan Ceo, Hubblelook Article General Although Two White Emmett was … -
pip install virtualenvwrapper-win shows error:
I am trying to install django in my windows 7 machine, as a prerequisite I am installing virtualenvwrapper. pip install virtualenvwrapper-win But it throws the following error: Error [WinError 87] The parameter is incorrect while executing command pytho n setup.py egg_info Could not install packages due to an EnvironmentError: [WinError 87] The paramet er is incorrect python version : Python 3.7.0b4 pip version: pip 10.0.1 -
Python/Django/Q search, How to find B field info. by searching A field info
from Python, Django DB This is my DB first data {title:'1', price:'20'} second data {title:'2', price:'30'} third data {title:'1', price:'10'} I want to DO this find title '1' and then return price fileds expectation result: {title:'1', price:'20'} {title:'1', price:'10'} My code (Views.py) @csrf_exempt def searching(request): if request.method == "POST": parameter = request.POST.get('title') searchResult = NaverData.objects.filter(Q(title__icontains=parameter)).distinct() ouput = searchResult return HttpResponse(ouput) else: #GET request return HttpResponse('GET REQUEST') -
django ListView with auto suggest search box
i am making a simple site in django. what i want is search box and when a string is entered return a list of matching strings in dropdown as suggestions (based on strings defined in model) for ex searching for books. My current solution: i have a html page and on keyup event i send a get request and for that i have a view defined , it fetches data from db and return it and i dispay it in suggestions and it works completely fine. My question: but what i to know is can i use a ListView here? becuase i want a list of results to be displayed. is this overly complicting things which i got working in a simple manner as i said? -
Django authorization error encountered using syncdb to remote Postgres database
The Situation: In our company, each developer has their own server where the full development stack gets installed. We have a build script that builds out the whole environment on that server, including Django, Python, and the PostgreSQL database. I am in the process of upgrading the database from PostgreSQL 9.4 to PostgreSQL 10. Since the developers need to main access to both versions of the database, while we go through the upgrade process, I have setup a database server for the new version and have modified the build script to look to the remote database server for all database calls. The Problem: The build script uses, along with SQL commands, manage.py to build the database on the remote server - the command executed is: python manage.py syncdb --noinput --database=default Access to each database being built (there are three total, default is just the main db) is controlled via two mechanisms: (1) a local ~/.pgpass file that specifies the host, port, database name, user and password. Sample ~/.pgpass file: #hostname:port:database:username:password localhost:5432:*:user:pass fqdn.net:5432:*:user:pass and (2) an entry in the pg_hba.conf file on the database server which details the database, user, networks allowed to access, and the authentication method allowed. The relevant … -
Prompt the errors form forms using flat structure code
I prompt the users error in form with triple nested code as: {% for field in form %} {% if field.errors %} {% for error in field.errors %} <div class="alert alert-danger"> {{ field.label }}: {{ error }}</div> {% endfor %} {% endif %} {% endfor %} Could such a multiple nested structure be achieved in a straightforward way? -
Error 'docker' is not recognized as an internal or external command
I already install docker with this command in django: pip install docker But when i try to run docker command, it give me error -- it is not recognize.. what is wrong? -
Cannot find reverse lookup of User model
I am using Django 2.0 and I have created a custom user model, if it helps. I want to be able to retrieve the set of role instances for a given user account. A user account can be included as an Owner or an Employee for a given Company instance. However, when I am trying to do user.employee_set (or user.owner_set), then I get no results. User Class class User(AbstractBaseUser): email = models.EmailField(max_length=254,unique=True,null=False,blank=False) staff = models.BooleanField(default=False) admin = models.BooleanField(default=False) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] def __str__(self): return self.get_full_name() def get_full_name(self): return self.first_name + " " + self.last_name def get_short_name(self): return def has_perm(self, perm, obj=None): "Does the user have a specific permission?" # Simplest possible answer: Yes, always return True def has_module_perms(self, app_label): "Does the user have permissions to view the app `app_label`?" # Simplest possible answer: Yes, always return True @property def is_active(self): return self.active @property def is_staff(self): return self.staff @property def is_admin(self): return self.admin Employee Class class Employee(models.Model): class Meta: unique_together = (('user','company'),) user = models.ForeignKey(to=User,on_delete=models.CASCADE,related_name='employee_accounts') company = models.ForeignKey(to='Company',on_delete=models.CASCADE) Owner Class class Owner(models.Model): class Meta: unique_together = (('user','company'),) user = models.ForeignKey(to=User,on_delete=models.CASCADE,related_name='owner_accounts') company = models.ForeignKey(to='Company',on_delete=models.CASCADE) When I lookup either user.owner_accounts or user.employee_accounts, then I get an empty set of results. … -
How to access media folder in django-react
I'm currently using django with react on my current project. My media folder is located in localhost:9000/media. But my react app runs on localhost:3000. I already set a proxy setting in my package.json. Whenever I access localhost:9000/media/image, it works. How do I use this in react? localhost:3000/media/image returns an empty page. Pls help thank you! -
Creating a super user that is not able to access admin site
I am creating an admin user using the following code. However this user is unable to login. Any suggestions on why this user cant log in to the admin site user = User.objects.create(username = "joe",first_name="jordan", last_name="...", email="jordan@gmail.com", password="admin123",is_staff=True,is_superuser=True) The username is joe and password is admin123 however this user cant login -
how to reverse the URL of a ViewSet's custom action in django restframework
I have defined a custom action for a ViewSet from rest_framework import viewsets class UserViewSet(viewsets.ModelViewSet): @action(methods=['get'], detail=False, permission_classes=[permissions.AllowAny]) def gender(self, request): .... And the viewset is registered to url in the conventional way from django.conf.urls import url, include from rest_framework import routers from api import views router = routers.DefaultRouter() router.register(r'users', views.UserViewSet, base_name='myuser') urlpatterns = [ url(r'^', include(router.urls)), ] The URL /api/users/gender/ works. But I don't know how to get it using reverse in unit test. (I can surely hard code this URL, but it'll be nice to get it from code) According to the django documentation, the following code should work reverse('admin:app_list', kwargs={'app_label': 'auth'}) # '/admin/auth/' But I tried the following and they don't work reverse('myuser-list', kwargs={'app_label':'gender'}) # errors out reverse('myuser-list', args=('gender',)) # '/api/users.gender' In the django-restframework documentation, there is a function called reverse_action. from api.views import UserViewSet a = UserViewSet() a.reverse_action('gender') # error out from django.http import HttpRequest req = HttpRequest() req.method = 'GET' a.reverse_action('gender', request=req) # still error out What is the proper way to reverse the URL of that action? -
Django1.10 Error: django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS
I am using Django 1.10, and trying to use the django-dynamic-scraper package following the tutorial: http://django-dynamic-scraper.readthedocs.io/en/latest/getting_started.html I have encountered the problem when I was calling "python manage.py makemigrations" :RuntimeError: Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS. The full version is: Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line utility.execute() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/__init__.py", line 359, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 305, in run_from_argv self.execute(*args, **cmd_options) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute self.check() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 385, in check include_deployment_checks=include_deployment_checks, File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 372, in _run_checks return checks.run_checks(**kwargs) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/checks/registry.py", line 81, in run_checks new_errors = check(app_configs=app_configs) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/checks/urls.py", line 14, in check_url_config return check_resolver(resolver) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/checks/urls.py", line 24, in check_resolver for pattern in resolver.url_patterns: File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/urls/resolvers.py", line 310, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/urls/resolvers.py", line 303, in urlconf_module return import_module(self.urlconf_name) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line … -
Django, Heroku: Build succeeded buy app crash error code = H10
Followed the MDN Tutorial for web client deployment here: https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Deployment I managed to get everything working until the last step where I opened my Heroku App. However, there was an error code =H10 and my application could not be displayed. How should I troubleshoot this? Thanks in advance! 2018-07-13T03:29:20.924110+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=coollibrary.herokuapp.com request_id=4e932070-a4a3-482e-bf04-2d4e2aced086 fwd="119.56.98.177" dyno= connect= service= status=503 bytes= protocol=https 2018-07-13T03:29:23.464662+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=coollibrary.herokuapp.com request_id=05882f35-5e3a-41e7-b394-9b6a5264e536 fwd="119.56.98.177" dyno= connect= service= status=503 bytes= protocol=https -
Django new attribute not up showing in admin dashboard after making migrations
Just some context: I took over my live website from my developer recently, I have some basic coding knowledge but I'm not very proficient. I tried adding a 'purchase_type' attribute to the Product model, but the new attribute is not showing up in the admin dashboard even after making migrations. When I query the database however, the attribute is there and returns the right value. Added 'purchase_type' to models.py: class Product(models.Model): index_number = models.IntegerField(default=None, blank=True, null=True) name = models.CharField(max_length=500, blank=True, null=True) coming_soon = models.BooleanField(default=False) retail_price = models.DecimalField(max_digits=100, decimal_places=2, default=None, null=True) calories = models.IntegerField(default=None, blank=True, null=True) protein_class = models.CharField(max_length=500, blank=True, null=True) carb_class = models.CharField(max_length=500, blank=True, null=True) fat_class = models.CharField(max_length=500, blank=True, null=True) purchase_type = models.CharField(max_length=500, default="Subscription") Added 'purchase_type' into the fieldsets in admin.py: class ProductAdmin(admin.ModelAdmin): list_display = ("name", "index_number", "coming_soon", "retail_price", "calories", "protein_class", "carb_class", "fat_class") search_fields = ("name",) list_filter = ("protein_class", "carb_class", "fat_class") ordering = ("index_number",) fieldsets = ( ("Main Info", { "fields": ("index_number", "name", "coming_soon", "retail_price", "calories", "protein_class", "carb_class", "fat_class", "purchase_type"), }), Ran the following commmands in running order: ./manage.py migrate ./manage.py makemigrations webapp ./manage.py migrate When I query the database for purchase_type, the correct value is returned: ./manage.py shell from webapp.models import Product print(Product.objects.values('purchase_type')) [{'purchase_type': u'Subscription'}, {'purchase_type': u'Subscription'}, {'purchase_type': u'Subscription'}, … -
Django: inlineformset 'attribute has no file associated with it' error
I have a inline formset set I can upload multiple instances of a model at once. How do you add a file? I keep getting that this error message 'The 'document' attribute has no file associated with it.' Error happens here: if formset.is_valid(): Models class A(models.Modle): total ... class B(models.Model): invoice_id = models.ForeignKey(A) misc_amt... = models.DecimalField(default=0.00, max_digits=100, decimal_places=2) document = models.FileField(upload_to='images/', blank=True) if I add this property, I get a different error: datastructures.MultiValueDictKeyError: "'b-0-id'" @property def document_url(self): if self.document and hasattr(self.document, 'url'): return self.document.url formset BFormSet = inlineformset_factory(A, B, extra=0, widgets={ 'misc_amt':forms.TextInput(attrs={'size': '6',}), 'document':forms.FileInput(attrs={'multiple': False}), } ) HTML <form method="post" enctype="multipart/form-data">{% csrf_token %} {{ b_form.management_form }} <table class="table" > <tr class="text-center"> <td><strong>Misc.</strong></td> <td><strong>Document</strong></td> </tr> {% for form in getperinfo_form.forms %} <tr class="text-center"> <td>${{ form.misc_amt }}</td> <td>{{ form.document }}</td> </tr> {% endfor %} </table> </form> views.py class AUpdateView(LoginRequiredMixin, UpdateView): model = B form_class = BForm template_name = 'A.html' def post(self,request,*args,**kwargs): self.object =None form_class = self.get_form_class() form = self.get_form(form_class) qs = A.objects.filter( ... ) formset = BFormSet(self.request.POST,instance=qs.first()) if formset.is_valid(): return self.form_valid(formset) else: return self.form_invalid(form,formset) def form_valid(self,formset): formset = formset.save(commit=False) for i in formset: i.save() return HttpResponseRedirect(self.get_success_url()) -
Storing non-user details in Django
I'm in the planning stages of an interaction database and I'd like to have a shot at using Django to get some exposure to the big boy tools. My problem is I'm stuck at an early stage. It seems like every second website I read contradicts the one before and I can't work out how to store "person" details the Django way. I need to record profiles including name, address, dob, phone number for a number of users and non-users. The non-users will never have access, but the users will need to record their interaction with the non-user. Reporting requirements means that the interaction records will be quite straightforward. They will be based on multiple choice questions with a couple of notes sections available for anything that doesn't fit. If I was just plugging tables into a DB, I'd have a person table and store profiles there and have a users table linking to it. Would it be sensible to create a 'profile' model for the details common to both types of person and link the users table back to it by a foreign key for the actual users? Also, if I do that, does that mean that I should … -
Django: How to prevent another user from updating or deleting a post to a profile that does not correspond?
How can I prevent a user from modifying a post that does not correspond to him? Example: a user enters to: www.localhost: 8080 / profile / number / emergency / update / 1 <- avoid that the auto-incremental post that the database has (the model) I can not modify to one that does not correspond to he. Example of a view I have view.py def EmergenciaUpdate(request, emergencia_id): instancia = get_object_or_404(Emergencia,id=emergencia_id) form = EmergenciaUpdateForm(request.POST or None, instance=instancia) if request.method == 'POST': if form.is_valid(): form.save() return redirect('emergencialista') return render(request, 'app/emergenciaupdate.html', {'emergencia_update_form':form}) url.py url(r'^perfil/numero/emergencia/update/(?P<emergencia_id>\d+)/$', EmergenciaUpdate, name='emergenciaupdate'), -
Prefetch or annotate Django model with the foreign key of a related object
Let's say we have the following models: class Author(Model): ... class Serie(Model): ... class Book(Model): authors = ManyToManyField(Author, related_name="books") serie = ForeignKey(Serie) ... How can I get the list of authors, with their series ? I tried different combinations of annotate and prefetch: list_authors = Author.objects.prefetch(Prefetch("books__series", queryset=Serie.objects.all(), to_attr="series")) Trying to use list_authors[0].series throws an exception because Author has no series field list_authors = Author.objects.annotate(series=FilteredExpression("books__series", condition=Q(...)) Trying to use list_authors[0].series throws an exception because Author has no series field BUT I can get the number of series for an author, so why not the actual list of them: list_authors = Author.objects.annotate(nb_series=Count("books__series", filter=Q(...), distinct=True) list_authors[0].nb_series >>> 2 Thus I assume that what I try to do is possible, but I am at a loss regarding the "How"... -
Djagno: inlineformset field with dropdown menu choices
I have a inlineformset that I use to update multiple fields. I'm struggling to get a dropdown menu for my form. Multiplier= ( (1,0.25), (2,0.5), (3,0.75), (4,1), (5,1.25), (6,1.5), (7,1.75), (8,2), ) ChildSet = inlineformset_factory(Parent, Child, extra=0, widgets={ 'a':forms.ChoiceField(choices=Multiplier), 'b':forms.TextInput(attrs={'size': '6',}), 'c':forms.TextInput(attrs={'size': '6',}), } The form likes TextInput, but it doesn't like choicefield. Is there a better way to do this? -
pg_restore not restoring a certain table?
In a Django project, I have a model Question in the lucy_web app, but the corresponding lucy_web_question table does not exist, as seen from a \dt command in the database shell: (lucy-web-CVxkrCFK) bash-3.2$ python manage.py dbshell psql (10.4) Type "help" for help. lucy=> \dt List of relations Schema | Name | Type | Owner --------+------------------------------+-------+--------- public | auditlog_logentry | table | lucyapp public | auth_group | table | lucyapp public | auth_group_permissions | table | lucyapp public | auth_permission | table | lucyapp public | auth_user | table | lucyapp public | auth_user_groups | table | lucyapp public | auth_user_user_permissions | table | lucyapp public | defender_accessattempt | table | lucyapp public | django_admin_log | table | lucyapp public | django_content_type | table | lucyapp public | django_migrations | table | lucyapp public | django_session | table | lucyapp public | lucy_web_checkin | table | lucyapp public | lucy_web_checkintype | table | lucyapp public | lucy_web_company | table | lucyapp public | lucy_web_expert | table | lucyapp public | lucy_web_expertsessiontype | table | lucyapp public | lucy_web_family | table | lucyapp public | lucy_web_lucyguide | table | lucyapp public | lucy_web_notification | table | lucyapp public | lucy_web_package | table … -
Why do I get a 500 internal service error when doing an AJAX post in Django
I am trying to send data to my database without having to load a new page. Here is my Javascript: function submit(){ var xhttp = new XMLHttpRequest(); xhttp.open("POST", "/185post/", true); xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhttp.send("noun=bananas&userAnswer=textajaxNow"); } That will be processed by the following function in views.py: def _185post(request): joke =Joke185.objects.all().filter(noun=request.POST.dict()['noun']) _185Joke = Joke(text=request.POST.dict()['userAnswer'],source='improv') _185Joke.save() print (_185Joke) joke[0].joke.add(_185Joke) joke[0].answers += 1 print (joke[0].answers) joke[0].save() print (joke[0].save()) As you can see there are several print statements there and they all return what I expect them to, so I'm not sure why I'm getting a 500 Internal Service Error