Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Please clarify convention for Django Media, Static, and Template file locations
I've started working on a project and decided I wanted to learn Django to do it. I finished their basic tutorial on the framework, but it's still unclear to me how template, static files, and media files ought to be organized. Django instructs to organize files like this: ---Project |---manage.py |---db.sqlite3 |---site | |---settings.py | |---urls.py | |---wsgi.py |---app1 |---templates | |---app1 | |---templatefiles... |---static |---app1 |---exampleDirectory(photos) |---photo.jpg I understand why we create subdirectories of the same app name inside the static and template directories. This allows us to namespace our templates/static files, and refer to them specifically when/if our app is packaged and used on another site with templates/files of the same name. What I don't understand is two things: What we do when we are building two applications on the same site that need access to the same templates, static, and media files? Where should the media root folder usually be kept? Should the project look something like this? ---Project |---manage.py |---db.sqlite3 |---site | |---settings.py | |---urls.py | |---wsgi.py | |---templates | |---media | |---static |---app1 |---app2 -
AttributeError: 'QuerySet' object has no attribute 'major_id'
I want to store all major id's that correspond to the school chosen in order to display only the schools corresponding to that major. views.py from django.http import HttpResponse from django.shortcuts import render from .models import professor, School, Major, School_Major def index(request): schools = School.objects.all() return render(request, 'locate/index.html', {'schools': schools}) # def Major(request, Major): # major_choice = professor.objects.filter(Major =Major) # return render(request, 'locate/major.html', {'major_choice': major_choice}) def Majors(request, school_pk): schools_majors_ids = [] major_after_filter = [] #Filter to a show the association of 1 schools majors school_choice = School_Major.objects.filter(school_id = school_pk) #Append each of the major id's to school_majors_ids list for store in school_choice.major_id: schools_majors_ids.append(school_choice.major_id) #Filter majors names required for store in schools_major_ids: major_after_filter = Major.objects.filter(id = schools_majors_id[store]) return render(request, 'locate/major.html', {'major_after_filter' : major_after_filter}) Models.py from django.db import models class Major(models.Model): name = models.CharField(max_length=30, db_index=True) class School(models.Model): name = models.CharField(max_length=50, db_index=True) school_Major_merge = models.ManyToManyField(Major, through='School_Major') class School_Major(models.Model): major = models.ForeignKey(Major, on_delete=models.CASCADE) school = models.ForeignKey(School, on_delete=models.CASCADE) class professor(models.Model): ProfessorIDS = models.IntegerField() ProfessorName = models.CharField(max_length=100) ProfessorRating = models.DecimalField(decimal_places=2,max_digits=4) NumberofRatings = models.CharField(max_length=50) #delete major from the model school = models.ForeignKey(School , on_delete=models.CASCADE) major = models.ForeignKey(Major , on_delete=models.CASCADE) def __str__(self): return self.ProfessorName url.py from django.urls import path from . import views urlpatterns = [ path('', views.index, … -
VersatileImageField failing to save with formsets
When I save an instance of a model that has a VersatileImageField field, it saves just fine. When I save an instance of a model from a formset, I get the following error: Thumbnail generation failed Traceback (most recent call last): File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\versatileimagefield\image_warmer.py", line 117, in _prewarm_versatileimagefield url = get_url_from_image_key(versatileimagefieldfile, size_key) File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\versatileimagefield\utils.py", line 216, in get_url_from_image_key img_url = img_url[size_key].url File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\versatileimagefield\datastructures\sizedimage.py", line 149, in __getitem__ height=height File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\versatileimagefield\datastructures\sizedimage.py", line 201, in create_resized_image path_to_image File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\versatileimagefield\datastructures\base.py", line 140, in retrieve_image image = self.storage.open(path_to_image, 'rb') File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\files\storage.py", line 33, in open return self._open(name, mode) File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\files\storage.py", line 218, in _open return File(open(self.path(name), mode)) PermissionError: [Errno 13] Permission denied: 'C:\\Users\\jason\\Desktop\\staticfiles\\media_root' Any thoughts? -
Django - convert queryset to html elements
Im using Bokeh library for visualizing data. Embeding Bokeh charts into web apps is possible via exporting and components of visualization and inserting them in html code. I have these components in Django database. How to insert them into templates, so they will be treated as html elements? Thank you for help! -
ignored null byte in input while deploying django app
enter image description here I'm trying to deploy django applicantion on heroku and getting this this error: line 5: warning: command substitution: ignored null byte in input. I'm using Windows so didn't find clear answer in Google. -
ManyToManyField not allowing multiple selection Django MultiSelectField
I want the field interest = ManyToManyField(Interest) in the Profile model to allow users to select more than one interest by setting it as a MultiSelectField or something similar when they go to edit their profile (ProfileUpdateForm) I do so in another field, group = MultiSelectField(choices = GROUP_CHOICES, blank=True) however because interest is a ManyToMany(Interest) field I don't think I can set MultiSelectField as well, can I? I've only been able to make the Interest field appear as a list where a user can select one (or multiple by holding down SHIFT and selecting) I would like it to look like this I've tried adding things like interest = forms.ModelMultipleChoiceField(Interest.objects.all()) To the ProfileUpdateForm but nothing changes. Can anyone help me? models.py class Interest(models.Model): interest_name = models.CharField(max_length=30) def __str__(self): return self.interest_name class Profile(models.Model): GROUP_CHOICES = ( ('STUDENT', 'Student'), ('OVER 80S', 'Over 80s'), ) user = models.OneToOneField(User, on_delete=models.CASCADE) interest = models.ManyToManyField(Interest) group = MultiSelectField(choices = GROUP_CHOICES, blank=True) views.py def profile_view(request): if request.method == 'POST': p_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.profile) if p_form.is_valid(): p_form.save() return redirect('profile') else: p_form = ProfileUpdateForm(instance=request.user.profile) context = { 'p_form': p_form, } return render(request, 'users/profile.html', context) forms.py class ProfileUpdateForm(forms.ModelForm): class Meta: model = Profile fields = ['interest', 'group'] profile.html <form … -
Migrating TextField() to JSONField()
I used to have a TextField(blank=True, default='') in my model. Due some changes in the requirements of the project, it now become a better idea to have a dict stored, something like this: instructions { wait_time: { active: True message: 'This is a standard message' } } So I changed it to a JSONField: JSONField(blank=True, null=True). Did the changes in the serializers, and it passed on on the test for that specific field. When I tried to run the rest of the suit, I got this error: AssertionError: {u'non_field_errors': [u'null value in column "instructions" violates not-null constraint\n Which makes a lot of sense, since the TextField was set null=False. This field should now accept null values. I imagined that makemigrations and migrate would do the job. django.db.utils.DataError: invalid input syntax for type json DETAIL: The input string ended unexpectedly. CONTEXT: JSON data, line 1: My first idea was regarding the default value set for the TextField() before. To test it, I reverted the migration to the moment before its creation, delete the new migrations, 'mademigrations' and ran the tests. For some weird reasons, I still got: 'violates not-null constraint' error. This lead me to think the problem is not in … -
Can't run "python manage.py runserver" via command prompt
I want to run "python manage.py runserver", when doing so I get the error which says "Watchman unavailable: pywatchman not installed..". When installing pywatchman by typing pip install pywatchman I get error written " Failed building wheel for pywatchman" Please anybody with solution -
Email in django not being sent
I have a simple django application and I am not understanding why email are not being sent In my settings file I have EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = 587 EMAIL_HOST_USER = 'MyHost@gmail.com' EMAIL_HOST_PASSWORD = 'Mypassword' DEFAULT_FROM_EMAIL = 'From Email' but replaced with the actual and correct values Then when I create an instance of a model I want to send an email. The code I am using to do this is as follows @receiver(post_save, sender = Alerta) def my_callback(sender, created, **kwargs): if created: from_email = settings.DEFAULT_FROM_EMAIL print(from_email) try: send_mail( 'Fogo Florestal', "Mensagem", from_email, ["some_destination@gmail.com"], fail_silently=False, ) except Exception as e: print(e) I also made sure that the Gmail account I am using can be used by less secure apps. Moreover when the email is not sent no exception is printed to the terminal I have another web app which uses the the same send email procedure and it works properly. Has anyone faced a similar problem? I am using python 3.5 and django 2.1 -
django-allauth don't migrate
i'm creating an app with django-allauth, and django-tenant-schemas, with django 2.1.7 and python 3, im using the migrate command, but with django-tenant-schemas, so i use migrate_schemas, and it works perfectly, then i try to put all auth apps in shared and tenant apps, in the settings, but when i try to access to the admin to create my credentials, i get the next error ProgrammingError at /es/admin/socialaccount/socialaccount/ relation "socialaccount_socialaccount" does not exist LINE 1: SELECT COUNT(*) AS "__count" FROM "socialaccount_socialaccou... there is something i can do with this? those are my tenant and shared apps SHARED_APPS = [ 'tenant_schemas', # the tenant model 'shared_apps.geolocations', # the app where the tenant exists 'tenant_apps.accounts', 'shared_apps.commons', # the django apps that must be shared 'django.contrib.admin', 'django.contrib.admindocs', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.humanize', 'django.contrib.sites', 'allauth', 'allauth.account', 'allauth.socialaccount', 'allauth.socialaccount.providers.google', 'allauth.socialaccount.providers.facebook', 'allauth.socialaccount.providers.twitter', 'widget_tweaks', 'rest_framework', 'django_select2', ] TENANT_APPS = [ # The following Django contrib apps must be in TENANT_APPS 'django.contrib.contenttypes', 'django.contrib.auth', 'tenant_apps.accounts', 'simple_history', ] INSTALLED_APPS = list(SHARED_APPS) + [app for app in TENANT_APPS if app not in SHARED_APPS] -
I want "2019-02-26T19:15:00" convert to appropriate date time format in python?
I have to find the time duration of below date format ? I am trying to convert - 2019-02-27T08:28:00 to python date format ? But its give an error does not match format "%Y-%m-%d'T'%H:%M:%S" My code is datetimeFormat = "%Y-%m-%d'T'%H:%M:%S" timeDuration = datetime.strptime(str(2019-02-26T19:15:00), datetimeFormat) - datetime.strptime(str(2019-02-27T08:28:00), datetimeFormat) Your answer is very helpful to me ? Thanks in Advance . -
Use one table data as input to another table input in django 2.0
My first table is DJANGO Table: A Columns: ItemCode varchar(30) PK ItemName varchar(500) Quatity double RateOfPurchase double no_of_piece_in_qty double RateOfSale double My second table is DJANGO Table: B Columns: ItemCode varchar(30) PK ItemName varchar(500) QuatityForSale double SaleRate double can I enter ItemCode in a form and it get ItemName data from Table A and QuatityForSale and SaleRate is blank. So I can fill it and update table B? Thanks in advance -
How to implement drag and drop file upload with django?
I am looking for a way to implement drag and drop file upload with Django. So far I have tried Dropzone js and Filepond js and have had issues with both. In case you're wondering, Dropzone didn't work because it wouldn't allow me to submit the drag and drop images with other input fields and I can't seem to get FilePond to upload the photos to the server. Is there a better way to implement this feature that is better suited for Django? -
django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'core.User' that has not been installed
I want create custom fields in user_auth table.I just wrote a code in models.py and AUTH_USER_MODEL in the settings.py from django.db import models from django.contrib.auth.models import AbstractUser class User(AbstractUser): bio = models.TextField(max_length=500, blank=True) location = models.CharField(max_length=30, blank=True) birth_date = models.DateField(null=True, blank=True) and in settings.py AUTH_USER_MODEL = 'core.User' How can I get rid of this problem. I am new in django. Help me -
How to pre-select facets (i.e. get selected checkbox on page load) using Django-Haystack?
On the image below you can see how facets look when cpu_producer == "" (i.e. nothing selected). There are circumstances when cpu_producer may be AMD or INTEL and on a page load appropriate facet's checkbox must be selected. How to select it in backend in order to get in frontend appropriately filtered cpu? if category.slug == 'cpu': possible_sockets = '(socket_exact:"LGA1151" OR socket_exact:"LGA2066" OR socket_exact:"AM4" OR socket_exact:"TR4")' sqs = sqs.narrow(possible_sockets) possible_producers = '(producer_exact:"AMD" OR producer_exact:"INTEL")' sqs = sqs.narrow(possible_producers) cpu_producer = RECEIVED_VALUE # "AMD" or "INTEL" or "" # I NEED SOMETHING LIKE THIS. if cpu_producer: sqs.PRESELECT(producer=cpu_producer) -
Legacy database Django
I followed the steps for linking to a legacy app in Django. Everything seems to have migrated fine, but when I try to access the data, I get No module named xxx.models Here is settings.py DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'spam_filter.db'), } } I also added spamfilter under installed apps. Here is an example of my model class: class Inbound(models.Model): field_id = models.IntegerField(db_column='_id', primary_key=True, blank=True, null=True) # Field renamed because it started with '_'. filter_name = models.TextField(blank=True, null=True) day = models.TextField(blank=True, null=True) rate_controlled = models.IntegerField(blank=True, null=True) bad_recipient = models.IntegerField(blank=True, null=True) spam = models.IntegerField(blank=True, null=True) virus = models.IntegerField(blank=True, null=True) quarantined = models.IntegerField(blank=True, null=True) tagged = models.IntegerField(blank=True, null=True) allowed = models.IntegerField(blank=True, null=True) total_received = models.IntegerField(blank=True, null=True) When I enter from spamfilter.models import Inbound, I get the error that spamfilter.models is not found. What am I doing wrong. -
Django: "{% for x in stories %}" won't work
Excuse the non-descriptive title of this question, I wasn't sure how to name it. My problem is this: I have created a function in my views.py file, that should be able to show all the user stories, if there are any ( {% if user_story %} ). However, the user won't reach the for loop and I don't understand why! Below you will find my html template of this part, as well as part of my views.py file. Thank you ! user.html {% for story in user_stories %} <a href="{% url 'pinkrubies:story' story.author.id story.id %}"> <h2 class="post-title"> {{ story.title }} </h2> </a> <p class="post-meta">Posted on {{ story.date }} </p> <p class="post-subtitle"> {{ story.story|truncatewords:30 }}</p> {% endfor %} views.py def user_stories_view(request, user_id): user_stories = Story.objects.filter(author=user_id) context = {'user_stories': user_stories} return render(request, 'pinkrubies/user.html', context) -
Функция render не отсылает шаблон на сторону клиента
Посылаю post запрос со стороны клиента на сервер. Запрос заходит в необходимую функцию, но когда приходит время вернуть ответ с сервера(return render(request, 'front/sendmessage.html')) то ничего не происходит. Файл views.py @login_required @csrf_exempt def send_message(request): receiver = User.objects.all().filter(pk=int(request.POST.get('id'))) print(receiver) return render(request, 'front/sendmessage.html') файл urls.py: urlpatterns = [ url(r'^signin/$', view=auth_views.LoginView.as_view(template_name='front/auth.html'), name='signin'), url(r'^list/$', view=views.show_messages, name='show_messages'), url(r'^sendmessage$', view=views.send_message, name='send_message'), path('list/<int:pk>/', view=views.MessagesView.as_view()), path('list/<int:pk>/read/', view=views.read_text) ] С какого сайта уходит запрос: {% extends 'front/base.html' %} {% block title %} listOfMessages {% endblock %} {% block content %} <table class="table" id="clients"> <thead> <tr> <th>Имя пользователя</th> <th>Сообщение</th> <th>Дата</th> <th>Действие</th> </tr> </thead> {% for message in messages %} {% if message.is_read %} <tr> {% else %} <tr bgcolor="#ffe4c4"> {% endif %} <td>{{ message.sender.username }}</td> <td><a href="{{ message.id }}">{{ message.text }}</a></td> <td>{{ message.date }}</td> <td> <button type="button" onclick="answer({{ message.sender.id }})" class="btn btn-primary">Ответить</button> </td> </tr> {% endfor %} </table> <script> function answer(userID) { $.ajax({ type: 'post', url: '/sendmessage', data: { id: userID, }, }) } </script> </html> {% endblock %} На какое отображение должен перебросить сервер: {% extends 'front/base.html' %} {% block title %} mainpage {% endblock %} {% block content %} <body> <form method="post">{% csrf_token %} <div class="form-row"> <div class="col-4"> <input type="text" class="form-control" placeholder="Send message" id="message"> </div> <button type="button" onclick="addmessage()" href="/sendmessage" … -
Problem adding Let's Encrypt SSL to Django App deployed on Heroku
I have a Django application with a paid dyno deployed on Heroku for which I am trying to configure SSL with LetsEncrypt, I am trying to complete the ACME challenge by going to the URL http://myapp.com/.well-known/acme-challenge/challenge_list to generate the certificate but I get the following error on my browser This va-acm.heroku.com page can’t be found. HTTP Error 404 I have installed the django-letsencrypt package on my Django application and it created ACME Challenges table in my Django application where I am providing the challenge and response provided from certbot. I am able to get the response in my local machine http://127.0.0.1:8000/.well-known/acme-challenge/challenge_list. Not sure if I am missing some steps for the Heroku I have letsencrypt in my settings.py INSTALLED_APPS = [ .......... 'letsencrypt', ......... ] My main urls.py is as follows: path('.well-known/', include('letsencrypt.urls')), I am using Django version - 2.0.8 django-letsencrypt - 3.0.1 python - 3.6 -
selecting Models Randomly under specific conditions
I am completely biggener. I've made a WebApp using django to organize a class room. I want to generate random work groups of 2 students where the two students don't talk the same first_languge. Evrey thing Works, but still have results don't match that condition. this is the code that I have done: from students.models import students import random #make a list of all students a =list(students.objects.all()) #the select function def group (x,y): res = [] for i in range(y): while len(res)<y: res = random.sample(x, k=y) while x[i].first_language == x[i-1].first_language: group(x,y) return None return res #multiple call for the function for n in range(10): p = group(a,2) print(p) if i call the function multiple times i get groups from students with the same mother language, and this is wrong. -
Django, gunicorn, nginx throws 504 Gateway Time-out: AttributeError: module 'static' has no attribute 'Cling'
yesterday I deployed a new version of my little website online and immediately received a 504 Gateway Time-out error. After some digging in the log files I found the following error: File "/home/dev/venuepark/ENV/lib/python3.6/site-packages/django/utils/autoreload.py", line 225, in wrapper fn(*args, **kwargs) File "/home/dev/venuepark/ENV/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 137, in inner_run handler = self.get_handler(*args, **options) File "/home/dev/venuepark/ENV/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/runserver.py", line 27, in get_handler handler = super().get_handler(*args, **options) File "/home/dev/venuepark/ENV/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 64, in get_handler return get_internal_wsgi_application() File "/home/dev/venuepark/ENV/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 44, in get_internal_wsgi_application return import_string(app_path) File "/home/dev/venuepark/ENV/lib/python3.6/site-packages/django/utils/module_loading.py", line 17, in import_string module = import_module(module_path) File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/home/dev/venuepark/venuepark/venuepark/wsgi.py", line 17, in <module> application = Cling(MediaCling(get_wsgi_application())) File "/home/dev/venuepark/ENV/lib/python3.6/site-packages/dj_static.py", line 97, in __init__ super(MediaCling, self).__init__(application, base_dir=base_dir) File "/home/dev/venuepark/ENV/lib/python3.6/site-packages/dj_static.py", line 48, in __init__ self.cling = static.Cling(base_dir) AttributeError: module 'static' has no attribute 'Cling' my wsgi.py: import os from django.core.wsgi import get_wsgi_application from dj_static import Cling, MediaCling os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'venuepark.config.settings.production_settings') application = Cling(MediaCling(get_wsgi_application())) but dj-static is installed properly. What could cause this problem? Thanks in … -
save() got multiple values for argument 'commit'
I'm getting an error that indicates that save() got multiple values for argument 'commit'. I'm unsure why this is. views.py if formset.is_valid(): instances = formset.save(request, commit=False) forms.py def save(self, request, commit=True): instance = super(FAQForm, self).save(commit=False) user = request.user userFAQS = FAQ.objects.filter(user=user) userFAQScount = userFAQS.count() if userFAQScount < 5: instance.save() return instance Any help would be appreciated! -
Random Character Generator Query with Django + Django Rest framework
I have created a table of Character Origins, and I want to run a query against that table that will return Three Choices back. Each choice will have two random Character Origins in it. I am currently using Django and DRF to build out my API, I've attempted to use Nested Serializers from Django-rest-framework-tricks but have failed and now I think my best bet is to use a better query than Djangos ORM can do. Serializers.py class OriginsNestedSerializer(serializers.ModelSerializer): class Meta: model = Origin fields = ( 'id', 'origin', 'ability', 'skill', 'bonus', 'ac', 'fort', 'ref', 'will', 'defense', 'lvl_1', 'lvl_2_or_6', 'novice', 'utility', 'expert', ) read_only_fields = ['id', ] nested_proxy_field = True class ChoiceCharacterCreationSerializer(serializers.ModelSerializer): origin_primary = OriginsNestedSerializer() origin_secondary = OriginsNestedSerializer() class Meta: model = Origin fields = ( 'origin_primary', 'origin_secondary', ) nested_proxy_field = True class ChoicesSerializer(serializers.ModelSerializer): choice = ChoiceCharacterCreationSerializer() class Meta: model = Origin fields = ( 'choice', ) Views.py class CreateACharacterViewSet(viewsets.ModelViewSet): serializer_class = serializers.ChoicesSerializer queryset = models.Origin.objects.order_by('?')[:3] My result is this... [ { "choice": { "origin_primary": { "id": 60, "origin": "Lagomorph", "ability": " STR", "skill": " Perception", "bonus": " Bio", "ac": 0, "fort": 2, "ref": 2, "will": 2, "defense": "You gain a +2 bonus on saving throws.", "lvl_1": "At the start of … -
DRF : Generic way to inject additional info into request.data
I'm in a situation where I have a endpoint samples which represents a model sample via a ModelViewSet. My goal is, that when a user POST's against this endpoint with data like { "a":1, "b":2 , "c":3 } i want to be able to override/add key:value pairs to this incoming payload stored in request.data within the create method. This can not be done by simply accessing request.data since it's a QueryDict which is immutable. Furthermore i can not achieve this in the perform_create() method since the data i might inject is validation-critical. Currently I'm stuck with the following solution which requires me to REWRITE the complete create() method : class MyViewSet(viewsets.ModelViewSet): queryset = Sample.objects.all() serializer_class = MSampleSerializer name = "samples" def add_info(self, request): ... <acquire_info> ... data = request.data.dict() data["s"] = <info1> data["r"] = <info1> data["t"] = <info1> return data def create(self, request, *args, **kwargs): data = self.add_info(request) serializer = self.get_serializer(data=data) serializer.is_valid(raise_exception=True) self.perform_create(serializer) headers = self.get_success_headers(serializer.data) return Response( serializer.data, status=status.HTTP_201_CREATED, headers=headers ) Is there a generic way to edit the request.data before any action method, like create() or put(), is called ? If not 1.); is there a different possibility ? Thanks in advance. -
Is it possible to use only a few Wagtail modules in a Django project?
I want to know if it is possible to only use some parts of the wagtail in a Django Project. I want to just use StreamField to use some blocks and upload images, but from what I've researched, it's not possible to use the wagtail out of the packet, so I wonder if it really is not possible to use its modules outside of a wagtail project. I want to do this because I want to "rebuild the wheel" because I'm still a beginner and doing it helps to learn, but I do not want to do that much like creating my own StreamField and my blocks, -end, which I do not have at the moment (not JS only).