Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
DataTables warning: table id=DataTables_Table_0 : OperationFailure and Authentication failed
I am using mongoengine with Django 1.8 for making a application.My project needs to connect to one instances of MongoDB while another with sql. But when i try to run my application it displaying table with out data and showing this error:- DataTables warning: table id=DataTables_Table_0 - OperationFailure Authentication failed. Django Version: 1.8 Python Executable: /var/www/html/admin_python/orahienv/bin/python Python Version: 2.7.12 Python Path: ['/var/www/html/admin_python', '/var/www/html/admin_python/orahienv/lib/python2.7', '/var/www/html/admin_python/orahienv/lib/python2.7/plat-x86_64-linux-gnu', '/var/www/html/admin_python/orahienv/lib/python2.7/lib-tk', '/var/www/html/admin_python/orahienv/lib/python2.7/lib-old', '/var/www/html/admin_python/orahienv/lib/python2.7/lib-dynload', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/var/www/html/admin_python/orahienv/local/lib/python2.7/site-packages', '/var/www/html/admin_python'] Server time: Thu, 13 Jul 2017 12:46:06 +0530 Installed Applications: ('django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'admin_app', 'celery') Installed Middleware: ('django.contrib.sessions.middleware.SessionMiddleware', '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', 'django.middleware.security.SecurityMiddleware', 'djangoflash.middleware.FlashMiddleware') Traceback: File "/var/www/html/admin_python/orahienv/local/lib/python2.7/site-packages/django_datatables_view/base_datatable_view.py" in get_context_data 195. total_records = qs.count() File "/var/www/html/admin_python/orahienv/local/lib/python2.7/site-packages/mongoengine/queryset/queryset.py" in count 131. return super(QuerySet, self).count(with_limit_and_skip) File "/var/www/html/admin_python/orahienv/local/lib/python2.7/site-packages/mongoengine/queryset/base.py" in count 390. return self._cursor.count(with_limit_and_skip=with_limit_and_skip) File "/var/www/html/admin_python/orahienv/local/lib/python2.7/site-packages/pymongo/cursor.py" in count 711. return self.__collection._count(cmd, self.__collation) File "/var/www/html/admin_python/orahienv/local/lib/python2.7/site-packages/pymongo/collection.py" in _count 1304. with self._socket_for_reads() as (sock_info, slave_ok): File "/usr/lib/python2.7/contextlib.py" in __enter__ 17. return self.gen.next() File "/var/www/html/admin_python/orahienv/local/lib/python2.7/site-packages/pymongo/mongo_client.py" in _socket_for_reads 859. with self._get_socket(read_preference) as sock_info: File "/usr/lib/python2.7/contextlib.py" in __enter__ 17. return self.gen.next() File "/var/www/html/admin_python/orahienv/local/lib/python2.7/site-packages/pymongo/mongo_client.py" in _get_socket 825. with server.get_socket(self.__all_credentials) as sock_info: File "/usr/lib/python2.7/contextlib.py" in __enter__ 17. return self.gen.next() File "/var/www/html/admin_python/orahienv/local/lib/python2.7/site-packages/pymongo/server.py" in get_socket 168. with self.pool.get_socket(all_credentials, checkout) as sock_info: File "/usr/lib/python2.7/contextlib.py" in __enter__ 17. return self.gen.next() … -
Getting this error - 'tuple' object does not support item assignment
Hello hope some one helps me on this challenge. Getting this error - 'tuple' object does not support item assignment the error is pointing at the first statement . - ({% for post in posts_list %}) {% for post in posts_list %} {{ post.title }} {% endfor %} -
Unable to install Django channels
I'm new to Django channels and just when i tried to install it, i ran into the following errors. I then tried installing the twisted package in the virtualenv as well but i ran into the same error. Any help? copying src\twisted\internet\test\fake_CAs\not-a-certificate -> build\lib.wi n32-3.4\twisted\internet\test\fake_CAs copying src\twisted\internet\test\fake_CAs\thing1.pem -> build\lib.win32-3.4 \twisted\internet\test\fake_CAs copying src\twisted\internet\test\fake_CAs\thing2-duplicate.pem -> build\lib .win32-3.4\twisted\internet\test\fake_CAs copying src\twisted\internet\test\fake_CAs\thing2.pem -> build\lib.win32-3.4 \twisted\internet\test\fake_CAs copying src\twisted\mail\test\rfc822.message -> build\lib.win32- 3.4\twisted\ mail\test copying src\twisted\python\test\_deprecatetests.py.3only -> build\lib.win32- 3.4\twisted\python\test copying src\twisted\words\im\instancemessenger.glade -> build\lib.win32- 3.4\ twisted\words\im copying src\twisted\words\xish\xpathparser.g -> build\lib.win32- 3.4\twisted\ words\xish running build_ext building 'twisted.test.raiser' extension error: INCLUDE environment variable is empty -Command "C:\Python34\python.exe -u -c "import setuptools, tokenize;__file__='C:\ \Users\\HP\\AppData\\Local\\Temp\\pip-build- 55mad5tf\\twisted\\setup.py';f=getat tr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\HP\AppData\Local\Temp\pip-yqs62oz9-record\install-record.txt -- single-version-externally-managed --compile" failed with error code 1 in C:\Users\HP\AppData\Local\Temp\pip-build-55mad5tf\twisted\ -
Django Query set to fetch a data from a database?
I have created a Modelas given bellow: from __future__ import unicode_literals from django.db import models class TypesOfVehicle(models.Model): type = models.CharField(max_length=50) def __unicode__(self): return self.type class vehicleDetails (models.Model): T = models.ForeignKey(TypesOfVehicle) NoOfWhl = models.PositiveIntegerField() year = models.CharField(max_length=4) ModelName = models.CharField(max_length=254) VID = models.CharField(max_length=254, verbose_name="VID") To View the above data I have writte down a view as follows: from django.shortcuts import render from .models import CountryDiseases, Country def VData(request): Count = vehicleDetails.objects.all() return render(request, 'DATAPLO/MAP.html', {'Count': Count }) and to render the view of i have write down a simple template like this MAP.html {% for c in Count %} {{c.NoOfWhl }} {{ c.year }} {{ c.ModelName }}<br/> {% endfor %} My Question is that I'm very novice for Django, After few unsuccessful attempts I am not able to write down a method which can render my data as given bellow. How can I modified the view and template section so that it could return something like this Sample Input data: NoOfwhl year modelName VID Type 4 2014 xyz111 786 SUV 2 2012 445444 789 bk 4 2014 655656 676 car 3 2013 565656 459 tax 4 2010 565656 567 SUV 3 2019 345353 359 tax 3 2013 234224 789 tax 4 … -
plot a graph in d3.js and call it in django view
Im new to django. I need to create a django view to plot a graph using d3.js I have no idea how to do it.Can anyone explain me with an example.I need to plot a graph for male and female working on day and night shifts and create a django view to pass the data to the graph -
Is this condition satisfy remote file inclusion Vulnerabilities in Python?
I need some help. I need to implement remote file inclusion Vulnerabilities in my code using python. Here I have done something and need to check whether the Vulnerabilities satisfy the right condition or not. I am explaining my code below. if request.method == 'POST': param = request.POST.get('param') execfile(param) pers = User.objects.get(pk=request.session['id']) root = [] user_name = pers.uname Here param parameter is containing the external file URL and the remote file inclusion should happen. Please help. -
Celeryd worker received task but do not work
My develop env. is base : python 2.7, Django==1.11, celery==3.1.25 VM #01 : nginx + gunicorn (web) VM #02 : RabbitMQ server on ubuntu 14.04 VM #03 : celery worker Case #1 : Normal works RabbitMQ running celeryd worker running and push the async messages to rabbitmq => it works very well, Case #2 : Receive the task but do not fire in worker. RabbitMQ running push the async messages to rabbitmq ( without running worker ) and then execute the celeryd worker => it received task but do not work. .. celeryd logs for case of #2 is [2017-07-13 14:37:21,327: INFO/MainProcess] Received task: task.campaign.update_revenues[faf1b584-9af9-437f-a5e5-ce54749b73e9] that's all. no more logs. no task logs(success?fail?). and the message still exist in rabbitmq. why not executed the tasks ? Any helps for me ? -
Make UpdateView accept an encrypted pk in urls.py and return a model object for editing after decrypting the pk
I have a simple working class based view inheriting UpdateView. class UpdateModel(UpdateView): model = ModelName fields = ['field_1' , 'field_2' , ] template_name_suffix = '_update_form' success_url = reverse_lazy('home') and the url that maps back to this view url(r'^edit/(?P<pk>[\w-]+)$' , UpdateModel.as_view() , name="update_model"), Now the issue I'm facing is that I usually encrypt the PK value before sending it outside(since they are sensitive). When I receive them back, I decrypt them to get the Model Object. Brief working of encryption process. def pk_encoder(pk): int_pk = int(pk) hashids = Hashids("MySalt") encoded_pk = hashids.encode(pk_id) return encoded_pk ans similarly I use hashids.decode('string') to obtain my Model Object. But in UpdateView there is no provision for this(that I know of). In urls.py it simply accepts the pk id to return the relevant form for updating a model. I understand that I have to override UpdateView or any of it's function in some way but can't figure out how. May I know how to edit this functionality of UpdateView Thanks in advance. -
Django model query's database access mechanism
class parent(models.Model): ap=models.CharField(max_length=10) user=models.CharField(max_length=10) class Meta: unique_together=(("ap","user"),) db_table='parent' class child(models.Model): userkey=models.ForeignKey(parent,on_delete=models.CASCADE,db_column="ap") pn=models.CharField(max_length=10) st=models.CharField(max_length=10,default='Y') def get_ap(self): return self.ap.ap def get_pn(self): return self.pn class Meta: db_table="child" unique_together=(('userkey','pn'),) Let's say i have ap="apkey" then i can access all child model object for "apkey" by following query. child_obj=child.objects.filter(userkey__ap="apkey") This can be also done without using foreign key relation as follows. parent_obj=parent.objects.get(ap="apkey") child_obj=child.objects.filter(userkey=parent_obj) What i have to know is that how many database access is occurred while executing query in both methods. ? In the second, we knows that it access parent table once and then access child table once. Hence actually two sql query occurs. What about the first one? -
Python xhtml2pdf table cell text display to vertical
Im using xhtml2pdf to generate report in django and i would like to let one of my cells text display vertically but i couldn't make it using css. Here is some attempt: .vertical-text { writing-mode: tb-rl; } <table> <tbody> <tr> <td class="vertical-text" >V text</td> </tr> </tbody> </table> UPDATE writing-mode property is missing in the supported css properties. Is there any workaround? -
uwsgi processes moving to IDLE state after some time
I'm using uwsgi + nginx for a django application and after some time it seems like some of the uwsgi processes moved to IDLE state(top results 0 %CPU, x %Memory for those uwsgi processes) hence the responses from server gets delayed. My initial configuration was:- workers=2 threads=10 enable-threads=true single-interpreter=true master=true max-requests=50000 In this case, 1 uwsgi process gradually moved to IDLE state, So I updated the worker count like workers=4 threads=10 enable-threads=true single-interpreter=true master=true max-requests=25000 after this setting, on first day 1 process moved to IDLE state and on second day 2 uwsgi process moved to IDLE state. How I can solve this? Due to this 1 active uwsgi process, responses from the server gets delayed and it impacting my users -
Trigger a function in a Django model every time its variables change
I'm working on a Django model and I want to trigger a function every time its variables change. Here's my model: class Cv(models.Model): name = models.CharField(max_length=100) position = models.ForeignKey( OpenPosition, on_delete=models.CASCADE, null=True, ) team = models.ForeignKey( Team, on_delete=models.CASCADE, null=True ) leader = models.ForeignKey(Leader, on_delete=models.CASCADE) email = models.EmailField( max_length=100, null=False, validators=[EmailValidator()], blank=True ) email_sent_status = models.BooleanField(default=False) phone = models.CharField( validators=[ RegexValidator( regex=r'^(0\d{9,11})$', message=''' Phone number must be started with 0 and has 10-12 digits ''' )], blank=True, null=True, max_length=20, ) link = models.CharField( max_length=150, validators=[URLValidator()], ) source = models.ForeignKey(CvSource, on_delete=models.CASCADE) cv_status = models.CharField( max_length=10, choices=STATUS, default='u', ) schedule = models.DateTimeField(blank=True, null=True) schedule_confirm = models.BooleanField(default=False) interview_status = models.CharField( max_length=10, choices=FULL_STATUS, default='u', ) test_status = models.CharField( max_length=10, choices=STATUS, default='u', ) test_comment = models.TextField(max_length=200, blank=True) decision_status = models.CharField( max_length=10, choices=FULL_STATUS, default='u', ) offer_status = models.CharField( max_length=10, choices=OFFER_STATUS, default='u,' ) internal_comment = models.TextField(max_length=200, blank=True) created_at = models.DateTimeField( editable=False, null=True, ) updated_by = models.CharField(max_length=30, editable=False, null=True) Currently I'm using an approach that is mentioned in Django: When saving, how can you check if a field has changed? but with many variables this process become repetitive: def __init__(self, *args, **kwargs): super(Cv, self).__init__(*args, **kwargs) #override original fields' values with current values self.__original_schedule = self.schedule self.__original_schedule_confirm = self.schedule_confirm self.__original_name … -
Google oAuth2 AuthMissingParameter
I'm trying to use Google oAuth2 for login. I get this error Request Method: GET Request URL: http://localhost:8000/oauth/complete/google-oauth2/?code=blah Django Version: 1.11.3 Exception Type: AuthMissingParameter Exception Value: Missing needed parameter state Exception Location: C:\Python27\lib\site-packages\social_core\backends\oauth.py My settings.py has the secret set, I don't know what to set in the KEY. Is that the problem? I checked the clients_secrets.json file and I see nothing called KEY. Not sure where this KEY comes from SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET ="SECRET*" SOCIAL_AUTH_GOOGLE_OAUTH2_KEY="" -
Django annotate count of foreign key's foreign key
I have three main models: Class Client(models.Model): stuff Class Property(models.Model): client = models.ForeignKey(Client) branch = models.ForeignKey(Branch, blank=True, null=True) Class Branch(models.Model): name = models.CharField(max_length=200) My final goal is basically to try and deduce a client's most involved branch based on the properties it is connected to. I'm sure the best way to do this is using Django's aggregate using annotate, but I'm not sure how exactly to do this. I might have to use extra instead. I know I'll need to something like Client.objects.annotate(branch_count=Count('property__branch')), but I need to somehow add filtering for properties attached to each branch. The other way perhaps is to make use of Collections.Counter d = {} for c in Client.objects.all(): c_qs = Client.objects.filter(pk=c.pk) d[c] = Counter(c_qs.values_list('property__branch', flat=True)) This would build a dictionary of counts, then I'll use it to look up the branch with the highest count for any one client. -
DATE_FORMAT mysql django
I'm currently trying to migrate some MySQL logic to Django (and learning about it in the process). So far the "normal" queries I do understand how to make, but I've hit a wall trying to translate this query: SELECT hour, AVG(sessions) FROM ( SELECT DATE_FORMAT(acctstarttime, '%d-%m-%Y') AS date, DATE_FORMAT(acctstarttime, '%H:00') as hour, COUNT(DISTINCT username) AS sessions FROM radacct WHERE calledstationid = 'CLIENT' AND acctstarttime < 'DATE' GROUP BY date, hour) tb1 GROUP BY hour I can't figure this out, specially the "DATE_FORMAT" part, this query is being used basically to find averages of users per hour over a single table. "CLIENT" and "DATE" are just values I add to the query when executing it. As such it returns something like this: Hour --- AVG 00:00 --- 50 01:00 --- 100 02:00 --- 350 . . . 23:00 --- 120 This query works as I need to, although I have to admit maybe it's flawed since I am by no means an SQL expert (more like a newbie). Thank you in advance for any help -
Django with Postgresql on Heroku - settings.DATABASES is improperly configured. Please supply the NAME value
I have a problem with database connection on Heroku with Django project in Docker. Based on this topic I changed my database settings from DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'aso', 'USER': 'postgres', 'HOST': 'db', 'PORT': 5432, } } to DATABASES = {'default': dj_database_url.config(default='postgres://localhost')} Unfortunately, I get: ImproperlyConfigured at / settings.DATABASES is improperly configured. Please supply the NAME value. Any suggestions? -
Stay on the same html page with output in django
I want an user to select few products in a dropdown menu and based on that display a chart on the same page. User should be able to select/ deselect the options again from the dropdown menu and then refresh it, for which I want to stay in the same page. My requirement I have written the code, but since for a separate view in django I have to have a different url, its going to the specified url where my dropdown menu is no longer working. I have rendered the same display page with context to the get the above, just my url is different. How can i make it work and stay in the same url. If possible reload the same page with the output data. Below is my code. index.html: <div class="container"> <div class="row"> <div class="col-md-6"> <h3>Select products:</h3> <form id="selectProduct" role="search" method="get" action="{% url 'selectedproducts' %}"> <select name="parameters[]" data-placeholder="Choose products" class="chosen-select" multiple tabindex="4"> {% for p in productnames %} <option value="{{ p.productname }}"> {{ p.productname }} </option> {% endfor %} </select><br/> <label for="submit"></label><button id="submit" type="submit" class="btn btn-default">Submit</button> </form> </div> </div> <div class="row"></div><br /> <h3> Distribution of sales in the products:</h3> </div> </div> <p>{{ productList }}</p> urls.py url(r'^products/', … -
Sending a jQuery value to Django view
I am pretty new in Django and jQuery. I am looking for a way to send some jquery variable to my django views when i click a button. I have created a button and some jQuery code which can display an alert message with the button's value when clicked, but i do not know how to send that value to my django views. -
How to access context variables in parents template django
I have base.html and file with header _header_main.html in my main template index.html i extends base.html and include _header_main.html but variables that i pass into index.html not visible in parent template base.html: <html> <head> <title>{% block title %}{% endblock %}</title> <!-- styles --> ... </head> <body> {% block _header_main %}{% endblock %} {% block _header_mobile %}{% endblock %} <div class="wrapper"> <!-- header --> {% block header_main %}{% endblock %} {% block header_mobile %}{% endblock %} <div class="after_header"></div> <!-- end header --> {% block content %}{% endblock %} <footer class="footer"> ... </footer> </div> </body> </html> _header_main.html: <header class="header"> <ul> {% for i in items %} <li>{{ i.title }}</li> {% endfor %} </ul> </header> index.html: {% extends "base.html" %} {% load static %} {% block title %}Title{% endblock %} {% block header_main %} {% include "_header_main.html" %} {% endblock %} {% block content %} Some content... {% endblock %} How i can access to variables items in my template? -
How can I get the username of the logged-in user in Django views.py
I am new to python and Django and struggling with the following issue: I have a logged-in user that completes a form with 2 fields (urlA and urlB). These 2 fields, together with the timestamp and the users username should get stored in my PSQL database. My current problem is that the urlA and urlB fields are pushed in the database, but the username stays empty or I get an error that self is not defined. I have tried follwoing variations inside views.py: forwardform.user = request.user.username User.objects.get(username=self.request.user) # -> gives error concering self views.py def forwardthis(request): forwardform = AddUrlForm(request.POST or None) if request.method == 'POST' and forwardform.is_valid(): forwardform.user = request.user.username forwardform.save() query_results = forwards.objects.all() template = loader.get_template('forwardthis.html') context = { 'forwardform': forwardform , 'query_results':query_results } #output = ', '.join([p.user for p in query_results]) return HttpResponse(template.render(context,request)) models.py class forwards(models.Model): user = models.CharField(max_length = 150) urlA = models.CharField(max_length = 254) urlB = models.CharField(max_length = 254) timestamp = models.DateTimeField('date created', auto_now_add=True) forms.py class AddUrlForm(forms.ModelForm): class Meta: model = forwards # fields = '__all__' exclude = ["user"] -
djangotables to djangotables2 checking column ordering
I've upgraded my Django project from djangotables to djangotables2, and have uninstalled djangotables to ensure that I've made all of the correct imports. I'm having trouble with the column.order_by.is_ascending substitute for column.is_ordered_straight), as described here: http://django-tables2.readthedocs.io/en/latest/pages/upgrading-from-v1.html My code so is: def function(columns): pics = dict() for column in columns: image = "" if (column.is_ordered): if (column.order_by.is_ascending): image = 'images/image1.png' else: image = 'images/image2.png' pics[column.name] = image return pics I get the following error: 'OrderByTuple' object has no attribute 'is_ascending' Here is the documentation that I've been using: http://django-tables2.readthedocs.io/en/latest/pages/internal.html I'm not sure why I'm getting this error. Any suggestions? -
Why am I getting a 404 error when trying to access my website's domain name, yet if I domain name/home it works?
Okay... let's try to explain things clearly. I've used Python Django to create a dynamic webpage/web-app. After completing the website I have published it using DigitalOcean and have successfully attached my purchased domain name to the name server of DigitalOcean. When I access my website, ordinanceservices.com, i get an error 404; however, if I type ordinanceservices.com/home it works as it should and displays the home page. How, by editing the python files, can I have it to where ordinanceservices.com will display the home page as opposed to error 404? I feel like there's something that I am doing that is fundamentally wrong regarding my .urls structure and thus a rewrite/redirect in the nginx config should not be necessary. Here is the specific error: Page not found (404) Request Method: GET Request URL: http://ordinanceservices.com/ Using the URLconf defined in django_project.urls, Django tried these URL patterns, in this order: ^admin/ ^ ^home/ [name='home'] ^ ^contact/ [name='contact'] ^ ^services/ [name='services'] The current URL, , didn't match any of these. I somewhat understand what is happening here though I do not know how to fix this. Next I will provide my .urls files for each folder that contains such: /django_project urls.py from django.conf.urls import … -
How to use lazy_attribute with Faker in Factory Boy
Context: I have a model with two dates, I want to use factory.Faker for both of them but the second date should always be greater that the first one. I tried this: Model excerpt: class Event(models.Model): execution_start_date = models.DateTimeField() execution_end_date = models.DateTimeField() Factory: class EventFactory(factory.DjangoModelFactory): class Meta: model = Event strategy = factory.BUILD_STRATEGY execution_start_date = factory.Faker('date_time_this_year', tzinfo=pytz.utc) @factory.lazy_attribute def execution_end_date(self): return factory.Faker('date_time_between_dates', datetime_start=self.execution_start_date, datetime_end=now(), tzinfo=pytz.utc) But when I try to use the factory from the python shell I got this: In [3]: e = EventFactory() In [4]: e.execution_end_date Out[4]: <factory.faker.Faker at 0x1103f51d0> The only way I managed to make it work was with like this: @factory.lazy_attribute def execution_end_date(self): # return factory.Faker('date_time_between_dates', # datetime_start=self.execution_start_date, # datetime_end=now(), # tzinfo=pytz.utc) faker = factory.Faker._get_faker() return faker.date_time_between_dates(datetime_start=self.execution_start_date, datetime_end=now(), tzinfo=pytz.utc) But I honestly think there is a better way to do it. My dependencies are: Django (1.8.18) factory-boy (2.8.1) Faker (0.7.17) -
Django App with data from Postgres and dataviz in d3.js
This is my first brush with Django. I'm trying to create an app which has a textinput whose value needs to be queried in the Postgres database. The results will be read into a Pandas dataframe and some aggregations are done, and then the result set would be converted into json that feeds a d3 force directed graph. What I did is: Create a model that has the source, target and weight class Graph(models.Model): source = models.CharField(max_length=25) target = models.CharField(max_length=25) weight = models.IntegerField() I viewed many tutorials online but couldn't get a sense of where to write the code to make the psycopg2 calls to fetch results (is it views.py?) and then how to map the aggregated values to the objects in the model above. Please assist with the workflow. Thanks. -
Django Admin: Save and continue editing raising ValueError
I have to submit an image to an AWS S3 bucket for our one of our models and subsequently save its URI as one of the model's fields. My current approach involves overriding the default save_model method within the ModelAdmin. I haven't gotten around to submitting the image yet, as I'm testing the override code alone. Everything is saving just dandy except when creating a new instance and also when the user clicks "Save and continue editing". When the page tries to load again, a ValueError is raised: invalid literal for int() with base 10: 'None' from django trying to load the url ``/lift/organization/None/` instead of the primary key. I assumed it would have something to do with the return value, but upon inspecting the source code it doesn't appear to be the case (I've also tried returning the object and the object's id). My last attempt to solve was using a redirect, which doesn't seem to have any effect. The main problem is that I want to use the Organization's primary key as the association between the Model instance and the image within the S3 bucket so this is only a problem when the user is creating a new …