Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to rename the folder of a Django model when there are external references to it?
Recently I renamed a Django model and its parent folder: from input_source_type/ models.py to event_source_type/ models.py The models.py contains the InputSourceType which is also renamed to EventSourceType. Another model in (in the system folder) refers to to this model in its migration (0001_initial.py): class Migration(migrations.Migration): initial = True dependencies = [ ('admin_input_source_type', '0001_initial'), ] operations = [ migrations.CreateModel( name='Systm', ... When I run python manage.py makemigrations I got django.db.migrations.exceptions.NodeNotFoundError: Migration admin_system.0001_initial dependencies reference nonexistent parent node ('admin_input_source_type', '0001_initial') which is correct as I don't the admin_input_source_type anymore. I don't want to change the migration manually, what would be the Django way in this scenario? Thanks! -
Django 4 Static files : what's the best practice
I'm currently building a project on Django 4.0 and I want to do the static files management the best and the cleaner for this version. Currently I have this project tree : And here is my settings file : BASE_DIR = Path(__file__).resolve().parent.parent.parent (...) STATIC_URL = '/static/' STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static'), ] When I try to find some videos about the subject, no one is using the same structure and setup for static files. In this sample, I have a 404 error on my dist/css/output.css file. In my HTML template I try to call it that way : <link href='{% static "css/dist/output.css" %}' type="text/css" rel="stylesheet"> Could someone please copy/past me an easy static setup for handling static properly ? Or at least, help me to understand why it doesn't work and what I should do ? Moreover, I put my static directory outside my main app, but some are putting it in. So I don't know what's best... Thanks :) -
DOCKER WIN10 WSL2BASED ENGINE PermissionError: [Errno 13] Permission denied:
Hello im trying to learn docker for deployment purposes. Im trying to deploy my django app using WSL2 BASED DOCKER on WIN10. the django app works fine at local development server but when i tried to run it with docker container(development) i get the following error during makemigration command: PermissionError: [Errno 13] Permission denied: '/py/lib/python3.9/site-packages/cities_light/migrations/0011_auto_20211220_1316.py' My DockerFile is like below: FROM python:3.9-alpine3.13 LABEL maintainer="zetamedcompany" ENV PYTHONUNBUFFERED 1 COPY ./requirements.txt /requirements.txt COPY ./app /app WORKDIR /app EXPOSE 8000 RUN python -m venv /py && \ /py/bin/pip install --upgrade pip && \ apk add --update --no-cache postgresql-client && \ apk add --update --no-cache --virtual .tmp-deps \ build-base postgresql-dev musl-dev && \ /py/bin/pip install -r /requirements.txt && \ apk del .tmp-deps && \ adduser --disabled-password --no-create-home app ENV PATH="/py/bin:$PATH" USER app and my composer: version: '3.9' services: app: build: context: . command: > sh -c "python manage.py wait_for_db && python manage.py makemigrations && python manage.py migrate && python manage.py runserver 0.0.0.0:8000" ports: - 8000:8000 volumes: - ./app:/app environment: - SECRET_KEY=devsecretkey - DEBUG=1 - DB_HOST=db - DB_NAME=devdb - DB_USER=devuser - DB_PASS=**** depends_on: - db db: image: postgres:13-alpine environment: - POSTGRES_DB=devdb - POSTGRES_USER=devuser - POSTGRES_PASSWORD=***** i tried lots of approaches from web, tried to give … -
Django MariaDB 10.2 db sometimes not fetching object, using threads/rabbitmq
I made a web frontend in Django that saves an object, then signals another application to fetch that opbject using RabbitMQ. The backend application uses a queue to handle the incoming RabbitMQ traffic. Sometimes though, the object isn't fetched by the datbase..consider this worker in the backend: def worker(): while True: slug = q.get() print(f'Working on {slug}') i = 0 ost = None while i < 3 and not ost: print('getting ost for ' + slug) try: ost = Ost.objects.get(slug=slug) except ObjectDoesNotExist: pass if not ost: print('Sleeping 1') time.sleep(1) i += 1 if not ost: #raise error print('Start download') q.task_done() # turn-on the worker thread print('running worker') threading.Thread(target=worker, daemon=True).start() This will output a log like this in rare cases: Working on civilization-iii getting ost for civilization-iii Sleeping 1 getting ost for civilization-iii Start download How is it possible that the db can't fetch the object, but a second later it can? The object is really in the database from the start, it has a creation date of about 4 seconds before this script is run. -
How to rearrange priority field for a django model?
I have a Model with a priority field of type postitive integer. This field is unique and allows me to manage the priority of objects. For example, I want the most important object to have priority one, the second most important to have priority two, etc... Example: [ { "name": "object82", "priority": 1 } { "name": "object54", "priority": 2 } { "name": "object12", "priority": 3 } ] class MyObject(models.Model): name = models.CharField(_("name"), max_length=255) priority = models.PositiveSmallIntegerField(_("priority"), unique=True) I want to override the object serializer so that if I add a new object with an existing priority, it unpacks the existing objects. (same thing for the path of an existing object) For example if I take the example above and add: { "name": "object22", "priority": 2 } I want the following result: [ { "name": "object82", "priority": 1 // the priority didn't changed } { "name": "object22", // my new object "priority": 2 } { "name": "object54", "priority": 3 // the priority had changed } { "name": "object12", // the priority had changed "priority": 4 } ] I think I have to check first if an object with the same priority exists in the database or not. If not => I … -
how can i save some information that i got in views to one of fields in models - django
this is my views.py : i want save type in device field in model class GetDeviceMixin( object): def setup(self, request, *args, **kwargs): super().setup( request, *args, **kwargs) type= request.META['HTTP_USER_AGENT'] print(type) return type class RegisterView(GetDeviceMixin , generic.CreateView): form_class = CustomUserCreationForm success_url = reverse_lazy("register") template_name = "man/man.html" and this is my models.py class account(AbstractBaseUser): first_name= models.CharField(max_length=20,verbose_name="first name") device = models.CharField(verbose_name="device" , max_length=100) this is my forms.py: class GetReq(forms.ModelForm): class Meta: model = account fields = ['device',] -
Outputting "Following relationships 'backward'" to a template
I started working with Django earlier this week and watched a few tutorials and thought I would try out switching over a site I made in PHP to something a little more current. I ran into some issues over the weekend and managed to get help with some of them, but one issue remains. I already have an existing database with some information it that I want to retrieve to display on a website. The information is modified through the database so Django doesn't have to deal with any of that - just displaying results to a bootstrapped template file. So, in essence Django would have 2 models - one for each relevant database table. The first model relates to products class Bikes(models.Model): bikempn = models.CharField(primary_key=True, max_length=50) bikecategory = models.CharField(max_length=50) bikeyear = models.CharField(max_length=4) bikebrand = models.CharField(max_length=50) bikedesc = models.CharField(max_length=255) bikesize = models.CharField(max_length=50) bikecolour = models.CharField(max_length=255) bikeurl = models.CharField(max_length=255) class Meta: managed = False db_table = 'bikes' The second model relates to their expected arrival dates. This model would represent a database view which performs some logic comparing product that is on its way to the number of matching items that are on reserve. The model is: class Eta(models.Model): bikempn = … -
Django - for loop in one line
I'm exporting all product details from db to an XML file. One of the fields need to export is images. There are two fields where images should be exported. If there is one image (product table) should be exported to item_image_link. If there are more than one (ProductImage table) to item_additional_image_link. products = Product.objects.filter(product_status=True).prefetch_related('images') for product in products: item = ET.SubElement(channel, "item") g_item_id = ET.SubElement(item, ("{http://base.google.com/ns/1.0}id")).text = product.sku g_item_image_link = ET.SubElement(item, ("{http://base.google.com/ns/1.0}image_link")).text = 'http://127.0.0.1:8000'+products.image.url for image in product.images.all(): g_item_additional_image_link = ET.SubElement(item, ("{http://base.google.com/ns/1.0}additional_image_link")).text = 'http://127.0.0.1:8000'+image.image.url I successfully export the images per product in the respective field item_additional_image_link however they are shown in three different lines according to the number of images in db. <item> <g:id>55555</g:id> <g:additional_image_link>http://127.0.0.1:8000/media/photos/2021/12/20/K003-min.jpeg</g:additional_image_link> <g:additional_image_link>http://127.0.0.1:8000/media/photos/2021/12/20/K009-min.jpeg</g:additional_image_link> <g:additional_image_link>http://127.0.0.1:8000/media/photos/2021/12/20/image00024-min.jpeg</g:additional_image_link> </item> How can i make the three lines above in one, comma separated between each image? Something like: <item> <g:id>55555</g:id> <g:additional_image_link>http://127.0.0.1:8000/media/photos/2021/12/20/K003-min.jpeg, http://127.0.0.1:8000/media/photos/2021/12/20/image00024-min.jpeg, http://127.0.0.1:8000/media/photos/2021/12/20/K009-min.jpeg</g:additional_image_link> </item> Thank you -
DRF password reset option email
Is it okay to send password reset email with raw authentication token attached to url.I am not using jwt, if using jwt one have option to decode encrypted token but in drf basic auth token one can't encrypt it. I am not sure but aren't dj-rest-auth, djsoer both using jwt at backend. I have strong requirements of not to use jwt.I also need suggestions of other possible solution. -
Django background-task autodiscovery not working as expected
I'm currently using django 3.1.4 and I've implemented django-background-task 1.2.5. What are the reasons for which a background task can have a different behavior when executed by the autodiscovery feature vs me manually executing it, whether it's on the shell, or using process_tasks? From what I've noticed, if I register the task without activating the virtual environment, it can lead to a BrokenPipeError. Now I've noticed that a function will return a different output when I manually run execute the code vs autodiscovery. Can anyone offer a clue in what may be the cause? -
How to invoke a value validation with a Django model Field
Given the following models: class MyModel1(models.Model): field11 = ... field12 = ... class MyModel2(models.Model): field21 = ... field22 = ... ... , a list of model fields, e.g. [Model1.field11, Model1.field12, ...] and finally a list of values [val11, val12, ....], how to loop over the 2 lists (of the same size) and validate the values with something like for i in range(0, len(value_list)): try: field = fields_list[i] field.validate(value_list[i]) except: # TODO : error handling pass ? -
html form in Django returns none
I am trying to save this HTML form in my table in the database, but I am getting "None" error. I have been on this for some hour. Please any help will be appreciated Please, how do i fix this The is the HTML order.html i created <form action="" method="post" id="payment-form"> <input type="text" class="form-control" id="first_name" name="first_name" value="{{request.user.first_name}}"> <textarea type="text" class="form-control" id="address" name="address" placeholder="1234 Main St" required></textarea> <button id="submit" class="btn btn-success lg w-100 fw-bold" > Proceed to Payment </button> </form> Here is my views.py def add(request): basket = Basket(request) if request.POST.get("action") == "post": order_key = request.POST.get("order_key") user_id = request.user.id baskettotal = basket.get_total_price() first_name = request.POST.get("first_name") last_name = request.POST.get("last_name") address = request.POST.get("address") print(first_name, last_name, address) order = Order.objects.create( first_name = first_name, address=address, total_paid=baskettotal, ) order_id = order.pk response = JsonResponse({"success": "Order created"}) return response The js file <script type="text/javascript"> function makePayment(e) { e.preventDefault(); $.ajax({ type: "POST", url: '{% url "order:add" %}', data: { csrfmiddlewaretoken: "{{csrf_token}}", action: "post", }, success: function (json) { console.log(json.success) }, error: function (xhr, errmsg, err) {}, }); } </script> -
Does it matter in which order you use prefetch_related and filter in Django?
The title says it all. Let's take a look at this code for example: Model.objects.prefetch_related().filter() vs Model.objects.filter().prefetch_related() Question When using prefetch_related() first, does Django fetch all the ManyToOne/ManyToMany relations without taking into consideration .filter() and after everything is fetched, the filter is applied? IMO, that doesn't matter since there's still one query executed at the end. Thanks in advance. -
Read a value from the URL in django
i'm trying to read the value of a url and add it to the models in django. Basically if i have the following link my_site.com/special_event/123 How would i be able to catch the last part of the link the (123) and save it as an entry for my models. For context i am trying to do a raffle on my website, and when someone scans a QR code it will send them to my site and the end of the link will be a random number that i will use to raffle. So in this case a person's raffle ticket would be 123. So far i have this code: the model: class RaffleEntry(models.Model): entry_number = models.IntegerField(blank=False) def __str__(self): return self.entry_number And the view i tried doing it this way: def add_entry(request, entry_number): entry_number = RaffleEntry.objects.create() return render(request, 'front/entry_success') I also tried to add an INT parameter to the URL like this: path('special_events/add_entry/<int:entry_number>', views.add_entry, name='special_events/add_entry>'), Any help or even just point me in the right direction would be greatly appreciated. Thank you. -
Reading Filter query set in Django framework
I'm very new to Django , I'm trying to return the sum of total revenue attained by selling cars with respect to a particular site in Django . I have tried the annotate method to fetch the results. I have written a query set using annotate. mum_data = Cars_Showroom_Filter(request.GET, queryset = Cars.objects.filter(Site__in = ( "Mumbai",)).annotate(price=Sum('price'))) This returns me a filter object <users.filters.Cars_Showroom_Filter object at 0x00000264ABBA2A90> and I'm unable to read it . I tried using qs.count() but it returns me the entire query set list . Can some one help me with a way to read this particular query set value -
Volley ClientError on Video Upload Post Request
I am trying to upload video from android to Django server. I am able to upload bitmap but when comes to video mp4 upload the code is causing errors. I am getting this error 'com.android.volley.ClientError' after calling the following function uploadMP4. Though, the same code works very well on uploading bitmap but on uploading video the same code is causing errors. Please Help. Thanks. private void uploadMP4(final Uri videoUri, final String ext) { if (selected_item_id == null) { // return; } String URL = "http://" + getIP() + "/inventory_apis/uploadMP4File"; VolleyMultipartRequest volleyMultipartRequest = new VolleyMultipartRequest(Request.Method.POST, URL, new Response.Listener<NetworkResponse>() { @Override public void onResponse(NetworkResponse response) { try { JSONObject jresponse = new JSONObject(new String(response.data)); } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_LONG).show(); Log.e("GotError", "" + error.getMessage()); } }) { @Override protected Map<String, String> getParams() throws AuthFailureError { Map<String, String> params = new HashMap<>(); params.put("clubbed_item_id", selected_item_id); return params; } @Override protected Map<String, DataPart> getByteData() { Map<String, DataPart> params = new HashMap<>(); long filename = System.currentTimeMillis(); params.put("video", new DataPart(filename + ".mp4", getFileDataFromDrawable(getApplicationContext(), videoUri), selected_item_id)); return params; } }; //adding the request to volley Volley.newRequestQueue(this).add(volleyMultipartRequest); } public byte[] getFileDataFromDrawable(Context context, Uri uri) … -
How to read or write an uploaded file from FileField model in Django 3.0+?
I'm new in python and programming in general. I have this project to create a simple library to add new authors and upload books. I must also display the uploaded book details(total words, most common words, different words, etc.) when I open the book. Now to do this I know that I first must open the uploaded book in readmode, but I don't know how to access the file that I uploaded. This is my models: from django.db import models from authors.models import Author class Book(models.Model): author = models.ForeignKey(Author, on_delete=models.CASCADE) book_name = models.CharField(max_length=50) genre = models.CharField(max_length=50) files = models.FileField(upload_to='books/files/') def __str__(self): return self.book_name() This is my forms: from django import forms from .models import Book class BookForm(forms.ModelForm): class Meta: model = Book fields = ('book_name', 'author', 'genre', 'files') My views: def create(request): if request.method == 'POST': form = BookForm(request.POST, request.FILES) if form.is_valid(): form.save() return redirect('books:home') elif request.method == 'GET': form = BookForm() return render(request, 'books/create.html', { 'form': form }) def detail(request, pk): book = get_object_or_404(Book, pk=pk) return render(request, 'books/detail.html', context={'book': book}) My details.html: {% extends 'base.html' %} {% block title %} {{ book.book_name }} {% endblock %} {% block content %} <p>Book title: {{ book.book_name }}</p> <p>Genre: {{ book.genre }}</p> … -
erf django restframework Got AttributeError when attempting to get a value for field `image_id` on serializer `SoftwareSerializer' (status code 406)
I am facing this error when trying to open the endpoint (http://127.0.0.1:8000/api/metrics/) I am using django restramework (drf), software and category enpoints are working fine, but the metric endpoint is giving the following error: Error { "message": "Got AttributeError when attempting to get a value for field `image_id` on serializer `SoftwareSerializer`.\nThe serializer field might be named incorrectly and not match any attribute or key on the `Category` instance.\nOriginal exception text was: 'Category' object has no attribute 'image'.", "code": null, "status_code": 406 } Models class Category(models.Model): name = models.CharField(max_length=256, blank=True) created_datetime = models.DateTimeField(auto_now_add=True, verbose_name="تاریخ ایجاد ") update_datetime = models.DateTimeField(auto_now=True, verbose_name="تاریخ بروزرسانی ") def __str__(self): return self.name class Metric(models.Model): title = models.CharField(max_length=254) categorymetric = models.ForeignKey("main.Category",on_delete=models.SET_NULL,null=True) def __str__(self): return self.title class Software(models.Model): software_name = models.CharField(max_length=150, default="software_name", null=False, verbose_name="اسم نرم افزار") created_datetime = models.DateTimeField(auto_now_add=True, verbose_name="تاریخ ایجاد ") update_datetime = models.DateTimeField(auto_now=True, verbose_name="تاریخ بروزرسانی ") image = models.ForeignKey("main.Image", on_delete=models.SET_NULL, blank=True, null=True) created_by = models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE, null=True) class Meta: verbose_name = "software" verbose_name_plural = "softwares" def __str__(self) : return self.software_name Views class CategoryViewSet(ModelViewSet): serializer_class = CategorySerializer pagination_class = None queryset = Category.objects.all() class SoftwareViewSet(ModelViewSet): serializer_class = SoftwareSerializer pagination_class = None queryset = Software.objects.all() permission_classes = ( IsAuthenticated, ) def perform_create(self, serializer): serializer.save(created_by=self.request.user) class MetricViewSet(ModelViewSet): serializer_class = MetricSerializer pagination_class … -
Passing a value to a modal in Django
I want to add a delete confirmation modal after clicking on a delete button on a table, generated by a number of objects from a Django view: ... {% for i in items %} <tr> <td>{{ i.name }}</td> <td><a href="#" data-bs-toggle="modal" data-bs-target="#modal-delete-item">Delete</a></td> </tr> {% endfor %} .... What I have in the modal is something like this: <div class="modal modal-blur fade" id="modal-delete-item" tabindex="-1" role="dialog" aria-hidden="true"> .... <button href="{% url 'remove_quote_item' i.pk %}" type="button" class="btn btn-danger" data-bs-dismiss="modal">Oui, je confirme.</button> .... </div> How can I use the "i" variable in the modal since I am outside the loop, can I use anything to reference that variable into the modal? Or probably use javascript to perform that action? Or is there something I can do with jinja itself? Thanks! -
How to export a Django-Html web page as an xml file
I need to export (basically a download button) an html page with django syntax in XML format. How do I do this? -
How can I solve this ModuleNotFoundError: No module named 'axes_login_action' Error?
I got this error message: 2021-12-20 14:01:34,788: *************************************************** 2021-12-20 14:01:40,783: Error running WSGI application 2021-12-20 14:01:40,786: ModuleNotFoundError: No module named 'axes_login_action' 2021-12-20 14:01:40,787: File "/var/www/xxx_pythonanywhere_com_wsgi.py", line 18, in <module> 2021-12-20 14:01:40,787: application = get_wsgi_application() 2021-12-20 14:01:40,787: 2021-12-20 14:01:40,787: File "/home/xxx/.virtualenvs/groupu-virtualenv/lib/python3.8/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application 2021-12-20 14:01:40,787: django.setup(set_prefix=False) 2021-12-20 14:01:40,787: 2021-12-20 14:01:40,787: File "/home/xxx/.virtualenvs/groupu-virtualenv/lib/python3.8/site-packages/django/__init__.py", line 24, in setup 2021-12-20 14:01:40,788: apps.populate(settings.INSTALLED_APPS) 2021-12-20 14:01:40,788: 2021-12-20 14:01:40,788: File "/home/xxx/.virtualenvs/groupu-virtualenv/lib/python3.8/site-packages/django/apps/registry.py", line 91, in populate 2021-12-20 14:01:40,788: app_config = AppConfig.create(entry) 2021-12-20 14:01:40,788: 2021-12-20 14:01:40,788: File "/home/xxx/.virtualenvs/groupu-virtualenv/lib/python3.8/site-packages/django/apps/config.py", line 223, in create 2021-12-20 14:01:40,788: import_module(entry) 2021-12-20 14:01:40,788: *************************************************** settings.py INSTALLED_APPS = [ 'axes_login_action', ] Installation: pip3.8 install django-axes-login-actions==1.3.0 NB: I installed the dependency too. pip3.8 install django-axes==5.28.0 Furthermore, I keep getting ModuleNotFoundError: No module named **** when I install a new project. -
Django Unable to add WYSIWYG
I am trying to implement WYSIWYG on my page with this link : https://www.geeksforgeeks.org/adding-wysiwyg-editor-to-django-project/ I am currently at point 5, when they want me to add below: # add condition in django urls file if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT) but when I added above, I got below error message File "C:\Download\Development\NowaStrona_Django\mysite\my_site\my_site\urls.py", line 6, in <module> path('', include('blog.urls')), File "C:\Download\Development\NowaStrona_Django\lib\site-packages\django\urls\conf.py", line 34, in include urlconf_module = import_module(urlconf_module) File "C:\Download\Development\NowaStrona_Django\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 728, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "C:\Download\Development\NowaStrona_Django\mysite\my_site\blog\urls.py", line 16, in <module> urlpatterns += static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT) NameError: name 'static' is not defined I am attaching urls.py: from . import views from django.urls import path urlpatterns = [ path('', views.PostList.as_view(), name='home'), path('<slug:slug>/', views.PostDetail.as_view(), name='post_detail'), ] # to jest dla wysiwyg # add condition in django urls file from django.conf import settings if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT) Do you know why I am getting pasted error message? -
Django.db.utils.ProgramingError Relation doesn't exist
I am using Django3 and Postgres as Database, I clone the old project using Django and postgres, I cloned and setup the virtual environment for my project. At the time of runserver, its throws me the error of Django.db.utils.ProgramingError realtion "Table name" doesn't exist There was the migrations file in the project when I cloned it, but I removed them, so can create my own, but this error still there, even I remove the migrations folder, but its still there and can't create my own migrations and not even start the server. I tried it with cloned migrations files and without it but can't runserver -
Error while deploying django project on herokuapp
$ python manage.py collectstatic --noinput Traceback (most recent call last): File "/tmp/build_41ced892/manage.py", line 22, in main() File "/tmp/build_41ced892/manage.py", line 18, in main execute_from_command_line(sys.argv) File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/init.py", line 419, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/init.py", line 395, in execute django.setup() File "/app/.heroku/python/lib/python3.9/site-packages/django/init.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/app/.heroku/python/lib/python3.9/site-packages/django/apps/registry.py", line 122, in populate app_config.ready() File "/app/.heroku/python/lib/python3.9/site-packages/django/contrib/admin/apps.py", line 27, in ready self.module.autodiscover() File "/app/.heroku/python/lib/python3.9/site-packages/django/contrib/admin/init.py", line 24, in autodiscover autodiscover_modules('admin', register_to=site) File "/app/.heroku/python/lib/python3.9/site-packages/django/utils/module_loading.py", line 47, in autodiscover_modules import_module('%s.%s' % (app_config.name, module_to_search)) File "/app/.heroku/python/lib/python3.9/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 986, in _find_and_load_unlocked File "", line 680, in _load_unlocked File "", line 850, in exec_module File "", line 228, in _call_with_frames_removed File "/tmp/build_41ced892/home/admin.py", line 2, in from home.models import Contact ModuleNotFoundError: No module named 'home.models' ! Error while running '$ python manage.py collectstatic --noinput'. See traceback above for details. You may need to update application code to resolve this error. Or, you can disable collectstatic for this application: $ heroku config:set DISABLE_COLLECTSTATIC=1 https://devcenter.heroku.com/articles/django-assets ! Push rejected, failed to compile Python app. ! Push failed -
hosting django on apache cannot load in numpy
Hello I am hosting a django platform on an Apache server (Ubuntu 20.04). I hosted it like in this tutorial However, each time I try to submit my file the following error occurs: [Mon Dec 20 09:40:40.850837 2021] [wsgi:error] [pid XXX:tid XXX ] [remote XXX] /home/usr/app/backend/controller/appController.py:1: UserWarning: NumPy was imported from a Python sub-interpreter but NumPy does not properly support sub-interpreters. This will likely work for most users but might cause hard to track down issues or subtle bugs. A common user of the rare sub-interpreter feature is wsgi which also allows single-interpreter mode. [Mon Dec 20 09:40:40.850868 2021][wsgi:error] [pid XXX:tid XXX ] [remote XXX] Improvements in the case of bugs are welcome, but is not on the NumPy roadmap, and full support may require significant effort to achieve. [Mon Dec 20 09:40:40.850874 2021] [wsgi:error] [pid XXX:tid XXX ] [remote XXX] import numpy as np [Mon Dec 20 10:38:30.778296 2021] [mpm_event:notice] [pid XXX:tid XXX ] AH00491: caught SIGTERM, shutting down Exception ignored in: <function Local.del at 0x7f65a9b41940> Traceback (most recent call last): File "/home/user/app/env/lib/python3.8/site-packages/asgiref/local.py", line 96, in del NameError: name 'TypeError' is not defined Exception ignored in: <function Local.del at 0x7f65a9b41940> Traceback (most recent call last): File "/home/user/app/env/lib/python3.8/site-packages/asgiref/local.py", line 96, …