Issue with Django 1.9 admin interface not displaying CSS formatting

I am currently learning django and following the tutorial. Everything is going smoothly, but I keep encountering an issue where my admin site loses its CSS styling and ends up looking like this: https://i.sstatic.net/YTXET.png

This seems to be a common problem, as I have come across several posts on it (such as this one or this one). Following the suggestions in those posts, I have taken the following steps:

  1. Executed python manage.py collectstatic
  2. Modified settings.py:

    STATIC_URL = '/static/'
    STATIC_ROOT = os.path.join(BASE_DIR, 'static')

  3. Added the following lines to manage.py:

    import mimetypes
    mimetypes.init()
    mimetypes.types_map['.css'] = 'text/css'

  4. Ensured that 'django.contrib.staticfiles' in settings.py is uncommented.

However, none of these solutions worked and my admin site still lacks CSS styling.

It's worth mentioning that this issue is not consistent for me. When starting a new project, the admin page displays correctly. The problem only arises after completing specific (and different each time) steps during the tutorial. For instance, last time it occurred after I made changes to the DATABASES entry in settings.py (even though I had executed this step without any issues previously; reverting the entry to its original value did not resolve the styling problem).

I am using django 1.9.6 with python 3.4.3 on Ubuntu 14.04.

EDIT:

The server is running with #DEBUG = True and ALLOWED_HOSTS = ['*']

Answer №1

When DEBUG = False, Django will not handle serving static or media files.

By setting the variable to True, you can view the admin site's static files. Otherwise, a web server program must be used to serve the admin files and any other static/media files in your project.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Elevate a division within its container

Is there a way to make a smaller div positioned at the top when it's placed next to a larger one in the same container? I'm looking for a solution that doesn't involve using position-relative and manually adjusting the placement. Take a loo ...

Getting an error in Django: "One required positional argument is missing" while attempting to utilize form input in a separate function

As a beginner, I'm facing a challenge. I want to take an input (a category) from a ModelForm and pass it to another function. This other function should then render a table on the next page based on that input. This is the first function in my views ...

Guide on developing a CSS countdown timer

I recently came across an article discussing the creation of a CSS countdown timer. Intrigued by the concept, I decided to give it a try myself. However, my implementation seems flawed and the live demo link provided in the article is not working. Can some ...

Looking to enhance current CSS3 organizational chart by adding a second primary level

I'm having difficulty trying to replicate the first-level (director) box with a vertical line in between. The original chart only has one level with subs below. Take a look at the image provided to see the desired outcome... You can find the CodePen ...

Desktop media queries are functioning properly, yet experiencing issues on mobile devices

I've come across this same question multiple times, but the solutions I've found so far haven't been helpful. My media queries are working perfectly on desktop, but they don't seem to take effect on three different android devices. It&a ...

Problems with select box rendering in Internet Explorer with Materialize CSS

When using materializecss select box in Internet Explorer 9 or higher, scrolling with the mouse button is not working. You must click on the scroll bar inside the select box for it to scroll. This issue does not occur in other browsers. I have attached a s ...

Top Recommendation for Embedding Individual Text Passages in Django (outside of database)

Although I'm not a developer, I have been working on small Django projects for my business for quite some time now. I am currently contemplating the best way to incorporate longer text passages such as directions, privacy policies, or business hours ...

Retrieving JSON Data from Django Server

UPDATE: I am currently working on a project that involves the following steps: Submit a POST request with a file in the template --> Process the file in the view to generate an ID --> Display the ID in the template I am relatively new to Django and ...

What steps can be taken to achieve a smooth scrolling speed adjustment?

Upon discovering this website, I was impressed by its smooth scrolling features. The seamless scroll on the site creates a peaceful and calming experience without any abrupt jumps. It responds effortlessly to my mouse wheel, arrow buttons, and spacebar, p ...

Is there a way to incorporate a password text box in Django?

class Users(models.Model): username = models.CharField(max_length=255) password = models.CharField(max_length=300) password_token = models.CharField(max_length=300, default='0') The password input field is currently a regular text in ...

Is it possible to conceal or disregard text elements from the web browser search function by using CTRL+F?

I have a complex web application interface with a dedicated area for content display. Is there a way to ensure that when users utilize the browser's text search function (CTRL+F), the UI elements are ignored and only the actual content is searched? ...

Creating a grid layout by designing boxes using CSS and HTML

I'm in the process of creating a homepage and I'd like it to resemble this design: (not the best quality, but the software I used was subpar (I miss mspaint)) Originally, I used buttons which made linking and customization easy, but I encounter ...

Is it possible to have images automatically resize to fit the content div without becoming distorted?

I have created a webpage that I really enjoy, but now I need to ensure it supports smaller resolutions like 1020X768. However, for those with larger monitors, I want to take advantage of the extra space by setting a minimum width that can grow with the scr ...

Tips for aligning text in the middle of a customizable and adjustable button with the use of only Bootstrap 4

I am encountering an issue with button text alignment. After customizing the width and height of a button, I noticed that its text does not remain centered on certain screen sizes while in debugging mode. Html <!doctype html> <html lang="en> ...

Issue with Bootstrap 3 grid and features not displaying correctly on IE11/Windows 8 platform

Link to the current page I am working on: The design of the page looks great when viewed in Firefox and Chrome. Please review the layout on Internet Explorer 11 when viewing on a desktop or laptop at full screen width. I am currently using Windows 8, but ...

Having trouble accessing the authenticated user in my resource via the Django Rest Interface

Currently, I am utilizing django-rest-interface for constructing an API. However, I encounter an issue when I send a request via curl, like this: curl -u 'username:password' -X PUT --data "field=value" http://127.0.0.1:8080/resource/ Whenev ...

Optimizing CSS to eliminate extra space from the first button in the navigation menu bar

I'm currently working on creating a simple CSS-based navigation bar, but I've encountered an issue. The first item in my HTML list seems to have extra space to its left that I can't seem to remove. Check out the live example here Also avai ...

"Enhance Django user sign-up experience with formtools for secure password

Working on a project using Django-formtools to create a new user. Here is the code in forms.py: class CustomUserCreationForm(UserCreationForm): class Meta(UserCreationForm): model = User fields = ('username', 'password1& ...

Having difficulty with printing a particular div

I need help with printing a specific div containing checkboxes using jQuery. The checkboxes are initially checked based on data from a database, but when I try to print the div, the checkboxes remain unchecked in the print view. Below is the code snippet ...

Achieving Vertical Alignment of Text and Icon in the Same Line Using HTML and CSS

I am struggling to align these icons vertically center with the text. However, there seems to be a slight offset of a few pixels. I have experimented with different solutions, but this is the closest I could get to. Can anyone explain why it's not ali ...