最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

static - Django admin: strange view - Stack Overflow

programmeradmin11浏览0评论

Couldnt understand what wrong with my admin part. It looks like that:

I understood that this effect may depend on 'static' resources.. HTML preview shows:

<head>
<title>Log in | Django site admin</title>
<link rel="stylesheet" href="/staticfiles/admin/css/base.css">

  <link rel="stylesheet" href="/staticfiles/admin/css/dark_mode.css">
  <script src="/staticfiles/admin/js/theme.js"></script>


  <link rel="stylesheet" href="/staticfiles/admin/css/nav_sidebar.css">
  <script src="/staticfiles/admin/js/nav_sidebar.js" defer></script>

<link rel="stylesheet" href="/staticfiles/admin/css/login.css">

and I checked - all files exist inbb staticfiles directory. But when i click file in chrome - such page appears

Page not found (404)
Request Method: GET
Request URL:    .css
Using the URLconf defined in amodule.urls, Django tried these URL patterns, in this order:

[name='home']
news/
admin/
The current path, staticfiles/admin/css/nav_sidebar.css, didn’t match any of these.

my settings.py contains such definitions of static:

STATIC_URL = 'staticfiles/'

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

where am I wrong?

Couldnt understand what wrong with my admin part. It looks like that:

I understood that this effect may depend on 'static' resources.. HTML preview shows:

<head>
<title>Log in | Django site admin</title>
<link rel="stylesheet" href="/staticfiles/admin/css/base.css">

  <link rel="stylesheet" href="/staticfiles/admin/css/dark_mode.css">
  <script src="/staticfiles/admin/js/theme.js"></script>


  <link rel="stylesheet" href="/staticfiles/admin/css/nav_sidebar.css">
  <script src="/staticfiles/admin/js/nav_sidebar.js" defer></script>

<link rel="stylesheet" href="/staticfiles/admin/css/login.css">

and I checked - all files exist inbb staticfiles directory. But when i click file in chrome - such page appears

Page not found (404)
Request Method: GET
Request URL:    http://amodule.su/staticfiles/admin/css/nav_sidebar.css
Using the URLconf defined in amodule.urls, Django tried these URL patterns, in this order:

[name='home']
news/
admin/
The current path, staticfiles/admin/css/nav_sidebar.css, didn’t match any of these.

my settings.py contains such definitions of static:

STATIC_URL = 'staticfiles/'

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

where am I wrong?

Share Improve this question asked Feb 5 at 5:11 Alex PAlex P 114 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Found solution:

trouble was with rights on my directory for django project. Here the set up for rights:

/home/www - my directory for projects

www - my user for working with data in server session

sudo chown -R www-data:www-data /home/www
sudo chown -R www-data:www-data /home/www
sudo usermod -aG www-data www 
sudo chmod go-rwx /home/www
sudo chmod go+x /home/www
sudo chgrp -R www-data /home/www
sudo chmod -R go-rwx /home/www
sudo chmod -R g+rwx /home/www
发布评论

评论列表(0)

  1. 暂无评论