Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django: How to assign a template variable to a views variable?
I have the following code in Javascript, which takes a user's name from a drop down list and changes his/her "is_active" attribute to true: function acceptFunction(){ var select = document.getElementById("dropdown"); var elementText= select.options[select.selectedIndex].text; var lbl = document.getElementById("lbl"); {% for user in list %} {% ifequal user.username strUser %} {{ user.is_active }}=true; {% endifequal %} {% endfor %} var i; for (i=0;i<select.length; i++) { if (select.options[i].text==elementText) { lbl.textContent=select.options[0].text; select.remove(i); } } } The "select" variable is a drop down list, the "elementText" is the list's element selected the current time by the website user and the "lbl" variable is a label used to print the selected element. In views.py I have the following: def acceptUserRequest(request): list = User.objects.all() strUser='' return render(request, 'acceptUserRequest.html', {'list': list, 'strUser':strUser}) and I am having difficulty in assigning the value of elementText in strUser. Is there a way in Django to accomplish this? Thank you. -
Django - 'SafeText' object has no attribute 'get'
I'm trying to display a chart with help of Highchart by following this solution: Passing Django Database Queryset to Highcharts via JSON But I keep getting this error: 'SafeText' object has no attribute 'get' Which I have been trying to find for days. Still new to this and appreciate your help, folks! views.py class ChartData(object): def check_valve_data(self): data = {'member_no': []} people = Member.objects.all() for unit in people: data['member_no'].append(unit.member_no) return data def chartViewHigh(self, chartID='chart_ID', chart_type='column', chart_height=500): data = ChartData.check_valve_data(self) chart = {"renderTo": chartID, "type": chart_type, "height": chart_height, } title = {"text": 'Check Valve Data'} xAxis = {"title": {"text": 'Member'}, "categories": data['member_no']} yAxis = {"title": {"text": 'Data'}} return render_template('chart/chartViewHigh.html', {'chartID': chartID, 'chart': chart, 'title': title, 'xAxis': xAxis, 'yAxis': yAxis}) chartViewHigh.html {% extends 'base.html' %} {% load staticfiles i18n %} {% block head %} <link href="{% static 'css/chart.css' %}" rel="stylesheet"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <script src="https://code.highcharts.com/highcharts.js"></script> <script src="https://code.highcharts.com/modules/exporting.js"></script> {% endblock head %} {% block main %} <h1 align="center">Analysis</h1> {% block content %} <div id={{ chartID }} class="chart" style="height:100px; width:100%"></div> {% endblock %} {% block extrajs %} <script> var chart_id = {{ chartID }}; var chart = {{ chart }}; var title = {{ title }}; var xAxis = {{ xAxis }}; var yAxis = … -
django mulitple dynamic forms
I'm recently building a Fitness Web App with django. I new to web development and django. Therefor I created a page where a Member can create his own training plan. I like to store the plan in my database, but that's the point where it gets difficult. When the user visits the page 'add workout', he should have to enter a name for the workout. Next he can search for exercises in my DB, this works perfectly fine. Than he hast to set his sets, reps and weight for the exercise befor it is added to the training plan. image of my webpage Here are my models: class Exercise(models.Model): name = models.CharField(unique=True, max_length=150) difficultLevel = models.IntegerField() link = models.CharField(unique=True, max_length=1000, blank=True) description = models.CharField(max_length=5000, blank=True) muscleGroup1 = models.CharField(max_length=150, blank=True) muscleGroup2 = models.CharField(max_length=150, blank=True) muscleGroup3 = models.CharField(max_length=150, blank=True) equipment1 = models.CharField(max_length=150, blank=True) equipment2 = models.CharField(max_length=150, blank=True) equipment3 = models.CharField(max_length=150, blank=True) class TrainingPlan(models.Model): member = models.ForeignKey(Member) name = models.CharField(max_length=150) lastChange = models.DateField(auto_now=True) class MemberExercise(models.Model): member = models.ForeignKey(Member) exercise = models.ForeignKey(Exercise) trainingPlan = models.ForeignKey(TrainingPlan) sets = models.IntegerField(null=True) reps = models.IntegerField(null=True) weight = models.FloatField(null=True) # in kg duration = models.IntegerField(null=True) # in sec The results of the search are just of type Exercise, the … -
How to change Django admin filter option names
I have a list of vehicles in my Django app that can be filtered in the admin by the vehicle's make field. The make field is a Charfield with choices from a list of tuples, so the values are stored in the database as abbreviations. In my model admin class, I have a list filter for the make, but the options are just all the abbreviations, JD, KU, etc. How can I override this, so it shows its verbose name from the tuple it was assigned to, rather than it's abbreviation ? Model Admin Class class InventoryAdmin(admin.ModelAdmin): model = Inventory list_display = ['id', 'inv_stock_no', 'status', 'inv_type', 'inv_subtype', 'make', 'full_make_name', 'model_no', 'date_added_to_inv', 'image_count', 'is_featured', 'list_price'] search_fields = ['inv_stock_no', 'inv_type__name', 'inv_subtype__name', 'model_no', 'id'] list_filter = ['status', 'inv_type', 'make', 'description', ('make', custom_titled_filter('My Custom Title'))] raw_id_fields = ['parent', ] inlines = [InventoryImageInline, InventoryFeatureInline] fieldsets = ( (None, { 'classes': ('full-width', 'suit-tab', 'suit-tab-general'), 'fields': ( 'inv_stock_no', 'description', 'status', 'condition', 'location', 'inv_type', 'inv_subtype', 'make', 'model_no', 'model_year', 'hours', 'serial_no', 'original_cost', 'original_price', 'list_price', 'general_info', 'is_featured', 'date_added_to_inv', 'date_modified_in_inv' ) }), ) suit_form_tabs = (('general', 'General'), ('images', 'Images'), ('features', 'Features')) def full_make_name(self, obj): return obj.make.name class Media: js = [ '//tinymce.cachefly.net/4.2/tinymce.min.js', '/static/admin_js/tinymce_init.js' ] Inventory Model makes_list = ( ('KU', 'Kubota'), … -
Why isn't celery periodic task working?
I'm trying to create a periodic task within a Django app. I added this to my settings.py: from datetime import timedelta CELERYBEAT_SCHEDULE = { 'get_checkins': { 'task': 'api.tasks.get_checkins', 'schedule': timedelta(seconds=1) } } And created a celery.py file in my project folder: from __future__ import absolute_import, unicode_literals import os from celery import Celery os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'testproject.settings') app = Celery('testproject') app.config_from_object('django.conf:settings', namespace='CELERY') app.autodiscover_tasks() Inside my app, called api, I made a tasks.py file: from celery import shared_task @shared_task def get_checkins(): print('hello from get checkins') I'm running the worker and beat with celery -A testproject worker --beat -l info It starts up fine and I can see the task is registered under [tasks], but I don't see any jobs getting logged. Should be one per second. Can anyone tell why this isn't executing? -
Swagger boolean parameter value True/False instead of true/false and django_filters
Swagger UI submits boolean params in 'true/false' form, while django filter boolean field expects True/False (uppercase). Therefore when I query through swagger, the field is_published has no effect. {{api_url}}/api/v1/games/?limit=10&offset=0&is_published=true {{api_url}}/api/v1/games/?limit=10&offset=0&is_published=false Filter field is defined as is_published = BooleanFilter(name='versions__is_published') full definition class GameFilter(FilterSet): """Custom filter for ``GameViewSet``. Defines custom filter for ``genres`` field (based on TaggableManager). """ is_published = BooleanFilter(name='versions__is_published') class Meta: model = Game fields = { 'platforms': ['exact'], 'ages': ['exact'], 'developers': ['exact'], 'genres': ['exact'], 'created': ['gt', 'lt'] } Swagger definition of the method get: summary: Get list of games operationId: getGamesList parameters: - $ref: '../../parameters.yaml#/Offset' - $ref: '../../parameters.yaml#/Limit' - $ref: '../../parameters.yaml#/PlatformsFilter' - $ref: '../../parameters.yaml#/DevelopersFilter' - $ref: '../../parameters.yaml#/GenresFilter' - $ref: '../../parameters.yaml#/AgesFilter' - $ref: '../../parameters.yaml#/SearchFilter' - $ref: '../../parameters.yaml#/Order' - name: is_published in: query type: boolean required: false default: true -
In Django with Postgresql 9.6 how to sort case and accent insensitive?
What I would like is the equivalent of using utf8_unicode_ci in MySQL. So if I have those strings (default sort order with Postgresql): Barn Bubble Bœuf beef boulette bémol I wish they would be sorted like this (as with utf8_unicode_ci in MySQL): Barn beef bémol Bœuf boulette Bubble This kind of sort is case insensitive, accent insensitive and ligatures are converted to multiple characters. I know about unaccent and lower in Postgresql but I have no idea how to use them from Django. Possible solutions with Django/Postgresql: Add new column only for sorting with data normalized (lower, unaccent). Add an index (like in this answer), but I'm not sure how it will work with Django? I don't think Full Text Search or Trigram could help me here because I'm not necessarily doing searches base on text but I need to get the good sort order. Ideally queries should be fast so using another indexed column looks like a good avenue. But I wish to find a solution that I don't need to implement for every exisiting text column in my DB, that is easy to maintain, etc. Is there a best practice to do that? -
How to combine multi array in python
I want to combine array from 3 difference array for my project (web) using Django. I give some example: Input: Array A: ['A','B','C'] Array B: ['1','2','3'] Array C: ['a','b','c'] Output: [['A','1','a'],['B','2','b'],['C','3','c'] Please, help me how step for getting what i mean. -
Django Rest Framework Uploaded File Url
Django rest framework automatically generates urls for uploaded files. However, the url it automatically generates doesn't actually point to where the file is stored. For example, I upload a file to my api named example.txt and this is what the object in my database looks like after the upload: { name: "John Doe", bio: "localhost:8000/api/users/static/example.txt" } My static directory is located in the root directory so the file actually lives and can be accessed at localhost:8000/static/example.txt. The automatically generated url returns a 404. How can I overwrite the automatically generated url to be the correct one? Here's what my model looks like: class User(models.Model): name = models.CharField(primary_key=True, max_length=30) bio = models.FileField(null=True, blank=True, upload_to='static') -
Real time tweet analysis
I am working on a web application project using Django. The goal of this project is to take a Keyword from the user and by using tweepy api to stream tweets from twitter regarding this keyword and displaying a real time analysis dashboard. The problem facing me know is how to keep the streaming on and displaying the dashboard at the same time and the dashboard keep refreshing to reflect the real time analysis. I have searched alot but i didn't find a good solution. -
How do I annotate count of field occurances in another model?
Using Django 1.11. These are my models: class UserPromoCode(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL, related_name="user_promo_code") promo_code = models.ForeignKey(PromoCode, related_name="user_promo_code") class PromoCode(models.Model): code = models.CharField(max_length=20) @property def assigned_times(self): # how many promo code with same code assigned on users return UserPromoCode.objects.filter(promo_code__code=self.code).count() I'm trying to optimize DB requests when taking a list of promocodes with their assigned_times counts. Is it possible to put it into annotation? I mean something like PromoCode.objects.annontate(assigned_times=Count(???)) -
Multiple inheritance in Django Template
In some of my templates, I have to use some specific JS libraries. For the libraries that I use the most, I defined a helper template like this: {# general/libs/js_lib.html #} <script type="text/javascript" charset="utf8" src="https://cdn...js_lib.versionX.min.js"></script> And then in my page's template I include this template (suppose that base.html defines {% block body %}, {% block css %} and {% block javascript %}): {# page.html #} {% extends 'base.html' %} {% block body %} ... {% endblock body %} {% block javascript %} {{ block.super }} {% include 'general/libs/js_lib.html' %} {% endblock javascript%} I do this so that whenever I update the library's version, it immediately updates it on every page that uses it. This would also make the change easier if I then choose to serve it myself instead of using CDN. The problem is that sometimes the library also needs a specific CSS file. For the time being, I just include it in the same js_lib.html template, but this means that I have a <link> tag that's not in the <head>. What I would like to do is define a sort of 'template mixin', so that my page's template extends a base.html, but also implements my js_lib mixin. I'm … -
VS2015 community Django not able to start in debug
I have been working with VS2015 on a django project for awhile now. Today when I went to run the debugger I found that the manage.py script is not running It is showing that the subcommand appears to be missing Screenshot of the start of the debugging widow opened by VS2015, listing continues to show all of the manage.py subcommands I can start the django code using runserver with out any errors being raised. I just at this time can no longer debug. A wee bit frustrating. Here is the info on the current VS2015 install. **Note links removed from VS2015 info since Stackoverflow would not allow me to post with more than 2 links present at this time ** Microsoft Visual Studio Community 2015 Version 14.0.25431.01 Update 3 Microsoft .NET Framework Version 4.6.01586 Installed Version: Community Visual Basic 2015 00322-20000-00000-AA811 Microsoft Visual Basic 2015 Visual C# 2015 00322-20000-00000-AA811 Microsoft Visual C# 2015 Visual C++ 2015 00322-20000-00000-AA811 Microsoft Visual C++ 2015 Windows Phone SDK 8.0 - ENU 00322-20000-00000-AA811 Windows Phone SDK 8.0 - ENU Application Insights Tools for Visual Studio Package 7.18.00214.2 Application Insights Tools for Visual Studio ASP.NET and Web Tools 2015.1 (Beta8) 14.1.11107.0 ASP.NET and Web Tools 2015.1 … -
Django - handling form without the form model
I wish to handle a form I created with HTML in django, but I can't find the correct way to get the value from the inputs. This is my HTML form: <form action="" class="form-inline" method="post"> {% csrf_token %} <!-- malfunction description --> <label class="requiredField" for="malfunctionDescription">תאור התקלה</label> <br/> <textarea class="form-control" style="width: 100%; margin-bottom: 3px" id="malfunctionDescription" name="malfunctionDescription" rows="5"> </textarea> </form> And this is my view.py which is unfortunately empty: def index(request): return render(request, 'resources-management/home.html') The main goal for me is to get this information from the form and create a new object that will push it to the data base. If I understand correctly to create this object I need to do something like: Object_name.object.create(information=information) But I don't know how to get the information, I need something like request.form['name'] in Flask Thanks! -
Django: 0 and Null first when filter_by used in Ascending and Descending starts with lowest first and then highest
I created a leaderboard using Django. Except It doesn't. It displays the information except for one thing. Empty Fields and those with 0 get first. If it's set in Ascending Order. Left by Default But for Descending Null and 0 get last but a first number is 4 and then the highest numbers. Used a - on it. Why? This doesn't make sense or I'm a moron This is my views.py: Ascending participants = Participant.objects.order_by('totalpoints') Descending participants = Participant.objects.order_by('-totalpoints') Any Help would be appreciated! -
is there an easier way to either create or re-write exist object? django
I know in django we can create an object model easily by using something like this AbcModel.objects.create(field1='a', field2='b') But this would create the object even if it already exists. I know I can use filter() then use the exist() to check if the object already exist then decide to update or create. But is there an easier and faster way to do this? Since, there is get_or_create so I am curious if there's something similar. Thanks in advance -
Extending Django User model - form population errors
I'm extending Django's (v1.9) built-in User model with Player class, to add some extra properties. class Player(models.Model): TIMEZONES=() user = models.OneToOneField(User, on_delete=models.CASCADE) ... (player-specific properties here) time_zone = models.CharField(max_length=255, choices=PRETTY_TIMEZONE_CHOICES, blank=True, null=True,) When creating users from Django admin panel, I don't always need to create players, so sometimes only User gets created. As a result, Player and User IDs don't exactly match. Turns out that this leads to a problem when populating ModelForms of models that are linked to Player, like this one: class City(models.Model): player = models.ForeignKey(Player, on_delete=models.CASCADE) name = models.CharField(max_length = 100) x_coord = models.SmallIntegerField() y_coord = models.SmallIntegerField() region = models.CharField(max_length = 100) def __unicode__(self): return str(self.player) + "-" + str(self.name) class Meta: db_table = 'cities' class CityForm(ModelForm): class Meta: model = City fields = ( 'name', 'player', 'x_coord', 'y_coord', 'region') In views.py the modelForm is created from POST data: form = CityForm(request.POST) Player is rendered as a hidden field in the UI, and when User ID and Player ID match it gets populated correctly; however when they are different, Player field is empty and the form does not validate. I have no problem getting Player ID from request.user, and I could fix up the player ID before … -
Download site-packages from Heroku
I've been asked to make some amendments to a Python / Django application on Heroku. I've cloned the site and tried to run pip install -r requirements.txt to set it up locally but a number of the apps will not install. 4 of these are because pip cannot find the right versions (and that seems to be because they're from 2012) and some are because they appear to be previous supplier specific and so were probably not installed locally. My question is, can I get at the site-packages directory and download everything into my virtual environment (and will that even work - I think not but have promised to try) or is there a better way? -
How to rate limit Celery tasks by task name?
I'm using Celery to process asynchronous tasks from a Django app. Most tasks are short and run in a few seconds, but I have one task that can take a few hours. Due to processing restrictions on my server, Celery is configured to only run 2 tasks at once. That means if someone launches two my these long-running tasks, it effectively blocks all other Celery processing site wide for several hours. Is there any way to configure Celery so it only processes one type of task no more than one at a time? Something like: @task(max_running_instances=1) def my_really_long_task(): for i in range(1000000000): time.sleep(6000) Note, I don't want to cancel all other launches of my_really_long_task. I just don't want them to start right away, and only begin once all other tasks of the same name finish. -
Django Migrate Fails due to Type Conflict
Here is my Chapter model code: class Chapter(models.Model): name = models.CharField(max_length=180) is_canon = models.BooleanField(default=True) series_id = models.ForeignKey('Series', on_delete=models.CASCADE, blank=True, null=True) def __str__(self): return self.name When running python3 manage.py makemigrations, I provided a one off value of 'NULL' for the new field series_id in order to populate existing rows, when I should have backed out and added blank=True, null=True to the definition, as it is now in the code provided above. So, now, I want to run python3 manage.py migrate, but of course the migration fails because I've got a bunch of 'NULL' strings in places where django is expecting actual NULL values/integer values. How to I get rid of those 'NULL' values and reset things so I can migrate? Thank you for your time. -
Make a better code
from crispy_forms_materialize.layout import Div and the code is def get_submit(title=None, button=None): if title is None: title = LABEL_CREATE return Div( Div( Append the line here --> HTML('<a href="/accounts/signin/" class="btn btn-primary">%s</a>'% LABEL_SIGNIN), Submit('submit', title, css_class='white-text'), css_class="right-align"), css_class="card-action") You could see the line HTML('<a href="/accounts/signin/" class="btn btn-primary">%s</a>'% LABEL_SIGNIN), in the above code. This line is optional in fact. I would like to modify this code in such a way if button is not None, then it will append that line in the Div method. My problem is not the if statement, my problem is to append this line if the condition is respected. How could I do that? Thanks in advance! P.S. Please tell me if my question is unclear. To be clear, what I want is def get_submit(title=None, title2=None): if title is None: title = LABEL_CREATE if title2 != None: return Div( Div( HTML('<a href="/accounts/signin/" class="btn btn-primary">%s</a>'% LABEL_SIGNIN), Submit('submit', title, css_class='white-text'), css_class="right-align"), css_class="card-action") else: return Div( Div( Submit('submit', title, css_class='white-text'), css_class="right-align"), css_class="card-action") This worked, but it is a very bad programming to repeat the code. That's why I wanted to just add a line in the code. I use this code with get_submit(title=LABEL_SIGNUP, button=LABEL_SIGNIN), -
djangorest: StringRelatedField not filling select fields
I'm doing my first steps in jdango. I have a response from server { "name": "total tasks list", "tasks": [ "Task 1", "Task 2" ] } and the corresponding form class TasklistDetailsView(generics.RetrieveUpdateDestroyAPIView): queryset = Tasklist.objects.all() serializer_class = TasklistSerializer The models are simple as that: class Tasklist(models.Model): name = models.CharField(max_length=200) def __str__(self): return "{}".format(self.name) class Task(models.Model): name = models.CharField(max_length=200, blank=True) tasklist = models.ForeignKey(Tasklist, related_name='tasks', on_delete=models.CASCADE, null=True) def __str__(self): return "{}".format(self.name) And the serializer is class TasklistSerializer(serializers.ModelSerializer): tasks = serializers.StringRelatedField(many=True) class Meta: model = Tasklist fields = ('name', 'tasks') I have a default html form with inputs. It fine with name (and any simple fields) - i see but multiple select has only one option 'No items to select.'. It's ok that i cant't select any items, but how to I make it fill the select with those those two options ("Task 1" and "Task 2")? -
django server uses old url.py file with new project
I'm in the process of learning django. I started a project called "mysite" following one of the tutorials. Then I started another project. But when I run "python manage.py runserver" in my new project directory, and then try to load an app of the new project, it returned error because the server was still reading "mysite.urls", and couldn't find my newly defined url. Below is the screen shot error message. And help is appreciated. -
How to debug ajax django view function which doesn't work in production only
How to debug such big peace of code which works localy and doesn't work in production considering the fact this is ajax function covered by djangorestfranewokr decorator - debugging doesn't work, django doesn't log any error, the only info I have when something gets broken is just 500. Or Django has to log errors, and something is wrong @api_view(['POST', ]) def load_dialog(request): if request.method == 'POST': party_id = request.data['party_id'] ticket_id = request.data['ticket_id'] party = UserProfile.objects.get(pk=party_id) ticket = Ticket.objects.get(pk=ticket_id) try: dialog = Dialog.objects.get(Q(sales=party) | Q(sales=request.user.userprofile)) except Dialog.DoesNotExist: dialog = None if dialog: textbool = None if dialog.sales == request.user.userprofile: textbool = "show" messages = Message.objects.filter(dialog=dialog) s_messages = serializers.serialize('json', messages) s_textbool = json.dumps(textbool) s_dialog_id = json.dumps(dialog.id) data = { 'messages': s_messages, 'sales': s_textbool, 'dialog_id':s_dialog_id, } else: owner = ticket.ownership new_dialog = Dialog.objects.create(buyer=request.user.userprofile,sales=owner,ticket=ticket) textbool = None if new_dialog.sales == request.user.userprofile: textbool = "show" messages = Message.objects.filter(dialog=new_dialog) s_messages = serializers.serialize('json', messages) s_textbool = json.dumps(textbool) s_dialog_id = json.dumps(new_dialog.id) data = { 'messages': s_messages, 'sales': s_textbool, 'dialog_id':s_dialog_id, } else: error = "Fuck" return error return Response(data) -
Upgrading to Django 1.7. AssertionError: To use StatusField, the model 'ShellRequest' must have a STATUS choices class attribute
I was upgrading from Django 1.6 to 1.7. Python 2.7 is installed which is compatible with Django 1.7. While I did run the code python manage.py makemigrations, I got the following error message: Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 377, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 288, in run_from_argv self.execute(*args, **options.__dict__) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 338, in execute output = self.handle(*args, **options) File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/m akemigrations.py", line 111, in handle convert_apps=app_labels or None, File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/autodetector.py", line 42, in changes changes = self._detect_changes(convert_apps, graph) File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/autodetector.py", line 109, in _detect_changes self.old_apps = self.from_state.render(ignore_swappable=True) File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/state.py", line 67, in render model.render(self.apps) File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/state.py", line 312, in render body, File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 284, in __new__ new_class._prepare() File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 344, in _prepare signals.class_prepared.send(sender=cls) File "/usr/local/lib/python2.7/dist-packages/django/dispatch/dispatcher.py", line 198, in send response = receiver(signal=self, sender=sender, **named) File "/usr/local/lib/python2.7/dist-packages/model_utils/fields.py", line 57, in prepare_class % sender.__name__ AssertionError: To use StatusField, the model 'ShellRequest' must have a STATUS choices class attribute. Reading the blogpost here, I couldn't figure out where to start. If anyone can give me a guideline how to deal with this issue would be appreciated.