Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Can Auth0 JWT Tokens Be Used to Send POST Requests to Django Backend?
I was unable to find any valid documentation for the last 5-6 days on how to resolve my issue of sending POST-requests to a JWT (Auth0) secured API backend built on Django. I hope someone can help to verify if sending POST-requests is at all possible or what alternatives I may look at. My current issue stems from a supposed final major bug with using Auth0 JWT Tokens, through the Client Credential Flow M2M method. Though I may understand that I am using a very unique setup: React Frontend Django Backend No user login intended to access secured API access I guess it just now leads me to questioning on whether simply, “Can I even send POST requests to a Auth0 JWT Token secured backend?”. If it is possible, hope someone may redirect me to a potential solution, else, at least I know I really need to source something else entirely. The potential solutions I do only see with a React frontend, is to actually build a: Express.js backend Enable user-account login access This would not be ideal as both options are not the intended use case, and it will dramatically require me to change extensive code, especially to rebuild … -
pyintaller keeps giving error when converting django app to exacutable
I am trying to convert a Django project in visual studio 2019 into an executable file. I am using pyInstaller but it keeps giving me this errer: TypeError: expected str, bytes or os.PathLike object, not NoneType I have a virtual environment and a all of my necessary packages are in there the command I am using is: pyinstaller --name=mysite mysite/manage.py An error for generating an exe file using pyinstaller - typeerror: expected str, bytes or os.PathLike object, not NoneType This page explains that you need to go into one of the files of pyInstaller and replace it with a different version, but I don't know how to open the source code for pyInstaller, there is no option to do that in visual studio. 12034 INFO: Collecting Django migration scripts. 17330 INFO: Loading module hook "hook-encodings.py"... 17405 INFO: Loading module hook "hook-pkg_resources.py"... 17863 INFO: Processing pre-safe import module hook win32com Traceback (most recent call last): File "<string>", line 2, in <module> ModuleNotFoundError: No module named 'win32com' 17923 INFO: Processing pre-safe import module hook win32com Traceback (most recent call last): File "<string>", line 2, in <module> ModuleNotFoundError: No module named 'win32com' 17962 INFO: Loading module hook "hook-pydoc.py"... 17963 INFO: Loading module hook … -
General rule for djnago model class to always exclude "unpublished" instances
I'm searching a way to make some rule to exclude certain instances in each queryset. To follow DRY and to be sure that I(or some one else) will not accidentally include not accepted instances in queries. I'm relatively new in Djnago and didn't find the api to resolve this problem. class SomeClassModel(models.Model): value = models.CharField(max_length=244) accepted = models.BooleanField(default=False) How could I(or some one else) exclude not accepted instances from all queries? Even if I do SomeClassModel.objects.all() -
Django: DeferredAttribute object as string value to modify Context in class based ListView
In my template I would like to display a long name, however, I don't save the full name in the database, only a reference number. My attempted solution is to convert the Choices Tuple into a Dictionary prd_dic = dict(PRODUCTS) Then I call the Value in the dictionary with the Key name = prd_dic['0000'] In my list View, I modify the Context to feed the full name into the Template context['product_name'] = name When I pass an object into a place a string is expected a KeyError is raised (using DeferredAttribute object). My question is, is there a built in function to solve above, either in the View as a function to convert and feed into the Context, OR as making this conversion on the Model directly? The idea is to convert saved number into a full name according a key table to be displayed in Template. Thankful for some input. PRODUCTS = ( ('0000' , 'Hamburger'), ('1111' , 'Pizza') ) class Product(models.Model): product_number = models.CharField(max_length=20,choices=PRODUCTS, blank=True, null=True) class ProductListView(ListView): model = Product template_name = 'product/product_list.html' def get_context_data(self, **kwargs): context = super(ProductListView, self).get_context_data(**kwargs) prd_obj = Product.product_number # this is an object prd_dic = dict(PRODUCTS) name = prd_dic[prd_obj] # a single … -
how i can show my WYSIWYG Editor in my template django (html)
i want ues my data of WYSIWYG Editor in my model and show in my template django(html). my FroalaField in my model is : description = FroalaField(theme="dark",blank= True, null= True, verbose_name = 'message', help_text = 'Write Full Text') i use |safe in my template but it isn.t work! -
Django strange behaviour when an exception occurs, using django-rest-framework
I'm developing some REST api for a webservice. Starting from some days I've experienced a big problem that is blocking me. When the code has an exception (during developing) the django server respond only after 5/8 or 10 minutes... with the error that occurs. To understand what is happening I've started the server in debug using pycharm.... and then clicking on pause during the big waiting.. the code is looping here into python2.7/SocketServer.py def _eintr_retry(func, *args): """restart a system call interrupted by EINTR""" while True: try: return func(*args) except (OSError, select.error) as e: if e.args[0] != errno.EINTR: raise print(foo) What can I do? I'm pretty desperate! -
nonetype' object has no attribute 'decode' error when i upload the image to database
i am new to ionic4/angular4.i need to upload the profile pic to database.i wrote code but i don't know whether it is correct or not and when i am uploading it i am getting the above mentioned error. backed i am using Django and sorry for the bad indentation.i just beginner to programming. .ts async sendPictureToSomewhere() { const fileuri = await this.getPicture(); const blobinfo = await this.b64toBlob(fileuri); await this.upload(blobinfo); alert("done"); } async getPicture() { const options: CameraOptions = { quality: 100, destinationType: this.camera.DestinationType.FILE_URI, encodingType: this.camera.EncodingType.JPEG, mediaType: this.camera.MediaType.PICTURE // targetWidth: 200 }; let fileuri = await this.camera.getPicture(options); return fileuri; } b64toBlob(_imagePath) { return new Promise((resolve, reject) => { let fileName = ""; this.file .resolveLocalFilesystemUrl(_imagePath) .then(fileEntry => { let { name, nativeURL } = fileEntry; // get the path.. let path = nativeURL.substring(0, nativeURL.lastIndexOf("/")); console.log("path", path); console.log("fileName", name); fileName = name; // we are provided the name, so now read the file into // a buffer return this.file.readAsArrayBuffer(path, name); }) .then(buffer => { // get the buffer and make a blob to be saved let imgBlob = new Blob([buffer], { type: "image/jpeg" }); console.log(imgBlob.type, imgBlob.size); resolve({ fileName, imgBlob }); }) .catch(e => reject(e)); }); } upload(_Blobinfo) { this.profileService.postInfluencerProfile(_Blobinfo, null, null).subscribe( response => … -
Customize Django TabularInline intermediate model
Let's say I have two records in the Person table: John and Matthew. In the admin Group form, for every Group I would like to be able to add one person (from existing ones - IMPORTANT) and specify a membership. I want the combination of membership_id, person and group to be unique within the Membership table. I have tried TabularInline and it looks very promising, but I found some troubles with the solution. Imagine I have clicked GOLD for Membership, John for Person and then Add another Membership. Since John has already been used, he should not be visible as an option, but he is. I mean field combination constraint is not followed in the form. How can I change that? Models: class MembershipEnum(Enum): gold = 'GOLD' silver = 'SILVER' @classmethod def choices(cls): """Return Django-style choices for the model.""" return tuple((s.name.upper(), s.value) for s in cls) class Person(models.Model): name = models.CharField(max_length=128) class Group(models.Model): name = models.CharField(max_length=128) members = models.ManyToManyField(Person, through='Membership') class Membership(models.Model): person = models.ForeignKey(Person, on_delete=models.CASCADE) group = models.ForeignKey(Group, on_delete=models.CASCADE) name = models.CharField(max_length=300, choices=MembershipEnum.choices(), blank=False, default=None) class Meta: unique_together = [["id", "person", "group"]] Admin module: class MembershipInline(TabularInline): model = Membership extra = 1 class GroupForm(ModelForm): """Display Domain objects in the … -
AppConfig override restricts first makemigration
I am overriding the AppConfig and adding below in __init__ default_app_config = 'api.apps.AppnameConfig' which has some models check I want to create them if doesnot exits all works fine. But when I am deploying this to another machine python manage.py makemigrations fails obviously because there are no tables created as there is no migration on fresh project. It is raising ProgrammingError I can do try pass on this but I dont want to go this way. I also checked if migrations folder exists works fine but again fails on migrate. Please suggest best way to do this. -
Django Readiness Probe Fails
I am implementing RollingUpdate and Readiness/Liveness Probes into a Django deployment. I created an /healthz endpoint which simply returns OK and 200 as response code. The endpoint is manually working as expected. However when kubernetes is trying to reach that endpoint, it times out. Readiness probe failed: Get http://10.40.2.14:8080/v1/healthz/: net/http: request canceled (Client.Timeout exceeded while awaiting headers) But from the Django access log I can clearly see that it is indeed querying this endpoint periodicaly and it is retuning bytes of data and 200 as response. [api-prod-64bdff8d4-lcbtf api-prod] [pid: 14|app: 0|req: 34/86] 10.40.2.1 () {30 vars in 368 bytes} [Wed Jul 3 12:10:18 2019] GET /v1/healthz/ => generated 15 bytes in 3 msecs (HTTP/1.1 200) 5 headers in 149 bytes (1 switches on core 0) [api-prod-64bdff8d4-lcbtf api-prod] [pid: 13|app: 0|req: 11/87] 10.40.2.1 () {30 vars in 368 bytes} [Wed Jul 3 12:10:52 2019] GET /v1/healthz/ => generated 15 bytes in 2 msecs (HTTP/1.1 200) 5 headers in 149 bytes (1 switches on core 0) This is my yaml file readinessProbe: httpGet: path: /v1/healthz/ port: 8080 initialDelaySeconds: 30 periodSeconds: 60 successThreshold: 1 livenessProbe: httpGet: path: /v1/healthz/ port: 8080 initialDelaySeconds: 30 periodSeconds: 60 successThreshold: 1 Where did the request goes? -
MSGraph subscription create error: "message": "Operation: Create; Exception: [Status Code: Unauthorized; Reason: ]", "code": "ExtensionError"
I need to create subscription to users using Microsoft Graph. I have all rights in Aure Active Directory: User.Read.All. My subscription method: def create_subscription_to_users(self): t = datetime.utcnow() + timedelta(minutes=settings.MAX_TIME_DELTA_IN_MINUTES) payload = { "changeType": "updated", "notificationUrl": "{0}/webhooks/azure".format(settings.AZURE_WEBHOOKS_CALLBACK_BASE_URL), "resource": "users", "expirationDateTime": t.strftime("%Y-%m-%dT%H:%M:%S.%fZ") } response = self.graph_client.post(url='{0}/subscriptions'.format(settings.GRAPH_URL), json=payload).json() self.add_log(url='{0}/subscriptions'.format(settings.GRAPH_URL), method='POST', payload=payload, response=response) return response My validation class: class AzureHook(View): def post(self, request): url = request.get_full_path() parsed_url = parse_qs(urlsplit(url).query) validation = dict(parsed_url).get('validationToken')[0] return HttpResponse(validation.encode('utf-8'), content_type='text/plain') But I still receive as response for creating subscription: {"error": {"innerError": {"date": "2019-07-03T11:29:39", "request-id": "5e7f1fc3-8ef4-4511-b661-35bf7d146cc3"}, "message": "Operation: Create; Exception: [Status Code: Unauthorized; Reason: ]", "code": "ExtensionError"}} Could someone please help me with this? -
How to use multiple beforeshowday functions django?
I wish to give specific color to specific dates in datepicker and also disable the weekend days. Please help me out. Thank You! <script type="text/javascript"> $(document).ready(function() { var LiveDates = {}; LiveDates[new Date('07/18/2019')] = new Date('07/18/2019'); $('.datepicker1').datepicker({ dateFormat: 'yy-mm-dd', minDate: new Date({{a}},{{b}},{{c}}), maxDate: new Date({{d}},{{e}},{{f}}), beforeShowDay: function(date) { var Highlight = LiveDates[date]; if (Highlight) { return [true, "live", 'Tooltip text']; } else { return [true, '', '']; } } }); }); </script> -
How to store user review to database separately
I am trying to store user review to separate database table. e.g have two images(e.g image1 and image2), if user comments to image1 I want to store user comments to image1 Table. If someone commenting to image2 data stored to image2 Table. How to do this Please help me. view.py def review(request): address = request.session['address'] image1 = Offers.objects.filter(address=address) image2 = Ads.objects.filter(address=address) if 'username' in request.session: if request.method == 'POST': form = Comments(request.POST) if form.is_valid(): review = request.POST.get('review') id = request.POST.get('id_off') dt = datetime.now().strftime('%Y-%m-%d %H:%M:%S') result1 = Image1(review=review, id= id, date_time= dt) result2 = Image2(review=review, id= id, date_time= dt) result1.save() result2.save() return render(request, 'index.html', {'image1': image1, 'image2': image2}) return redirect('/review/') return redirect('/review/') return redirect('/review/') index.html {% for item in image1 %} <div class="col-md-4"> <div class="divi" style="height: 910px"> <img src="{{ item.image.url }}" alt="Images" width="300px" height="200px"/> <p>From Date: {{ item.from_date }}</p> <p>TO Date: {{ item.to_date }}</p> <p>Description: {{ item.description }}</p> <p>Address: {{ item.address }}</p> <!--if this ids ad: <form method="post" action="#"> elif:--> <form method="post" action="#"> {% csrf_token %} <input type="text" name="id_off" value="{{ item.id }}" style="display: none"> <input type="text" name="review"> <button type="submit">Send Review</button> </form> </div> </div> {% endfor %} </br> {% for items in image2 %} <div class="col-md-4"> <div class="divi" style="height: 410px"> <img src="{{ … -
Instance is not ListSerializer when many is True
The serializer is instantiated with many=True but isinstance(self, ObjectListSerializer) is False so the id field isn't being added back to the validated data in to_internal_value() class ObjectSerializer(serializers.ModelSerializer): class Meta: model = Object fields = ( 'id', 'other_field' ) read_only_fields = ('id',) list_serializer_class = ObjectListSerializer def to_internal_value(self, data): ret = super().to_internal_value(data) if all((isinstance(self, ObjectListSerializer), self.context['request'].method in ('PUT', 'PATCH'))): ret['id'] = self.fields['id'].get_value(data) return ret type(self) is still ObjectSerializer I know that it's many=True because the payload is a list and in the view get_serializer() is overidden. def get_serializer(self, *args, **kwargs): data = kwargs.get('data', None) if isinstance(data, list): kwargs['many'] = True return super().get_serializer(*args, **kwargs) Django==2.2.1 and djangorestframework==3.9.4 -
Portable python package with Django inside?
So, I'm trying to figure out, how to create fully portable python package having my venv included with django and several other related packages. I know this question is not new, but all tools are exists for freezing python apps on windows are not doing what i need. p2exe, pyInstaller, etc, are good but can't handle django framework. I want my app has one exe, which will start 1) python intpreter from subfolder 2) my venv with django and other deps 3) manage.py runserver with params Currently 2 and 3 works, if user installed python before runing my starter script (i'm actually wrapping all this with electron, so my web-app will be usable separately from browser) The main question is how to adjust python to work wih provided venv, without having it installed on target machine? -
Django approved comments
first of all, my problem is that I take comments with statusc = 2 and I don't have any problems. But with this code "{% for reply in comment.replies.all%}" appears with all approved or unanswered replies views.py comments=Comment.objects.filter(post=post,reply=None,statusc=2).order_by('-date')..... Model.py class Comment(models.Model): STATUS_C_DRAFT = 1 STATUS_C_PUBLISHED = 2 STATUSES_C = ( (STATUS_C_DRAFT, 'Draft'), (STATUS_C_PUBLISHED, 'Published'), ) post=models.ForeignKey(Post,verbose_name='post',related_name='comment',on_delete=models.CASCADE) name=models.CharField(verbose_name="name",max_length=60,blank=False) email=models.EmailField(max_length=120,blank=False,verbose_name="email") comment=models.TextField(max_length=1000,verbose_name="comment") reply=models.ForeignKey('Comment',null=True,related_name='replies',on_delete=models.CASCADE) date=models.DateTimeField(auto_now_add=True) statusc = models.SmallIntegerField(choices=STATUSES_C,default=STATUS_C_DRAFT) Html page {% for comment in comments %} <!-- POST COMMENT --> <div class="post-comment"> <!-- POST COMMENT USERNAME --> <p class="post-comment-username">{{ comment.name }}</p> <!-- /POST COMMENT USERNAME -->.... {% for reply in comment.replies.all %} <div class="post-comment"> <!-- POST COMMENT USERNAME --> <p class="post-comment-username">{{ reply.name }}</p> <!-- /POST COMMENT USERNAME -->... {% endfor%} {%endfor%} -
Update nested serializer with an overwritten to_representation
Context So i have an AlbumSerializer with a nested TrackSerializer. For convenience on the frontend I overwrite the representation of AlbumSerializer to make a dictionary of the tracks instead of a list. class TrackSerializer(serializers.ModelSerializer): class Meta: model = Track fields = ('id', 'order', 'title') # directly upsert tracks def create(self, validated_data): obj, created = Track.objects.update_or_create( album_id= validated_data['album_id'], order=validated_data['order'], defaults={'title': validated_data['title']} ) return obj class AlbumSerializer(serializers.ModelSerializer): tracks = TrackSerializer(many=True) class Meta: model = Album fields = ('album_name', 'artist', 'tracks') # make a dictionary of the tracks def to_representation(self, instance): representation = super().to_representation(instance) representation['tracks'] = {track['id']: track for track in representation['tracks']} return representation #update tracks with the album endpoint def update(self, instance, validated_data): for track in validated_data['tracks'] obj, created = Track.objects.update_or_create( album_id= track['album_id'], order=track['order'], defaults={'title': track['title']} ) return obj Problem Now when i try to update the album, including some track titles, i receive Expected a list of items but got type \"dict\". Which makes sense. Question How can i make DRF accept dictionaries instead of a list if tracks ? -
Basic group hierarchy in python django
I'm building a student registration system by using django where students are registered. Students can be viewed only by their class teachers and school principals based on object level permission. There are School, Class and Student models. Each school can have more than one school principals and each class can have more than one class teachers. There will be two object level permissions: School principals will be able to see all of the students registered to their school. They won't be able to see students of other schools. Class teachers will be able to see the students that are registered to their classes. They won't be able to see students registered to other classes in the same or different schools. I have searched through various 3rd party django libraries to implement such a hierarchical user group architecture. I have seen django-groups-manager, but it is a bit complicated for my issue. Then, I decided on django-mptt's registration of existing models feature and come up with model implementations such as: from django.contrib.auth.models import Group from django.db import models import mptt from mptt.fields import TreeForeignKey TreeForeignKey(Group, on_delete=models.CASCADE, blank=True, null=True).contribute_to_class(Group, 'parent') mptt.register(Group, order_insertion_by=['name']) class School(models.Model): """School object""" name = models.CharField(max_length=255) group = models.ForeignKey( Group, … -
how to develop a Task Management App using django
i am about to work on a project to develop a task management web app which should be able to create projects, create tasks in a particular project, assign team members to a particular task, track each team members' work flow and records and should be a able to display all activities of the project on a dashboard. will also want to integrate a live chat for team members to discuss. all this is to be done using django frameworks. i will need help on how to go about this development process. thank you. -
Wagtail RichTextField not showing in Django ModelForm
My problem is that the RichTextField is the only field not displayed in the form. I have a Model: class RealestateObject(models.Model): title = models.CharField( max_length=256, verbose_name=_('Object Title'), ) summary = RichTextField( verbose_name=_('Summary'), blank=True, null=True, ) description = models.TextField( verbose_name=_('Description'), blank=True, null=True, ) And a form: class RealestateObjectForm(forms.ModelForm): class Meta: model = TestRealestateObject fields = ('title', 'summary', 'description' ) and my template: <form method="POST" action=""> {% csrf_token %} {{ form }} <button type="submit">Insert</button> </form> the title and description field are displayed in the form, the summary not. Is there a solution for this and/or a work around? I can't use the Wagtail Form Builder. It also would be great if I could use the richtext editor. thanks. -
"How to write it in django"
I want to write a code in django template like this: for i in range(6): if i%2==0: print i, i+1 <table class="pp-choice-careers"> <caption>Parent's Choice for Interest Careers</caption> <tr><th>Careers</th><th>Why this career</th></tr> {% for career in resultArr.parent_choice_career %} <tr class="pp-class"> {% if forloop.counter|mod:2 == 0 %} <td>{% if career == 'NA' %}Not Available{% else %} . {{career.answer}}{% endif %}</td> {% else %} <td>{% if career == 'NA' %}Not Available{% else %}{{career.answer}}{% endif %}</td> {% endif %} </tr> {% endfor %} </table> I want to print two values from a list in a row in two columns, so I need current+1 index in "else" part. -
How to let users download json of Django detail page context object
I build an elaborate context for a DetailView, with data from the model instance and an Elasticsearch query. It renders to a template fine, iterating through data in context['payload'] and context['traces'] lists. If I display {{ payload }} and {{ traces }}, I can see all the data as raw JSON. I'd like to provide a button on the page to download that JSON as a file. I have tried copying my DetailView code as a simple View, and adding response lines at the top, generating the context, then writing to the response and returning it. response = HttpResponse(content_type='text/json') response['Content-Disposition'] = 'attachment;filename="place-full.json"' ... code to build context ... response.write(context['payload']) response.write(context['traces']) return response I run that view from a new url path('<int:id>/full', views.placeFull, name='place-full') and get the following Value error: "The view places.views.placeFull didn't return an HttpResponse object. It returned None instead." -
Is it possible to swap FileField's filename during download/referencing on FE?
I'm using Django+DRF to allow upload/keep/serve user uploaded asset files. I need to let users to download the uploaded assets later. Upon a file upload I need to md5-hash its real name and save it to filesystem with that hash as the filename. Then, when the user wants to download/view it on FE, say he's uploaded a file 'cute_cat.jpg', I want him to get the file named 'cute_cat.jpg' and not 3c808e77fc1b0aee4435533690be458d (the name is one problem, the other one is that browser serves files w/o extensions as application/octet-stream and I want it to render '.jpg' (originally) files as images) I feel that I need to inject a HTTP header with 'Content-Disposition: attachment; filename=cute_cat.jpg' (I'm storing the real filename in DB) somewhere on the way to DRF's Response(), but I'm not sure at which point I'm to do this and even if it's possible... I've tried a bunch of stuff, mainly implementing custom fields for the serializer and injecting a custom URL there, but obviously that's not the way to it, because there's nowhere to inject headers to a text URL and there's no point trying to output a Request object with headers in an API view... This is my model: … -
sending dynamic mail with django
I am trying to send mail with form field inside html table . mail function is working but how can i include table: views.py: from django.shortcuts import render from main_site.models import artist from django.urls import reverse_lazy from .forms import BookartistForm from django.core.mail import send_mail def artist_booking(request): if request.method == "POST": form = BookartistForm(request.POST) if form.is_valid(): name = form.cleaned_data['name'] email = form.cleaned_data['email'] number = form.cleaned_data['number'] artist_name = form.cleaned_data['artist_name'] artist_category = form.cleaned_data['artist_category'] #event_type = form.cleaned_data['event_type'] date = form.cleaned_data['date'] budget = form.cleaned_data['budget'] location = form.cleaned_data['location'] description = form.cleaned_data['description'] print(name,email,number,artist_name,artist_category,date,budget,location,description) send_mail('Celebbizz Enquiry', '<html> <table> <tr> <th>Contact</th> <th>Details</th> </tr> <tr> <td>name</td> <td>email</td> </tr> </table> </html>' , 'admin@celebizz.com', ['nedinemo@daily-email.com'], fail_silently=False ) form = BookartistForm return render(request,'main_site/book_artist.html', {'form': form}) I'm trying to send mail with all these fields. im trying to add html table inside message filed it doesn't work -
Django: queryset using __gte shows wrong results after serialization
I'm facing an extremely weird issue while showing filtered results. Here's my api method: ... @list_route(methods=['GET'], url_path='internal-users') def internal(self, request, *args, **kwargs): users = models.User.objects.internal_users() data = self.get_serializer(users, many=True, context={'request': request}).data return response.Ok(data) ... Here's the internal_users() call of User model: ... def internal_users(self) -> Union[QuerySet, List['User']]: queryset = super(UserManager, self).get_queryset() queryset = queryset.filter(role_policy__gte=constants.UserRolePolicy.editor) # role_polict >= 63 return queryset ... Up until this point, the control -> shows the correct query formation and results. ... @list_route(methods=['GET'], url_path='internal-users') def internal(self, request, *args, **kwargs): users = models.User.objects.internal_users() # -> correct results data = self.get_serializer(users, many=True, context={'request': request}).data return response.Ok(data) ... However, as soon as I pass my objects to serializer in the next line, the results automatically reduce to only those users with role_policy EQUAL TO 63. Here's the serializer: class UserListSerializer(serializers.ModelSerializer): class Meta: model = models.User fields = [ 'id', 'uuid', 'email', 'given', ... 'phone', ] What could be the issue? Please help.