Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django: many to many circular reference
I have a problem in my models because I have a circular reference in a many to many relationship This is a part of my web app, the Sessions are of a group (a group can have more than one session) and each Session have more than one assistant but the assistants only can be members of the session's group Here are my models: class GroupMember(models.Model): member = models.ForeignKey(Volunteer, null=True, blank=True) group = models.ForeignKey(Group) leader = models.BooleanField(default=False) created = models.DateTimeField(auto_now_add=True) def __str__(self): return '{}'.format(self.member) class Session(models.Model): name = models.CharField(max_length=250) group = models.ForeignKey(Group) assistants = models.ManyToManyField(GroupMember,through=SessionAssistant) created = models.DateTimeField(auto_now_add=True) def __str__(self): return '{}'.format(self.name) class SessionAssistant(models.Model): assistant = models.ForeignKey(GroupMember) session = models.ForeignKey(Session, null=True, blank=True, on_delete=models.CASCADE) assist = models.BooleanField(default=True) ability = models.IntegerField(null=True, blank=True, validators=[MaxValueValidator(5), MinValueValidator(1)]) performance = models.IntegerField(null=True, blank=True, validators=[MaxValueValidator(5), MinValueValidator(1)]) created = models.DateTimeField(auto_now_add=True) def __str__(self): return '{}'.format(self.assistant) -
Angular + Django REST Authentication credentials were not provided
I'm developing an API with Django REST. The client is a SPA in AngularJS running in node.js. Register and Login work fine, but when the user does logout the error message is showed: {"detail":"Authentication credentials were not provided."} I tried many solutions, like post 1 and post 2. but the problem continues. If my Angular files are in the server, my page works fine, but when I changed for a SPA created by yeoman, I have the credentials problem. My settings.py import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'y6u0gy4ij&8uoo6@p*$qukwp$-07@-1gd)@)(l!-j&wmpot4h#' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'rest_framework.authtoken', 'authentication', 'corsheaders', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', # 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'ServerLearn.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': ( 'rest_framework.permissions.IsAuthenticated', … -
Django - Change python version
I am running a Django 1.11 server that was initially started with Python2.7 I am trying to make it run on Python3, so I've decided that it would be easier to start a new project. I created a virtualenvironment with Python3 as the main version, then I ran django-admin. When I tried to see the error logs, it said that the version I was using was from python2.7 as below. Python Executable: /usr/bin/python Python Version: 2.7.12 Python Path: ['/var/www/realtranslation', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages'] I'm using apache2 and wsgi also, so I deleted wsgi for python 2.7 and started using wsgi for python3 sudo apt-get install libapache2-mod-wsgi-py3 This changed my python version, but now when I try installing packages with pip3 and including them in my settings.py installed app it won't find them. Python Executable: /usr/bin/python3 Python Version: 3.5.2 Python Path: ['/var/www/realtranslation', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages'] This are my server logs: [Mon Jun 19 21:28:03.821217 2017] [core:notice] [pid 1348:tid 139948324480896] AH00094: Command line: '/usr/sbin/apache2' [Mon Jun 19 21:28:58.155121 2017] [wsgi:error] [pid 3840:tid 139948153894656] [client 186.167.250.100:16422] mod_wsgi (pid=3840): Target WSGI script '/var/www/realtranslation/realtranslation/wsgi.py' cannot be loaded as Python module. [Mon Jun 19 21:28:58.155220 2017] [wsgi:error] [pid 3840:tid 139948153894656] … -
Issues with Algolia search indexing and Taggit Manager?
I'm having some issues implementing the Algolia search API with one of my models which contains the TaggitManager() field. I'm currently being thrown back the following error when running this command: $ python manage.py algolia_reindex AttributeError: '_TaggableManager' object has no attribute 'name' I've had a look at the Taggit documentation (http://django-taggit.readthedocs.io/en/latest/admin.html) I'm just not sure exactly how I would marry the method outlined with the Algolia search index method. index.py: import django django.setup() from algoliasearch_django import AlgoliaIndex class BlogPostIndex(AlgoliaIndex): fields = ('title') settings = {'searchableAttributes': ['title']} index_name = 'blog_post_index' models.py: from taggit.managers import TaggableManager class Post(models.Model): ...some model fields... tags = TaggableManager() -
Trouble making django-fluent-pages work in Ubuntu production server with gevent
Good morning, everyone. I am having troubles getting django-fluent-pages to work in my Ubuntu production server, running on Gunicorn with gevent. The problem seems to have something to do with gevent importing the apps at the same frame with django-fluent-pages. It works 100% fine in my localhost. I don't know what am I missing, or how to solve this. I really want to use django-fluent-pages for my project, but I can't move forward if it doesn't work in production server. Does anyone have any idea how to get it to work without clashing with gevent? Or know what's the real cause? This is the error message I get whenever I load a page. ImportError at / No module named page_type_plugins Exception Value: No module named page_type_plugins Exception Location: /var/www/tc_two/local/lib/python2.7/site-packages/gevent/builtins.py in import, line 93 Internal Server Error: / Traceback (most recent call last): File "/var/www/tc_two/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 42, in inner response = get_response(request) File "/var/www/tc_two/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 172, in _get_response resolver_match = resolver.resolve(request.path_info) File "/var/www/tc_two/local/lib/python2.7/site-packages/django/urls/resolvers.py", line 270, in resolve for pattern in self.url_patterns: File "/var/www/tc_two/local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/var/www/tc_two/local/lib/python2.7/site-packages/django/urls/resolvers.py", line 313, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/var/www/tc_two/local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__ res = … -
Django/HTML Templates
I purchased a bootstrap template that references assets files via a scripts.js file like so: var plugin_path = 'assets/plugins/'; I've been trying to reference this to my static files like so without any luck. var plugin_path = "{% static 'assets/plugins' %}"; Any suggestions on this would be much appreciated! -
Change verbose_name_plural in Dynamic Models
I am using dynamic Django models, and sometimes dealing with them is not as simple as dealing with regular models! In my case, each model has a different name once they are created, but they all inherit from the same model. So their plural names should also be different. Is there a way to change the verbose_name_plural for dynamic models? -
How to add an admin page item into navigation bar (for superuser)?
Could anybody please tell me how to realize a navigation bar containing among others an item leading to admin page? It should like this Home | Faculty | Student | Admin In the following code, it works for all items in the bar, except the 'admin' one: <ul class="nav navbar-nav navbar-right"> <li><a href="{% url 'home' %}">Home</a></li> <li><a href="{% url 'faculty' %}">Faculty</a></li> <li><a href="{% url 'student' %}">Student</a></li> <li><a href="{% url 'admin' %}">Admin</a></li> </ul> In the urls file admin is described as follows: urlpatterns = [ url(r'^admin/', admin.site.urls, name='admin'), ...] I would also appreciate if anyone enlighten me on how to make the 'admin' item visible only for superuser. Thank you very much! -
APIView (DRF) and similar Django view : how to avoid repeating the same code 2 times?
I wrote an APIView with Django Rest Framework (typically called from an external curl command) and I would like now to implement a BaseDatatableView (called in the browser) that essentially does the same: it calls the first and encapsulates the Response in a HttpResponse (I don't want to repeat the same block of code 2 times). class Process(APIView): parser_classes = (JSONParser,XMLParser) renderer_classes = (JSONRenderer,XMLRenderer,) def post(self,request): x = request.DATA.get('x', 0) # code to define documents list (fct of x) documents = self.fct(x) response = Response([d for d in documents], status=status.HTTP_200_OK) return response The code of the second view would be something like: class MyListJson(LoginRequiredMixin, BaseDatatableView): def get(self,request): request2 = request request2.DATA = request.GET response = Process().post(request2) aaData = extract_json_from(response) response_data = {'result': 'ok', 'aaData': aaData} return HttpResponse(json.dumps(response_data), content_type="application/json") How can I achieve that? Any help would be greatly appreciated. -
NoReverseMatch with django
Hey I did build a website two weeks ago and it worked perfectly fine but when I am trying to open it without any changes the NoReverseMatch found error pops up. I do not understand why. Μy view for the auswertung method is defined as auswertung(request, pk) This is my url code: urlpatterns = [ url(r'^$', views.main_page, name='main_page'), url(r'^machine/(?P<pk>\d+)/$', views.auswertung, name='auswertung'), url(r'^add$', views.add_machine, name='add_machine'), url(r'^delete$', views.delete_machine, name='delete_machine'), url(r'^machine/(?P<pk>\d+)/edit/$', views.edit_machine, name='edit_machine')] and this is the template which is producing the error: {% block content %} <div> <form class="MainFormClass" method="POST"> {% csrf_token %} {{ form }} <button type="submit" class="save btn btn-default">Submit</button> </form> <ol class="orderdList"> {% for machine in machines_only %} <p class="list-item">{{ machine.status.machine_number }} <a href="{% url 'auswertung' pk=machine.status.machine_number %}"> {{ machine.status.machine_description }} </a> <img class="main-imageClass" src="{{machine.overallsrc}}"/> </p> {% endfor %} </ol> </div> {% endblock %} I hope somebody can help me. -
Best practise for using API_KEYS and CLIENT_SECRETS within settings.py
As the title suggests - I'm looking for best practise for using API_KEYS, CLIENT_SECRETS etc etc within the settings.py of my Django project. I can't seem to find exactly what I'm looking for on this - documentation wise. So if anyone does have a bank of documentation that would be excellent. -
pycharm cached oall my output changes
Got pycharm version 2017.1. But yesterday i take little problem/ U can see that on this vidoe below https://jbsintellij.zendesk.com/attachments/token/rbEL2vop4pbwwB81XJ9N8e66S/?name=bandicam+2017-06-19+19-29-50-452.avi When i do manage.py runserver 127.0.0.1:8000 next all changes in HTML file doesn't shows in output runing server. How i can fix that. Please help me. -
Searching for the most optimal solution with Django, Docker, virtualenv and Heroku deployment
I would like to use Docker with my existing Django project in virtualenv and MySQL database. It seems to my that my solution is not optimal (BTW it is not working). My app is not finished, but I wonder if it is possible to deploy it on Heroku and working with it without publishing? I will be grateful if you could show me the best solution. To wit this is my docker-compose.yml: web: build: . command: python manage.py runserver 0.0.0.0:8000 volumes: - .:/code ports: - "8000:8000" db: image: mysql environment: - MYSQL_ALLOW_EMPTY_PASSWORD=yes - MYSQL_USER=root - MYSQL_DATABASE=pri Dockerfile: FROM python:3 ENV PYTHONUNBUFFERED 1 RUN mkdir /code WORKDIR /code ADD requirements.txt /code/ RUN pip install -r requirements.txt ADD . /code/ settings.py: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'pri', 'USER': 'root', 'HOST': 'db', } } Structure of my files looks in this way: DockerContainerDirectory: - docker-compose.yml - Dockerfile - requirements.txt - ProjectDirectory In ProjectDirectory I have virtualenv and Project: - bin - include - lib - pip-selfcheck.json - Project In Project I have git repository, back-end and front-end written in Angular2: - backendFolder - frontendFolder backendFolder: -backendProject backendProject: - my project with `manage.py` etc. -
Django smart-selects | auto_choose=False is not working
I am using smart_selects.db_fieldsChainedForeignKey I set the auto_choose option as False but that does not stop this field from automatically being selected when the number of available options is only one. class A(models.Model): chainedField = ChainedForeignKey('A', chained_field='B', chained_model_field='B', limit_choices_to={'C': 1}, auto_choose=False, show_all=False, on_delete=models.CASCADE, blank=True, unique=False, null=True) In the Django admin panel, when I use the create form, and select a value for field 'B', the 'chainedField' is automatically selected as the only available option when the number of available options is one. I would like it to pick the blank option (show as '----' in the Django admin) by default. I think setting auto_choose=False should do the trick but it isn't working. This also happens when I am editing an object in the model A. If there is an object in model A for which the 'chainedField' is blank, as soon as I open it to edit it, Django chooses the value of chainedField as the only available option instead of keeping it blank. I have to manually select the blank option every time. Can someone please help me with this? -
How to transfer django form submission from one page to another?
I am currently working my way through the following tutorial: https://www.tutorialspoint.com/django/django_form_processing.htm I am brand new to django, and the previous tutorials are the only experience I have in django, so that is obviously not much to go on. When I attempt to login using the form, I get the message: You are: Not Logged In, However the login credentials I apply are the same I applied when I created the superuser at the beginning of the tutorial, so I feel they should be valid. Here are my files: forms.py from django import forms class LoginForm(forms.Form): user = forms.CharField(max_length = 100) password = forms.CharField(max_length = 100) login.html <html> <body> <form name = "form" action = "{% url "login" %}" method = "POST" >{% csrf_token %} <div style = "max-width:470px;"> <center> <input type = "text" style = "margin-left:20%;" placeholder = "Identifiant" name = "username" /> </center> </div> <br> <div style = "max-width:470px;"> <center> <input type = "password" style = "margin-left:20%;" placeholder = "password" name = "password" /> </center> </div> <br> <div style = "max-width:470px;"> <center> <button style = "border:0px; background-color:#4285F4; margin-top:8%; height:35px; width:80%;margin-left:19%;" type = "submit" value = "Login" > <strong>Login</strong> </button> </center> </div> </form> </body> </html> urls.py (in myapp folder) from … -
How to override wagtail authentication?
When I attempt to access my wagtail back-office at /cms/, I get redirected to wagtail's login page, /cms/login/. However, I would like to use my own custom login, which is default for the rest of the site, and sits at /auth/. My LOGIN_URL is already set to /auth/ in django settings. -
Django - Generalising a Template with Optional Sidebar
I have a working solution for a template that allows for optional sidebars. Depending on the options selected by the user; significant DOM manipulations occur. The working solution is unnecessarily large and features some code duplication. It also doesn't extend nicely. I'm looking for a far more generic solution. One that allows for easier extending or abstracting so as to not have to repeat myself for every page that features a sidebar. The Working Solution {% extends "app/base.html" %} {% load wagtailcore_tags %} {% block content %} {% if self.sidebar == "left" %} <div class="row"> <div class="4u 12u(mobile)"> {% include "app/includes/sidebar.html" with sidebar_items=self.sidebar_items.all %} </div> <div class="8u 12u(mobile) important(mobile)"> <article class="box post"> {% include "app/includes/banner.html" with feed_image=self.feed_image only %} {{ self.body|richtext }} {% include "app/includes/related_links.html" with related_links=self.related_links.all only %} </article> </div> </div> {% elif self.sidebar == "right" %} <div class="row"> <div class="8u 12u(mobile)"> <article class="box post"> {% include "app/includes/banner.html" with feed_image=self.feed_image only %} {{ self.body|richtext }} {% include "app/includes/related_links.html" with related_links=self.related_links.all only %} </article> </div> <div class="4u 12u(mobile)"> {% include "app/includes/sidebar.html" with sidebar_items=self.sidebar_items.all %} </div> </div> {% else %} <article class="box post"> {% include "app/includes/banner.html" with feed_image=self.feed_image only %} {{ self.body|richtext }} {% include "app/includes/related_links.html" with related_links=self.related_links.all only %} </article> … -
Django model foreign key to Superuser
I have a django model Request which has a field Approver which is set to the User which has the superuser status. I would like to assign value to this field automatically such that it rotates among the project admins. Any suggestions are welcome. Thanks in advance. -
can't make if condition with django variable and javascript variable
i variable type table in javascript , and i need to make a test with if condition between this variable with a variable from django database but it' doesn't work : the example : var test_date = "2017-06-23"; var locations = [ {% for v in vs %} {% if v.date == test_date %} ['okok',{{ v.latitude }},{{ v.longitude}}], {% endif %} {% endfor%} ] the first example doesn't work and i don't know why. other example : var test_date = "2017-06-23"; var locations = [ {% for v in vs %} {% if v.date == "2017-06-23" %} ['okok',{{ v.latitude }},{{ v.longitude}}], {% endif %} {% endfor%} ] when i put the value of the variable in the test it's working -
Is it possible to load files(and manipulate them) in django without using static/media?
I want to pick files from a local folder using FileField model(by storing its path) and then manipulate this text files data in views and store values into different Dict. and render only specific information from the file into template. I know how if we use MEDIA we use this urlpatterns = [ url(r'^accessfiles/', include('accessfiles.urls')), url(r'^admin/', admin.site.urls), ]+static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) but in this case ++static(settings.MEDIA_URL,... files pass through static and renders them statically. But I want the program to pick requested file from the specific folder into views to render. I am new to django. please let me know if I didn't make anything clear. -
I am completely new to python and I tried installing django today after installing pip and a virtual environment and I get this errors
Traceback (most recent call last): File "c:\users\seunj\desktop\venv\lib\site-packages\pip\basecommand.py", line 215, in main status = self.run(options, args) File "c:\users\seunj\desktop\venv\lib\site-packages\pip\commands\install.py", line 335, in run wb.build(autobuilding=True) File "c:\users\seunj\desktop\venv\lib\site-packages\pip\wheel.py", line 749, in build self.requirement_set.prepare_files(self.finder) File "c:\users\seunj\desktop\venv\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files ignore_dependencies=self.ignore_dependencies)) File "c:\users\seunj\desktop\venv\lib\site-packages\pip\req\req_set.py", line 620, in _prepare_file session=self.session, hashes=hashes) File "c:\users\seunj\desktop\venv\lib\site-packages\pip\download.py", line 821, in unpack_url hashes=hashes File "c:\users\seunj\desktop\venv\lib\site-packages\pip\download.py", line 659, in unpack_http_url hashes) File "c:\users\seunj\desktop\venv\lib\site-packages\pip\download.py", line 882, in _download_http_url _download_url(resp, link, content_file, hashes) File "c:\users\seunj\desktop\venv\lib\site-packages\pip\download.py", line 603, in _download_url hashes.check_against_chunks(downloaded_chunks) File "c:\users\seunj\desktop\venv\lib\site-packages\pip\utils\hashes.py", line 46, in check_against_chunks for chunk in chunks: File "c:\users\seunj\desktop\venv\lib\site-packages\pip\download.py", line 571, in written_chunks for chunk in chunks: File "c:\users\seunj\desktop\venv\lib\site-packages\pip\utils\ui.py", line 139, in iter for x in it: File "c:\users\seunj\desktop\venv\lib\site-packages\pip\download.py", line 560, in resp_read decode_content=False): File "c:\users\seunj\desktop\venv\lib\site- packages\pip\_vendor\requests\packages\urllib3\response.py", line 357, in stream data = self.read(amt=amt, decode_content=decode_content) File "c:\users\seunj\desktop\venv\lib\site-packages\pip\_vendor\requests\packages\urllib3\response.py", line 324, in read flush_decoder = True File "c:\users\seunj\appdata\local\programs\python\python36-32\Lib\contextlib.py", line 100, in __exit__ self.gen.throw(type, value, traceback) File "c:\users\seunj\desktop\venv\lib\site-packages\pip\_vendor\requests\packages\urllib3\response.py", line 237, in _error_catcher raise ReadTimeoutError(self._pool, None, 'Read timed out.') pip._vendor.requests.packages.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='pypi.python.org', port=443): Read timed out. -
How to turn a list into a paginated JSON response for REST?
I'm new to Django REST Framework and I faced a problem. I'm building a backend for a social app. The task is to return a paginated JSON response to client. In the docs I only found how to do that for model instances, but what I have is a list: [368625, 507694, 687854, 765213, 778491, 1004752, 1024781, 1303354, 1311339, 1407238, 1506842, 1530012, 1797981, 2113318, 2179297, 2312363, 2361973, 2610241, 3005224, 3252169, 3291575, 3333882, 3486264, 3860625, 3964299, 3968863, 4299124, 4907284, 4941503, 5120504, 5210060, 5292840, 5460981, 5622576, 5746708, 5757967, 5968243, 6025451, 6040799, 6267952, 6282564, 6603517, 7271663, 7288106, 7486229, 7600623, 7981711, 8106982, 8460028, 10471602] Is there some nice way to do it? Do I have to serialize it in some special way? What client is waiting for is: {"users": [{"id": "368625"}, {"id": "507694"}, ...]} The question is: How to paginate such response? Any input is highly appreciated! Best regards, Alexey. -
How to load Django template after enter similar to facebook?
What I have been trying to find, with no answer yet, is how I could have a user click on link to a template, then instead of waiting for the whole page to load, allow the user to view what has already loaded while they wait for more load heavy content to arrive, similar to what Facebook does when you first get to a page and see things loading. -
Not able to create a select tag in Django
I have a models.py file: class MyUser(AbstractUser): YEAR_IN_SCHOOL_CHOICES = (('FRESHMAN', 'HOD'),('SOPHOMORE', 'Staff_Member'),) #phone = models.CharField(max_length = 10, null = True) Designation = models.CharField(max_length = 20, null = False,choices=YEAR_IN_SCHOOL_CHOICES,default='FRESHMAN') When I run the python manage.py migrate command,it's displays an error: django.db.utils.InternalError: (1067, "Invalid default value for 'Designation'") I have seen the documentation:link Can anyone please point what I am doing wrong in this implementation? Thanks. -
Django - Getting value from F expression
I believe this should be quite easy but it presented some challenge and no advice has came up googling. I have a django model like this: Affiliate -> Account where account has a balance attribute which keeps track of the account balance. Since it can be modified concurrently, I use an F() expression to modify it. The thing is... in a given test I am trying to compare affiliate.account.balance against the expected value -1.00 (a Decimal value), but it differs, since de F expression was not resolved: First differing element 12: # (yes... I'm comparing it within an array) Decimal('-1') <CombinedExpression: F(balance) - Value(1.00)> I use the F expression like this: def charge(self, **kwargs): amount = kwargs.get('amount') self.balance = F('balance') + amount self.save() Some (maybe) important info: $ python3 -m django --version 1.10.5 I've tried affiliate.account.balance.value() affiliate.account.balance.getValue() str(affiliate.account.balance) repr(affiliate.account.balance) Decimal(affiliate.account.balance) but none of those have the expected effect... So... How do I get a successful test when I assert self.assertEquals(Decimal(-1.00), affiliate.account.balance) Thanks!