Coder Social home page Coder Social logo

django-static-sitemaps's Introduction

👋 Hi there! I'm Filip Vařecha

A Full-stack Software Engineer that loves challenging projects

I'm looking for some new opportunities at the moment so feel free to reach me at xaralis93 'at' gmail 'dot' com

LinkedIn Facebook Stack Overflow

Stuff I like to work with

Python JavaScript

Django FastAPI Express.js

React Vue.js Apollo-GraphQL

Postgres Redis Kafka

HTML CSS3 TailwindCSS

Kubernetes

Prometheus Grafana

Nginx

GitLab

Trello

django-static-sitemaps's People

Contributors

akay7 avatar artscoop avatar auzhva avatar coagulant avatar dbrgn avatar dulacp avatar fotcorn avatar iancubitt avatar janezkranjc avatar lightstrike avatar lowks avatar luanp avatar marcosgabarda avatar nicolastobo avatar paramono avatar philipn avatar salvacarrion avatar seocam avatar simongreenhill avatar srivatsshankar avatar vimm0 avatar vint21h avatar xaralis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

django-static-sitemaps's Issues

Celery Task Time Limit Setting

Hello!

Sometimes the GenerateSitemap task reaches celery's hard timeout. It would be nice to be able to adjust it in the settings. How about adding one for that?

Thanks!

Doesn't install on python 3

Hello,

I am trying to install with pip (7.1.1) on python (3.4.0).

When I try to install with command:

$ pip install django-static-sitemaps

I get this error:

Collecting django-static-sitemaps
  Using cached django-static-sitemaps-2.1.7.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "/site/lib/python3.4/site-packages/setuptools/sandbox.py", line 152, in save_modules
        yield saved
      File "/site/lib/python3.4/site-packages/setuptools/sandbox.py", line 193, in setup_context
        yield
      File "/site/lib/python3.4/site-packages/setuptools/sandbox.py", line 237, in run_setup
        DirectorySandbox(setup_dir).run(runner)
      File "/site/lib/python3.4/site-packages/setuptools/sandbox.py", line 267, in run
        return func()
      File "/site/lib/python3.4/site-packages/setuptools/sandbox.py", line 236, in runner
        _execfile(setup_script, ns)
      File "/site/lib/python3.4/site-packages/setuptools/sandbox.py", line 45, in _execfile
        code = compile(script, filename, 'exec')
      File "/tmp/easy_install-792ml56b/setuptools_dummy-0.1.0.4/setup.py", line 10
        print "can't find ez_setup"
                                  ^
    SyntaxError: invalid syntax

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "/tmp/pip-build-8z1g3cee/django-static-sitemaps/setup.py", line 38, in <module>
        'setuptools_dummy',
      File "/usr/lib/python3.4/distutils/core.py", line 108, in setup
        _setup_distribution = dist = klass(attrs)
      File "/site/lib/python3.4/site-packages/setuptools/dist.py", line 268, in __init__
        self.fetch_build_eggs(attrs['setup_requires'])
      File "/site/lib/python3.4/site-packages/setuptools/dist.py", line 313, in fetch_build_eggs
        replace_conflicting=True,
      File "/site/lib/python3.4/site-packages/pkg_resources/__init__.py", line 836, in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)
      File "/site/lib/python3.4/site-packages/pkg_resources/__init__.py", line 1081, in best_match
        return self.obtain(req, installer)
      File "/site/lib/python3.4/site-packages/pkg_resources/__init__.py", line 1093, in obtain
        return installer(requirement)
      File "/site/lib/python3.4/site-packages/setuptools/dist.py", line 380, in fetch_build_egg
        return cmd.easy_install(req)
      File "/site/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 629, in easy_install
        return self.install_item(spec, dist.location, tmpdir, deps)
      File "/site/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 659, in install_item
        dists = self.install_eggs(spec, download, tmpdir)
      File "/site/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 842, in install_eggs
        return self.build_and_install(setup_script, setup_base)
      File "/site/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 1070, in build_and_install
        self.run_setup(setup_script, setup_base, args)
      File "/site/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 1056, in run_setup
        run_setup(setup_script, args)
      File "/site/lib/python3.4/site-packages/setuptools/sandbox.py", line 240, in run_setup
        raise
      File "/usr/lib/python3.4/contextlib.py", line 77, in __exit__
        self.gen.throw(type, value, traceback)
      File "/site/lib/python3.4/site-packages/setuptools/sandbox.py", line 193, in setup_context
        yield
      File "/usr/lib/python3.4/contextlib.py", line 77, in __exit__
        self.gen.throw(type, value, traceback)
      File "/site/lib/python3.4/site-packages/setuptools/sandbox.py", line 164, in save_modules
        saved_exc.resume()
      File "/site/lib/python3.4/site-packages/setuptools/sandbox.py", line 139, in resume
        compat.reraise(type, exc, self._tb)
      File "/site/lib/python3.4/site-packages/setuptools/compat.py", line 65, in reraise
        raise value.with_traceback(tb)
      File "/site/lib/python3.4/site-packages/setuptools/sandbox.py", line 152, in save_modules
        yield saved
      File "/site/lib/python3.4/site-packages/setuptools/sandbox.py", line 193, in setup_context
        yield
      File "/site/lib/python3.4/site-packages/setuptools/sandbox.py", line 237, in run_setup
        DirectorySandbox(setup_dir).run(runner)
      File "/site/lib/python3.4/site-packages/setuptools/sandbox.py", line 267, in run
        return func()
      File "/site/lib/python3.4/site-packages/setuptools/sandbox.py", line 236, in runner
        _execfile(setup_script, ns)
      File "/site/lib/python3.4/site-packages/setuptools/sandbox.py", line 45, in _execfile
        code = compile(script, filename, 'exec')
      File "/tmp/easy_install-792ml56b/setuptools_dummy-0.1.0.4/setup.py", line 10
        print "can't find ez_setup"
                                  ^
    SyntaxError: invalid syntax

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-8z1g3cee/django-static-sitemaps

