Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
ImportError: cannot import name '...' from partially initialized module '...' (most likely due to a circular import)
I'm upgrading an aplication from django 1.11.25 (python 2.6) to django 3.1.3 (python 3.8.5) and, when I run manage.py makemigrations, I receive this messasge: File "/home/eduardo/projdevs/upgrade-intra/corporate/models/section.py", line 9, in from authentication.models import get_sentinel ImportError: cannot import name 'get_sentinel' from partially initialized module 'authentication.models' (most likely due to a circular import) (/home/eduardo/projdevs/upgrade-intra/authentication/models.py) My models are: authentication / models.py class UserProfile(models.Model): user = models.OneToOneField( 'User', on_delete=models.CASCADE, unique=True, db_index=True ) ... phone = models.ForeignKey('corporate.Phone', on_delete=models.SET_NULL, ...) room = models.ForeignKey('corporate.Room', on_delete=models.SET_NULL, ...) section = models.ForeignKey('corporate.Section', on_delete=models.SET_NULL, ...) objects = models.Manager() ... class CustomUserManager(UserManager): def __init__(self, type=None): super(CustomUserManager, self).__init__() self.type = type def get_queryset(self): qs = super(CustomUserManager, self).get_queryset() if self.type: qs = qs.filter(type=self.type).order_by('first_name', 'last_name') return qs def get_this_types(self, types): qs = super(CustomUserManager, self).get_queryset() qs = qs.filter(type__in=types).order_by('first_name', 'last_name') return qs def get_all_excluding(self, types): qs = super(CustomUserManager, self).get_queryset() qs = qs.filter(~models.Q(type__in=types)).order_by('first_name', 'last_name') return qs class User(AbstractUser): type = models.PositiveIntegerField('...', default=SPECIAL_USER) username = models.CharField('...', max_length=256, unique=True) first_name = models.CharField('...', max_length=40, blank=True) last_name = models.CharField('...', max_length=80, blank=True) date_joined = models.DateTimeField('...', default=timezone.now) previous_login = models.DateTimeField('...', default=timezone.now) objects = CustomUserManager() ... def get_profile(self): if self.type == INTERNAL_USER: ... return None def get_or_create_profile(self): profile = self.get_profile() if not profile and self.type == INTERNAL_USER: ... return profile def update(self, changes): ... class ExternalUserProxy(User): … -
Put the website icon on each image uploaded
In my Django application users can upload images to be displayed on the website. I need a way to mark these images with the website icon upon upload but I can't seem to think of any way. Thanks in advance! -
How to safely use django-ckeditor with Django Rest Framework?
I've successfully implemented django-ckeditor with Django REST Framework and React, but I'm pretty sure that the way I've done it is not secure. I've created an art blog, where each art piece has a rich-text description. Here's a basic example of one of my models with a rich-text field: from ckeditor.fields import RichTextField class Artist(models.Model): biography = RichTextField(blank=True, null=False) ... So, if saved his biography as "He was a nice guy!", then DRF serializes that as: <p>He was a <em><strong>nice guy!</strong></em></p> In my React app, I render it with: <div dangerouslySetInnerHTML={{__html: artist.biography}} /> But, as the name implies, the React documentation says that this is generally risky. This is a personal blog, so I'm not worried about other users injecting code into posts. However, I'm sure that someday I'll want to provide a rich-text editor for my users. Is there a way to implement CKEditor with Django rest framework that doesn't require me to use dangerouslySetInnerHTML? If not, how can I safely implement a rich-text editor, and still use it with DRF? -
Django React js: ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
I'm creating a web app using React in the frontend and Django in the backend. I used this blog to integrate react with backend. However I get a strange error called ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine I searched the internet a lot found this question, did what the answer says but the problem persists. I don't think the database has something to do with my issue, because the pure django pages work fine but only react powered page throw this error. I found a question that is closest to mine, this one, but the question is unanswered, and apparently the problem is with loading some media page, but I just want to load <h1>Hello World!</h1>. Here's full traceback Traceback (most recent call last): File "c:\users\ilqar\appdata\local\programs\python\python38-32\lib\socketserver.py", line 650, in process_request_thread self.finish_request(request, client_address) File "c:\users\ilqar\appdata\local\programs\python\python38-32\lib\socketserver.py", line 360, in finish_request self.RequestHandlerClass(request, client_address, self) File "c:\users\ilqar\appdata\local\programs\python\python38-32\lib\socketserver.py", line 720, in __init__ self.handle() File "C:\Users\Ilqar\.virtualenvs\django-react-reddit-XsnOy92e\lib\site-packages\django\core\servers\basehttp.py", line 174, in handle self.handle_one_request() File "C:\Users\Ilqar\.virtualenvs\django-react-reddit-XsnOy92e\lib\site-packages\django\core\servers\basehttp.py", line 182, in handle_one_request self.raw_requestline = self.rfile.readline(65537) File "c:\users\ilqar\appdata\local\programs\python\python38-32\lib\socket.py", line 669, in readinto return self._sock.recv_into(b) ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine By the way, I … -
Get current user in djangocms plugins (CMSPluginBase)
I want to create a plugin whose content is different depending on the user who opens the page. I tried : @plugin_pool.register_plugin # register the plugin class RubriquePluginPublisher(CMSPluginBase): """ RubriquePluginPublisher : CMSPluginBase """ model = RubriquePluginModel # model where plugin data are saved module = "Rubrique" name = "Rubrique plugin" # name of the plugin in the interface render_template = "commission/rubrique_plugin.html" def render(self, context, instance, placeholder): context.update({'instance': instance}) query_set = Article.objects.filter(rubriques=instance.rubrique).filter(contact=self.request.user) page = context['request'].GET.get('page_{}'.format(instance.rubrique.name)) or 1 paginator, page, queryset, is_paginated = self.paginate_queryset(page, query_set, 3) context.update({'paginator': paginator, 'page_obj': page, 'is_paginated': is_paginated, 'articles': queryset }) return context But self.request doesn't exist in class CMSPluginBase. How can I access the current user? -
Filter rows from joined table
I´m struggling with an issue that seems simple but I cannot find the solution: I have a simple model to upload multiple photos to an item. Class Item: name: string Class Photo: item = ForeignKey(Item) image: ImageFile default: Boolean I want to get all the Items from the REST API but only with the default photo. Righ now I have: Class ItemViewSet(viewsets.ModelViewSet): queryset=Item,objects.all() serializer_class=ItemSerializer Class PhotoSerializer(serializers.ModelSerializer): class Meta: model = Photo fields = ['image', 'default'] Class ItemSerializer(serializers.ModelSerializer): photos=PhotoSerializer(source='photo_set', many=True) class Meta: model = Item fields = ['id', 'name', 'photos'] The problem is that I get all the photos of the Item. I don't know how to filter the Photos table to retrieve only the photos with default=True. It cannot be so difficult. Any help?? Appreciate it very much. Dalton -
Django Query contentType data for rating and review
I have a models for trip and anotehr models for rating: class Trip(models.Model): name = CharField(max_length=500) rating = GenericRelation(Ratings, related_query_name='trips') class Rating(models.Model): value = models.IntegerField() comment = models.TextField() created_on = models.DateTimeField(_("Created on"), auto_now_add=True) and this is how i am populating the trip = Trip.objects.first() ct = ContentType.objects.get_for_model(trip) rating = Ratings.objects.create( value = data['value'], comment = data['comment'], content_type = ct, content_object = trip, ) But the problem is when I query the data for rating like this: trip = Trip.objects.first() review = trip.rating.all() for r in review: print(r.created_at) it through me following error: AttributeErrorTraceback (most recent call last) <ipython-input-10-632676dd4f8f> in <module> 3 review = trip.rating.all() 4 for r in review: ----> 5 print(r.created_at) AttributeError: 'Ratings' object has no attribute 'created_at' But when i query in same way for comment: trip = Trip.objects.first() review = trip.rating.all() for r in review: print(r.commnet) It really works, also it returning value and created_by too like this r.value and r.created_by But the question is whats wrong with created_at? also when i add new fields like test_test = models.CharFeled..blab bla fields, they are not getting and fireing same error like such attribute not exist. my question is why comment and value are returning and why other are … -
Is it possible to pass a Django id inside an HTML element, to a jQuery function?
I am displaying a list of blog posts in a for loop, each has a comment form with send button underneath it. I need to let Django know which specific post has been clicked on so have added {{post.id}} to the button element's id. How do I then pass this information to jQuery? Is it possible to do something like this? <button id="addComBtn{{post.id}}...>Send</button> $('#addComBtn //post.id here').click(function() { ... }); Or is there a better way? -
Trouble integrating mysqlclient and django on windows
I've already tried: pip3 install mysqlclient This raised the error: It was not possible to include the file: 'mysql.h': No such file or directory Then I've tried: pip3 install mysqlclient-1.4.6-cp39-cp39-win_amd64.whl Which raised no errors. Then when I tried again: pip3 install mysqlclient It said: Requirement already satisfied: mysqlclient in c:\path\to\venv\lib\site-packages (1.4.6) Then when I type: python3 manage.py migrate No output is given and no modification is done to the database file. But whenever I try, as the django tutorial sugests: python3 manage.py makemigrations polls The following error raises: django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient? I am using a windows x64 enviroment and running codes on Windows PowerShell into a python3.9 virtual enviroment. Those are the packages and respective versions installed: Package Version ----------- ------- asgiref 3.3.1 Django 3.1.3 mysqlclient 1.4.6 pip 20.2.4 pytz 2020.4 setuptools 49.2.1 sqlparse 0.4.1 -
how to fix error: value too long for type character varying(20)
I'm trying to create an object in my view but this error raises: "value too long for type character varying(20)". I googled alot but i couldnt find an answer for this problem. (please let me know if there is) It happened when i add this column to my model: api_url = models.URLField() After i added this to the model, i ran the makemigrations/migrate without any problem. But when i load my view where i'm creating this new object, the error raises. What i tried: i've set the max_length=255 changed the "api_url" to CharField and TextField added a string "https://example.com" instead of the_url variable. unfortunately, the above didn't work so i'm not sure how to fix this issue. The weird thing about this, is that i did the exact same changes to my local project with a SQLite database, and it doesnt give me that error. So i think this has something to do with the PostgreSQL database. The objects.create() in my view where the error raises: Order.objects.create(ordernumber=ordernumber, order_id=id, full_name=full_name, email=email, price=price, created_at=created_at, status=status, paid=paid, paymethod=paymethod, address_line_1=address_line_1, address_line_2=address_line_2, zipcode=zipcode, city=city, telephone=telephone, country_code=country_code, services=service, total_tax=total_tax, price_excl_tax=price - total_tax, api_url=the_url) note: all the data is coming from a API call and i double … -
ObtainAuthToken view keep asking me about username
I've cereated custom user model. And I want to get teken for my user. I'm sending request with login and password. In response I'm getting "username": [ "This field is required." ] It's weird because in mmy user model this field is replaced by login field. What Am i doing wrong ? My User Model class CustomUser(AbstractBaseUser): login = models.CharField(max_length = 20, primary_key = True) password = models.CharField(max_length = 20) name = models.CharField(max_length = 20) surname = models.CharField(max_length = 20) city = models.ForeignKey(City,on_delete=models.CASCADE, null = True) is_patient = models.BooleanField(default=True) # Required for the AbstractBaseUser class date_joined = models.DateTimeField(verbose_name='date joined', auto_now_add=True) last_login = models.DateTimeField(verbose_name ='last login', auto_now=True) is_admin = models.BooleanField(default=False) is_active = models.BooleanField(default=True) is_staff = models.BooleanField(default=False) is_superuser = models.BooleanField(default=False) USERNAME_FIELD = 'login' REQUIRED_FIELDS = ['password'] objects = CustomUserManager() def __str__(self): return self.login # Required for the AbstractBaseUser class def has_perm(self, perm, obj=None): return self.is_admin def has_module_perms(self, app_label): return True I have added to settings.py this line AUTH_USER_MODEL = 'asystentWebApp.CustomUser' My view class AuthToken(ObtainAuthToken): def post(self, request, *args, **kwargs): serializer = self.serializer_class(data=request.data, context={'request': request}) serializer.is_valid(raise_exception=True) user = serializer.validated_data['user'] token, created = Token.objects.get_or_create(user=user) return Response({ 'token': token.key, 'login' : user.login }) -
How can Django and Django Rest Framework be used to create complex applications
How can a complex app like dropbox, Zoom, or Google Search be created using Django or Django-rest-framework. I understand how something like a blog, a LMS, a e-store, or something simple would work, but how about a complex file storage app, video conference, or search engine be created? -
How to group items by month and year using itertools.groupby()
Problem: I am trying to take a sorted list and group it based on the month and year but having trouble returning the grouped value correctly... Assuming this data, we have a title and date/time list that has been ordered by datetime lst = [ {'title': 'in the past','date_time': datetime.datetime(2020, 3, 18, 0, 0)}, {'title': 'Just another event','date_time': datetime.datetime(2020, 10, 1, 19, 7)}, {'title': 'earlier today 9am','date_time': datetime.datetime(2020, 10, 21, 9, 0)}, {'title': 'greater than .now()','date_time': datetime.datetime(2020, 10, 21, 23, 0)}, {'title': 'another one','date_time': datetime.datetime(2020, 10, 30, 10, 0)}, {'title': 'Me testing the latest event','date_time': datetime.datetime(2020, 10, 30, 12, 0)}, {'title': '18 Nov 20','date_time': datetime.datetime(2020, 11, 18, 20, 27)}, {'title': '18 January 2021','date_time': datetime.datetime(2021, 1, 18, 20, 0)}, {'title': '18 March 21','date_time': datetime.datetime(2021, 3, 18, 20, 0)} ] Then to group it, run it through itertools.groupby() from itertools import groupby def loop_tupe(): diction = {} for key,group in groupby(lst, key=lambda x: (x['date_time'].month, x['date_time'].year)): for element in group: append_value(diction, key, element) return diction After grouping it by the month and year the returned result looks like { (3, 2020): {'title': 'in the past', 'date_time': datetime.datetime(2020, 3, 18, 0, 0)}, (10, 2020): [ {'title': 'Just another event', 'date_time': datetime.datetime(2020, 10, 1, 19, … -
Why is Django trying to open a URL that I don't tell it to?
Hello Community! I am creating a small blog with Django, in which I have a single application. It happens that I have already defined a large part of the blog, this is: The Home view. Views for the categories of each publication. View for each of the posts Among other Now that I have wanted to add the "About Author" view, when it should redirect to its respective HTML template, Django ends up redirecting itself to another template, which generates a NoReverseMatch error. Simplifying the code, this is: views.py: from django.shortcuts import render from django.views.generic import ListView, DetailView from .models import Post, Author, Category class Home(ListView): def get(self, request, *args, **kwargs): context = { 'post': Post.objects.get(title='NamePost') } return render(request, 'PageWebApp/home.html', context) class PostSimple(DetailView): def get(self, request, slug_post, *args, **kwargs) context = { 'post': Post.objects.filter(slug_post=slug_post) } return render(request, 'PageWebApp/page-simple.html', context) class PostsCategory(DetailView): def get(self, request, category, *args, **kwargs): # View that shows each of the categories within the blog context = { 'categories': Category.objects.get(category=category) } return render(request, 'PageWebApp/posts-category.html', context) class AboutAuthor(DetailView): def get(self, request, slug_autor, *args, **kwargs): context = { 'author': Author.objects.get(slug_author=slug_author) } return render(request, 'PageWebApp/page-author.html', context) urls.py from django.contrib import admin from django.urls import path from PageWebApp import views urlpatterns … -
Is the combo of JavaScript on front end and Django + python on back end is good or not?
Actually i have a web app development project to do and i want to work through Django and python i am yet to decide the topic. I first want to decide front and back end development frameworks and languages. Let's suppose i want to build restaurant management system, should i use this combo or not in restaurant management system or python and Django are good as full stack only project will also need some little data mining work too (like predicting food orders etc.) continuing 3 where will that data mining lie (at back end) -
Why is my Django form for user sign up not “valid”? ValidationError 'This field is required.'
I am trying to write a signup form in Django, but I keep getting a Validation error when I post 'date_joined': [ValidationError(['This field is required.']) The form is based on the django user model. I have not got this field on the form because it's value can be set in code html <form method="post" action="{% url 'sign-up' %}"> {% csrf_token %} <h1>Bid for Game - Sign Up</h1> Your first and last names will be used to help your friends identify you on the site. <table> <tr> <td>{{ signup_form.first_name.label_tag }}</td> <td>{{ signup_form.first_name }}</td> </tr> <tr> <td>{{ signup_form.last_name.label_tag }}</td> <td>{{ signup_form.last_name }}</td> </tr> <tr> <td>{{ signup_form.username.label_tag }}</td> <td>{{ signup_form.username }}</td> </tr> <tr> <td>{{ signup_form.email.label_tag }}</td> <td class='email'>{{ signup_form.email }}</td> </tr> <tr> <td>{{ signup_form.password.label_tag }}</td> <td><class='password'>{{ signup_form.password }}</class></td> </tr> <tr> <td>Confirm password: </td> <td class='password'>{{ signup_form.confirm_password }}</class</td> </tr> </table> <button type="submit" class="btn btn-success">Submit</button> </form> forms.py class SignupForm(forms.ModelForm): first_name = forms.CharField(label='First name', max_length=30) last_name = forms.CharField(label='Last name', max_length=30) username = forms.CharField(label='User name', max_length=30) email = forms.EmailField(label='Email address', widget=forms.EmailInput(attrs={'class': 'email'})) password = forms.PasswordInput() confirm_password=forms.CharField(widget=forms.PasswordInput()) date_joined = forms.DateField() class Meta: model = User fields = '__all__' widgets = { 'password': forms.PasswordInput(), 'password_repeat': forms.PasswordInput(), } @staticmethod def initialise(request): """Return a dict of initial values.""" initial = { … -
Django - Error while trying to iterate a model class (db table) in views.py (need to compare dates)?
The idea is to compare a checking date & a checkout date stored , with checking & checkout dates obtained from a html file (hotel booking, with this I'm trying to see if there are habitaciones [rooms] available) this is what I did in views.py This is the models.py file This is the error that I get thanks in advance!!! -
redirect to a Django url in another app using JavaScript
Right now I have two apps in the project, here is the project structure: The current function being called is in chess1 and I want to redirect to a url in Chess_Django. My url in Chess_Django/urls.py is path('start/', views.start_game, name='start'). I tried to use window.location.href = "{% url 'Chess_Django:start/' %}". But I got this error: Right now I am able to access it using the absolute path. But I am just curious how to achieve it using Django template language. Thanks! -
removing the string character in integer value : Python
i want to remove the string character from int value in a list. when i remove str character from below statement then it's throw me TypeError: 'int' object is not iterable. how can i achieve that? for record in serializer.data: if record: less_eight = [x for x in str(record['car_cc'])] print(less_eight) else: #some logic output: ['8', '0', '0'] ['5', '0', '0'] what i want is: [8, 0, 0] [5, 0, 0] -
My function is creating and deleting objects incorrectly (django)
I'm trying to create or delete an object based on certain conditions. I am looping through rows on a csv as below. My problem is I am restricted as my variables are defined from within the csv loop, so when I delete - instead of deleting all, it deletes the object, then continues through the code and creates the next corresponding one on the csv, and then deletes the next one down etc for each row. My intention is to delete all the objects first, regardless of what is on the csv. And then create according to the csv - but I can't figure out how to do this as the variables are all contained within the loop. I hope that makes sense!! Please help list_of_people = [1,2,3,4] for row in csv: id = row["id"] person = Object1.objects.filter(id=id).first() if person=4203: Object1.objects.filter(id=id).exclude(otherfield__isnull=True).delete() if person not in list_of_people: Object1.objects.create(person=person) -
Endless Django websocket
There is a page that has a button that I can click and initiate the process on the server via Websocket. I get information about process via Websocket. How can I close and reopen the page to see the current status of the process, not at first, without a disconnect? -
how to create an api for nested comments in django rest framework?
I want to have a nested comment system for my project. I have product model so I want to clients can comment on my products. I have my product and comment models and serializers and I related comments to products in product serializer so I can show product comments. what should i do to clients can write their comment for products??? the comments must be nested. this is my code: #models class Comment(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) product = models.ForeignKey(Product, on_delete=models.CASCADE, related_name='comments') parent = models.ForeignKey('self', on_delete=models.CASCADE, null=True,blank=True, related_name='replys') body = models.TextField() created = models.DateTimeField(auto_now_add=True) def __str__(self): return f'{self.user} - {self.body[:30]}' class Meta: ordering = ('-created',) serializers: class CommentSerializer(serializers.ModelSerializer): class Meta: model = Comment fields = ['id', 'user', 'product', 'parent', 'body', 'created'] class ProductSerializer(serializers.ModelSerializer): comments = CommentSerializer(many=True, read_only=True) class Meta: model = Product fields = ['id', 'category', 'name', 'slug', 'image_1', 'image_2', 'image_3', 'image_4', 'image_5', 'description', 'price', 'available', 'created', 'updated', 'comments'] lookup_field = 'slug' extra_kwargs = { 'url': {'lookup_field': 'slug'} } views: class Home(generics.ListAPIView): queryset = Product.objects.filter(available=True) serializer_class = ProductSerializer permission_classes = (permissions.AllowAny,) filter_backends = [filters.SearchFilter] search_fields = ['name', 'category__name', 'description'] class RetrieveProductView(generics.RetrieveAPIView): queryset = Product.objects.all() serializer_class = ProductSerializer permission_classes = (permissions.AllowAny,) lookup_field = 'slug' -
the JSON object must be str, bytes or bytearray, not ListSerializer
I have a queryset which is: queryset = Business.objects.raw(query) I am trying to serialize the query using the Business serializer: serialized_data = BusinessSerializer(queryset, many=True) However, for some reason I get the error: the JSON object must be str, bytes or bytearray, not ListSerializer. The serialization works if I use the following: serialized_data = serializers.serialize('json', queryset) Could someone please tell me why I am unable to use the business serializer? Is it something to do with the raw query? Thanks in advance. -
In django using elastic search client how to insert data in elasticsearch document?
Basicall i am using django-elastic-search dsl...i am dealing with this model--> Class Post: .. title = models.Charfield() ...body = models.Charfield() I want to index it in my locally running index at localhost:9200 directly without writing any document.beacause i have al ready created the index in localhost:9200, I just want to push it through with a es client? -
How to save extra data sent using django signals in a model related to User model via OneToOne relationship?
I am trying to create a signup functionality for the Teacher model. The Teacher model is related to Django's User model via an OneToOne relationship. When I am trying to save the serializer I am getting this error- IntegrityError at /teacher/create-teacher NOT NULL constraint failed: teacher_teacher.school_id_id My Teacher model: from django.contrib.auth.models import User from django.core.validators import RegexValidator from django.db import models from django.db.models.signals import post_save from django.dispatch import receiver from school.models import School class Teacher(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) contact = models.CharField(max_length=10, validators=[RegexValidator(r'^\d{10}$')]) school_id = models.ForeignKey(School, on_delete=models.CASCADE) @receiver(post_save, sender=User) def create_user_teacher(sender, instance, created, **kwargs): if created: Teacher.objects.create(user=instance) @receiver(post_save, sender=User) def save_user_teacher(sender, instance, **kwargs): instance.teacher.save() TeacherCreateView: class TeacherCreateView(APIView): def post(self, request): serializer = TeacherSerializer(data=request.data) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) TeacherSerializer: from django.contrib.auth.models import User from rest_framework.serializers import ModelSerializer, EmailField, CharField from rest_framework.validators import UniqueValidator class TeacherSerializer(ModelSerializer): email = EmailField(required=True, validators=[UniqueValidator(queryset=User.objects.all())]) password = CharField(min_length=8, write_only=True) def create(self, validated_data): user = User.objects.create( email=validated_data['email'], username=validated_data['username'], first_name=validated_data['first_name'] ) user.set_password(validated_data['password']) user.teacher.contact = validated_data['contact'] user.teacher.school_id = validated_data['school_id'] user.save() return user class Meta: model = User fields = ['email', 'username', 'password', 'first_name'] JSON data for creating the teacher: { "email":"teacher@gmail.com", "username":"teacher", "password":"somepassword", "first_name": "Teacher", "contact":"1234567890", "school_id":"school" } The twist is that the email, first_name, …