Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • How to add CSS file and image file in Django?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 478
    Comment on it

    In Django framework first we create the project and follow these step shown below:

    Step1- First we create a project in your Django. If you are not able to create a project then use this link. This link helps to create a project in Django framework.

    Use this link show in given below,

    Step2- Then after in project we create the static file and configure static file in file in a project.

    Use this code show in below,

        # MYSITE is name of project in your django project
        # Put strings here, like "/home/html/static" or "C:/www/django/static".
        # Always use forward slashes, even on Windows.
        # Don't forget to use absolute paths, not relative paths.


    Step3- Then we create a CSS folder in a static file and create a CSS file like base.css pass in a HTML file. And also put an image file in a static folder in Django.

    Use this code show in below:

    # **log.html file name**
        # this is your css file path
            {% load static from staticfiles %}
            <link href="{% static 'css/base.css' %}" rel="stylesheet" type="text/css"/> 
        # this is your Image file path in your django project
    	{% load static from staticfiles %}
    	<img src="{% static "/static/django-logo.png" %}" alt="Picture of Child" width="200" height="113" id="head_img" /> 
        #this is your text box as par your requirments
           <tr><td><b>username:</td><td><input type="text" name="username" value=""/>
            <tr><td><b>username:</td><td><input type="text" name="username" value=""/>
    # **base.css file is css file name**


 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: