Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrap referencing bad glyphicons path #4950

Closed
5 of 6 tasks
MichaelPalmer1 opened this issue Mar 9, 2017 · 11 comments · Fixed by #4951
Closed
5 of 6 tasks

Bootstrap referencing bad glyphicons path #4950

MichaelPalmer1 opened this issue Mar 9, 2017 · 11 comments · Fixed by #4951
Labels
Milestone

Comments

@MichaelPalmer1
Copy link
Contributor

MichaelPalmer1 commented Mar 9, 2017

Overview

The file rest_framework/static/rest_framework/docs/css/bootstrap.min.css references ../fonts/glyphicons-halflings-regular.eot. However, the file actually exists at ../../fonts/glyphicons-halflings-regular.eot. This is throwing an error when trying to run collectstatic:

Post-processing 'rest_framework/docs/css/bootstrap-theme.min.css' failed!

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.5/site-packages/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.5/site-packages/django/core/management/base.py", line 294, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.5/site-packages/django/core/management/base.py", line 345, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.5/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 193, in handle
    collected = self.collect()
  File "/usr/local/lib/python3.5/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 145, in collect
    raise processed
whitenoise.storage.MissingFileError: The file 'rest_framework/docs/css/../fonts/glyphicons-halflings-regular.eot' could not be found with <whitenoise.storage.CompressedManifestStaticFilesStorage object at 0x7f89f54f9f60>.

The CSS file 'rest_framework/docs/css/bootstrap-theme.min.css' references a file which could not be found:
  rest_framework/docs/css/../fonts/glyphicons-halflings-regular.eot

Please check the URL references in this CSS file, particularly any
relative paths which might be pointing to the wrong location.

Affected Versions

3.6.0+

Suggested Solution

Copy the glyphicons to the appropriate directory.

Similar Issues

#4914
#2008

Checklist

  • I have verified that that issue exists against the master branch of Django REST framework.
  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • This is not a usage question. (Those should be directed to the discussion group instead.)
  • This cannot be dealt with as a third party library. (We prefer new functionality to be in the form of third party libraries where possible.)
  • I have reduced the issue to the simplest possible case.
  • I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)
MichaelPalmer1 pushed a commit to MichaelPalmer1/django-rest-framework that referenced this issue Mar 9, 2017
@MichaelPalmer1
Copy link
Contributor Author

MichaelPalmer1 commented Mar 9, 2017

On second thought, was there a specific reason why an additional bootstrap.min.css file was created in rest_framework/static/rest_framework/docs/css instead of using the existing one in rest_framework/static/rest_framework/css?

@eranrund
Copy link

eranrund commented Mar 9, 2017

Also seeing this when trying to upgrade from 3.5.4 to 3.6.1

@tomchristie
Copy link
Member

@MichaelPalmer1 - Not particularly intentional, other then ensuring that work on the API docs didn't run the risk of altering anything in the browsable API. Turns out there's no diff between them, so could remove that and use the existing one.

@tomchristie tomchristie added this to the 3.6.2 Release milestone Mar 10, 2017
@Matbj
Copy link

Matbj commented Mar 10, 2017

+1 on seeing this when upgrading from 3.5.4 to 3.6.0+3.6.1

@lizhongz
Copy link

Seeing this problem again using 3.7.4 with whitenoise 3.3.1

@xordoquy
Copy link
Collaborator

Referenced in #5692 for 3.7.4

@Eagleames
Copy link

saw this today when I upgraded django from 4.0.6 to 4.1

@thomasgubler
Copy link

saw this today when I upgraded django from 4.0.6 to 4.1

I can confirm this. Downgrading from 4.1 to 4.0.7 resolved the issue.

@marcgibbons
Copy link
Contributor

marcgibbons commented Sep 21, 2022

Experiencing this as well using STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' on Django 4.1

Unsure what the underlying problem is, but a workaround is to ignore DRF on collectstatic like:

python manage.py collectstatic -i rest_framework

Note: you will not be able to use the BrowsableAPIRenderer when DEBUG=False

@tomchristie
Copy link
Member

Thanks @marcgibbons - I think this is fixed in master with #8591, and should be resolved on our next release.

@aDramaQueen
Copy link

Quick & dirty workaround for current Django REST (v.3.13.1) with Django 4.1+:

  1. Download "bootstrap.min.css.map v.3.4.0"
  2. Download "bootstrap-theme.min.css.map v.3.4.0"
  3. Save these files within your project
  4. Subclass from ManifestStorage & copy missing files to your static directory
class WorkaroundFilesStorage(ManifestFilesMixin, StaticFilesStorage):

    def post_process(self, *args, **kwargs):
        missing_files = {'.../path/to/bootstrap-theme.min.css.map', '.../path/to/bootstrap.min.css.map'}

        for missing_file in missing_files:
            shutil.copyfile(missing_file, Path(settings.STATIC_ROOT, 'rest_framework', 'css', missing_file.split('/')[-1]).resolve())
        return super().post_process(*args, **kwargs)
  1. Redirect to this new Storage in your settings.py
STATICFILES_STORAGE = 'full.canonical.name.to.WorkaroundFilesStorage'

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

Successfully merging a pull request may close this issue.

10 participants