Skip to content
This repository has been archived by the owner on Jan 11, 2021. It is now read-only.

Source of the image throbber.gif is wrong #311

Closed
rosesonfire opened this issue Jun 28, 2015 · 11 comments
Closed

Source of the image throbber.gif is wrong #311

rosesonfire opened this issue Jun 28, 2015 · 11 comments

Comments

@rosesonfire
Copy link

the source given is
src="rest_framework_swagger/images/throbber.gif"

it should be
src="static/rest_framework_swagger/images/throbber.gif"

@ariovistus
Copy link
Contributor

effectively, what should be happening is

src="{{STATIC_URL}}rest_framework_swagger/images/throbber.gif"

if you aren't getting that, either STATIC_URL is misconfigured, or this line:

isn't being run.

@rosesonfire
Copy link
Author

Yea! that line is the problem.
While browsing,
window.static_url = '';

@ariovistus
Copy link
Contributor

so STATIC_URL is an empty string. maybe set

STATIC_URL = '/static/'

in your settings.py?

@rosesonfire
Copy link
Author

it is set already, I'm afraid :/

@ariovistus
Copy link
Contributor

hmm. are you using the default templates (base.html and index.html)?

@rosesonfire
Copy link
Author

Does this help:

myProject/Settings.py

DEBUG = True

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django_countries',

    'rest_framework',
    'rest_framework.authtoken',
    'rest_auth',
    'rest_framework_swagger',
    'rest_auth.registration',

    'allauth',
    'allauth.account',

    'django_extensions',
    .........
    ......
)

ROOT_URLCONF = 'myProject.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

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

myProject/urls.py

from django.conf.urls import include, url
from django.contrib import admin
from django.template.loader import render_to_string

urlpatterns = [
    url(r'^admin/', include(admin.site.urls)),

    .................
    .............

    url(r'^docs/', include('rest_framework_swagger.urls')),

    .........
    .....
]

@dpetzel
Copy link

dpetzel commented Aug 4, 2015

I've bumped into this today as well using the stock templates. I am using version 0.3.2 I hacked up a template override and can see that {{STATIC_URL}} returns empty. I tried changing it to {% static "" %} which does return the proper value (/static/ in my case), but still the image 404s with the wrong path. All the other static assets references in that link above work (and they are also using the static tag)

I made the following adjustment to the template: window.static_url = '{% static "" %}';, Looking at the js I can see its using src='"+ window.static_url +"rest_framework_swagger/images/throbber.gif' which sure seeme like it should work, but the static prefix is simply not part of the URL when the resource is fetched.

Its almost as if its attempting the fetch the image before that JS has fired but I don't know javascript well enough to know if that is the case for sure.

@ariovistus
Copy link
Contributor

pr #334 made the same fix. maybe try using master?

@dpetzel
Copy link

dpetzel commented Aug 5, 2015

I'll give master a shot, but when I mad that change it still didn't work properly.

@ccatterina
Copy link

ccatterina commented Oct 4, 2016

Hi, I have the same problem with version 0.3.10.
here is a screen:

image

@gabber7
Copy link

gabber7 commented Nov 14, 2016

Hi, the problem was reintroduced by #420

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants