Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Send message to RabbitMQ using Django and Docker
I have no idea how to use RabbitMQ. Any tutorial on how to use rabbitmq and django in docker to send messages would be helpful. -
heroku django showing stacktrace error 500 on logs?
I have heroku/django app. When i got error 500, i would like to get stacktrace in logs. So i do this: heroku logs -t --app myapp Then when i got error 500 i see this: The problem is i don't get stacktrace ... So to debug i have to put DEBUG to True, and i don't think that the right way to do it on production. How can i display error in logs please ? PS : I tried to set ADMINS email in settings.py to receive an email with stacktrace, but i don't :/ ADMINS= [('support@******.com', 'admin@******.com'),] So how can i see my stacktrace error 500 without setting debug = True please :3 ? Thank you ! -
django import export app error: django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet
I'm upgrading a Django site to 3.1.2 and noticed one backend app wasn't working, in the process of asking the community help in fixing this I found out the app wasn't a custom made code by a single coder for the site but a community project called django-import-export. Since it's up to date and supports django 3.1 i deleted the manual way it was setup as a folder and pip installed it. i then tried to do a makemigrations threw an error and after reading the setup docs assumed possibly you need to do collectstatic first, it also threw the same error (kpsga) sammy@kpsga:~/webapps/kpsga$ python manage.py collectstatic Traceback (most recent call last): File "manage.py", line 22, in <module> main() File "manage.py", line 18, in main execute_from_command_line(sys.argv) File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line utility.execute() File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/django/core/management/__init__.py", line 377, in execute django.setup() File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/django/apps/registry.py", line 114, in populate app_config.import_models() File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/django/apps/config.py", line 211, in import_models self.models_module = import_module(models_module_name) File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in … -
We can not request API service after build project
We develop the backend side of our project with the Django Rest Framework. We develop the frontend side of our project with the VueJs. The project will run on the apahce We had a problem after building Vuejs. We did not any problem with the Django Rest Framework. We can connect with Postman and we can do transactions. No problem. We finish our development in the frontend and write localhost or 127.0.0.1 to axios.default.baseURL; const ApiService = { init() { Vue.use(VueAxios, axios); Vue.axios.defaults.baseURL = "http://localhost:8000/"; //Vue.axios.defaults.baseURL = "http://127.0.0.1:8000/"; } } After build we move the files in dist to /var/www/htdocs We cannot send any request to the API service. The users can't login, can not perform any transactions. Even though both sides working on same device If i wrote endpoint IP address the axios.default.baseURL. The project will working inside in network. There is no domain name or endpoint IP address. Maybe There will be no internet connection on the this server. I think we should be able to write localhost or 127.0.0.1 on the VueJS. And by opening backend to a port we don't feel it's safe, because we are building security focused projects we want to have a close … -
Is this the right way to open object from DB for editing in the same form, and then saving the updated value for the same object using django?
This is my code: To create the new issue object, use form def raise_issue_view(request, *args, **kwargs): form = RaiseIssueForm(request.POST or None) if form.is_valid(): form.save() obj = RaiseIssueModel.objects.latest('id') return redirect("/raise_issue/" + str(obj.id)) context = { "form" : form } return render(request,"raise_issue.html", context) To edit the previously created issue, by link 127...8000/edit_issue/<issue_id> def edit_issue_view(request, id): obj = RaiseIssueModel.objects.get(id=id) form = RaiseIssueForm(instance=obj) new_form = RaiseIssueForm(request.POST, instance=obj) if new_form.is_valid(): new_form.save() return redirect("/raise_issue/" + str(obj.id)) context = { "form" : form } return render(request,"raise_issue.html", context) Here, in Edit issue view, first i'm loading the DB data into 'form', then I'm creating a new form (new_form) to save the updated data. Is this OK, or is there a better way to do this? Thanks, -
How to connect docker to oracle external database outside docker container?
i have create database on oracle. How to connect oracle external database with docker? -
How to get request user id in Django Serializers?
I'm getting KeyError: 'request' while i want to get the current user id through user request. I tried something like this: validated_data['user_id'] = CarOwnerCarDetails.objects.get(user_id=self.context['request'].user.id) but it's throwing me KeyError. How to get the current user id through request in serializers? if any help would be much appreciated. Thank you so much in advance my friends. models : class CarOwnerCarDetails(models.Model): user_id = models.OneToOneField(User, on_delete=models.CASCADE) car_plate_number = models.CharField(max_length=20, null=True, blank=True) class GetQuotes(models.Model): user = models.ForeignKey(CarOwnerCarDetails, on_delete=models.CASCADE, blank=True, null=True) subject = models.CharField(max_length=240, blank=False, null=True) serializers : class ShopGarageGetQuoteSerializer(ModelSerializer): subject = CharField(error_messages={'required':'subject key is required', 'blank':'subject is required'}) user_id = serializers.CharField(read_only=True) class Meta: model = GetQuotes fields= ['user_id', 'subject'] def create(self,validated_data): subject = validated_data['subject'] validated_data['user_id'] = CarOwnerCarDetails.objects.get(user_id=self.context['request'].user.id) quotes_obj = GetQuotes.objects.create( subject=subject, user_id=validated_data['user_id'] ) return validated_data views.py : class ShopGarageGetQuoteAPIView(APIView): permission_classes = (IsAuthenticated,) def post(self,request,*args,**kwargs): data = request.data serializer = ShopGarageGetQuoteSerializer(data=request.data) if serializer.is_valid(): serializer.save() return Response({'success' :'True','message' : 'Quotes send successfully','data' : serializer.data},status=200) return Response(serializer.errors,status=400) -
Wagtailadmin allow group only to view in CMS admin
Hello everyone I've been working with wagtail for a while I faced and interesting thing when I create a group with only view permissions and access to wagtail all its fancy tabs like pages and images begone. I might assume that it is due to permissions of add/edit missing. But the question is is it possible in a fast easy way make something like that? display_what_needed and still be with this menu which disappear -
How to implement Agora into a Django project?
I would like to implement Agora voice and video SDK into a Django project. I have found some articles on this issue such as https://medium.com/@rayanuthalas/build-a-video-call-website-using-django-agora-a20ba6b8e7d5 Which might be helpful for someone with a previous experience but for so first time implementer it is too little, also they omit chunks of code here and there which makes it impossible to follow. I have found some package for Django - https://pypi.org/project/django-agora/ but it seems inactive and it hasn't even reached version 1. I would appreciate any tips on what to follow or any advice on how to implement it with Django. Or if you have an experience with another such SDK with Django and you know it is fairly straight forward to implement, I am open to suggestions too. Any material will be appreciated. -
Django Filter Default Date
Unfortunately I can't wrap my head around how to set a default value for a Date Filter, as described in some other posts it should be possible to set it in the init function, but to no avail: filters.py: class LoaderErrorFilter(django_filters.FilterSet): product = django_filters.ModelChoiceFilter(queryset=Product.objects.all(), label='Product*') operator = django_filters.CharFilter(field_name="operator", lookup_expr='contains', label='Operator') load_from = django_filters.DateFilter(label='From*') load_to = django_filters.DateFilter(label='To*') error = django_filters.CharFilter(field_name="error", lookup_expr='contains', label='Error') def __init__(self, *args, **kwargs): super(LoaderErrorFilter, self).__init__(*args, **kwargs) self.form.initial['load_from'] = datetime.datetime.today().replace(day=1) self.form.initial['load_to'] = datetime.datetime.today() if self.data == {}: self.queryset = self.queryset.none() The queryset will be filled after the user makes a selection since there are different models affected depending on the choices. Any ideas would be highly appreciated! -
Django cache framework not working with django-cms
I am using django 3.1 and the database caching and it is working properly, but when I included the django-cms in the project the cache table started giving an error that psycopg2.errors.UndefinedTable: relation "abc_cache_table" does not exist is there any config that I am missing to add? any help and suggestion will appriated. Thank you. -
SystemError: <built-in function uwsgi_sendfile> returned a result with an error set
I habe deploy my django app on pythonanywhere but have an error with export in excel my code works except on pythonanywhere I try to use from werkzeug.wsgi import FileWrapper but module werkzeug is not found... how to fix this issue? views.py from django.shortcuts import render, get_object_or_404, redirect from django.http import HttpResponse, HttpResponseRedirect from django.urls import reverse from django.db.models import Q from django.utils.translation import ugettext as _ import time from django.utils import timezone from datetime import datetime # http://www.learningaboutelectronics.com/Articles/How-to-create-an-update-view-with-a-Django-form-in-Django.php from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import permission_required from randomization.models import Medicament, Randomisation, is_randomizable, categorie_medicament from parameters.models import Profile, Pays, Region, Site, Thesaurus from pharmacy.models import Entree, Sortie, Parametrage, Alerte, Stock, alerte_existe, alerte_activation, mise_a_jour_alerte, stock_site_existe, liste_medicaments_a_envoyer_site,liste_medicaments_a_envoyer_pays, quantite_medicament_a_expedier, liste_medicaments_a_expedier import os import xlwt import csv @login_required def export(request): response = HttpResponse(content_type='application/ms-excel') export_date = str(timezone.now())[0:10] sites = [s.sit_abr for s in request.session.get('user_authorized_sites')] pays = Pays.objects.get(pay_ide = request.session.get('user_pays')).pay_abr filename = str(export_date) + "_intensetbm_export.xls" response['Content-Disposition'] = 'attachment; filename= "{}"'.format(filename) # response['Content-Disposition'] = 'attachment; filename="intensetbm_export.xls"' wb = xlwt.Workbook(encoding='utf-8') # styles normal_style = xlwt.XFStyle() ... if request.user.has_perm('randomization.can_export_data_randomization'): ws = wb.add_sheet('crf_ran') row_num = 0 columns = ... wb.save(response) return response -
Need help in adding Foreign key using django models
Okay so I don't know how to frame this. I have two models Employee and Customer. I am storing the Employee as foreign key in Customer model under emp_id. The epm_id stores the primary key of the employee who admits the customer. I am not sure how to do this in django. Here are my models: class Customer(models.Model): firstname = models.CharField(max_length=15) lastname = models.CharField(max_length=15) age = models.IntegerField() sex = models.CharField(max_length=10) phoneno = models.IntegerField() emailid = models.CharField(max_length=25) address = models.CharField(max_length=50) children = models.IntegerField() adults = models.IntegerField() roomtype = models.CharField(max_length=10) aadharno = models.CharField(max_length=15) daysstayed = models.IntegerField() date_visited = models.DateTimeField(default=timezone.now) emp_id = models.ForeignKey(Employee,on_delete=models.SET_NULL,blank=True,null=True) class Employee(models.Model): firstname = models.CharField(max_length=15) lastname = models.CharField(max_length=15) age = models.IntegerField() sex = models.CharField(max_length=10) phoneno = models.IntegerField() emailid = models.CharField(max_length=25) address = models.CharField(max_length=50) salary = models.IntegerField() designation = models.CharField(max_length=10) password = models.CharField(max_length=10) aadharno = models.CharField(max_length=15) datejoined = models.DateField(default=timezone.now) I need some help here. -
How to display the user groups because they didn't show in django view?
I have CRUD operations for users which can be done only from admin and he can assign users to 6 different groups. It saved in the database and everything works well. The problem I faced now is that the groups are not visualize in my views (in the UI) I attached picture to show what I mean: model.py class CustomUserManager(BaseUserManager): def create_user(self, email, password, **extra_fields): if not email: raise ValueError(_('The Email must be set')) email = self.normalize_email(email) user = self.model(email=email, **extra_fields) user.set_password(password) user.save() return user def create_superuser(self, email, password, **extra_fields): extra_fields.setdefault('is_staff', True) extra_fields.setdefault('is_superuser', True) extra_fields.setdefault('is_active', True) if extra_fields.get('is_staff') is not True: raise ValueError(_('Superuser must have is_staff=True.')) if extra_fields.get('is_superuser') is not True: raise ValueError(_('Superuser must have is_superuser=True.')) return self.create_user(email, password, **extra_fields) class CustomUser(AbstractUser): username = None email = models.EmailField(_('email address'), unique=True) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] objects = CustomUserManager() def __str__(self): return self.email username = models.CharField(max_length=30, blank=True, default='') is_superuser = models.BooleanField(default=True) is_admin = models.BooleanField(default=True) is_employee = models.BooleanField(default=True) is_headofdepartment = models.BooleanField(default=True) is_reception = models.BooleanField(default=True) is_patient = models.BooleanField(default=True) is_active = models.BooleanField(default=True) is_staff = models.BooleanField(default=True) forms.py class UserForm(ModelForm): class Meta: model = CustomUser fields = ['email', 'password',] useradd.html <h1 class="display-4">Add new user</h1> <form action="" method="post" autocomplete="off"> {% csrf_token %} {{ form.as_p }} <button … -
Django 'GuideResource' object has no attribute '_meta'
I've upgraded a django project to the latest version 3.1.2 from an older version and one issue is Meta Classes imports. I have this model which intends to inherit meta classes like so class Guide(Contact): operator = models.ForeignKey('guides.SafariOperator', blank=True, null=True, on_delete=models.CASCADE) level = models.ForeignKey('guides.MembershipLevel', blank=True, null=True, on_delete=models.CASCADE) expiry_date = models.DateField(default=django.utils.timezone.now) language = models.ManyToManyField('guides.Language', blank=True) class Meta: ordering = ['name'] class GuideResource(resources.ModelResource): id = fields.Field(column_name='Bd/Sr', attribute="id") sortorder = fields.Field(column_name='Bd/Sr', attribute="sortorder") #description = fields.Field(column_name='Company', attribute="description") address = fields.Field(column_name='Wk PO Box', attribute="address") telephone = fields.Field(column_name='Tel', attribute="telephone") fax = fields.Field(column_name='Fax', attribute="fax") email = fields.Field(column_name='E-mail', attribute="email") class Meta(Guide): pass which then throws this error Traceback (most recent call last): File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/django/core/handlers/base.py", line 179, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/django/utils/decorators.py", line 130, in _wrapped_view response = view_func(request, *args, **kwargs) File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func response = view_func(request, *args, **kwargs) File "/home/sammy/webapps/envs/kpsga/lib/python3.8/site-packages/django/contrib/admin/sites.py", line 233, in inner return view(request, *args, **kwargs) File "/home/sammy/webapps/kpsga/import_export/admin.py", line 154, in import_action context['fields'] = [f.column_name for f in resource.get_fields()] File "/home/sammy/webapps/kpsga/import_export/resources.py", line 113, in get_fields return [self.fields[f] for f in self.get_export_order()] File "/home/sammy/webapps/kpsga/import_export/resources.py", line 296, in get_export_order return self._meta.export_order or self.fields.keys() Exception Type: AttributeError at /admin/guides/guide/import/ Exception Value: 'GuideResource' object … -
Django Form: comma separated decimal numbers throwing validation errors
I have a form where user can enter decimal/integer values as comma separated like, 500,000 or 500,000.00. When I process the field using the Django ModelForm it raises the validation error like Enter a number, I want to remove those "," before the value makes into the DB. My Form: class EmployeeSalaryForm(forms.ModelForm): class Meta: model = Salary fields = [ 'basic_salary', 'convyence_allowance', 'medical_allowance', 'mobile_allowance', 'executive_allowance', 'gross_salary', 'epf', 'health_benefit', 'ctc', 'join_bonus', 'var_pay', ] basic_salary = forms.DecimalField(max_digits=11,decimal_places=2) convyence_allowance = forms.DecimalField(max_digits=11,decimal_places=2) medical_allowance = forms.DecimalField(max_digits=11,decimal_places=2) mobile_allowance = forms.DecimalField(max_digits=11,decimal_places=2) executive_allowance = forms.DecimalField(max_digits=11,decimal_places=2) gross_salary = forms.DecimalField(max_digits=11,decimal_places=2) epf = forms.DecimalField(max_digits=11,decimal_places=2) health_benefit = forms.DecimalField(max_digits=11,decimal_places=2) ctc = forms.DecimalField(max_digits=11,decimal_places=2) join_bonus = forms.DecimalField(max_digits=11,decimal_places=2, required=False) var_pay = forms.DecimalField(max_digits=11,decimal_places=2, required=False) def clean_basic_salary(self): basic_salary = self.cleaned_data['basic_salary'] return basic_salary.replace(',', '') def clean_convyence_allowance(self): convyence_allowance = self.cleaned_data['convyence_allowance'] return convyence_allowance.replace(',', '') def clean_medical_allowance(self): medical_allowance = self.cleaned_data['medical_allowance'] return medical_allowance.replace(',', '') def clean_mobile_allowance(self): mobile_allowance = self.cleaned_data['mobile_allowance'] return mobile_allowance.replace(',', '') def clean_executive_allowance(self): executive_allowance = self.cleaned_data['executive_allowance'] return executive_allowance.replace(',', '') def clean_gross_salary(self): gross_salary = self.cleaned_data['gross_salary'] return gross_salary.replace(',', '') def clean_epf(self): epf = self.cleaned_data['epf'] return epf.replace(',', '') def clean_health_benefit(self): health_benefit = self.cleaned_data['health_benefit'] return health_benefit.replace(',', '') def clean_ctc(self): ctc = self.cleaned_data['ctc'] return ctc.replace(',', '') def clean_join_bonus(self): join_bonus = self.cleaned_data['join_bonus'] return 0 if join_bonus == None else join_bonus.replace(',', '') def clean_var_pay(self): var_pay = self.cleaned_data['var_pay'] return 0 … -
How to rename default "id" field in django
Is there any way to rename the default Primary key(model) Value "id".(I am not talking about my own created fields)? admin.py class ShiftChangeAdmin(ImportExportModelAdmin): list_display=['id','ldap_id','Vendor_Company','EmailID','Shift_timing','Reason','last_updated_time'] -
Integrating Google Calendars API into Django
I found some examples on using the API in Python, but I was wondering if there is any guidance or examples on using the Calendars API in a Django project. For our website, we want users to be able to enter an event name, start time, and number of hours (event duration) into a form, and for this information to then be used to generate the appropriate Google Calendars event. One concern we had was that the start/end date strings look like they are very specifically formatted, so we were wondering how to translate the form input into start/end time strings. -
How can I call parent's parent class method withouting calling parent's method when using chaining inheritance?
I have a serializer class looks like this: class BargainOrdersAdminSerializer(BargainOrdersSerializer): def update(self, instance, validated_data): if validated_data.get('logistics_company') and validated_data.get('logistics_tracking_no'): validated_data.update(is_shipped=True) return super().update(instance, validated_data) # here, it will also call `BargainOrdersSerializer`'s update method which is not I am expected. As you can see, it inherits from another serializer class as below: class BargainOrdersSerializer(ModelSerializer): ...... def update(self, instance, validated_data): order = instance.order order.status = 'W' order.save(update_fields=['status']) wxpay_query.apply_async((order.id,), countdown=60, link_error=wxpay_error_handler.s(order.id)) return super().update(instance, validated_data) Which also override update method. And now, when I call super().update(instance, validated_data) in child class BargainOrdersAdminSerializer, it calls its parent class's overrided update also which is not I am expected. I want to ignore it. One approach I can figure out is copying the update source code in ModelSerializer and write some custom code in BargainOrdersAdminSerializer's update method. But, it is stupid right? How can I handle it properly? -
How to Access the Logic from a Docker Container?
I am working with a Django App now, and I am new with Docker and a Rookie who is trying turn the App into Microservices. The logics and models I am using are written in a common file. What approach do I have to follow so that I can make my loosely coupled as Microservice? -
Connecting Django models to database names with primary key name other than ID
I have a project where primary column name is 'N' in place of standard 'id'. I have no access to the original database to change it, so I hoped that the following code will do the trick: class ExSLoc(models.Model): id = models.IntegerField(primary_key=True, db_column='n') class Meta: db_table = original_db_table managed = False It actually does, but I run into a strange bug from Django model forms, telling that: 'ExSLoc' object has no attribute 'id' Here's the full traceback. | Traceback (most recent call last): website_1 | File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 174, in get_response website_1 | response = self.process_exception_by_middleware(e, request) website_1 | File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 172, in get_response website_1 | response = response.render() website_1 | File "/usr/local/lib/python2.7/dist-packages/django/template/response.py", line 160, in render website_1 | self.content = self.rendered_content website_1 | File "/usr/local/lib/python2.7/dist-packages/django/template/response.py", line 137, in rendered_content website_1 | content = template.render(context, self._request) website_1 | File "/usr/local/lib/python2.7/dist-packages/django/template/backends/jinja2.py", line 70, in render website_1 | return self.template.render(context) website_1 | File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 1090, in render website_1 | self.environment.handle_exception() website_1 | File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 832, in handle_exception website_1 | reraise(*rewrite_traceback_stack(source=source)) website_1 | File "/opt/project/templates/rfs_submission/rfs_new_0.html", line 1, in top-level template code website_1 | {% extends "rfs_submission/rfs_new.html" %} website_1 | File "/opt/project/templates/rfs_submission/rfs_new.html", line 9, in top-level template code website_1 | {% … -
I want to host my django webpage from my computer publically (Globally)
I've made a django app which I want to host from my own computer using my public IP such that anyone from any part of the world can access it through http://0.0.0.0:8000 where the 0's will be replaced by my public IP. In simple words, I want to make my computer the server for my website. Can anyone help? -
hide previous collapse when i press on other button and show button data - django
hello i want to hide previous collapse when i press on other button and show button data I'm using this format , my problem is data keep show when i press on other button ... i want show just the data when i press on some button and hide other data my html code : <div class="d-flex justify-content-center"> <div class="btn-group" role="group" aria-label="Basic example"> <button type="button" class="btn btn-secondary" data-toggle="collapse" data-target="#phone_pics" aria-expanded="true" style="background-color:#7952b3;border-radius:7px"> phone pics </button>&nbsp; <button type="button" class="btn btn-secondary" data-toggle="collapse" data-target="#space" aria-expanded="true" style="background-color:#7952b3;border-radius:7px"> phone space </button>&nbsp; <button type="button" class="btn btn-secondary" data-toggle="collapse" data-target="#review" aria-expanded="true" style="background-color:#7952b3;border-radius:7px"> review </button>&nbsp; </div> </div> <!-- this for phone pics --> <div id="phone_pics" class="collapse" aria-expanded="true"> <br> <div class="d-flex justify-content-center"> <div class="img"> {% for img in mobile_posts.mobile_images_set.all %} <div class="d-flex justify-content-center"> <img src="{{img.get_image}}" class="img-responsive img-thumbnail" width="50%" height="80%"> </div> {% endfor %} </div> </div> </div> <!-- this for review --> <div id="review" class="collapse" aria-expanded="true"> <br> <iframe width="100%" height="400px" src="{{mobile_posts.mobile_review_video}}" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen> </iframe> </div> <!-- this for space --> <div id="space" class="collapse show" aria-labelledby="headingOne" > <br> </div> -
Get class name of descendant in mixin
I want to get the name of the descendant class in the mixin for GenericRelation in Django. Do you have any ideas on how to do that? class ItemMixin: items = GenericRelation(Item, related_query_name="Here I want to get name of a child class") -
How to resolve django react app with webpack?
I am creating django + react project.So instead of running npx create-react-app my-app I created this folder structure inside the frontend django app. To run react components I have webpack with script like this inside package.json file "scripts": { "dev": "webpack --mode development ./frontend/src/index.js -o ./frontend/static/frontend/main.js", "build": "webpack --mode production ./frontend/src/index.js -o ./frontend/static/frontend/main.js" } ├── src │ ├── components │ │ ├── App.js │ │ └── layout │ │ └── Header.js │ └── index.js ├── static │ └── frontend │ └── main.js ├── templates │ └── frontend │ └── index.html ├── tests.py ├── urls.py └── views.py so when I run npm run dev It will see main.js as package and it will create ./frontend/static/frontend/main.js/main.js** as the compiled output file. so when I run django server it will show static file main.js not found (means HTTP 404). So how do I resolve this issue?