1

I have created a project in Django. Also, I am using django-allauth for sign up and login.

In order to use my own templates with django-allauth, I have created a html file called signup.html in a folder called account inside a folder called templates which is outside of of all my apps (/templates/account/signup.html). That works.

I tried to use some custom css file inside signup.html:

<link rel="stylesheet" href="/templates/account/signup.css">

It says that the file can not be found. Though, it is located in templates/account.

IordanouGiannis
  • 4,149
  • 16
  • 65
  • 99

1 Answers1

11

your css file must under STATICFILES_DIRS in settings.py,set this in settings.py:

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

and put account/signup.css file to /static/account/signup.css,you can get it like:

<link rel="stylesheet" href="/static/account/signup.css">

or

{% load static %}
<link rel="stylesheet" href="{% static 'account/signup.css' %}">
Ykh
  • 7,567
  • 1
  • 22
  • 31