Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to deploy Django app to heroku for production
I have deployed Django apps to heroku before but I am having a bit of trouble understanding why one of my applications is not being deployed. My Procfile has the following web worker web: gunicorn project_name.wsgi I have my requirements.txt and in my root directory a staticfiles directory with an empty txt file to collect all static files when running heroku local. Everything works as expected but when actually trying to start the production server after pushing to heroku master my app does not work. I have in my ALLOWED_HOST the url for my local server and production. also, I have the following settings... MIDDLEWARE = [ 'whitenoise.middleware.WhiteNoiseMiddleware', ... ] STATIC_URL = '/static/' BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.9/howto/static-files/ STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') # Extra places for collectstatic to find static files. STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), ) STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' I am using whitenoise in order to be able to serve static files in production directly using gunicorn. -
inner function raise in Django rest API
How can I catch a 4XX series raise in inner function of an API in Django rest framework? from rest_framework.exceptions import ValidationError class DummyView(APIView): def get(self, request, id): if id==something: dummy_function_1(id) else: dummy_function_2(id) return Response() def dummy_function_1(): try: validate_1(id) except: raise ValidationError() #do something with id Return id When I send a HTTP GET request, I receive a 5XX series error if exception occurs. I want to get 400 Bad Request error in response. -
Ensure unique objects for get_or_create without unique, unique_together in django
Is it possible to use get_or_create for an object where the kwargs are not defined as unique/unique_together and still achieve atomicity in the face of concurrency? The django documentation explicitly states that get_or_create ensures atomicity when the database ensures atomicity. I am kind of in a situation where; forcing uniqueness using unique, unique_together is out of the question. I need to use the get_or_create. What options do I have. I have come across a duplicate record LUCKILY during testing and I need to find a fix. I am using postgres, if that can be helpful. -
Is there anyway to create a view like in the Django admin site?
i'm now making a job portal website. When an applicant registered to a certain job posted by a certain company, the company can see the applicants and update their status such as accepted or rejected. Now, i'm currently is dealing on how to view the status in the applicant site. Do you guys have any idea on how to do that? I will insert the code for the company who updates the status, but i have no clue at all on how to view those status in the applicant site. I'm a beginner so please help me guys.. models.py class StatusForm(forms.ModelForm): applicant = forms.ModelChoiceField( queryset=Applicants.objects.all(), widget=forms.Select(attrs={'class': 'form-control input-sm'}), required=False ) class Meta: model = ApplicantsJobMap fields = ['applicant','status', 'feedback'] views.py class job_applicants(ListView): model = ApplicantsJobMap template_name = "jobs/job_applicant.html" context_object_name = "assign_job" paginate_by = 1 def dispatch(self, request, *args, **kwargs): return super().dispatch(self.request, *args, **kwargs) def get_queryset(self): return ApplicantsJobMap.objects.filter(job_id=self.kwargs["id"]).order_by("id") def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context["job"] = Job.objects.get(id=self.kwargs["id"]) return context def update(request, applicant_id): applicants = ApplicantsJobMap.objects.get(id=applicant_id) #obj = get_object_or_404(ApplicantsJobMap, id=pk) formset = StatusForm(instance=applicants) if request.method == 'POST': formset = StatusForm(request.POST, instance=applicants) if formset.is_valid(): formset = formset.save(commit=False) formset.save() messages.success(request, 'Applicant status update successful') return redirect('home') else: formset = StatusForm(instance=applicants) context = {'formset': formset} … -
Can I change the verbose_name for a field inherited from the parent class in Django?
There is a parent class class Category(models.Model) category = models.CharField('category', max_length=255, blank=True, help_text='Specified category') Can I change the verbose_name for the category field in the descendant class? And also help_text? Something like this: class TableCategory(Category) class Meta: verbose_name__category = 'table category' help_text__category = 'Specified table category' class ChairCategory(Category) class Meta: verbose_name__category = 'chair category' help_text__category = 'Specified chair category' -
How do I package the templates from react frontend into a Django app?
I'm trying to package a Django+react app into a reusable app to be installed into another Django project. I followed the tutorial here to package it but after installing in a new project, I get a TemplateDoesNotExist error. I tried moving the build files out of the react app to a folder named templates inside the Django app and recursively including it in the Manifest. But when I install the app elsewhere, it keeps throwing a TemplateDoesNotExist error. Here's my directory structure: ├── app ├── migrations ├── static │ ├── css │ ├── js │ └── media ├── templates └── tests ├── ui ├── public ├── src Here's my MANIFEST.in: include LICENSE include README.rst recursive-include ui * recursive-include app/templates * recursive-include app/static * I've added the app in the new project's INSTALLED_APPS and ran migrations. I've also edited the urls in the new project's urls.py to include: path('app/', include('app.urls')), path('', TemplateView.as_view(template_name='index.html')) But when I run the server and try to send a GET request to any APIs within the installed app, I get a TemplateDoesNotExist with the following traceback. Internal Server Error: /app/ Traceback (most recent call last): File "/home/test_env/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/home/test_env/lib/python3.8/site-packages/django/core/handlers/base.py", line … -
ckeditor outside admin panel - django 3.1
I'm trying to use CKEditor based on instructions in Django CKEditor — Django CKEditor 5.3.1 documentation. it works just fine in the admin panel. But outside the admin panel, I want to add it to a message section. settings.py: INSTALLED_APPS = [ ... 'ckeditor_uploader', 'ckeditor', ] STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_URL = '/static/' STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'cms/static') ] # MEDIA Folder Settings MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = '/media/' # CKEditor path CKEDITOR_UPLOAD_PATH = "uploads/" AWS_QUERYSTRING_AUTH = False CKEDITOR_ALLOW_NONIMAGE_FILES = False CKEDITOR_IMAGE_BACKEND = "pillow" urls.py: url(r'^ckeditor/', include('ckeditor_uploader.urls')), base_site.html: {% extends 'admin/base_site.html' %} {% load static %} {% block extrahead %} <script>window.CKEDITOR_BASEPATH = '/static/ckeditor/ckeditor/';</script> {{ block.super }} {% endblock %} To use it outside the admin panel I added the following configs. models.py: from ckeditor.fields import RichTextField class Contact(models.Model): message = RichTextField(blank=True) in base.html: {% load static %} <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.3/styles/default.min.css"> {% block content %} {% endblock %} <script type="text/javascript" src="{% static "ckeditor/ckeditor-init.js" %}"></script> <script type="text/javascript" src="{% static "ckeditor/ckeditor/ckeditor.js" %}"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.3/highlight.min.js"></script> <script>hljs.initHighlightingOnLoad();</script> <script src="//cdn.ckeditor.com/4.15.1/basic/ckeditor.js"></script> In a html file(contacts.html): {% load static %} <script type="text/javascript" src="{% static "ckeditor/ckeditor-init.js" %}"></script> <script type="text/javascript" src="{% static "ckeditor/ckeditor/ckeditor.js" %}"></script> <div class="col-md-8" > <h3 class="mt-3"> New Message </h3> <hr> <form action="{% url 'contact' %}" method="POST"> … -
Django Channels with NGINX and SSL
I have a django channels Chat app hosted using Nginx, Gunicorn and Daphne. After adding SSL from Cloudflare the sockets are unable to connect and giving error 502 in the browser console. My nginx/sites-available/my-site file is as follows: and my daphne.service file is as follows: And Upon checking nginx error logs i get the following: Everything was working fine before SSL but as soon as I used SSL from cloudflare. The connections stopped. After checking from multiple forums and youtube videos, I am still unable to run websockets with active SSL. Any help is appreciated. Thanks -
Ensure that there are no more than 0 digits before the decimal point
When I fill the bathroom field in my model with a value like 1.1, 2.5 anything with a digit before decimal it shows an error that no more than 0 digits before decimal point. If I give a value like .2, .3 then Django does not show any error. Same problem with the lot field. class listing(models.Model): realtor = models.ForeignKey(Realtor,on_delete=models.DO_NOTHING) title = models.CharField(max_length=200) address = models.CharField(max_length=200) city = models.CharField(max_length=100) state = models.CharField(max_length=100) state = models.CharField(max_length=20) description = models.TextField(blank=True) price = models.IntegerField() bedrooms = models.IntegerField() bathrooms = models.DecimalField(max_digits=2, decimal_places=2) garage = models.IntegerField(default=0) sqft = models.IntegerField() lot_size = models.DecimalField(max_digits=2, decimal_places=2) photo_main = models.ImageField(upload_to='photos/%Y/%m/%d/') photo_1 = models.ImageField(upload_to='photos/%Y/%m/%d/', blank = True) photo_2 = models.ImageField(upload_to='photos/%Y/%m/%d/', blank = True) photo_3 = models.ImageField(upload_to='photos/%Y/%m/%d/', blank = True) photo_4 = models.ImageField(upload_to='photos/%Y/%m/%d/', blank = True) photo_5 = models.ImageField(upload_to='photos/%Y/%m/%d/', blank = True) photo_6 = models.ImageField(upload_to='photos/%Y/%m/%d/', blank = True) is_published = models.BooleanField(default= True) list_date = models.DateTimeField(default=datetime.now, blank=True) def __str__(self): return f'self.date' -
Two formsets, ManagementForm data is missing or has been tampered with
i need two formsets in my form on django. i started with creating the first one and it works well, but when i created the second i had an error that says Management data is missing or has been tampred with. i tried to discover where i have the problem by doing "print" in many lines of my views file and i detected that the problem is in my formset2 = MaintenancesFormset(request.POST or None, queryset= Maintenances.objects.none(),prefix='Maintenances')(because when i print the first formsset it workes but when i put print(formset2) i have error in this line. could someone help me please? views.py def home(request): context = {} Initialisation_laveries_pipelinesFormset = modelformset_factory(Initialisation_laveries_pipelines, form=Initialisation_laveries_pipelinesForm) MaintenancesFormset = modelformset_factory(Maintenances, form=MaintenancesForm) form = EntréeForm(request.POST or None) formset = Initialisation_laveries_pipelinesFormset(request.POST or None, queryset= Initialisation_laveries_pipelines.objects.none(), prefix='Initialisation_laveries_pipelines') formset2 = MaintenancesFormset(request.POST or None, queryset= Maintenances.objects.none(),prefix='Maintenances') if request.method == "POST": print(formset2) if form.is_valid() and formset.is_valid() and formset2.is_valid(): try: with transaction.atomic(): entrée = form.save(commit=False) entrée.save() for initialisation in formset: data = initialisation.save(commit=False) data.entrée = entrée data.save() for maintenance in formset2: data2 = maintenance.save(commit=False) data2.data = data data2.save() except IntegrityError: print("Error Encountered") context['formset2'] = formset2 context['formset'] = formset context['form'] = form return render(request, 'entrée/index.html', context) class Initialisation_laveries_pipelines(models.Model): entrée = models.ForeignKey(Entrée, related_name = "Entrée", on_delete=models.CASCADE) … -
calling ajax function in views.py to get the data from database
I want to fetch data from the database. I am using ajax function to get it in the index.html. How should I call this ajax function to the views.py so i can display it in view. How should I attain it? My codes: index.html <script type="text/javascript"> function submitData(){ // Get answer from the input element var dt = document.getElementById("major1").value; var dtt = document.getElementById("major2").value; var dttt = document.getElementById("major3").value; var dtttt = document.getElementById("major4").value; var dttttt = document.getElementById("major5").value; // add the url over here where you want to submit form . var url = "{% url 'home' %}"; $.ajax({ url: url, data: { 'major1': dt, 'major2': dtt, 'major3': dttt, 'major4': dtttt, 'major5': dttttt, }, dataType: 'JSON', success: function(data){ // show an alert message when form is submitted and it gets a response from the view where result is provided and if url is provided then redirect the user to that url. alert(data.result); if (data.url){ window.open(data.url, '_self'); } } }); } </script> views.py: def home(request): majors = Major.objects.filter(percentages__isnull=False).distinct().order_by("pk") if request.method == 'POST': form = request.POST.get('be_nextyr_total') line_chart = pygal.Line(width=1500) line_chart.title = 'Budget Estimation' context = { "chart": line_chart.render_data_uri(), 'majors': majors } return render(request, "website/index.html" , context ) -
I am trying to deploy Deploy a Django with Celery, Celery-beat, Redis, Postgresql, Nginx, Gunicorn with Docker to Heroku
I am trying to deploy Django with Celery, Celery-beat, Redis, Postgresql, Nginx, Gunicorn Dockerized on Heroku using container registry. After building the image, pushing, and release to Heroku, the static files are not being served by Nginx, and the Redis isn't communicating with celery, I don't know if the celery is working either. This is my Dockerfile # pull official base image FROM python:3.8.3-alpine as builder # set work directory WORKDIR /usr/src/app # set environment variables ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 # install psycopg2 dependencies RUN apk update \ && apk add postgresql-dev gcc python3-dev musl-dev RUN apk add zlib libjpeg-turbo-dev libpng-dev \ freetype-dev lcms2-dev libwebp-dev \ harfbuzz-dev fribidi-dev tcl-dev tk-dev # lint RUN pip install --upgrade pip RUN pip install flake8 COPY . . # install dependencies COPY ./requirements.txt . RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt # pull official base image FROM python:3.8.3-alpine # create directory for the app user RUN mkdir -p /home/app # create the app user RUN addgroup -S app && adduser -S app -G app # create the appropriate directories ENV HOME=/home/app ENV APP_HOME=/home/app/web RUN mkdir $APP_HOME RUN mkdir $APP_HOME/static RUN mkdir $APP_HOME/media WORKDIR $APP_HOME # install dependencies RUN apk update … -
Reverse for 'chained_filter' not found. 'chained_filter' is not a valid view function or pattern name Django admin
I working on a project where I need to add two dependant dropdowns for that I tried to use Django-smart-selects but I having an issue. Here's what I did Here is my models class District(models.Model): name = models.CharField(max_length=100, default=None) created_at = models.DateField(default=django.utils.timezone.now) class Meta: managed = True db_table = 'District' def __str__(self): return self.name class PoliceStation(models.Model): name = models.CharField(max_length=100, default=None) district = models.ForeignKey( District, on_delete=models.CASCADE, max_length=100) created_at = models.DateField(default=django.utils.timezone.now) class Meta: managed = True db_table = 'PoliceStation' def __str__(self): return self.name class NewsAndUpdates(models.Model): title = models.CharField(max_length=250) description = HTMLField() category = models.ForeignKey( Category, on_delete=models.CASCADE, max_length=100) district = models.ForeignKey( District, on_delete=models.CASCADE) policeStation = ChainedForeignKey( PoliceStation, chained_field="district", chained_model_field="district", show_all=False, auto_choose=True, on_delete=models.CASCADE) class Meta: managed = True db_table = 'NewsAndUpdates' This is my urls.py urlpatterns = [ path('admin/', admin.site.urls), path('chaining/', include('smart_selects.urls')), ] Here is my installed apps INSTALLED_APPS = [ .... 'smart_selects', ] In setting.py I used this as it was suggested when I was searching about the issue USE_DJANGO_JQUERY = True This is my admin.py class NewsAndUpdatesAdmin(admin.ModelAdmin): list_display = ('title', 'category', 'created_at', 'is_published', 'is_draft') admin.site.register(NewsAndUpdates, NewsAndUpdatesAdmin) But I am getting issue which is Reverse for 'chained_filter' not found. 'chained_filter' is not a valid view function or pattern name Using Django version 3.1 -
Getting error message even after setting safe=False
I am working in Django. I have following list of dictionaries - userList = [{'value': '1', 'time': '2020-11-30T04:48:57.642Z'}] I want to use it in Json Response as follows - data = { 'status': 'success', 'message': userList } For that I did the following - return JsonResponse(data, safe=False) Still I am getting error as - In order to allow non-dict objects to be serialized set the safe parameter to False. Can anyone please tell me where I am going wrong or what should I do to achieve the aim? Thanks in advance -
Django-import-export, Export to xlsx only one model object. Django
I am completely new Django and I am building an e-commerce website with Django. I want to export the model's object to xlsx format. I am using django-import-export library to do that but the problem is this library exports model's all objects. I just want to export only one object. For example, if someone orders a product I want that order object export to xlsx format. I can write that in python shell but I want it to be done in the admin panel. In the picture below you can see my Order model and OrderItem model. How can I export exactly like in the picture to xlsx. Order model in admin panel Models.py class Order(models.Model): STATUS = (("NEW", "NEW"), ("ACCEPTED", "ACCEPTED"), ("COMPLETED", "COMPLETED")) customer = models.ForeignKey(Customer,on_delete=models.CASCADE, blank=True, null=True) name = models.CharField(max_length=50) surname = models.CharField(max_length=50) phone = models.CharField(max_length=50) email = models.EmailField(max_length=50, blank=True) address = models.CharField(max_length=100) status=models.CharField(max_length=10, choices=STATUS,default='NEW') total = models.FloatField() adminnote = models.CharField(max_length=100, blank=True) updated_at=models.DateTimeField(auto_now=True) ordered_at = models.DateTimeField(auto_now_add=True) def __str__(self): return self.name + self.surname class OrderItem(models.Model): order = models.ForeignKey(Order, on_delete=models.CASCADE) product = models.ForeignKey(Product, on_delete=models.CASCADE) quantity = models.IntegerField() price = models.DecimalField(max_digits=8, decimal_places=2) total_price = models.DecimalField(max_digits=8, decimal_places=2) date_added = models.DateTimeField(auto_now_add=True) admin.py class OrderProductline(admin.TabularInline): model = OrderItem readonly_fields = ('order', 'product', 'price', 'quantity', … -
How do I send file upload progress % in Django?
I have a iOS app which can upload files to my Django API. Heres the front-end code: AF.upload(multipartFormData: { multipartFormData in multipartFormData.append( data1!, withName: "one", fileName: "one") }, to: "https://httpbin.org/post") .response { response in print(response) } .uploadProgress { prog in print(prog.fractionCompleted) } This works perfectly on https://httpbin.org/post , It keeps printing the progress % until its 100%. However, When I post the same file my own API It will only print the progress once at 100%. So, I assume it's because I have to set up my http response so it also sends the progress %? How can i mimic the http response of httpbin.org/post ? Heres what I have currently. @csrf_exempt def test (request): f = request.FILES["1"] default_storage.save(f.name, f) return HttpResponse("file saved") -
How do I establish a connection between public frontend and private backend both hosted on IIS server
I am new to this sorry but when hosting public frontend and private backend there is not a connection, no request headers are being sent. Please help how can I configure the iis server to make private backend accessible. Frontend: Reactjs Backend: django, django rest framework -
Where to download eav-django v0.9.2?
I'm working on a legacy project, and it's a customization based on eav-django version 0.9.2. My plan is to re-base the same customization to django-eav2. The original software developer didn't keep any history of change, and the only thing I have now is a lump sum commit of the final version. So I need to find the original source code and compare to find out the changes. pip install eav-django==0.9.2 now gets the below error. Could anyone give me some pointers about where to download the exact version of v0.9.2? (venv.2.7) -bash-4.2$ pip install eav-django==0.9.2 DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality. ERROR: Could not find a version that satisfies the requirement eav-django==0.9.2 (from versions: 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.1.0, 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.4.0, 1.4.1, 1.4.3, 1.4.4, 1.4.5, 1.4.6, 1.4.7) ERROR: No matching distribution found for eav-django==0.9.2 WARNING: You are using pip version 20.2.3; … -
How does Django find out which modules, functions to load in?
Django has been amazing at making things easy, to the point that I am convinced this is black magic. As with most Django projects, I have some custom models in models.py. How do Django knows that this is where I keep my modules? Is it just assume that anything in a particular modules (for example, models.py) will be important to the app? That my only explanation because not only my custom models but also my callback functions is also automatically called somehow... @receiver(request_finished) def my_callback(sender, **kwargs): print("Request finished!") Can someone give me an explanation? -
Django Download/Upload Files In Production
I have a Django project that is currently hosted. I am serving static files but do not know how to handle user file uploads / downloads in the MEDIA folder. I've read a lot about Docker, Nginx, and Gunicorn but have no idea which I need nor how to set them up. I've followed no less than 20 tutorials and watched no less than 15 YouTube videos but am still confused (I've visited every link for the first 2 pages of all my Google searches). My question is, which of these do I need to allow users to upload/download files from a site? On top of that, I have tried getting all three working but can't figure them out, surely I'm not the only one that has so much difficulty with this, is there a good resource/tutorial which would guide me through the process (I've spent well over 40 hours reading about this stuff and trying to get it to work, I've gotten to the point where so long as it works, I don't care for understanding how it all fits together)? Thank you. -
Does pytest-django allow modification of the database during the test?
Let's say in my conftest.py, I have the following: import pytest from django.core.management import call_command @pytest.fixture(scope='session') def django_db_setup(django_db_setup, django_db_blocker): with django_db_blocker.unblock(): call_command('loaddata', 'my_fixture.json') And then in my test_script.py: @pytest.mark.django_db def test_delete_some_data(django_db_setup): # Do some deleting... Will this change the database that is used by other test function? -
I want to fetch data from database using ajax and then define it in views.py to display in bar-chart
I want to fetch the data from database. I am using Ajax and then I want to define it in views.py to extract the data and display it in view(webpage) using Django. How may I approach in order to bring "be_total" the data from the database and then display the values of "be_total" in the form of bar chart on my webpage? Can anyone please help me ? My codes are: index.html: <form class="form-row" method="post" > {% csrf_token %} <div class="form-group col-md-2" > <select class="form-control select2" > <option>Select M Head</option> {% for major in majors %} <option value="{{ major.pk }}" id="m1">{{ major.pk }}: {{ major.description }}</option> {% endfor %} </select> </div> <div class="form-group col-md-2"> <select class="form-control select2" > <option>Select M Head</option> {% for major in majors %} <option value="{{ major.pk }}" id="m2">{{ major.pk }}: {{ major.description }}</option> {% endfor %} </select> </div> <div class="form-group col-md-2"> <select class="form-control select2" > <option>Select M Head</option> {% for major in majors %} <option value="{{ major.pk }}" id="m3">{{ major.pk }}: {{ major.description }}</option> {% endfor %} </select> </div> <div class="form-group col-md-2"> <select class="form-control select2" > <option>Select M Head</option> {% for major in majors %} <option value="{{ major.pk }}" id="m4">{{ major.pk }}: {{ major.description }}</option> {% … -
Django allauth SocialAccount model's "extra_data" field
SocialAccount model has the extra_data field in the table. And this model has a relation with the User table. when I am retrieving the User table, trying to add the SocialAccount into the User but having an error. serializers.py from rest_framework import serializers from django.contrib.auth.models import User from allauth.socialaccount.models import SocialAccount class SocialAccountExtraDataSerializer(serializers.ModelSerializer): class Meta: model = SocialAccount fields = ["extra_data"] depth = 1 class UserDisplaySerializer(serializers.ModelSerializer): extra_data = SocialAccountExtraDataSerializer() class Meta: model = User fields = ["username", "extra_data"] depth = 1 the error message says: Got AttributeError when attempting to get a value for field extra_data on serializer UserDisplaySerializer. The serializer field might be named incorrectly and not match any attribute or key on the User instance. Original exception text was: 'User' object has no attribute 'extra_data'. How should I insert the SocialAccount's extra_data into User serializer as field. incase if you need to see views.py from rest_framework.response import Response from rest_framework.views import APIView from users.routes.serializers import UserDisplaySerializer class UserDisplayApiView(APIView): def get(self, request): serializer = UserDisplaySerializer(request.user) return Response(serializer.data) -
MultiValueDictKeyError at /register 'email'
class User(AbstractUser): is_reader = models.BooleanField(default=False) is_writer= models.BooleanField(default=False) -
Multiple root pages in Wagtail
I currently use wagtail as a blog which is accessible via example.com/blog and the admin via example.com/blog/admin. I would like to also use wagtail to create a support (knowledge base) section. This would then be accessible via example.com/support. The pages and models for the blog vs support section would be different since they're catering to different use cases. Would something like the following be possible? example.com/wagtail - wagtail admin (for both the blog and knowledge base) example.com/blog - blog section of the site example.com/support - knowledge base / support section of the site If the above is not possible I would also be open to having two completely separate wagtail apps in my django project, eg: example.com/blog - this is a blog wagtail section with its own admin example.com/blog/admin example.com/support - this is a separate support wagtail section with its own admin example.com/support/admin I'm not entirely sure which option is possible or how to go about getting either one to work.