celery 5 removed previsouly deprecated celery.task module

Using celery 5 with latest django-static-sitemaps doesn't work. In celery 4, the celery.tasks module was deprecated and then removed in version 5. You might be able to simply replace:

tasks.py:

from celery.task import PeriodicTask

with

from celery import Task

and

    class GenerateSitemap(PeriodicTask):

with

    class GenerateSitemap(Task):

I haven't tested this.

How to use with Heroku?

Hi,

First of all thank you for django-static-stitemaps. I am trying to use it with Heroku but Heroku generated a "slug" (their term for compiling an app and packaging it for distribution) and I can't seem to add any sitemap* file into staticfiles even if I manually trigger ./manage.py refresh_sitemap.

Any help would be appreciated.

Thanks.

Running with Celery

Hi!
We use in our projects Celery. Current Celery version 5.2.7.
And celery-task of this subject is not starting automatically.
What is reason?

No Way to Disable Task if using Celery

The way the PeriodicTask is setup prevents you from disabling it if you are running celery. The only way to disable it would be to pass in "None" as the value for STATICSITEMAPS_REFRESH_AFTER. However, if you attempt this it fails when trying to cast the None value into a timedelta() https://github.com/xaralis/django-static-sitemaps/blob/master/static_sitemaps/tasks.py#L12

