Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django form field is required while content is visibly in the form
View def work_entry(request): if request.method == "POST": form = WorkHoursEntryForm(data=request.POST) if form.is_valid(): form.save() return redirect('home') else: print(form.errors) else: form = WorkHoursEntryForm() return render(request, 'Work_Data_Entry.html', context={'form': form}) Form class WorkHoursEntryForm(forms.ModelForm): time_worked = forms.CharField(widget=forms.TextInput( attrs={'class': 'form-control', 'id': "entry_time_worked", 'type': 'text'})) shift_num = forms.CharField(widget=forms.TextInput( attrs={'class': 'form-control', 'id': "shift_num", "type": "text"})) class Meta: model = WorkHoursEntry fields = ('shift_number', 'time_worked_entry') Model: class WorkHoursEntry(models.Model): entry_date = models.DateField(auto_now=True) entry_time = models.TimeField(auto_now=True) time_worked_entry = models.CharField(max_length=50) shift_number = models.CharField(max_length=10) I have entered the required data into the form but the form error i keep getting is ul class="errorlist"shift_number ul class="errorlist" id="id_shift_number_error"This field is required. id=time_worked_entry ul class="errorlist" id="id_time_worked_entry_error">This field is required. and i can't figure out how to fix it as the inputs are filled out but i get this error. does anyone see something i am missing. Any help would be great. -
I need help to create a multi-task calendary for my Django framework website
I have a project and I need help. I have several bikes in my database, each bike has a number and a status (available, in maintenance, etc.). And I need to create, on my main page, a table that would be as follows: A month selector (each month would have its own table), and the table itself, with the columns being the days of the month (yes, 31 columns), and the rows being each bike. On each different day, the bike's status would be stored, and each day the user would update the table, adding the correct status for the day. For example: In the column for day 24, there are all the different statuses of the bikes, represented by different colored dots. This table would be used to keep a history of the data of all the bikes in the system. This way, we would have both a status history and a table that would be updated daily. But I honestly have no idea how to do this. JavaScript-based calendars seem to be inefficient in my case, but I'm accepting any tips. Thanks for your help! -
Sizing list-style-image
I wish to apply images as list icons to the list below: <ul id="AB1C2D"> <li id="AB1C2D1">Dashboard </li> <li id="AB1C2D2">Mechanics </li> <li id="AB1C2D3">Individuals </li> <li id="AB1C2D4">Settings </li> <li id="AB1C2D5">Messages </li> <li id="AB1C2D6">Support </li> <li id="AB1C2D7">Logout </li> </ul> I tried ul li{ padding-left: 22px; background: url("img/piz.png") left center no-repeat; line-height: 22px; list-style-position: outside; } I got my list in box shaped background without images anywhere also I tried ul li{ list-style-image: url("img/piz.png"); width: 10px; height: 10px; } ul li:before { width: 10PX; height: 10PX; size: 3px; } I got large images beside my list creating large spaces between each list item what i am looking for is how to control the list size to be small icons by the side of the list. please assist -
Django Advanced Tutorial: Executing a Command in Dockerfile Leads to Error
I followed the advanced django tutorial on reusable apps, for which I created a Dockerfile: FROM python:3.11.11-alpine3.21 # Install packages (acc. to instructions # https://github.com/gliderlabs/docker-alpine/blob/master/docs/usage.md) RUN apk --no-cache add curl ca-certificates sqlite git WORKDIR /app COPY setup.py . COPY pyproject.toml . # Install `uv` acc. to the instructions # https://docs.astral.sh/uv/guides/integration/docker/#installing-uv ADD https://astral.sh/uv/0.5.29/install.sh /uv-installer.sh RUN sh /uv-installer.sh && rm /uv-installer.sh ENV PATH="/root/.local/bin/:$PATH" # Install packages with uv into system python RUN uv pip install --system -e . # Expose the Django port EXPOSE 8000 RUN git config --global --add safe.directory /app Now, I have the following structure: django-polls-v2/ - dist/ - .gitignore - django_polls_v2-0.0.1-py3-none-any.whl - django_polls_v2-0.0.1.tar.gz - django_polls_v2/ - migrations/ - ... - static/ - ... - templates/ - ... - __init__.py - admin.py - ... - README.rst - pyproject.toml - MANIFEST.in - LICENSE In order to install my own package, cf. here, the documentation states to execute the following (where I adjusted the filenames to reflect my setting): python -m pip install --user django-polls-v2/dist/django_polls_v2/0.0.1.tar.gz Now, when I execute this command inside a running docker container (where I get into the docker container by running docker run -p 8000:8000 --shm-size 512m --rm -v $(pwd):/app -it django:0.0.1 sh), the package gets installed. … -
Cannot get NGINX, UWSGI, DJANGO working on port 80
I'm following this tutorial to setup Nginx --> uwsgi --> Django. It all works fine when the Nginx server block is set to listen on port 8000 but I cannot get it to work when the port is set to 80. I eventually get site unreachable. My sites-enabled/conf file is: # tracking_nginx.conf # the upstream component nginx needs to connect to upstream django { server unix:///home/dconran/django3/tracking/mainsite.sock; # for a file socket # server 127.0.0.1:8001; # for a web port socket (we'll use this first) } # configuration of the server server { # the port your site will be served on listen 8000; # <--- works # listen 80; # <--- doesn't work # the domain name it will serve for server_name corunna.com www.corunna.com; # substitute your machine's IP address or FQDN charset utf-8; # max upload size client_max_body_size 75M; # adjust to taste # Django media # location /media { # alias /path/to/your/mysite/media; # your Django project's media files - amend as required # } location /static { alias /home/dconran/django3/tracking/tracker/static; # your Django project's static files - amend as required } # Finally, send all non-media requests to the Django server. location / { uwsgi_pass django; include /home/dconran/django3/tracking/uwsgi_params; # … -
Output django formset as table rows
I have a Django formset which I'd like to output as one table row per nested form like so: <form> {{ feature_formset.management_form }} <table> {% for form in feature_formset %} <tr> {% for field in form %} <td>{{ field.name }} {{ field }}</td> {% endfor %} </tr> </table> {% endfor %} </form> However, somehow (I think) the automatic field rendering gets confused by the table wrapper. What I'd expect would be output like: <form> ... <table> <tr> <td>id: <input ...></td> <td>name: <input ...></td> <td>foobar: <input ...></td> </tr> <tr> <td>id: <input ...></td> <td>name: <input ...></td> <td>foobar: <input ...></td> </tr> <tr> <td>id: <input ...></td> <td>name: <input ...></td> <td>foobar: <input ...></td> </tr> </table> {% endfor %} </form> However, what I'm getting is a form row for the first form of the formset, and the rest of the forms just dumping the fields. Somehow the {% for field in form %} does not iterate properly, and I guess the remaining fields are dumped: <form> ... <table> <tr> <td>id: <input ...></td> <td>name: <input ...></td> <td>foobar: <input ...></td> </tr> id: <input ...> name: <input ...> foobar: <input ...> id: <input ...> name: <input ...> foobar: <input ...> </table> {% endfor %} </form> Any pointers as to … -
django custom user and django admin
#views.py def destroy(self, request,pk, *args, **kwargs): employee = get_object_or_404(Employee, pk=pk) user = CustomUser.objects.filter(id = employee.user.id) print('employee', employee) print('user', user) employee.delete() user.delete() # manually delete linked user return Response({"detail": "Employee and user deleted successfully."}, status=status.HTTP_204_NO_CONTENT) #models.py #Base model class BaseModel(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, unique=True, editable=False) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) class Meta: abstract = True #Custom user model class CustomUser(AbstractBaseUser,BaseModel): EMPLOYEE = "employee" CLIENT = "client" USER_TYPE_CHOICES = [ ( EMPLOYEE, 'Employee'), (CLIENT, 'Client'), ] email = models.EmailField(unique=True, validators=[email_validator]) is_active = models.BooleanField(default=True) is_superuser = models.BooleanField(default=False) is_staff = models.BooleanField(default=False) user_type = models.CharField(max_length=10, choices=USER_TYPE_CHOICES) username = None # Remove username field since we use email for login objects = CustomUserManager() USERNAME_FIELD = "email" REQUIRED_FIELDS = ["user_type"] def __str__(self): return f"{self.email} - {self.user_type}" #Employee model class Employee(BaseModel): MALE = "Male" FEMALE = "Female" OTHER = "Other" GENDER_CHOICES = [ (MALE, "Male"), (FEMALE, "Female"), (OTHER, "Other"), ] user = models.OneToOneField(CustomUser, on_delete=models.CASCADE, related_name="employee") name = models.CharField(max_length = 250) father_name = models.CharField(max_length=250) contact_no = models.CharField(max_length=250, validators=[contact_no_validator]) alternate_contact_no = models.CharField(max_length=15, validators=[contact_no_validator], null=True, blank=True) gender = models.CharField(max_length=10, choices= GENDER_CHOICES, default=MALE) pan_no = models.CharField(max_length=20) aadhar_no = models.CharField(max_length=12, validators=[aadhar_no_validator]) dob = models.DateField(null=True, blank=True) department = models.ForeignKey(Department, on_delete=models.SET_NULL, related_name="department_employees", null=True) designation = models.ForeignKey(Designation, on_delete= models.SET_NULL, related_name="designation_employees", null=True) joining_date = models.DateField() … -
Backend development
I'm a systems engineering student in Mexico. I'm interested in backend engineering because of a project I need to develop. So, if anyone could give me advice or recommend tutorials so I can learn more about this and pursue it professionally, I'd be very grateful I expect help from developers -
DJANGO Duplication of HTML on page load
I am using DJANGO to create a website, with minimal add ins. At this time, I have a page that duplicates itself on select change. Trying to change its' behavior only makes it worse, like if I change the swap to outer, then it duplicates outside of the element rather than in it. The environment: Windows 11 Pro x64 Visual Studio Code x64 python 3.12.3 Packages Versions asgiref 3.8.1 certifi 2025.1.31 charset-normalizer 3.4.1 Django 5.2 django-htmx 1.23.0 django-multiselectfield 0.1.13 django-phonenumber-field 8.1.0 idna 3.10 phonenumberslite 9.0.3 pip 24.0 pyasn1 0.6.1 pyasn1_modules 0.4.2 python-ldap 3.4.4 The base html: {% load django_htmx %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="keywords" content="HTML, CSS, Python, JINJA"/> <meta name="viewport" content="width=device-width, initial-scale=1" /> {% htmx_script %} </head> <bod hx-headers='{"x-csrftoken": "{{ csrf_token }}"}'> <div id="navbar"> <nav class="navbar navbar-expand-lg navbar-dark bg-dark"> <span ><h1>{% block page_title %}base_title{% endblock page_title %}</h1></span> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbar" > <div class="navbar-nav" style="margin-left: auto; margin-right: 0;"> <a class="nav-item nav-link" id="logout" href="/mytickets"> My Tickets </a> <a class="nav-item nav-link" id="logout" href="/createticket"> Create Ticket </a> <a class="nav-item nav-link" id="logout" href="/companytickets"> Company Tickets </a> <a class="nav-item nav-link" id="logout" href="/companyalerts"> Company Alerts </a> <a class="nav-item nav-link" id="logout" href="/logout"> Logout … -
How to create a table for every user to store timesheets data in Django
I am working on a timesheet application for a client. The User model in django is used for storing user data. But I am using a timesheet table to store User information related to the company (like role/position, client, project name, hours spent, feedback rating). I want to store the hours worked each day in a separate table with a foreign key relationship(to the timesheet data table), and create a separate table for each user to store their hours worked data separately. Is this possible in Django? Or storing the all the worked hours data in a single table seems easy, but over time it will get accumulated and the retrieval would be slow? Since it will be accumulating 150K records every year (600 employees, 250 work days in a year, using sqlite db). -
I'm trying to move from development to production with Gunicorn and Nginx with Django, but my 'static' files are not loading. Please help me
Hi everyone, I've been having issues with Gunicorn and Nginx — the latter is not loading my 'static' files. Please help, I've been stuck on this for a week and I don't know what's going on. The 'static' files are not loading. This is my 'settings.py' file. This is the Nginx configuration This is my 'urls.py' -
What should be the best practice for handling migration files in Django when multiple developers are involved?
I have a question regarding Django migration files and version control. When I run migration commands in Django python manage.py makemigrations and python manage.py migrate, files such as 0001_initial.py are created. I've come across differing opinions online about whether migration files should be committed to Git or added to .gitignore. Some suggest ignoring them, while others recommend committing them and squashing when necessary. Could someone explain the scenarios that arise when multiple developers commit migration files, what issues or errors might occur, and how we can avoid these problems in a collaborative environment? I am new to Django. Thanks -
post() missing 1 required positional argument: 'slug'
I'm facing a problem in my Django project, and I need your help. When I try to access the view that handles requests to the post page, I get the following error: post() missing 1 required positional argument: 'slug' This happens when I try to navigate to a URL that should handle viewing a specific post. I have determined the route in urls.py , which takes the slug parameter, and it looks like this: path('post//', post, name='post'), In my post view, I expect to accept this parameter, but it looks like it is not being passed properly. I would really appreciate any help or advice. My models.py: from django.db import models from django.utils.text import slugify from django.contrib.auth import get_user_model from django_resized import ResizedImageField from tinymce.models import HTMLField from hitcount.models import HitCountMixin, HitCount from django.contrib.contenttypes.fields import GenericRelation from taggit.managers import TaggableManager from django.shortcuts import reverse User= get_user_model() class Author(models.Model): user =models.ForeignKey(User,on_delete=models.CASCADE) fullname = models.CharField(max_length=40,blank=True) slug = slug = models.SlugField(max_length=400,unique=True,blank=True) bio = models.TextField(HTMLField) points = models.IntegerField(default=0) profile_pic = ResizedImageField(size=[50,80],quality=100,upload_to='authors',default=None,null=True,blank=True) def __str__(self): return self.fullname def save(self,*args,**kwargs): if not self.slug: self.slug = slugify(self.fullname) super(Author,self).save(*args, **kwargs) class Category(models.Model): title = models.CharField(max_length=50) slug = models.SlugField(max_length=400,unique=True,blank=True) class Meta: verbose_name_plural = 'categories' def __str__(self): return self.title def save(self,*args,**kwargs): … -
Error connect with Cloud SQL, Cloud Run and Django
I have an application running on Django in Cloud Run that connects to a PostgreSQL database hosted on Cloud SQL. It is currently working and configured as follows: DATABASES = {'default': env.db()} DATABASES['default']['OPTIONS'] = { 'pool': { 'min_size': 5, 'max_size': 20 } } This configuration works, but the active connections remain high. When I remove the pool configuration, I end up getting several errors. 2025/04/12 16:24:15 Cloud SQL connection failed. Please see https://cloud.google.com/sql/docs/mysql/connect-run for additional details: failed to get instance: Refresh error: failed to get instance metadata (connection name = "xxx"): googleapi: Error 429: Quota exceeded for quota metric 'Connect Queries' and limit 'Connect Queries per minute per user per region' of service 'sqladmin.googleapis.com' for consumer 'xxx'. Even after configuring CONN_MAX_AGE, it keeps throwing errors. I’ve tried setting up pgBouncer, but was unsuccessful due to needing permissions that are impossible to access on Cloud SQL. Lastly, I’m running Django in the following way: WEB_CONCURRENCY=${WEB_CONCURRENCY:-4} THREADS=${THREADS:-8} exec /usr/local/bin/gunicorn project.asgi:application \ --bind "0.0.0.0:$PORT" \ --workers "$WEB_CONCURRENCY" \ --worker-class uvicorn.workers.UvicornWorker \ --threads "$THREADS" \ --timeout 0 Has anyone ever faced something similar or has a solution for this? -
Migrations is not working for this model in my project
I have create multiple models in Django project but this model migration is not working in my project can anybody give me the reason for tis problem and how to fix this. models.py class Profile(models.Model): user=models.OneToOneField(User,on_delete=models.CASCADE) avatar=models.ImageField(upload_to='avatar/',blank=True,null=True) def __str__(self): return f"{self.user.email}" running migrations output is no change in Migration -
Infinite redirection loop for Django backend (hosted on railway) application (hosted on cloudfare)
tl;dr I'm getting an infinite loop when I request my django backend, and I don't know how to fix it I'll give some context to what's happening: My django backend works on localhost (I used nginx as a reverse proxy when developing it) I've got a cloudfare domain, and I've registered by backend to it on railway when I try to connect to the backend over the Cloudflare domain, I keep getting redirected to the page I requested- so it's an infinite loop I'll give some outputs to show what's happening Request headers: Request URL: https:... <--- my project domain Request Method: GET Status Code: 301 Moved Permanently Remote Address: x.x.x.x:443 Referrer Policy: strict-origin-when-cross-origin And the response: alt-svc: h3=":443"; ma=86400 cf-cache-status: DYNAMIC cf-ray: 92efc2dfbffc57dd-SYD content-type: text/html; charset=utf-8 date: Sat, 12 Apr 2025 03:50:44 GMT location: ... <--- same domain name as I requested nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800} report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=BY0YmE3vW8uxgXBlVKUb%2BBuxQrbGw%2F2J2wEGzGndoKueBiCzA%2FYkGsADUkrcMq6KC02ocvzetSIzDhSun56YdCECv04ANU3UaaxEzBQ6%2BnNfN9r5tmjhDD53DHq3IPVCnWnwPw%3D%3D"}],"group":"cf-nel","max_age":604800} server: cloudflare server-timing: cfL4;desc="?proto=QUIC&rtt=8014&min_rtt=7349&rtt_var=1550&sent=12&recv=11&lost=0&retrans=0&sent_bytes=3715&recv_bytes=3440&delivery_rate=821&cwnd=12000&unsent_bytes=0&cid=b1e2e4808802a704&ts=2802&x=16" x-railway-edge: railway/us-west2 x-railway-request-id: hd3fL70KS824dNgkcC4bnQ_3336177264 This request and response keep happening until the browser steps in. If I curl the endpoint, I just get: <a href="my backend domain">Moved Permanently</a>. So Cloudflare has the flexible SSL/TLS encryption mode, and in my settings.py, I have: SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') SECURE_SSL_REDIRECT = False … -
Problem with Layout of my personal website, i using Django and JavaScript in this project
base.html <body> {% block content %} {% endblock %} {% block js %} {% endblock %} </body> base.css * { margin: 0; padding: 0; box-sizing: border-box; } html, body { font-size: 62.5%; scroll-behavior: smooth; } body { display: flex; align-items: center; justify-content: center; flex-direction: column; } navbar.html <header id="header"> <nav id="navbar"> <div class="photo-name"> <img id="photo" src="{% static 'images/perfil.png' %}" alt="foto-perfil" /> <h1>Gabriel Gattini</h1> <div class="line"></div> <p class="p-dev">{% trans "Desenvolvedor Full Stack" %}</p> </div> <div class="container-nav-links"> <div class="projects"> <a class="a-nav" href="#projects">{% trans "Projetos" %}</a> <i id="icon" class="fa-solid fa-laptop-code"></i> </div> <div class="aboutme"> <a class="a-nav" href="#aboutme">{% trans "Sobre Mim" %}</a> <i id="icon" class="fa-solid fa-book-open-reader"></i> </div> <div class="tools"> <a class="a-nav" href="#skills">{% trans "Habilidades" %}</a> <i id="icon" class="fa-solid fa-fire"></i> </div> <div class="contacts"> <a class="a-nav" href="#contacts">{% trans "Contato" %}</a> <i id="icon" class="fa-solid fa-at"></i> </div> <div class="background-color"> <i id="sun-icon" class="fa-solid fa-sun"></i> <i id="moon-icon" class="fa-solid fa-moon"></i> </div> <form action="{% url 'set_language' %}" method="post"> {% csrf_token %} <input type="hidden" name="next" value="{{ request.get_full_path }}"> <button class="nav-btn" type="submit" name="language" value="pt-br"> <img id="brazil" src="{% static 'images/brasil.svg' %}" alt="flag-brasil" /> </button> <button class="nav-btn" type="submit" name="language" value="en"> <img id="eua" src="{% static 'images/eua.svg' %}" alt="flag-eua" /> </button> </form> </div> </nav> </header> navbar.css #header { z-index: 1; position: fixed; height: 100vh; width: 20%; left: 0; top: … -
Optimizing Django ORM for Hybrid Queries (PostgreSQL + Vector Similarity Search)
I'm implementing a RAG (Retrieval-Augmented Generation) system that requires combining traditional Django ORM filtering with vector similarity searches. The specific workflow needs to: First filter products by standard relational fields (e.g., category="books") Then perform vector similarity search on just that filtered subset of product descriptions Current Implementation and Challenges: # Current inefficient approach (two separate operations) books = Product.objects.filter(category="books") # Initial DB query vectors = get_embeddings([b.description for b in books]) # Expensive embedding generation results = faiss_search(vectors, query_embedding) # Vector search Key problems with this approach: Requires loading all filtered records into memory Makes two separate passes over the data Doesn't leverage PostgreSQL's native capabilities when using pgvector What I've Tried: Raw SQL with pgvector: query = """ SELECT id FROM products WHERE category = 'books' ORDER BY description_embedding <=> %s LIMIT 10 """ results = Product.objects.raw(query, [query_embedding]) Problem: Loses Django ORM benefits like chaining, model methods. django-pgvector extension: from pgvector.django import L2Distance books = Product.objects.annotate( distance=L2Distance('description_embedding', query_embedding) ).filter(category="books").order_by('distance')[:10] Problem: Doesn't scale well with complex filter conditions Expected Solution: Looking for a way to: Maintain Django ORM's expressiveness for initial filtering. Efficiently combine with vector search on the filtered subset. Avoid loading all records into memory. Preferably stay within Django's … -
Can not preview s3 bucket images in django admin
I'm uploading images to s3 bucket from django adimin (image field). However, when I try to preview image in the admin its not showing with following error. I added configured dajngo-csp and added the s3 domain to allow requests. But still image is broken. I can right click on image placeholder and view it anyway. Here are my settings.py entries: INSTALLED_APPS = [ ... "csp", ] MIDDLEWARE = [ ... "csp.middleware.CSPMiddleware", ] from csp.constants import SELF CONTENT_SECURITY_POLICY = { "DIRECTIVES": { "default-src": [SELF], "img-src": [SELF, "s3.eu-central-1.amazonaws.com"], } } Browser error: Content-Security-Policy: The page’s settings blocked the loading of a resource (img-src) at https://s3.eu-central-1.amazonaws.com/xxx/media/xxx/xxx.png because it violates the following directive: “default-src 'self'” -
Django's StatReloader returning error but server runs (although all requests written in red in the console)
I run python manage.py runserver in a folder (which worked finely yesterday) and get python : Watching for file changes with StatReloader Au caractère Ligne:1 : 1 + python manage.py runserver + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (Watching for fi...th StatReloader:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError but the server seems to work all the same even if requests are written in red in the console. I've tried what's advised here but nothing changes. I'm on Windows Powershell. -
why does this error in Template syntax keep coming for a django file?
I am new to python and I am working on a project. I completed the entire project but this error is not getting fixed. attaching the error and the code where there is error. this is the error TemplateSyntaxError at /meeting/ Invalid block tag on line 13: 'static'. Did you forget to register or load this tag? Request Method: GET Request URL: http://127.0.0.1:8000/meeting/ Django Version: 5.2 Exception Type: TemplateSyntaxError Exception Value: Invalid block tag on line 13: 'static'. Did you forget to register or load this tag? Exception Location: D:\django-video-chat\venv\Lib\site-packages\django\template\base.py, line 577, in invalid_block_tag Raised during: chat.views.room Python Executable: D:\django-video-chat\venv\Scripts\python.exe Python Version: 3.12.8 code where there is error Can someone please help. -
International Phone Number Widget in Django Model Form
I am trying to include International code for the phone number, so users like easily select the country code from the drop down menu. I am following this example https://www.youtube.com/watch?v=Q5UPMEA5fX0 , but getting MultiWidget error. Here is how my ModelForm looks. Here is what the error looks like. It says I am missing 'widgets' argument. I am not able to find any examples online. Any help would be appreciated. -
Running Django tests ends with MigrationSchemaMissing exception
I'm writing because I have a big problem. Well, I have a project in Django where I am using django-tenants. Unfortunately, I can't run any tests as these end up with the following error when calling migrations: ‘django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table (no schema has been selected to create in LINE 1: CREATE TABLE ‘django_migrations’ (‘id’ bigint NOT NULL PRIMA...’ The problem is quite acute. I am fed up with regression errors and would like to write tests for the code. I will appreciate any suggestion. If you have any suggestions for improvements to the project, I'd love to read about that too. Project details below. Best regards Dependencies [tool.poetry.dependencies] python = "^3.13" django = "5.1.8" # The newest version is not compatible with django-tenants yet django-tenants = "^3.7.0" dj-database-url = "^2.3.0" django-bootstrap5 = "^25.1" django-bootstrap-icons = "^0.9.0" uvicorn = "^0.34.0" uvicorn-worker = "^0.3.0" gunicorn = "^23.0.0" whitenoise = "^6.8.2" encrypt-decrypt-fields = "^1.3.6" django-bootstrap-modal-forms = "^3.0.5" django-model-utils = "^5.0.0" werkzeug = "^3.1.3" tzdata = "^2025.2" pytz = "^2025.2" psycopg = {extras = ["binary", "pool"], version = "^3.2.4"} django-colorfield = "^0.13.0" sentry-sdk = {extras = ["django"], version = "^2.25.1"} Settings.py import os from pathlib import Path from uuid import … -
Unable to open nginx with domain and can't open checkmk in Firefox browser
So I'm unable to open nginx with my domain name, arborhub.io and I can't open checkmk on the browser either. I decided to try & run checkmk behind nginx instead of apache, which I did successfully. I was hoping to fix the issue of the conflict between apache (checkmk) and nginx. But I still can't open either programs in my Firefox browser. I initially assumed my Django was causing this 502 gateway page error, but my Django server is running fine. Also my nginx is running with no problems either with `sudo sDoing 'status' on site arborhub: agent-receiver: running mkeventd: running rrdcached: running npcd: running nagios: running apache: running redis: running crontab: running Overall state: running ystemctl reload nginx` ● nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: en> Active: active (running) since Wed 2025-04-09 20:03:09 MDT; 3h 49min ago Invocation: 5e827ca7649a43b8bd078f49a64d7c77 Docs: man:nginx(8) Process: 10356 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_proc> Process: 10360 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (> Process: 15562 ExecReload=/usr/sbin/nginx -g daemon on; master_process on; > Main PID: 10361 (nginx) Tasks: 5 (limit: 18232) Memory: 4.4M (peak: 8.4M) CPU: 85ms CGroup: /system.slice/nginx.service ├─10361 "nginx: master process … -
Django unable to read "static" folder even though its available
It might look like a duplicate question but I read and tried various solutions and its not working for me. I'm using MAC OS and running venv with Django5. Getting error stating the "STATICFILES_DIRS setting does not exist.". The error output is as follows: Desktop/Projects/Django/moviestore/moviesstore/static' in the STATICFILES_DIRS setting does not exist. System check identified 1 issue (0 silenced). You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions. Run 'python manage.py migrate' to apply them. April 10, 2025 - 02:45:10 Django version 5.0, using settings 'moviestore.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C. settings.py import os from pathlib import Path BASE_DIR = Path(__file__).resolve().parent.parent SECRET_KEY = "**********" DEBUG = True ALLOWED_HOSTS = [] INSTALLED_APPS = [ "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", "home" ] MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", ] ROOT_URLCONF = "moviestore.urls" TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", "DIRS": [os.path.join(BASE_DIR, 'moviesstore/templates')], "APP_DIRS": True, "OPTIONS": { "context_processors": [ "django.template.context_processors.debug", "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", ], }, }, ] WSGI_APPLICATION = "moviestore.wsgi.application" DATABASES = { "default": { "ENGINE": "django.db.backends.sqlite3", "NAME": BASE_DIR / "db.sqlite3", } } AUTH_PASSWORD_VALIDATORS = [ { "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", }, { …