Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django Deploy ElasticBeanstalk AWS error creating Enviroment
Im trying to deploy my django application at EB since I failed with django django.config file: option_settings: aws:elasticbeanstalk:container:python: WSGIPath: store/wsgi.py Note: My normal python Virtual Env the python Version is 3.9.12 but when i run eb init -p python-3.9.12 store it doesent get recognized, even if i just set as: eb init -p python-3.9 store so i did eb init -p python-3.8 store and it worked Also at the full log, it choose atumatcally the region,how can i change that? I ran eb create store-env Error Log: 2022-04-22 04:04:14 ERROR Instance deployment failed. For details, see 'eb-engine.log'. 2022-04-22 04:04:16 ERROR [Instance: i-0e999ebdfd96bb4d9] Command failed on instance. Return code: 1 Output: Engine execution has encountered an error.. 2022-04-22 04:04:16 INFO Command execution completed on all instances. Summary: [Successful: 0, Failed: 1]. 2022-04-22 04:05:19 ERROR Create environment operation is complete, but with errors. For more information, see troubleshooting documentation. ERROR: ServiceError - Create environment operation is complete, but with errors. For more information, see troubleshooting documentation. The full log: Creating application version archive "app-220422_005816740583". Uploading: [##################################################] 100% Done... Environment details for: store-env Application name: store Region: us-west-2 Deployed Version: app-220422_005816740583 Environment ID: e-7rraydvprc Platform: arn:aws:elasticbeanstalk:us-west-2::platform/Python 3.8 running on 64bit Amazon Linux 2/3.3.12 … -
django - 'module' object does not support item assignment
When clicking the like button on a article the following error shows up: 'module' object does not support item assignment and it leads to this piece of code: def get_context_data(self, *args,**kwargs): stuff = get_object_or_404(Article, id=self.kwargs['pk']) #grab article with pk that you're currently on total_likes = stuff.total_likes() context["total_likes"] = total_likes return context but when I remove this piece the feature works fine but you cant see the likes - the only way you know its working is if you go into django admin and see which user is highlighted. my articles views.py: class ArticleDetailView(LoginRequiredMixin,DetailView): model = Article template_name = 'article_detail.html' def get_context_data(self, *args,**kwargs): stuff = get_object_or_404(Article, id=self.kwargs['pk']) #grab article with pk that you're currently on total_likes = stuff.total_likes() context["total_likes"] = total_likes return context def LikeView(request, pk): article = get_object_or_404(Article, id=request.POST.get('article_id')) article.likes.add(request.user) #might need check later return HttpResponseRedirect(reverse('article_detail', args=[str(pk)])) my articles models.py: class Article(models.Model): title = models.CharField(max_length=255) body = RichTextField(blank=True, null=True) #body = models.TextField() date = models.DateTimeField(auto_now_add=True) likes = models.ManyToManyField(get_user_model(), related_name='article_post') author = models.ForeignKey( get_user_model(), on_delete=models.CASCADE, ) def total_likes(self): return self.likes.count() def __str__(self): return self.title def get_absolute_url(self): return reverse('article_detail', args=[str(self.id)]) full error pic: -
Item could not be retrieved UNAUTORIZED (HEROKU)
I simply want to deploy my django app on heroku and getting this little pop up on top-right corner. tried almost all solutions given by heroku help still stuck with this error. Please Help! -
How to ignore special characters from the search field in Django
The model is something like class Product(BaseModel): name = models.CharField(db_column='name', max_length=200, blank=False, null=False, unique=True) View is class ProductViewSet(BaseViewSet): queryset = Product.objects.all() ... filterset_class = ProductFilter The filter is class ProductFilter(django_filters.FilterSet): search = django_filters.CharFilter(field_name='name', lookup_expr='icontains') class Meta: model = Product fields = [] Now.. if the name field has a value something like "This is a/sample" and search text is "asample". I would like to return that row. Thanks in advance. -
How to optimize data scrape
I am scraping data from an external API to my database on Django. This method is taking a very long time to load. Is there a better way to do this? Here is the code from my views.py file: def market_data(request): # GET MARKETPLACE ASKS NFT_list = {} URL = '...&page_number=1' response = requests.get(URL).json() pages = response['result']['page_count'] page_index = 1 for page in range(pages): URL = "...&page_number="+str(page_index) response = requests.get(URL).json() nfts = response['result']['ask_summaries'] for item in nfts: if NFT.objects.filter(nft_data_id = ['nft_data_id']).exists(): pass else: nft_data = NFT( nft_data_id = item['nft_data_id'], brand = item['brand'], price_low = item['price_low'], price_high = item['price_high'], nft_count = item['nft_count'], name = item['name'], series = item['series'], rarity = item['rarity'], ) nft_data.save() NFT_list = NFT.objects.all() page_index += 1 return render(request, 'main/market_data.html', {'NFT_list' : NFT_list} ) -
Django for loop in Carousel
I'm trying to add a title to each slide in a dynamic carousel in Django. I have the images functioning properly and working as expected. The title is stacking on the first slide and as it progresses towards the end it removes a title and once it reaches the end it has only one title and it is correct. What would be the best way to fix this? html <div id="CarouselWithControls" class="carousel slide" data-ride="carousel"> <div class="carousel-inner"> {% for item in carousel_items %} {% if forloop.first %} <div class="carousel-item {% if forloop.first %} active {% endif %}"> <img src="{{ item.carousel_picture.url }}" class="d-block w-100"> </div> <div class="carousel-caption d-none d-sm-block"> <h5 class="text-white">{{ item.carousel_title }}</h5> </div> {% else %} <div class="carousel-item {% if forloop.first %} active {% endif %}"> <img src="{{ item.carousel_picture.url }}" class="d-block w-100"> </div> <div class="carousel-caption d-none d-sm-block {% if forloop.first %} active {% endif %}"> <h5 class="text-white">{{ item.carousel_title }}</h5> </div> {% endif %} <a class="carousel-control-prev" href="#CarouselWithControls" role="button" data-bs-slide="prev"> <span class="carousel-control-prev-icon" aria-hidden="true"></span> <span class="sr-only">Previous</span> </a> <a class="carousel-control-next" href="#CarouselWithControls" role="button" data-bs-slide="next"> <span class="carousel-control-next-icon" aria-hidden="true"></span> <span class="sr-only">Next</span> </a> {% endfor %} views.py def gallery(request): carousel_items = CarouselItem.objects.all() context = {'carousel_items': carousel_items} return render(request, 'home/gallery.html', context=context) models.py class CarouselItem(models.Model): carousel_title = models.CharField(max_length=200 , blank=True, null=True) … -
Django pymongo search, sort, limit on inner array and count them
I am learning Django with MongoDb and have a collection to search into. Here is a sample document in the collection: { "_id": { "$oid": "62615907568ddfca4fef3a25" }, "word": 'entropy, "count": 4, "occurrence": [ {"book": "62615907568ddfca4fef3a23", "year": 1942, "sentence": 0 }, {"book": "62615907568ddfca4fef3a23", "year": 1942, "sentence": 5 }, {"book": "62615907568ddfca4fef3a75", "year": 1928, "sentence": 0 }, {"book": "62615907568ddfca4fef3a90", "year": 1959, "sentence": 8 } ] } I want to retrieve the array elements of 'occurrence' field of a specific document (word): Sorted by year Within an year range Limited with offset count the total results (without limit/offset) What I have done so far is: offset= 0 limit= 10 search= {'$and': [{"_id": word_id_obj, "occurrence": {"$elemMatch": {"year": {"$gte": 1940, "$lte": 1960}}}}]} word_docs= wordcollec.aggregate([ {"$match": search}, {"$project": {"occurrence": {"$slice": ['$occurrence', offset, limit]} } }, {"$sort": {'occurrence.year': -1}} ]) # Count total results recnt= wordcollec.aggregate([{"$match": search}, {'$group' : {"_id": "$_id", "sno" : {"$sum" : {"$size": "$occurrence"}}}}]) The year range, count are not working and I am unable to sort them. How can I rewrite my query for this? Thanks in advance. -
Detecting changes in file without restarting Python application (Django APP)
I'm using Django, I want my web page to see the changes I've made to the JSON file as the web page is refreshed. When I close and open Django, the features I added to the json file or I changed it see some settings, but I don't want this, it needs to see the changes instantly -
django traceback errors manage.py
I am new to Django and followed a tutorial to set up my venv now I am trying to startserver using manage.py I have sqlit3 installed and running when I run the following command python manage.py startserver I receive the following error in the picture I have tried fixing my settings.py and other cofigs and also reinstalling the python libs but nothing is working please help. -
Django channels group_send not passing the event messages in Test environment
I have a Django Channels consumer receive function like the following: async def receive(self, text_data=None, bytes_data=None): ## Some other code before await self.channel_layer.group_send( self.room_name, { 'type': 'answered_users_count', 'increment_answer_id': 15, }, ) The answered_users_count function goes like this: async def answered_users_count(self, event): print(event) increment_answer_id = event['increment_answer_id'] await self.send( text_data=json.dumps({ 'meant_for': 'all', 'type': 'answer_count', 'data': { 'increment_answer_id': increment_answer_id } }) ) The whole thing works fine with python manage.py runserver, where the print(event) also prints the following dictionary into the command line: {'type': 'answered_users_count', 'increment_answer_id': 15} However, this part of the consumer does not work when it comes to running the unit test that I have written for it. Here's the unit test that I've written for testing the above code: class SampleConsumerTest(TransactionTestCase): async def test_channel(self): communicator = WebsocketCommunicator(application, "/ws/walk/qa_control/12/") connected, subprotocol = await communicator.connect() self.assertEqual(connected, True) await communicator.send_to(json.dumps({ "abc": "xyz" })) raw_message = await communicator.receive_from() message = json.loads(raw_message) When I run the above test case by using python manage.py test, it fails. I figured out that the cause of this is that the event given as the input to answered_users_count does not carry the field increment_answer_id in the test execution. I got to know about this because the print(event) line in … -
Fit Layout to any screen
I have tried to make it responsive but it appears like the image I shared.I used bootstraps owl carousel to make image-slider it doesn't fit to screens larger or smaller than my laptop.I make containers and they are also not responsive even the footer moves here and there and is not stickyI tried everyway to make these 3 things appear responsive at a same time but I can't do that.It also has css.min CSS file. This is what it is showing when I check responsiveness *{ padding: 0; margin: 0; box-sizing: border-box; } html{ height: 100%; } .body{ display: flex; min-height: 100%; } .container1{ position: relative; width:1500px; display: flex; justify-content: center; align-items: center; flex-wrap: wrap; padding: 30px; margin-top: 8%; } .container1 .card1{ background: rgb(70, 218, 203); width: 308px; position: relative; height: 400px; margin: 30px 20px; padding: 20px 15px; display: flex; flex-direction: column; flex-wrap: nowrap; box-shadow: 0.5px 10px rgb(0, 217, 255); transition: 0.3s ease-in-out; margin-top: 5%; } .container1 .card1 .imgbx{ position: relative; width: 260px; height: 260px; top: -80px; left:20px; box-shadow: 0 5px 20px rbga(0,0,0,1.2); } .container1 .card1 .imgbx img{ max-width: 100%; margin-left: 20px; border-radius: 10px; padding-top: 20px; } .imgbx:hover img{ transform:scale(1.1); } .navbar{ background-color: #30d5b9dc !important; } .navbar .navbar-brand{ color: white; … -
putting dictionary values inside a table in Django template
Its my first time using Django template. I'm trying to make a table inside my page with values from a dictionary that I built consuming an API. Here is how I'm sending the data inside my views.py: data = { "year_most_launches": result_launches, "launch_sites":response_sites, "launches_2019_2021":response_2019_2021 } return render(request,"main/launches.html", {"data":data}) Here is how it is my html page: <table class="table"> <thead> <tr> <th>Year with most launches</th> <th>Launch site with most launches</th> <th>Number of launches between 2019 and 2021</th> </tr> </thead> <tbody> <tr> <td>{{ data["year_most_launches"] }}</td> <td>{{ data["launch_sites"] }}</td> <td>{{ data["launches_2019_2021"] }}</td> </tr> </tbody> </table> But I'm getting the following error django.template.exceptions.TemplateSyntaxError: Could not parse the remainder: '["year_most_launches"]' from 'data["year_most_launches"]' How can I solve this? Can someone help? -
Filtering in Django which depends on first field
>Suppose I have 3 fields of a Car Shop. those are Condition, Brand, Model . class Car(models.Model): ConditionType=( ('1','New'),('2','Used'),('3','Reconditon') ) BrandType=( ('Toyota','Toyota'),('Honda','Honda'),('Mitsubishi','Mitsubishi'), ('Nissan','Nissan'),('Hyindai','Hyindai')) >now model will depends on Brand user select . if user select Toyota as brand then >available model for toyota are (Axio,Premio ,Allion etc) ,for Honda carmodels are (civic >,vezel,Grace) Condition=models.CharField(max_length=120,choices=ConditionType,default='New') Brand=models.CharField(max_length=120,choices=BrandType,default=None) Condition=models.CharField(max_length=120,choices=ConditionType,default='New') CarModel=models.CharField(max_length=120,choices=ModelType,default=None) Now how can I make carmodel dependent on Brand . Suppose if user choose Brand - Toyota >then user can only choose Carmodel of Toyota if user Choose Honda than he can choose >CarModel of Honda . which means how can I make my model selection dependent on Brand ? if no brand is selected than user won't able to choose CarModel .** -
erro h14 do heroku
fiz o deploy com sucesso no heroku , criei as tabelas e o super user , mas não tem nenhuma execução web ate o momento... mostra esse erro h14 e as tags abaixo heroku logs 2010-09-16T15:13:46.677020+00:00 app[web.1]: Processing PostController#list (for 208.39.138.12 at 2010-09-16 15:13:46) [GET] 2010-09-16T15:13:46.677023+00:00 app[web.1]: Rendering template within layouts/application 2010-09-16T15:13:46.677902+00:00 app[web.1]: Rendering post/list 2010-09-16T15:13:46.678990+00:00 app[web.1]: Rendered includes/_header (0.1ms) 2010-09-16T15:13:46.698234+00:00 app[web.1]: Completed in 74ms (View: 31, DB: 40) | 200 OK [http://myapp.heroku.com/] 2010-09-16T15:13:46.723498+00:00 heroku[router]: at=info method=GET path="/posts" host=myapp.herokuapp.com" fwd="204.204.204.204" dyno=web.1 connect=1ms service=18ms status=200 bytes=975 2010-09-16T15:13:47.893472+00:00 app[worker.1]: 2 jobs processed at 16.6761 j/s, 0 failed . -
How Not to render visible
i want to define this function not to render as default. Right now with connect with html template i am seeing this field as default, how to not make as default visible def check(self, obj): return format_html( "<ul>{}</ul>", format_html_join( "\n", "<li>{}</li>", obj.tee_rates.values_list( "tee__name__chek__short_name", ), ), ) -
Django-Rules working in some apps views but not others
I am integrating Django-Rules into my project for object-level permissions. Once I got it configured, I was initially successful in getting it to function properly for my Users and Profiles apps-models/views. I just cannot figure out why it won't work for my others apps-models/views. I've written the predicates and when I run them independently in the shell they return True. However, when I try to access the view it returns a 403 and the debugger doesn't even indicate that the rules were checked. I have been working on this for 2 days and would appreciate any insight offered. profiles rules.py import rules @rules.predicate def is_patient(user, profile): return profile.user == user @rules.predicate def is_provider(user, profile): return getattr(profile.user.patientprofile, "provider") == user change_profile = is_patient|is_provider view_profile = is_patient|is_provider rules.add_rule('can_edit_profile', change_profile) rules.add_rule('can_view_profile', view_profile) When User enters view with correct permission, console logs: | Testing (is_patient | is_provider) | is_patient = True | (is_patient | is_provider) = True When User enters view with incorrect permission, console logs: | Testing (is_patient | is_provider) | is_patient = False | is_provider = False | (is_patient | is_provider) = False profiles views.py ... from rules.contrib.views import PermissionRequiredMixin ... class MedicalProfileUpdate(LoginRequiredMixin, PermissionRequiredMixin, SuccessMessageMixin, UserDetailRedirectMixin, UpdateView): model = MedicalProfile permission_required = … -
django html: how to center the login form?
my login form is not looking good, it's too wide. how to make it smaller and center in the middle of the page? signin html: {% extends "accounts/_base.html" %} {% block title %} Sign In {% endblock %} {% block control %} <form class="form-signin" action="{% url 'login' %}" method="post"> {% csrf_token %} <h2 class="form-signin-heading">Sign In</h2> <div class="form-group"> <div class="fieldWrapper"> {{ form.username.errors }} {{ form.username.label_tag }} {{ form.username }} </div> <div class="fieldWrapper"> {{ form.password.errors }} {{ form.password.label_tag }} {{ form.password }} </div> </div> <label for="signIn" class="sr-only">Click</label> <button id="signIn" class="btn btn-lg btn-primary btn-block" >Sign In</button> </form> <form class="form-signin" action="{% url 'signup' %}"> <button id="signUp" class="btn btn-lg btn-default btn-block">Sign up now!</button> </form> {% endblock %} base html: <!DOCTYPE html> <html lang='en'> <head> <meta CharacterSet='UTF-8'> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>{% block title %}{% endblock %}</title> {% load static %} <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap-theme.min.css"> <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.css"> <link rel="stylesheet" href="{% static 'css/style.css' %}"> <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script> <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script> <script src="{% static 'js/main.js' %}"></script> {% block script %}{% endblock %} </head> <body> <!-- head --> <nav id="navbar" class="navbar navbar-default" role="navigation"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand mb-0" href="#">Pizza</a> </div> {% if user is not none %} <div id="navbar-collapse" class="collapse navbar-collapse"> <ul class="nav … -
mock queryset in Django unittest
I have sample code and test: queryset_response = something.object.filter(foo="bar", foo1="bar1") for count, queryset_res in enumerate(queryset_response): store = queryset_response[0].data print(store) I wanna test this situation using mock and probably return list of queryset using mock if possible. m_queryset = Mock() m_queryset.filter.return_value = #<queryset> if possible # also I wanna return data for the 0th value to test store = queryset_response[0].data m_queryset.filter().data.return_value = "some string" # i tried sending dict into m_qeueryset.filter.return_value. nothing works. -
Django admin allow to sort postgres DateTimeRangeField
Say I have the following model: from django.contrib.postgres.fields import DateTimeRangeField class Record(models.Model): .... range = DateTimeRangeField() When I add the model to admin, the range field is not sortable, even I explicitly declared in sortable_by attribute. Please note the range field can be used for "order by" in raw query. Any ideas how to enable sort on this field? -
How not to visible all columns as default
Hi with this code i can see all the columns as default but how to make the column as visible not default. {% block object-tools %} <ul class="grp-object-tools"> {% block object-tools-items %} {% if has_add_permission %} {% url opts|admin_urlname:'add' as add_url %} <li><a href="{% add_preserved_filters add_url is_popup to_field %}" class="grp-add-link grp-state-focus">{% blocktrans with opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}</a></li> {% endif %} {% endblock %} </ul> {% endblock %} -
PostgresQL Query totally baffling me
I'm dealing with a django-silk issue trying to figure out what it won't migrate. It says all migrations complete and then when I run my code it gives me a warning that I still have 8 unapplied migrations, despite double checking with python manage.py migrate --plan. I'm pretty stumped at this point so I began setting up queries to just populate the db with the info already. And now the query is giving me a syntax error that for the life of me I can't understand! Hoping there are some Postgres masters here who can tell me what I'm missing. Thanks! Here's the query: -- Table: public.silk_request -- DROP TABLE IF EXISTS public.silk_request; CREATE TABLE IF NOT EXISTS public.silk_request( id character varying(36) COLLATE pg_catalog."default" NOT NULL, path character varying(190) COLLATE pg_catalog."default" NOT NULL, query_params text COLLATE pg_catalog."default" NOT NULL, raw_body text COLLATE pg_catalog."default" NOT NULL, body text COLLATE pg_catalog."default" NOT NULL, method character varying(10) COLLATE pg_catalog."default" NOT NULL, start_time timestamp with time zone NOT NULL, view_name character varying(190) COLLATE pg_catalog."default", end_time timestamp with time zone, time_taken double precision, encoded_headers text COLLATE pg_catalog."default" NOT NULL, meta_time double precision, meta_num_queries integer, meta_time_spent_queries double precision, pyprofile text COLLATE pg_catalog."default" NOT NULL, num_sql_queries integer … -
Date filtering not working in django queryset
The queryset needed is so basic I am stumped as to why this is not working Basic layout class ExampleModel(models.Model): ... date = models.DateTimeField() # this field is filled by an API It is a valid datetime field such that when I pull it individually and check data by actions like .day or .year it works fine. When I pull one individual record and do `type(record.date), it a datetime.datetime object. It does not have second or millisecond data. I do not know if this is the reason behind my results. For example here is the output of one of the records datetime.datetime(2022, 4, 21, 15, 32, 59) I just want to fetch all the entries for a given day. Thats it. In my code I specify todays date at time 00:00:00 via const_today = datetime.combine(datetime.today(), time(0,0,0), tzinfo=timezone.utc) I have tried almost every method. ExampleModel.objects.filter(date__date = today) ExampleModel.objects.filter(date__day = today.day) (just to see if even this would work even though i know it should pull up other months on this day) I have done date__gte and date___lte date__range[const_today, const_today+timedelta(days=1)] I have flicked USE_TZ in django settings on and off And basically every other method on stackoverflow with exception to building a … -
Error when autocreating slug in django models
This is my model: class post (models.Model): title = models.CharField(max_length=200) post = models.CharField(max_length=75000) picture = models.URLField(max_length=200, default="https://i.ibb.co/0MZ5mFt/download.jpg") show_date = models.DateTimeField() slug = models.SlugField(editable=False) def save(self, *args, **kwargs): to_slug = f"{self.title} {self.show_date}" self.slug = slugify(to_slug) super(Job, self).save(*args, **kwargs) When I run my website and try to add an item from the admin portal, though, I get this: NameError at /admin/blog/post/add/ name 'Job' is not defined I got the autoslugging part from here, what is 'Job' that I have to define? -
Unknown field(s) (groups, user_permissions, date_joined, is_superuser) specified for Account
I just try add "is_saler = models.BooleanField(default=False)" into class Account and migrate. And now i got the error when trying to change the superuser data. The line "is_saler = models.BooleanField(default=False)" had been deleted but still got this error after migrate. from django.db import models from django.contrib.auth.models import AbstractBaseUser, BaseUserManager class MyAccountManager(BaseUserManager): def create_user(self, first_name, last_name, username, email, password=None): if not email: raise ValueError('User must have an email address') if not username: raise ValueError('User must have an username') user = self.model( email = self.normalize_email(email), username = username, password = password, first_name = first_name, last_name = last_name, ) user.set_password(password) user.save(using=self._db) return user def create_superuser(self, first_name, last_name, email, username, password): user = self.create_user( email = self.normalize_email(email), username = username, password = password, first_name = first_name, last_name = last_name, ) user.is_admin = True user.is_active = True user.is_staff = True user.is_superadmin = True user.save(using=self._db) return user class Account(AbstractBaseUser): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) username = models.CharField(max_length=50, unique=True) email = models.EmailField(max_length=100, unique=True) phone_number = models.CharField(max_length=50) data_joined = models.DateTimeField(auto_now_add=True) last_login = models.DateTimeField(auto_now_add=True) is_admin = models.BooleanField(default=False) is_staff = models.BooleanField(default=False) is_active = models.BooleanField(default=False) is_superadmin = models.BooleanField(default=False) USERNAME_FIELD = 'username' REQUIRED_FIELDS = ['first_name', 'last_name', 'email'] objects = MyAccountManager() def __str__(self): return self.email def has_perm(self, perm, obj=None): return self.is_admin def … -
Django Serialize a JsonField, Django Rest API
I have a class for example from django.forms import JSONField class Area(models.model): GeoJson = JSONField ... and a serializer for the class class AreaSerializer(serializers.ModelSerializer): model = Areas fields = ('GeoJson', ... ) but when I try to get the data from my rest frame work I get this error Object of type 'JSONField' is not JSON serializable What am I doing wrong? it is my first time using django and I need to store GeoJson in the database so im really stuck on how to fix this issue as I dont understand why it wont work, Any help or advice is greatly appreciated.