IMO, the default value should be None, not 60 inside conf.py so that it can be an opt in scenario, after the above issue has been addressed. (see https://github.com/xaralis/django-static-sitemaps/blob/master/static_sitemaps/conf.py#L41 ).

Bytes/String issues with GZip using Python 3

Ran into an issue with string/bytes handling. Looks like it slipped through the cracks when adding the Python 3 support. STATICSITEMAPS_USE_GZIP = False serves as a workaround until a more permanent fix is written.

Generating sitemaps.
Raven is not configured (logging is disabled). Please see the documentation for more information.
Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/techdragon/.pyenv/versions/test_project/lib/python3.4/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
    utility.execute()
  File "/home/techdragon/.pyenv/versions/test_project/lib/python3.4/site-packages/django/core/management/__init__.py", line 345, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/techdragon/.pyenv/versions/test_project/lib/python3.4/site-packages/django/core/management/base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/techdragon/.pyenv/versions/test_project/lib/python3.4/site-packages/raven/contrib/django/management/__init__.py", line 41, in new_execute
    return original_func(self, *args, **kwargs)
  File "/home/techdragon/.pyenv/versions/test_project/lib/python3.4/site-packages/django/core/management/base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "/home/techdragon/.pyenv/versions/test_project/lib/python3.4/site-packages/django/core/management/base.py", line 584, in handle
    return self.handle_noargs(**options)
  File "/home/techdragon/.pyenv/versions/test_project/lib/python3.4/site-packages/static_sitemaps/management/commands/refresh_sitemap.py", line 14, in handle_noargs
    generator.write()
  File "/home/techdragon/.pyenv/versions/test_project/lib/python3.4/site-packages/static_sitemaps/generator.py", line 69, in write
    self.write_index()
  File "/home/techdragon/.pyenv/versions/test_project/lib/python3.4/site-packages/static_sitemaps/generator.py", line 89, in write_index
    lastmod = self.write_page(site, page, filename)
  File "/home/techdragon/.pyenv/versions/test_project/lib/python3.4/site-packages/static_sitemaps/generator.py", line 175, in write_page
    with gzip.GzipFile(fileobj=buf, mode="w") as f:
  File "/home/techdragon/.pyenv/versions/3.4.3/lib/python3.4/gzip.py", line 220, in __init__
    self._write_gzip_header()
  File "/home/techdragon/.pyenv/versions/3.4.3/lib/python3.4/gzip.py", line 252, in _write_gzip_header
    self.fileobj.write(b'\037\213')             # magic header
TypeError: string argument expected, got 'bytes'

Didn't create database schema

Environment
python 3.5
Django 2.1.7
django-static-sitemap 4.6.0

When I try to create database schema,
$python manage.py makemigrations $python manage.py migrate
nothing happens.

SuspiciousFileOperation when saving sitemaps to STATIC_ROOT

After upgrading to v2.0.0 I am getting the following django storage error when refreshing the sitemaps:

 File "/home/vagrant/.virtualenvs/env/local/lib/python2.7/site-packages/static_sitemaps/management/commands/refresh_sitemap.py", line 17, in handle_noargs
    generator.write_index()
  File "/home/vagrant/.virtualenvs/env/local/lib/python2.7/site-packages/static_sitemaps/generator.py", line 40, in write_index
    lastmod = self.write_page(site, page, filename, storage)
  File "/home/vagrant/.virtualenvs/env/local/lib/python2.7/site-packages/static_sitemaps/generator.py", line 96, in write_page
    if storage.exists(path):
  File "/home/vagrant/.virtualenvs/env/local/lib/python2.7/site-packages/django/core/files/storage.py", line 245, in exists
    return os.path.exists(self.path(name))
  File "/home/vagrant/.virtualenvs/env/local/lib/python2.7/site-packages/django/core/files/storage.py", line 261, in path
    raise SuspiciousFileOperation("Attempted access to '%s' denied." % name)
django.core.exceptions.SuspiciousFileOperation: Attempted access to '/vagrant/static/sitemap-static-1.xml' denied.

This occurs when STATICSITEMAPS_ROOT_DIR is set to STATIC_ROOT or any other directory. It only works when MEDIA_ROOT is used. It therefore appears to be a directory permissions issue, but the collectstatic command is able to write files to the static directory without errors.

This error occurs on windows and linux systems, including in a clean vagrant environment, which the above error message is taken from.

Does anyone have any ideas on how to fix this?

How to install on windows

Hello,

I am using windows machine to install this. But it is giving me this error:

"Command "python setup.py egg_info" failed with error code 1 in C:\xx\AppData\Local\Temp\pip-build-jzlzgeur\django-static-sitemaps"

So, please tell me how can I solve this issue and install it.

Thanks

Version 4.5.0, TemplateDoesNotExist: static_sitemaps/sitemap_index.xml

Update:
I just realized that the new version is only compatible with Django 2.0+. However, Django 1.11 is a LTS release, is this final? Shouldn't it be mentioned at the README file?


After upgrading to version 4.5.0 I receive the following error:

Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/path/to/virtualenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/path/to/virtualenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/path/to/virtualenv/lib/python3.5/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/path/to/virtualenv/lib/python3.5/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
   File "/path/to/virtualenv/lib/python3.5/site-packages/static_sitemaps/management/commands/refresh_sitemap.py", line 13, in handle
    generator.write()
  File "/path/to/virtualenv/lib/python3.5/site-packages/static_sitemaps/generator.py", line 80, in write
    self.write_index()
  File "/path/to/virtualenv/lib/python3.5/site-packages/static_sitemaps/generator.py", line 117, in write_index
    output = loader.render_to_string(conf.INDEX_TEMPLATE, {'sitemaps': parts})
  File "/path/to/virtualenv/lib/python3.5/site-packages/django/template/loader.py", line 67, in render_to_string
    template = get_template(template_name, using=using)
  File "/path/to/virtualenv/lib/python3.5/site-packages/django/template/loader.py", line 25, in get_template
    raise TemplateDoesNotExist(template_name, chain=chain)
django.template.exceptions.TemplateDoesNotExist: static_sitemaps/sitemap_index.xml

Donwgrading to 4.4.1, the error disappears.

Empty sitemap generated

I guess I'm doing something wrong by getting an empty sitemap after running the refresh_sitemaps command.

I'm running Django 1.4.8 along with latest django-static-sitemaps
Can anyone spot whats missing?

This is my conf:

STATICSITEMAPS_ROOT_DIR = MEDIA_ROOT
STATICSITEMAPS_URL = MEDIA_URL + 'sitemaps/'
STATICSITEMAPS_ROOT_SITEMAP = 'proj.sitemaps.base_sitemaps'

SITEMAP:

class StaticSitemap(Sitemap):

def items(self):
    return ['home', 'features']

def location(self, obj):
    return reverse(obj)

def changefreq(self, obj):
    return 'weekly'

def lastmode(self, obj):
    return datetime.now()

Django 1.7

In django 1.7 mimetype keyword is removed from HttpResponse.

Is it possible to fix this in future versions of packege?

Upload Sitemap on S3 with django-storages

Hello,

I am trying to override the default path of staticfils by adding the following line on my SETTINGS

STATICSITEMAPS_ROOT_DIR = 'production-basket.s3.amazonaws.com/sitemaps/'

As you can imagine, it doesn't work... Any ideas?
I just need to upload by sitemaps on S3 and serve them directly through there.

Thank you in advance,
Michael.

Urls Structure incorrect for .xml.gz files?

I believe the current URL patterns don't pickup the compressed xml files, altering the include urls to the following solved the problem for me (just added the last line).

from static_sitemaps.views import SitemapView

url(r'^sitemap\.xml$', SitemapView.as_view(), 
    kwargs={'section': 'sitemap'}, name='static_sitemaps_index'),
url(r'^(?P<section>sitemap-.+)\.xml$', SitemapView.as_view()),
url(r'^(?P<section>sitemap-.+)\.xml.gz$', SitemapView.as_view()),

Please let me know if I've missed something or made a mistake.

Thanks, Tom

Django 2.0 support

Hello.

In django v 2.0 i have error.

File "/home/eugene/VirtualEnv/Django2/lib/python3.4/site-packages/static_sitemaps/generator.py", line 18, in <module>
    from django.core.urlresolvers import reverse, NoReverseMatch
ImportError: No module named 'django.core.urlresolvers'

Please fix in file: static_sitemaps/generator.py

try:
    from django.core.urlresolvers import reverse, NoReverseMatch
except ImportError:
    from django.urls import reverse, NoReverseMatch

Thanks.

When using s3 boto storage, path gets prepended to the filename twice

The value of SITEMAP_ROOT_DIR gets prepended to the filename twice. I had do use a custom storage to avoid this happening:

class S3SitemapStorage(S3BotoStorage):
    def __init__(self, *args, **kwargs):
        super(S3SitemapStorage, self).__init__(*args, **kwargs)
        self.location = ''

No way to change default protocol for relative URLs

Can't see how to change to https (which should be the default). It looks hardcoded:

    @staticmethod
    def normalize_url(url):
        if url[-1] != '/':
            url += '/'
        if not url.startswith(('http://', 'https://')):
            if url.startswith('/'):
                from django.contrib.sites.models import Site
                url = 'http://' + Site.objects.get_current().domain + url
            else:
                url = 'http://' + url
        return url

Invoke Celery Task

Hello,
I have everything setup and when I run the command
python manage.py refresh_sitemap
I get the desired result.
But my platform is reaaaally big thus it takes several hours to generate the complete sitemap.
I need to have it run as a celery job.
I just haven't managed to make it work.. I have it added on my django apps, I also have celery run on the background, when celery starts the task
. static_sitemaps.tasks.GenerateSitemap
is registered properly. But looking on what celery jobs run, this never goes there..
Sooo... How do I invoke to run on the background?

Sitemap for multiple languages

I have a web page in multiple languages and I'd like my sitemaps linking to each one of the pages.

Since they have different URLs and different content for each URL all of them should be linked my the sitemap.

Perhaps that should be something to be implemented in Django instead of here...

STATICSITEMAPS_REFRESH_AFTER = None seems not to be working

I'm not sure if I'm doing something wrong, but if I set:

STATICSITEMAPS_REFRESH_AFTER = None

Celery still attempts at running it:

[2019-09-19 22:01:16,571: ERROR/MainProcess] Received unregistered task of type 'static_sitemaps.tasks.GenerateSitemap'.
The message has been ignored and discarded.

Did you remember to import the module containing this task?
Or maybe you're using relative imports?

Please see
http://docs.celeryq.org/en/latest/internals/protocol.html
for more information.

The full contents of the message body was:
b'[[], {}, {"callbacks": null, "errbacks": null, "chain": null, "chord": null}]' (77b)
KeyError: 'static_sitemaps.tasks.GenerateSitemap'

UnicodeDecodeError

I'm getting the error:
manage.py refresh_sitemap

/python2.7/site-packages/static_sitemaps/generator.py", line 189, in write_page
f.write(output.encode('utf-8'))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 326175: ordinal not in range(128)

It seems that the problem symbol is accented a - À.
How can I resolve it?

Python 2.7.12
Django 1.9.12
charset in mysql, if it can help - utf8mb4_unicode_ci

Create conf.ROOT_DIR if it doesn't exist

When the conf.ROOT_DIR directory doesn't exist, yet, it should be created.

So if someone uses os.path.join(STATIC_ROOT, 'sitemaps') as ROOT_DIR, the sitemaps directory should automatically be created.

In case something fails, a clean error or exception message should be printed. Currently it's just an IOError...

(Nice module btw!)

Using GenericSitemap with no sitemap configuration

I'm configuring my sitemaps with indexing stuff like;

from django.conf.urls import patterns
from django.contrib.sitemaps import FlatPageSitemap, GenericSitemap
from blog.models import Entry

info_dict = {
    'queryset': Entry.objects.all(),
    'date_field': 'pub_date',
}

sitemaps = {
    'flatpages': FlatPageSitemap,
    'blog': GenericSitemap(info_dict, priority=0.6),
}

urlpatterns = patterns('',
    # some generic view using info_dict
    # ...

    # the sitemap
    (r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps})
)

