Wednesday, June 30, 2021

Re: when i am writing {%load static%} rather than getting exectuted it is getting displayed as simple text on htmloutput screen

Dear Patel Druvish ,
I have tried with that one 

Its showing such kind of error when trying to css file

Failed to load resource: the server responded with a status of 404 (Not Found)
extension.js:24 onMessage extension
ial.js:450 Clean the cache of the scraper (new onComplete event)
style.css'%%7D:1 Failed to load resource: the server responded with a status of 404 (Not Found)
The attempt to bind "/static/%7B%static%20'styles/style.css'%%7D" in the workspace failed as this URI is malformed.

HTML CODE{%load static%}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Fotoxplor</title>
    <link rel="stylesheet" type="text/css" href="{%static 'styles/style.css'%}">
</head>
<body>
    <h1 style="color: red;">Welcome to Fotoxplor</h1>
    <div class="box">
        <p>
            Fotoxplor
        </p>
    </div>
</body>
<header class="header">
    <div class="container">
        <div class="row">
            <div class="col">
                <div class="header_content d-flex flex-row align-items-center justify-content-start">
                    <div class="header_content_inner d-flex flex-row align-items-end justify-content-start">
                        <div class="logo"><a href="{%static 'home.html'%}">Fotoxplor</a></div>
                        <nav class="main_nav">
                            <ul class="d-flex flex-row align-items-start justify-content-start">
                                <li><a href="{%static 'aboutus.html'%}">About us</a></li>
                                <li><a href="">Services</a></li>
                                <li><a href="">News</a></li>
                                <li><a href="{%static 'contactus.html'%}">Contact</a></li>
                            </ul>
                        </nav>
                        <div class="header_phone ml-auto">Call us: 00-56 445 678 33</div>
                        <!-- Hamburger -->
                        <div class="hamburger ml-auto">
                            <i class="fa fa-bars" aria-hidden="true"></i>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</header>
<div class="Phototype">
        <title>Photocateogry </title>
        <label for="browser">Choose your Photocateogry:</label>
        <input list="browsers" name="browser" id="browser">
        <datalist id="browsers">
          <option value="Nature">
          <option value="Animals">
          <option value="Food">
          <option value="Travel">
          <option value="Sports">
        </datalist>
        <input type="submit">
</div>


On Wed, Jun 30, 2021 at 9:58 AM patel dhruvish <pateldhruvish612000@gmail.com> wrote:
Do you add static code in setting.py and urls.py? Code is here....
 
Setting.py:-
Project  urls.py:-
Then load static file with format like:-
STATICFILES_DIRS = [      BASE_DIR / "static",      '/var/www/static/',  ]

Project  urls.py:-
from django.conf import settings  from django.conf.urls.static import static    urlpatterns = [      # ... the rest of your URLconf goes here ...  ] 
+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
Or
 + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Then load static file with format like:-
{% load static %}  <img src="{% static 'my_app/example.jpg' %}" alt="My image">


On Wed, Jun 30, 2021, 09:47 UJJWAL AGRAWAL <ujjwalgl.sgi@gmail.com> wrote:
Dear all I am facing one problem.
When I am writing {%load static%} rather than getting executed it is getting displayed as simple text on the HTML output screen

Please provide me the solution.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALQ%3D5fyZPWiBGnY6VJB1_C6Rb1Ls4dfsGfTef%2BBSqi1BXKHtfw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANMvxF0juEz51Pua5PRAR8uNjKPsSGVkZUnDYjTTtve7hfObag%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALQ%3D5fwh338p62K759MHec2AKP-_R4H%3DKN8ZdEs3axhopJL2GQ%40mail.gmail.com.

No comments:

Post a Comment