Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
JSON.parse returning syntax error only when deployed on pythonanywhere
I'm new to javascript and web development in general.So this is an app to retrieve and display the last 10 tweets of a Twitter user.It uses AJAX to retrieve the tweets from the Django-powered server.The app works fine on my local machine but when i deployed it on pythonanywhere, the Javascript part shows a Syntax error. Following is the script part in the HTML file. <script> $("#HandleForm").on("submit", function (event) { event.preventDefault(); var handle = $('#handle').val(); get_tweets(handle); }); function get_tweets(handle){ $.ajax({ url : "ajax/returntweets/", type : "GET", data : {handle_data : handle}, success : function(json){ var response = $.parseJSON(json)['tweet_data'] $('#tweet_table').append('<li class="list-group-item list-group-item-success">Tweets of @' + handle + '</li>'); for(i=0;i<response.length;i++){ $('#tweet_table').append('<li class="list-group-item">'+response[i]+'</li>'); } $('#tweet_table').append('<li class="list-group-item list-group-item-warning">Tweets End Here!</li>'); }, }); } </script> This is the views.py returning the tweet data: auth = OAuth1(APIKey, APISecret, AccessToken, AccessTokenSecret) username = request.GET.get('handle_data') verificationUrl = ' https://api.twitter.com/1.1/users/show.json?screen_name=%s' %username response = requests.get(verificationUrl, auth=auth) tweets = [] if response.status_code == 200: requestUrl = ' https://api.twitter.com/1.1/statuses/user_timeline.json?tweet_mode=extended&screen_name=%s&count=10' %username r = requests.get(requestUrl, auth=auth,) for tweet in r.json(): tweets.append(tweet['full_text']) else: tweets.append("Invalid Handle") response_data = {"tweet_data" : tweets} return HttpResponse(json.dumps(response_data)) The browser console shows the following error SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data console.log(json) prints the … -
Django: Image Compression
I'm working on a django project on which i'm trying to resize & compress an image before saving. Resizing & Compression is working fine. But, it's re-naming the images in a very poor/wrong way. For example, I saved an image originally named, StarChild.jpg, after the compression & resizing, it re-named it StarChild_SNNYByd_lJ59FKh_tYB56u7_d23fUHs_qHICQxb_MFuW3DN_Y6JAvNE_SDzC_s20OMui.jpg. Here's my code, # Model class Content(models.Model): data = models.TextField() image = models.ImageField(upload_to='images/') # Compression & Resizing def save(self, *args, **kwargs): if self.image: img = Image.open(self.image) resize = img.resize((240, 240), Image.ANTIALIAS) new_image = BytesIO() resize.save(new_image, format=img.format, quality=80, save=False) temp_name = os.path.split(self.image.name)[1] self.image.save(temp_name, content=ContentFile(new_image.getvalue()), save=False) super(Content, self).save(*args, **kwargs) How can we solve this problem? Thank You . . . -
How to Restrict Django GenericRelation to One Related Object
The code below (from Django contenttype docs) permits multiple related objects (i.e. 'tags'). Is it possible to restrict this to one related object (i.e. 'tag')? And, if so, how? from django.db import models from django.contrib.contenttypes.fields import GenericRelation class Bookmark(models.Model): url = models.URLField() tags = GenericRelation(TaggedItem) -
Allow Invalid Keyword Argument on Django Model
Anyone know how to prevent Django from raising a TypeError on save when a field isn't present? I've included simplified models below. Essentially, I'd like to pass a 'name' attribute when creating a Tag. A custom save action would then get_or_create a TagDetail with the name and create the association. class TagDetail(models.Model): name = models.CharField(max_length=100, unique=True) class Tag(models.Model): detail = models.ForeignKey(TagDetail, on_delete=models.CASCADE) content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) object_id = models.PositiveIntegerField() content_object = GenericForeignKey('content_type', 'object_id') class Meta: abstract = True -
Creating users represented by two models in OneToOne relation
This quesion is related to the common pattern of representing a site user (henceforth referred to as "member"), by two models that have a one-to-one relation: A builtin contrib.auth.models.User model, used for authentication, that holds authentication credentials and basic information An application specific Profile model with additional personal information, such as language for example. Profile.user is a OneToOneField pointing to `auth.User' My questions relate to the creation of such members. The view that handles account creation must populate and save two model instances with the submitted form data. What approaches would you recommend to implement the creation form? How can generic class-based views be leveraged to handle member creation? I briefly present my current solution below, with its limitations. Form: a ModelForm associated to the User model, with extra fields corresponding to the profile information. class MemberForm(ModelForm): # These fields map to those on the Profile model # One for brevity here, but think of many more in practice language = forms.CharField( max_length=3, widget=forms.Select(choices=Profile.LANGUAGES) ) class Meta: model = User fields = ['first_name', 'last_name', 'email'] View: CreateView subclass associated to the User model, overriding the form_valid() method in which the Profile model is populated "by hand" from the form's cleaned_data … -
Django inspect() throws TypeError on For Iteration
This is a follow-on question to this question. I would like to automate the import of classes from a django models.py file and then register each with admin.site.register(). Here is my code: from django.contrib import admin import inspect from . import models for name, obj in inspect.getmembers(models): if inspect.isclass(obj): admin.site.register(obj) This code throws a TypeError: 'type' object is not iterable. The OP marked this question as answered and I've found several other examples where this code is presented. I've also reviewed the documentation here and didn't see anything that would indicate that this is wrong. Thoughts? -
Salt: Activate virtual environment on salt minion
I have some questions about saltstack. I'm trying to deploy my Django project with saltstack and made that minion install required packages with pip by setting it's bin_env. (django lib, etc...) But when I run a command ('python manage.py something) It says there's no django and to activate virtual environment. I read salt docs about venv module(state) but the only thing in there was creating venv. How can I activate the minion's venv? thank you. -
Intellisense issue with imported models in pycharm
Using pycharm with python3 I have an issue when trying to access methods from one class in a file structure to imported into another. I can use the methods but they aren't pre-filled by intellisense which makes it very difficult since I am just learning python. my files are as follows: tictactoe ---- gameplay ||--->migrations ||---> init.py ||---> admin.py ||---> models.py ||---> test.py ||---> views.py ---- player ||---> migrations ||--->templates ||---> init.py ||---> admin.py ||---> apps.py ||---> models.py ||---> tests.py ||---> utils.py ||---> views.py Gameplay/Models.py from __future__ import unicode_literals # if you use this put this first from django.utils.encoding import python_2_unicode_compatible from django.db import models from django.db.models import Q from django.contrib.auth.models import User GAME_STATUS_CHOICES = ( ('F', 'First Player To Move'), ('S', 'Second Player To Move'), ('W', 'First Player Wins'), ('L', 'Second Player Wins'), ('D', 'Draw') ) class GameQuerySet(models.QuerySet): def games_for_user(self, user): return self.filter( Q(first_player=user) | Q(secondplayer=user) ) def active(self): return self.filter( Q(status='F') | Q(status='S') ) player/views.py from django.shortcuts import render from gameplay.models import Game def home(request): my_games = Game.objects.games_for_user(request.user) active_games = my_games.active() return render(request, "player/home.html", {'games':active_games} so my code runs and functions correctly but when I type Game.objects. (games_for_user) doesn't show up, even when i press ctrl+space. I have … -
Django ManyToMany or ForeignKey
Really loving Django so far, however, I came across a problem that I'm having trouble grasping. I will try to simplify my models down to the core problem I'm facing. Let's say I have three models. class Website(models.Model): url = models.CharField(max_length=120) class External_Link(models.Model): source_website = models.ForeignKey(Website, on_delete=models.CASCADE, related_name='src') data = models.ForeignKey('Link_Data', on_delete=models.CASCADE, related_name='data') occurrences = models.IntegerField(default=1) class Link_Data(models.Model): domain = models.CharField(max_length=120) response_code = models.CharField(blank=True) last_updated = models.DateTimeField('Last updated', auto_now=True) A website can have many external links, each occurs a number of times, be it one or 2^32. A external link also has some data attached to it in a separate model. The data is in a separate model because it does not change often, so in case the link appears again on a different website the existing data can be reused to reduce data redundancy. The code above does partially work, however, there must be a better way. The queries to navigate this tree seem far too long for it to be the optimal way. -
How to send files to website after needing to login in another url?
I am making a Pyqt5 app and I'm trying now to make it post a file on my django website with a button click. I can make the script login to my site using requests with no problem (using csrftoken), but when uploading the file (to "http://127.0.0.1:8000/ranking") it raises an 403 Forbidden Error ("CSRF cookie not set.") even though I sent the csrftoken with the file. Here is the code: send_file.py import requests login_url = "http://127.0.0.1:8000/accounts/login/" MAX_RETRIES = 2 client = requests.Session() adapter = requests.adapters.HTTPAdapter(max_retries=MAX_RETRIES) client.mount('http://', adapter) # I know that I should use https, but the server doesn't have it yet client.get(login_url) # Goes to login page csrftoken = client.cookies['csrftoken'] # get csrf token login_data = {'username': 'b','password':'senha123', 'csrfmiddlewaretoken': csrftoken} try: response = client.post(login_url, data=login_data) # executes login if "Logout from b" in str(response.content): # this is to confirm the user logged in print("Logged in at {}".format(response.url)) # "Logged in at http://127.0.0.1:8000/home/" response2 = client.get('http://127.0.0.1:8000/ranking/') # Goes to the uploading page print("Logged in at {}".format(response2.url)) # "Logged in at http://127.0.0.1:8000/ranking/" csrftoken1 = client.cookies['csrftoken'] # get another crsf token file_data = {'csrfmiddlewaretoken': csrftoken1} headers = {"Referer": 'http://127.0.0.1:8000/ranking/'} print(csrftoken, csrftoken1) # Both are different with open('Data\\training_data.npy', 'rb') as f: r = … -
Loading the HTML while still working in Django (probably through asynchronous functions)
I have this project that I’ve been working on for a while https://github.com/Grumpy-Kat/WebScraping In the views.py, I scrape a lot of information from IMDB, with each call taking around 0.3 of a second. Meanwhile my page will stand idle. I want to have it load the page and then finish up the call. For instance, I want it to load the recommended after already showing the actors and actresses that played in both. Or in index, I want to allow the user to type and then show the options to click on. I’ve tried Celery with Redis, but Django can’t display asynchronous tasks. How could I do this? Thank you. -
Best way to query and save necessary objects
I am creating a website that allows user to follow certain stocks and view articles related to what they follow. In 'index.html' On index.html I would only like to show the last 5 Articles for each Stock the user follows. How can this be accomplished? models.py: class Stock(models.Model): name = models.CharField(max_length = 50) ticker = models.CharField(max_length = 50) class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) followed_stocks = models.ManyToManyField(Stock, blank=True) @receiver(post_save, sender=User) def update_user_profile(sender, instance, created, **kwargs): if created: Profile.objects.create(user=instance) instance.profile.save() class Article(models.Model): stock = models.ForeignKey(Stock, on_delete=models.CASCADE, default = 0 ) title = models.CharField(max_length = 200) url = models.URLField() description = models.TextField() views.py: def index(request): stocks_user_follows = list(request.user.profile.followed_stocks.all()) articles_to_display = Article.objects.filter(stock__in = stocks_user_follows) return render(request, 'core/index.html', {'stocks_user_follows':stocks_user_follows, 'articles_to_display':articles_to_display}) index.html: <div class="container"> <div class="row"> {% for stock in stocks_user_follows %} <div class="col-md-4"> <div class="card"> <h2>{{ stock }}</h2> <ul> {% for article in articles_to_display %} {% if article.stock == stock %} <li><a href="{{article.url}}">{{ article.title }}</a></li> {% endif %} {% endfor %} </ul> <a href="#" class="btn btn-light w-50 mx-auto mb-4">All {{ stock }} News</a> </div> </div> My current code prints every Article for each Stock the user follows, but I would only like to display the last five articles for each stock. I realized this … -
Testing Homepage in Django returning 404
Writing a Django test to test if the home page properly loads. The homepage of my site isn't '/' but rather '/home/' and the '/' and '/home' actually redirects to '/home/' so I have written the following test suite for this: tests_main.py from django.test import TestCase class homepage_redirects(TestCase): def test_redirect_homepage(self): r1 = self.client.get('/') r2 = self.client.get('/home') self.assertEqual(r1.status_code, 301) self.assertEqual(r1.url, '/home/') self.assertEqual(r2.status_code, 301) self.assertEqual(r2.url, '/home/') class homepag_loads(TestCase): def test_homepage(self): r = self.client.get('/home/') self.assertEqual(r.status_code, 200) For some reason, homepage_redirects tests don't fail, but the homepage_loads fails with the following traceback. Traceback self.assertEqual(r.status_code, 200) AssertionError: 404 != 200 Weirdly enough, if I go to the python django shell, I should be getting a 200 status code. Python Shell In[1]: from django.test import Client In[2]: c = Client() In[3]: c.get('/home/') Out[3]: <HttpResponse status_code=200, "text/html; charset=utf-8"> What am I doing wrong? -
ListSerializer in Django Restful - When is it called?
I have the following code for my serializers.py: from rest_framework import serializers from django.db import transaction from secdata_finder.models import File class FileListSerializer(serializers.ListSerializer): @transaction.atomic def batch_save_files(file_data): files = [File(**data) for data in file_data] return File.objects.bulk_create(files) def create(self, validated_data): print("I am creating multiple rows!") return self.batch_save_files(validated_data) class FileSerializer(serializers.ModelSerializer): class Meta: list_serializer_class = FileListSerializer model = File fields = (...) # omitted I'm experimenting with it on my Django test suite: def test_file_post(self): request = self.factory.post('/path/file_query', {"many":False}) request.data = { ... # omitted fields here } response = FileQuery.as_view()(request) It prints I am creating multiple rows!, which is not what should happen. Per the docs: ... customize the create or update behavior of multiple objects. For these cases you can modify the class that is used when many=True is passed, by using the list_serializer_class option on the serializer Meta class. So what am I not understanding? I passed in many:False in my post request, and yet it still delegates the create function to the FileListSerializer! -
Django rendering correct view but incorrect URL
I'm creating a video sharing application. On my video page, I have allowed users to post comments and to delete comments. def video_content(request, video_id): video = get_object_or_404(Video, pk=video_id) .... return render( request, 'video-content.html', context={ 'video': video, } ) I'm obviously omitting a lot of things in the code. I also have a comment handler function def add_comment(request, video_id): video = get_object_or_404(Video, pk=video_id) if request.method == 'POST' and request.user.is_authenticated: # Get comment and save it return HttpResponse() On my video page, I have a form: <form action="/comment/add/{{video.id}}" method="post"> <input type="text"></input> <button type="submit">Comment</button> </form> All of this works fine. When the user inputs a comment and submits the form, the add_comment function is successfully called just like its supposed to, and the comment is saved. The video page does not reload, which is what I want, but the URL on the top bar changes. How can I prevent that from happening? -
Select only 5 objects at a time django [duplicate]
This question already has an answer here: Query a certain number of objects django 1 answer I am creating a website that allows user to follow certain stocks and view articles related to what they follow. In 'index.html' I would only like to show the last 5 Articles for each Stock the user follows. How can this be accomplished? models.py: class Stock(models.Model): name = models.CharField(max_length = 50) ticker = models.CharField(max_length = 50) class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) followed_stocks = models.ManyToManyField(Stock, blank=True) @receiver(post_save, sender=User) def update_user_profile(sender, instance, created, **kwargs): if created: Profile.objects.create(user=instance) instance.profile.save() class Article(models.Model): stock = models.ForeignKey(Stock, on_delete=models.CASCADE, default = 0 ) title = models.CharField(max_length = 200) url = models.URLField() description = models.TextField() views.py: def index(request): stocks_user_follows = list(request.user.profile.followed_stocks.all()) articles_to_display = Article.objects.filter(stock__in = stocks_user_follows) return render(request, 'core/index.html', {'stocks_user_follows':stocks_user_follows, 'articles_to_display':articles_to_display}) index.html: <div class="container"> <div class="row"> {% for stock in stocks_user_follows %} <div class="col-md-4"> <div class="card"> <h2>{{ stock }}</h2> <ul> {% for article in articles_to_display %} {% if article.stock == stock %} <li><a href="{{article.url}}">{{ article.title }}</a></li> {% endif %} {% endfor %} </ul> <a href="#" class="btn btn-light w-50 mx-auto mb-4">All {{ stock }} News</a> </div> </div> My current code prints every Article for each Stock the user follows, but I would … -
Combine 2 object of same model Django
Is there any way to combine/merge 2+ objects of the same model to 1 with total values of all field. I mean like Author.objects.annotate(Sum('book__pages')) but for all fields in model. 1 object - {'user':2, 'events':20, 'time': 233} 2 object - {'user':2, 'events':10, 'time': 400} need total - {'user':2, 'events':30, 'time': 633} thx -
How to put image url in Open Graph tags
I have a problem showing an image from my Open Graph tags, and there is my OG tags, and here is my OG tags. <meta name="description" content="Modvisor is the place to find store and boutique reviews, promo codes, return and exchange policy, similar stores, and more."> <meta name="keywords" content="modvisor, women, clothing, boutiques, stores, reviews, promo codes, coupons, similar stores"> <meta property="og:site_name" content="Modvisor"> <meta property="og:site" content="modvisor.com"> <meta property="og:title" content="Modvisor: Store & Boutique Reviews, Promo Codes, Similar Stores"> <meta property="og:description" content="Modvisor is the place to find store and boutique reviews, promo codes, return and exchange policy, similar stores, and more."> <meta property="og:image" content="https://s3-us-west-1.amazonaws.com/connectshops/static/boutique/img/modvisor_logo_white.png" /> <meta property="og:image:secure_url" content="https://s3-us-west-1.amazonaws.com/connectshops/static/boutique/img/modvisor_logo_white.png" /> <meta property="og:image:type" content="image/png" /> <meta property="og:image:width" content="400" /> <meta property="og:image:height" content="300" /> <meta property="og:url" content="https://www.modvisor.com/"> <meta property="og:type" content="website"> When I gave a link on some messenger, the OG tags show everything perfectly except for the image. I'm currently dealing with the image in AWS S3. When you check the link, it's working well too. Is there something wrong on my codes? -
Django isn't loading static admin files
when I access to my admin dashboard in Django, it doesn't load css and img files, so doesn't work well. All the files are in 'project/static/admin', and in my settins.py I have this: STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, "static") When I execute collectstatic, appears: 0 static files copied to '/opt/myenv/myenv/static', 318 unmodified. I'm using Nginx + Gunicorn, also I'm using https with Cloudflare. Can anyone help me? Thanks. -
Django scaling beginner advice / resources
I am a relatively new to Django web development with about one year of experience with programming as a whole, and a few months less with Django web development. With two friends we came up with a business idea, and we are developing that. And even though I (I am the person programming the most, together with one more experienced friend guiding me) am quite new to this, I would like to make this project a success. So, to come to the point, I would like to set up the project in such a way that the project could handle large loads with grace, in the future. I am thinking about a worldwide platform, and so, a very large number of visitors. We are using Django Rest Framework to build an API which serves a ReactJS powered front-end, using PostgreSQL as our database. Short description of application: The web application will be a platform where (registered) users will be able to manage their storage. Other users (registered or not) will be able to search within the total storage. It will not be a website that handles a lot of media (images, videos). And their will not be a lot of … -
How to Set Default Version of Python to 3.x vs 2.7 on Mac OSX?
I am attempting to install django framework using pip install -e django/, however, it requires Python 3.5+. Mac OSX by default comes with Python 2.7 so I have installed Python 3.6.5 from the python website. I have confirmed the latest version of Python is installed through python3 . I am still unable to install Django likely because Python 2.7 is also installed and seen first by pip. Is it necessary to remove Python 2.7 from my system or can I modify PYTHON_HOME to achieve what I would like to do? -
Embedding a variable in an html style tag in Django
I have this code in my template syntax: {% for massage in massages %} <div style="background-image: url('{% static 'application/images/" + {{massage.name}} + ".jpg' %}');"> <p>{{massage.name}}<span class="price">${{massage.price}}</span><br /><br /> <small>{{massage.desc}}</small></p> </div> {% endfor %} However, it is not fetching the image because it isn't reading the variable. What do I need to do? -
Django, set img src dynamicly
Before someone marks this as duplicate I have read and tryed solutions in these threads: Use Django Template Tags in img src django 1.5 - How to use variables inside static tag Django: Insert image in a template whose path is dynamic And still have not been able to get it to work. So I'm using Django built in UpdateView to update an data base entry and I'm trying to load image to template where part of src is dynamic like this: edit_journal_entry_form.html {% extends 'base.html' %} {% load staticfiles%} <form method="post"> {% csrf_token %} {% static "" as baseUrl %} <img src="{{ baseUrl }}/lpr_images/{{journalEntry.license_plate_nr_img}}"></img> <img src="{% static "" %}/lpr_images/{{journalEntry.license_plate_nr_img}}" /> <img id="edit_img" src="{% static 'lpr_images/' %}{{journalEntry.license_plate_nr_img}}" alt="Image not read!"/> {{ form.as_p }} <button class="btn btn-success" type="submit">Submit</button> ... views.py class JournalEntryUpdate(UpdateView): model = JournalEntry template_name = 'gate_operator/edit_journal_entry_form.html' success_url = '/gate_operator/journal/' fields = [ 'license_plate_nr', 'license_plate_nr_img', ... ] def form_valid(self, form): object = form.save(commit=False) object.user = self.request.user object.save() return super(JournalEntryUpdate, self).form_valid(form) models.py class JournalEntry(models.Model): license_plate_nr = models.CharField(max_length=20, blank=True) license_plate_nr_img = models.CharField(max_length=100, blank=True) ... None of this works in console I can se that I'm getting only the static part: GET http://127.0.0.1:8000/static//lpr_images/ 404 (Not Found) I tried to hard code the url … -
How to handle multiple buttons that need to post parts of the same information to different locations
My HTML currently has three buttons. The first button is an update, which is to POST the student information to an update view. I can't seem to get this to work correctly to post to a different view. My second button submits my POST to a view called submittedand is currently working as intended. Below is my html which has two buttons, the first is the one i'm having issues with the other is working as intended. Essentially what i'm trying to do is POST the student information to my update view. I've tried to nest the forms, but regardless of what I do pushing the button submits to the same view. {% extends 'base.html' %} {% load static %} {% block head %} <title> Profile </title> {% endblock %} {% block content %} <form action = "{% url 'submitted' %}" form method = "POST"> <form action = "{% url 'update' %}" form method = "POST"> {% csrf_token %} <div class="well"> <h4 style="margin-top: 0"><strong> Student Details </strong></h4> <div class="row"> <div class="form-group col-md-4"> <label/> 3-4 Student ID <input class="form-control" type="text" name = "studentpost" value= "{{student.studentntname}}" readonly> </div> <div class="form-group col-md-4"> <label/> First Name <input class="form-control" type="text" value= "{{student.studentfirstname}}" readonly> </div> <div … -
Django serializer DoesNotExist: Task matching query does not exist error
I have a scenario model: class Scenario(models.Model): stakeholder = models.ForeignKey(User, related_name='scenarios', blank=True,) tasks = models.ManyToManyField(Task, blank=True) Serializer: class ScenarioSerializer(serializers.ModelSerializer): tasks = TaskSerializer(many=True, required=False) class Meta: model = Scenario fields = '__all__' def create(self, validated_data): tasks = validated_data.pop('tasks') instance = Scenario.objects.create(**validated_data) for task_data in tasks: print('task_data: ', task_data) task = Task.objects.get(pk=task_data.get('id')) instance.tasks.add(task) return instance def update(self, instance, validated_data): tasks = validated_data.pop('tasks', []) instance = super().update(instance, alidated_data) for task_data in tasks: task = Task.objects.get(pk=task_data.get('id')) instance.tasks.add(task) return instance and view to create a scenario: elif request.method == 'POST': print(request.data) serializer = ScenarioSerializer(data=request.data) if serializer.is_valid(): serializer.save(stakeholder=request.user) return Response(serializer.data, status=status.HTTP_201_CREATED) else: return Response( serializer.errors, status=status.HTTP_400_BAD_REQUEST) the print statement in view prints: {u'tasks': [{u'what_can_go_wrong': u'', u'stakeholder': 2, u'why_perform_task': u'', u'how_often': u'', u'title': u'Seven', u'how_important_task': u'', u'people_involved': u'', u'special_training_required': None, u'why_important_task': None, u'project': 1, u'sequence_of_actions': u'', u'how_important_improvement': u'', u'role': u'', u'benefits_of_improvement': u'', u'effects_of_task': u'', u'tools_used': u'', u'special_vocabulary_used': u'', u'id': 7, u'any_improvements': u'', u'what_training_required': u''}, {u'what_can_go_wrong': u'', u'stakeholder': 2, u'why_perform_task': u'', u'how_often': u'DS', u'title': u'Eight', u'how_important_task': u'', u'people_involved': u'', u'special_training_required': None, u'why_important_task': None, u'project': 2, u'sequence_of_actions': u'', u'how_important_improvement': u'', u'role': u'', u'benefits_of_improvement': u'', u'effects_of_task': u'', u'tools_used': u'', u'special_vocabulary_used': u'', u'id': 8, u'any_improvements': u'', u'what_training_required': u''}]} print statement in serializer create() method prints: ('task_data: ', OrderedDict([(u'title', u'Seven'), (u'how_often', u''), …