And README.rst says;

Set STATICSITEMAPS_ROOT_SITEMAP variable in your settings.py to point to dictionary holding the sitemaps configuration

But as using GenericSitemap, I keep sitemap config stuff in root urls.py. So how I can set STATICSITEMAPS_ROOT_SITEMAP ?, or how can I make this working with my current configuration ?

File paths are doubled in my case

Environment

  • python 3.6
  • Django 1.11
  • django-static-sitemap 4.4.1

Django Settings

STATIC_ROOT = 'static/'
STATIC_URL = '/static/'

# noj is my app name
STATICSITEMAPS_ROOT_SITEMAP = 'noj.sitemap.sitemaps'
STATICSITEMAPS_PING_GOOGLE = False

Behaviors

It's fine to generate a sitemap index, and I can visit it in http://127.0.0.1:8000/sitemap.xml.

<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap>
    <loc>
      http://127.0.0.1:8000/static/sitemap-static-1.xml.gz
    </loc>
  </sitemap>
...
</sitemapindex>

But if I visit http://127.0.0.1:8000/static/sitemap-static-1.xml.gz, I would get a 404 there.
I found that sitemap-static-1.xml.gz is generated actually in /static/static/sitemap-static-1.xml.gz

After some digging in the source codes, I figured out that I could get what I want after modifying this line

