Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Pass user access token from Django app to ELasticsearch
Im developing a django app that requires users to authenticate via azure ad (Oauth2). The app also interacts with an elasticsearch service that requires the same oauth2 authentication. during development I have used a static username and password to login like this: user_name = "elastic" host_ip = "127.0.0.1" host_ports = 9200 elk_url = f'https://{user_name}:{ESPASSWORD}@{host_ip}:{host_ports}' ELASTICSEARCH_DSL = { 'default': { 'hosts': elk_url, 'ca_certs': False, 'verify_certs': False, } } How can I pass the users token to the elasticsearch service? -
How can I sort instances by a fk related field in a serializer in Django?
According to a prior answer to one of my questions I am trying to re-arrange the queryset qs_payments of objects by field month utilising their fk relationship. The statement in my prior enquiry was you can just serialize the Payments on each Month directly But how would I basically achieve this? As far as I understand I have to use the serializer for the months model then and tell it to sort the qs by month? # models.py class Period(models.Model): period = models.DateField() class Payment(models.Model): offer = models.ForeignKey(Offer, on_delete=models.CASCADE) month = models.ForeignKey(Period, on_delete=models.CASCADE) amount = models.PositiveIntegerField() # serializers.py class PaymentSerializer(serializers.ModelSerializer): class Meta: model = Payment fields = '__all__' class PeriodSerializer(serializers.ModelSerializer): class Meta: model = Period fields = '__all__' class PayrollRun(APIView): def get(self, request): # Get the related company according to the logged in user company = Company.objects.get(userprofile__user=request.user) # Get a queryset of payments that relate to the company and are not older than XX days qs_payments = Payment.objects.filter(offer__company=company) print(qs_payments) serializer = PaymentSerializer(qs_payments, many=True) return Response(serializer.data) The desired output is that I want to map each month to a React component containing all line items of that particular month. So I need (at least imho) a dictionary of months each having … -
django nested inline formsets with adding fields dynamically
I need a form for grand-parent parent and children form which will go like this grand-parent-- parent-- children in which I can add n number of parent for grand parent and n number for children for each parent , I have implemented this function in django's admin page using django-super-inlines thispip package but I need it for front end. Any help? and Thanks in advance -
JWT Cookie sent as Set-Cookie causing "Invalid Signature" in DRF jwt
I've been trying to solve this problem a week ago, from now on after looking for a solution in almost every forum, blog and lib's github issues I realized that it gonna be easier asking here. I have a django app using JWT for authentication (Web and Mobile), when I change the user email the mobile app (react native) keeps sending the old jwt in cookies to server which leads to an "Invalid Signature" response (in any endpoint including login) Here is my djangorestframework-jwt conf: JWT_AUTH = { 'JWT_VERIFY_EXPIRATION': True, 'JWT_AUTH_COOKIE': "JWT", 'JWT_EXPIRATION_DELTA': datetime.timedelta(seconds=3000), 'JWT_ALLOW_REFRESH': True, } Setting this line 'JWT_AUTH_COOKIE': "JWT", To 'JWT_AUTH_COOKIE': None, The server won't look for jwt cookies in request however the next api calls don't find token in Authorization Header which leads to Authentication credentials were not provided Even sending the token in Header. At web app there is no problem with that, so I'd like to know how can I fix it, looking for a way to stop sending JWT cookie from mobile app. -
Django silently removes constraints when removing columns, then arbitrarily choses to include them in migrations
I’ve encountered an odd bug(?) in Django in our production code. Dropping a column manually in migrations without removing its constraints leads to Django being unaware those constraints have been removed, and auto-generating incorrect migrations. A short example: Creating the migrations for this schema: class M(): a = models.IntegerField(default=1) b = models.IntegerField(default=2) class Meta: constraints = [ UniqueConstraint( name="uniq_ab_1”, fields=[“a”, “b”] ) ] Create the constraint uniq_ab_1 is Postgres as expected (when using the \d+ command on the table to visualise) However, this manual migration will remove the constraint, due to one of it’s member columns being deleted, this is just standard Postgres behavior: migrations.RemoveField( model_name=“m”, name=“a”, ), migrations.AddField( model_name=“m”, name=“a”, field=models.IntegerField(default=6), ), This migration runs just fine. I can even modify the field of M again and run a further migration. However, using \d+ reveals that the uniq_ab_1 constraint` is gone from the database. The only way I found out about this behaviour was renaming the constraint to uniq_ab_2, then auto-generating migrations and getting the error: django.db.utils.ProgrammingError: constraint "uniq_ab_1" of relation … does not exist. In other words, on a rename, Django become aware a rename was happening and tried to remove the constraint from the database, in spite … -
Error during template rendering / __str__ returned non-string (type NoneType)
I was trying to edit from Django admin panel then this error occure Error: Error during template rendering In template D:\Django\new\venv\lib\site-packages\django\contrib\admin\templates\admin\includes\fieldset.html, error at line 19 str returned non-string (type NoneType) enter image description here models.py looks like: class hotel(models.Model): user = models.OneToOneField(User, null=True, on_delete=models.CASCADE) hotel_name = models.CharField(max_length=500, null=True) registration_no = models.CharField(max_length=500, null=True) company_PAN_number = models.CharField(max_length=500, null=True) registered_owner_name = models.CharField(max_length=500, null=True) gender = models.CharField(max_length=100, blank=True, null=True, choices=gender_choice) email = models.EmailField(max_length=500, null=True) phone_no = models.CharField(max_length=500, null=True) website = models.URLField(max_length=500, null=True) registration_certificate = models.ImageField(null=True, upload_to='documents/%y/%m/%d/') PAN_certificate = models.ImageField(null=True, upload_to='documents/%y/%m/%d/') citizen_id_front = models.ImageField(null=True, upload_to='citizen_id/%y/%m/%d/') citizen_id_back = models.ImageField(null=True, upload_to='citizen_id/%y/%m/%d/') verified_hotel = models.BooleanField(default=False, null=True) def __str__(self): return self.hotel_name class hotel_application_status(models.Model): hotel = models.ForeignKey(hotel, null=True, on_delete=models.CASCADE) resubmitted = models.BooleanField(default=False, null=True) comment = models.CharField(max_length=500, null=True) def __str__(self): return self.hotel.hotel_name -
AWS ElasticBeanstalk Django display images
i uploaded my Media directory which contains my Images but i cant access it to display my images. My images are correctly being uploaded when i send them, but i cant view them in the page Im utilizing ElasticBeanstalk and RDS - Mysql I only configured my RDS everything else like EC2, S3 are automattically configured by ElasticBeanstalk static-files.config: option_settings: aws:elasticbeanstalk:environment:proxy:staticfiles: /static: static /media: media django.config: option_settings: aws:elasticbeanstalk:container:python: WSGIPath: store.wsgi:application 01_packages.config: packages: yum: python3-devel: [] mariadb-devel: [] models.py: class Product(models.Model): image = models.ImageField(upload_to='product_images/%Y/%m/%d') settings.py: MEDIA_URL = '/media/' MEDIA_ROOT = BASE_DIR / 'media' my html: <a href="{{product.get_absolute_url}}"> <img class="default-img" src="{{product.image.url}}}" alt="550x750"> </a> -
Django timezone issue?
I'm not sure what causes this issue but this has been a headache for me. Sometimes in the morning there will be a runtime error (see below log). And after that, almost all the views will trigger the same error, until I restart the httpd service. (Something related to the cache?) I'm not sure if there is something wrong with my timezone setting? I'm using Python 3.10 and Django 4.0.2. Any suggestions will be helpful. File "/var/www/venv310/lib/python3.10/site-packages/django/db/models/lookups.py", line 96, in process_lhs sql, params = compiler.compile(lhs) File "/var/www/venv310/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 463, in compile sql, params = node.as_sql(self, self.connection) File "/var/www/venv310/lib/python3.10/site-packages/django/db/models/functions/datetime.py", line 47, in as_sql tzname = self.get_tzname() File "/var/www/venv310/lib/python3.10/site-packages/django/db/models/functions/datetime.py", line 25, in get_tzname tzname = timezone.get_current_timezone_name() File "/var/www/venv310/lib/python3.10/site-packages/django/utils/timezone.py", line 79, in get_current_timezone_name return _get_timezone_name(get_current_timezone()) File "/var/www/venv310/lib/python3.10/site-packages/django/utils/timezone.py", line 74, in get_current_timezone return getattr(_active, "value", get_default_timezone()) File "/var/www/venv310/lib/python3.10/site-packages/django/utils/timezone.py", line 60, in get_default_timezone return zoneinfo.ZoneInfo(settings.TIME_ZONE) File "/usr/local/python-3.10/lib/python3.10/weakref.py", line 285, in setdefault self.data[key] = KeyedRef(default, self._remove, key) File "/usr/local/python-3.10/lib/python3.10/weakref.py", line 354, in __init__ super().__init__(ob, callback) RuntimeError: super(): __class__ cell not found -
Django Sessions - Pass data between views
I am trying to use Django sessions to pass data between separate views when completing a booking submission. The booking form uses two HTML templates, the first to capture the date and time information (view -booking) about the booking and then when the user clicks Next, it takes the user to the second page (view -booking_details) to collect the booking details about the person booking. From reading online I have the below code, but I don't seem to get any data from the first page. Thanks in advance for any help, appreciate it. Views class Booking(CreateView): form_class = BookingsForm model = Bookings template_name = 'advancement/booking.html' def post_booking_details(request): if request.method == 'POST': form = BookingsForm(request.POST) if form.is_valid(): request.session['form_data_page_1'] = form.cleaned_data return HttpResponseRedirect(reverse('advancement/form.html')) return render(request, 'advancement/booking.html') class Booking_Details(CreateView): form_class = BookingsForm model = Bookings template_name = 'advancement/booking_details.html' def get_booking_details(request): first_page_data = request.session['form_data_page_1'] print(first_page_data) return render(request, 'advancement/booking_details.html') html (First Page) <!DOCTYPE html> {% load static %} <html> <head> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script> <style type="text/css"> .card-header{ background: #0a233e url(https://www.vis.org.au/theme/vis/img/header.png) center center no-repeat; background-size: cover; color: white; } b{ color: #f8981d; } .card-title{ color: #0a233e; } .badge{ font-size: inherit; font-weight: inherit; } </style> <title></title> </head> <body onload="method_time()"> <form action="http://127.0.0.1:8000/details/" method="post"> … -
I can't run django test via pycharm
When I run test via terminal 'RUN_TEST=1 REUSE_DB=1 python manage.py test blahblah -v 2 --nologcapture --noinpu -s -x' then it works But when I run test via pycharm, then it fails with these message myvenv_path/bin/python /Applications/PyCharm.app/Contents/plugins/python/helpers/pycharm/django_test_manage.py test my_test Testing started at 11:10 AM ... nosetests blahblah_my_test --verbosity=1 ====================================================================== ERROR: Failure: ImportError (No module named my_test) ---------------------------------------------------------------------- blahblah ====================================================================== ERROR: Failure: TypeError (issubclass() arg 1 must be a class) ---------------------------------------------------------------------- Traceback (most recent call last): File "myvenv_path/lib/python2.7/site-packages/nose/loader.py", line 495, in makeTest return self._makeTest(obj, parent) File "myvenv_path/lib/python2.7/site-packages/nose/loader.py", line 548, in _makeTest if issubclass(parent, unittest.TestCase): Error Traceback (most recent call last): File "myvenv_path/lib/python2.7/unittest/case.py", line 329, in run testMethod() File "myvenv_path/lib/python2.7/site-packages/nose/loader.py", line 495, in makeTest return self._makeTest(obj, parent) File "myvenv_path/lib/python2.7/site-packages/nose/loader.py", line 548, in _makeTest if issubclass(parent, unittest.TestCase): TypeError: issubclass() arg 1 must be a class TypeError: issubclass() arg 1 must be a class ====================================================================== ERROR: Failure: TypeError (issubclass() arg 1 must be a class) ---------------------------------------------------------------------- Traceback (most recent call last): File "myvenv_path/lib/python2.7/site-packages/nose/loader.py", line 495, in makeTest return self._makeTest(obj, parent) File "myvenv_path/lib/python2.7/site-packages/nose/loader.py", line 548, in _makeTest if issubclass(parent, unittest.TestCase): TypeError: issubclass() arg 1 must be a class ====================================================================== ERROR: Failure: TypeError (issubclass() arg 1 must be a class) ---------------------------------------------------------------------- Traceback (most recent call last): File … -
How does companies make staff users?
Apologies since this might not be the best way to word the question nor is this a coding question per say. I get the general process of creating a staff user within Django. What I would like to know is if companies send email links that allow their workers to sign up a form to be a staff user or if the employer provides their details and someone on the backend creates this account for them, or some other process I am unaware of? -
Django Authorization Checking in URL having wild card pattern
I am trying to implement permission checking mechanism in URLs for a request using wildcard techniques, rather than implement permission checking on each views. Currently What I have is. urlpatterns = [ path('admin/', include('admin_urls.py')), ... ] and my admin_urls.py is as follows urlpatterns = [ path('', ViewSpaceIndex.as_view(), name="admin_index"), path('', EmployeeView.as_view(), name="employee"), ... ] and views are as follows @method_decorator(admin_required, name='dispatch') class EmployeeView(TemplateView): template_name = 'secret.html' @method_decorator(admin_required, name='dispatch') class EmployeeView(TemplateView): template_name = 'secret.html' What I want to achieve is without using the repeated @method_decorator(admin_required, name='dispatch') decorator in every view I want to apply the permission to a wild card URLs '/admin/**' with admin_required permission like in Spring boot as follows. http.authorizeRequests() .antMatchers("/admin/**").has_permission("is_admin") -
Django: how to sum up numbers in django
i want to calculate the total sales and display the total price, i dont know how to write the function to do this. I have tried writing a little function to do it in models.py but it working as expected. This is what i want, i have a model named UserCourse which stored all the purchased courses, now i want to calculate and sum up all the price of a single course that was sold. models.py class Course(models.Model): course_title = models.CharField(max_length=10000) slug = models.SlugField(unique=True) price = models.IntegerField(default=0) class UserCourse(models.Model): user = models.ForeignKey(User , null = False , on_delete=models.CASCADE) course = models.ForeignKey(Course , null = False , on_delete=models.CASCADE) date = models.DateTimeField(auto_now_add=True) and also how do i filter this models in views.py so i can display the total price of courses a particular creator have sold. -
Django error - QuerySet,Matching Query DoesNotExist
This is the Memo text where User can submit their Memo form. I need to add(update) new message this record via Update button in DJANGO,but when I sumbit it error: Query Matching Does Not Exist. by the way I used PK and FK db table. How can I modify it? Tks. Error Message : DoesNotExist at /addshowmemo/32/ Software matching query does not exist. Request Method: POST Request URL: http:/127.0.0.1/addshowmemo/32/ Django Version: 3.1.5 Exception Type: DoesNotExist Exception Value: Software matching query does not exist. Exception Location: d:\project\python\it\venv\lib\site-packages\django\db\models\query.py, line 429, in get Python Executable: d:\project\python\it\venv\Scripts\python.exe Python Version: 3.10.2 Python Path: ['D:\project\python\it', 'c:\Users\tou52\.vscode\extensions\ms-python.python-2022.4.1\pythonFiles\lib\python\debugpy\_vendored\pydevd', 'C:\Users\tou52\AppData\Local\Programs\Python\Python310\python310.zip', 'C:\Users\tou52\AppData\Local\Programs\Python\Python310\DLLs', 'C:\Users\tou52\AppData\Local\Programs\Python\Python310\lib', 'C:\Users\tou52\AppData\Local\Programs\Python\Python310', 'd:\project\python\it\venv', 'd:\project\python\it\venv\lib\site-packages'] Models: class Memo(models.Model): notes = models.TextField() software = models.ForeignKey(Software, on_delete=models.CASCADE) timestamp = models.DateTimeField(default=timezone.now) def __str__(self): return self.notes # QuerySet class Software(models.Model): STATUS_CHOICES = [ (0, 'Planning'), (1, 'Development'), (2, 'Using'), (3, 'Obsolete') ] name = models.CharField(max_length=100, verbose_name="SysName") url = models.CharField(max_length=100, verbose_name="SysAdd") status = models.PositiveIntegerField(default=0, choices=STATUS_CHOICES, verbose_name="Status") company = models.ForeignKey(Company, on_delete=models.CASCADE, verbose_name="Company") team = models.ForeignKey(Team, on_delete=models.DO_NOTHING, verbose_name="Team") def __str__(self): return self.name # QuerySet Templates: <form method="POST" name="myform" action="." > {% csrf_token %} <table class="table table-striped"> <tr> <td align=right>Memo:</td> <td> <input type=text size=50 name="Cmemo" value='{{Nmemo.notes}}'> </td> </tr> <tr> <td> </td> <td> <input type=submit value="Confirm" class="btn btn-primary">||<a … -
return self.cursor.execute(sql, params) django.db.utils.DataError: value too long for type character varying(3)
This happens after python manage.py makemirgations which works okay. Then when I run python manage.py migrate I get this error. I've tried changing the max_length in the charfield, same error. I tried deleting and changing the default value and null and run makemigrations which states no change detected. class Casting_Role(models.Model): name = models.TextField() min_age = models.IntegerField(default='18', blank=False) max_age = models.IntegerField(default='100', blank=False) ETHNICITIES = ( ('BA', 'Black / African Descent'), ('WC', 'White / European Descent'), ('A', 'Asian'), ('H', 'Hispanic'), ('I', 'Indian'), ('ME', 'Middle Eastern'), ('PI', 'Pacific Islander'), ('EA', 'Ethnically Ambiguous'), ('IP', 'Indigenous People'), ('OP', 'Open'), ) ethinicity = models.CharField( max_length=30, choices=ETHNICITIES, default='Open') -
Django: Alert the user that he hasn't yet completed something specific in the app
I would like to create a feature that alerts the user that he has not completed his profile. Just like it is on LinkedIn. Any ideas how to do this in Django? -
Element added to DOM has HTML / SVG attributes, but not the corresponding JS properties
I am using HTMX with Django to render a page which is basically an SVG with a lot of sticky notes () that you can move around on the page, like you might use for brainstorming. When you edit the text, htmx POSTs that back to a Django view which returns the updated content. This is the Django template for a single form: <g id="g1-{{form.instance.pk}}" hx-post="{% url 'architech:updatetech' form.instance.map.pk form.instance.pk %}" hx-swap="outerHTML" hx-trigger="focusout" hx-include="#fo-{{form.instance.pk}}"> <g id="g2-{{form.instance.pk}}" transform="{{form.instance.presentation|safe|default:"matrix(1,0,0,1,50,50)"}}" class="ui drags" draggable="true"> <foreignObject id="fo-{{form.instance.pk}}" height="203" width="319"> <form class="card" id="form-{{form.instance.pk}}" draggable="true"> <div id="header-{{form.instance.pk}}" class="card-header" draggable="true"> {{ form.name.errors}} {{ form.name }} {{ form.presentation }} <input type="button" value="x" hx-post="{% url 'architech:deletetech' form.instance.map.pk form.instance.pk %}" hx-swap="outerHTML" hx-target="#g-{{form.instance.pk}}" hx-trigger="click"> </div> <div id="body-{{form.instance.pk}}" class="card-body" draggable="true"> {{ form.notes.errors}} {{ form.notes }} </div> </form> </foreignObject> </g> </g> I've been using hx-swap="outerHTML" (and more recently "morphdom") to re-render and replace this block of code. When its reloaded, the same SVG/HTML doesn't get rendered correctly or respond to javascript. The key element is the second group, with id beginning g2. When loaded with the whole page, height and width are honored, and attributes like 'transform' are accessible with element.transform: # console interaction on initial state using 'save to a global variable' >temp1 … -
Static File Hosting, WhiteNoise not Updating - Django
I have a Django website in production and a while back I successfully hosted my static files using Whitenoise so I could use them in production. Now a few months later I want to add a new .png along with a bunch of other code and push it to production. I added the .png I wanted into my static files then deleted my 'staticfiles' folder in my code and reran python manage.py collectstatic. The files all collected like normal but when I ran my local server the page is no longer hosting that new .png using whitenoise. All the other static files that were hosting successfully before are STILL hosting fine now and being hosted by whitenoise. Its just the new one that is not being hosted through whitenoise. I checked the 'static files' folder and the new .png is in there fine with a copy of itself and additional characters added to its name like whitenoise usually does and like how all the other files are that are being successfully hosted. How do I update/refresh Whitenoise to acknowledge a new static file added? Thanks! -
How do I clean multiple files at once on a FileField with multiple attachments?
I am looking to throw a validation error if the user tries to upload more than 1 video file (they are allowed to upload more than 1 image). Here is the code for the field: media = forms.FileField( widget=forms.ClearableFileInput(attrs={"multiple": True}), label="Add image/video", required=False, validators=[validate_file_size, validate_file_extension], ) I am able to go through each file one by one using a validator on the field (checking the file extension of each file), or by using the clean function. -
Making an instagram story using rest framework django
How can i make an Instagram story using rest framework Django How can anyone make a story and how can every body in app see it -
compare between 2 codes in django
I want to add (add comment form) but I face a problem in views.py you will see codes down below. in views.py there are 2 different codes 1- that code works for me 2- that code didn't work with me and I want to know why code num 2 didn't work with me # in models.py class Comment(models.Model): user = models.ForeignKey(User, verbose_name="User", on_delete=models.CASCADE) product = models.ForeignKey(Product, verbose_name="Product", on_delete=models.CASCADE, related_name="comments") is_active = models.BooleanField(verbose_name="Is Active?",default=True) created_at = models.DateTimeField(auto_now_add=True, verbose_name="Created Date") updated_at = models.DateTimeField(auto_now=True, verbose_name="Updated Date") content = models.TextField(verbose_name="comment") # in forms.py class AddComment(forms.ModelForm): content = forms.CharField(label='التعليق', widget = forms.TextInput(attrs={'class': 'form-control', 'placeholder':'ما رأيك في المنتج؟'})) class Meta: model = Comment fields = ['content',] and # in urls.py path('product/<slug:slug>/', views.detail, name="product-detail"), and # in details.html {% if request.user.is_authenticated %} <form action="" method="post"> {% csrf_token %} {{AddComment}} <br> <input type="submit" value="إرسال"> </form> {% endif %} now my problem in views.py # in views.py def detail(request, slug): product = get_object_or_404(Product, slug=slug) related_products = Product.objects.exclude(id=product.id).filter(is_active=True, category=product.category) comment = Comment.objects.filter(is_active=True,product=product) # start add comment system # that code work for me form = AddComment() if request.method == 'POST': if form.is_valid(): content = request.POST.get('content', '') user = request.user c = Comment.objects.create(product= product, user= user, content=content, created_at = datetime.now(), updated_at … -
How to find static files using regex in django in view?
I have django project that has a staticfile with the structure staticfiles/bundles/static/js/main.[hash of 8 random characters].js I want to get the name of main.[hash].js in my view. Though I can use python glob to find such file but is there any clean way that is specific to django that I can use to find such file. Maybe using regex with django.contrib.staticfiles.finders ? -
user & request.user displaying different objects - Django
Not even sure where to begin here. Currently running into an issue where users are intermittently loading pages to find themselves "logged in" as other users (Templates rendering with wrong context). The error seems to come down to request.user showing the incorrect user while user has the correct user context. I currently use {{request.user}} in my templates and recognize that I could just switch to {{user}} but don't want to look over anything deeper that is going wrong. Any idea what would cause this? I've confirmed this issue is only contained to the site proper templates. The Admin site as well as some AJAX requests I have going to the server all seem to be processing the correct user context. EX. This is from a template render captured while the issue presented itself. UID is the user id from request.user.pk while User-UID is from user.pk I thought it could be the context processors, but I don't think my ordering is any cause for concern: "django.contrib.auth.context_processors.auth", "django.template.context_processors.debug", "django.template.context_processors.request", "django.contrib.messages.context_processors.messages", I've done my fair share of googling and head-banging so any help would be appreciated -
Django app for docking using autodock vina without conda env
I want to create an app that can calculate binding through molecules, with autodock vina, but it requires a conda enviroments. Its there other way to do this? This is my first app project with Django. -
Packaging django app that includes management commands
I am working on a django app that includes a custom management command. This app should be packed for pip. Layout of the app is standard django-simpl_ssg simple_ssg management commands __init__.py testcommand.py migrations __init__.py __init__.py admin.py .... setup.cfg setup.py pyproject.toml based on django 4.0 docu setup.cfg is setup like this .... [options] include_package_data = true packages = find: python_requires = >=3.8 install_requires = Django >= 3.2 # Replace "X.Y" as appropriate Now the problem is when running python setup.py sdist the app gets packaged but the management command is omitted running sdist running egg_info writing requirements to django_simple_ssg.egg-info/requires.txt writing django_simple_ssg.egg-info/PKG-INFO writing top-level names to django_simple_ssg.egg-info/top_level.txt writing dependency_links to django_simple_ssg.egg-info/dependency_links.txt reading manifest file 'django_simple_ssg.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no files found matching '*' under directory 'django-simple_ssg/static' warning: no files found matching '*' under directory 'django-simple_ssg/templates' warning: no files found matching '*' under directory 'django-simple_ssg/docs' writing manifest file 'django_simple_ssg.egg-info/SOURCES.txt' running check creating django-simple_ssg-0.1 creating django-simple_ssg-0.1/django_simple_ssg.egg-info creating django-simple_ssg-0.1/simple_ssg creating django-simple_ssg-0.1/simple_ssg/migrations copying files to django-simple_ssg-0.1... copying LICENSE -> django-simple_ssg-0.1 copying MANIFEST.in -> django-simple_ssg-0.1 copying README.md -> django-simple_ssg-0.1 copying setup.cfg -> django-simple_ssg-0.1 copying setup.py -> django-simple_ssg-0.1 copying django_simple_ssg.egg-info/PKG-INFO -> django-simple_ssg-0.1/django_simple_ssg.egg-info copying django_simple_ssg.egg-info/SOURCES.txt -> django-simple_ssg-0.1/django_simple_ssg.egg-info copying django_simple_ssg.egg-info/dependency_links.txt -> django-simple_ssg-0.1/django_simple_ssg.egg-info copying django_simple_ssg.egg-info/requires.txt -> django-simple_ssg-0.1/django_simple_ssg.egg-info copying django_simple_ssg.egg-info/top_level.txt …