path = os.path.join(conf.ROOT_DIR, filename)

to

path = filename

I don't know if it's the right way, and if there is a better way to do this. Need some help here. 😂

Cannot use S3BotoStorage - The Content-MD5 you specified did not match what we received.

I have this exception raised when I use the S3BotoStorage.

boto.exception.S3ResponseError: S3ResponseError: 400 Bad Request
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>BadDigest</Code><Message>The Content-MD5 you specified did not match what we received.</Message><ExpectedDigest>fcedd25c*****66d9634a2a328</ExpectedDigest><CalculatedDigest>r1/g6VL***p41gkVAjyw==</CalculatedDigest><RequestId>0B7221D8CBBFE210</RequestId><HostId>eICRC46tfCpNF*******************oBlt6om+qGWV/L***Tik/lBH*******gm/ZK****UNk=</HostId></Error>

Apparently, it's because the file changes when uploading.
(http://stackoverflow.com/questions/36179310/a-exception-the-content-md5-you-specified-did-not-match-what-we-received-what)

Django 1.4.8 AttributeError: 'cStringIO.StringO' object has no attribute 'name'

I received the following exception while running the refresh_sitemap command:

Generating sitemaps.
Traceback (most recent call last):
File "./manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/Development/local/lib/python2.7/site-packages/django/core/management/init.py", line 443, in execute_from_command_line
utility.execute()
File "/Development/local/lib/python2.7/site-packages/django/core/management/init.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Development/local/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(_args, *_options.dict)
File "/Development/local/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(_args, *_options)
File "/Development/local/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
File "/Development/local/lib/python2.7/site-packages/static_sitemaps/management/commands/refresh_sitemap.py", line 14, in handle_noargs
generator.write()
File "/Development/local/lib/python2.7/site-packages/static_sitemaps/generator.py", line 68, in write
self.write_index()
File "/Development/local/lib/python2.7/site-packages/static_sitemaps/generator.py", line 88, in write_index
lastmod = self.write_page(site, page, filename)
File "/Development/local/lib/python2.7/site-packages/static_sitemaps/generator.py", line 146, in write_page
self._write(path, output)
File "/Development/local/lib/python2.7/site-packages/static_sitemaps/generator.py", line 54, in _write
self.storage.save(path, File(buf))
File "/Development/local/lib/python2.7/site-packages/django/core/files/storage.py", line 45, in save
name = self._save(name, content)
File "/Development/local/lib/python2.7/site-packages/django/core/files/storage.py", line 195, in _save
for chunk in content.chunks():
File "/Development/local/lib/python2.7/site-packages/django/core/files/base.py", line 65, in chunks
counter = self.size
File "/Development/local/lib/python2.7/site-packages/django/core/files/base.py", line 39, in _get_size
elif os.path.exists(self.file.name):
AttributeError: 'cStringIO.StringO' object has no attribute 'name'

AttributeError: 'cStringIO.StringO' object has no attribute 'chunks'

This error occurs when running refresh_sitemap on Django 1.5.4 and django-static-sitemaps 2.1.1

Settings -

STATICSITEMAPS_ROOT_SITEMAP = 'main_project.sitemaps.sitemaps'
STATICSITEMAPS_ROOT_DIR = os.path.join(PROJECT_PATH, os.pardir)
STATICSITEMAPS_URL = '/'

Doesn't work even with STATICSITEMAPS_USE_GZIP turned off.

Full traceback -

  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 222, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 255, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 385, in handle
    return self.handle_noargs(**options)
  File "/usr/local/lib/python2.7/dist-packages/static_sitemaps/management/commands/refresh_sitemap.py", line 14, in handle_noargs
    generator.write()
  File "/usr/local/lib/python2.7/dist-packages/static_sitemaps/generator.py", line 67, in write
    self.write_index()
  File "/usr/local/lib/python2.7/dist-packages/static_sitemaps/generator.py", line 87, in write_index
    lastmod = self.write_page(site, page, filename)
  File "/usr/local/lib/python2.7/dist-packages/static_sitemaps/generator.py", line 145, in write_page
    self._write(path, output)
  File "/usr/local/lib/python2.7/dist-packages/static_sitemaps/generator.py", line 53, in _write
    self.storage.save(path, buf)
  File "/usr/local/lib/python2.7/dist-packages/django/core/files/storage.py", line 48, in save
    name = self._save(name, content)
  File "/usr/local/lib/python2.7/dist-packages/django/core/files/storage.py", line 202, in _save
    for chunk in content.chunks():
AttributeError: 'cStringIO.StringO' object has no attribute 'chunks'

Use storages backend, and consider moving to MEDIA_URL as default

Hi, lovely project, thank you. Unfortunately I can't use it because I host all my media and static files on S3. It would be great if django-static-sitemaps were to use the Django storages backend instead of writing to the filesystem directly.
I'd also argue that dynamic sitemaps belong more into media files than static files. Static files are just that - static, and are treated as such by e.g. the collectstatic command. So MEDIA_URL might be a more sensible default

Is Celery a required dependency?

Is it possible to run without Celery installed?

app_1           |   File "/usr/local/lib/python3.7/site-packages/static_sitemaps/tasks.py", line 3, in <module>
app_1           |     from celery import Task
app_1           | ModuleNotFoundError: No module named 'celery'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.