Skip to main content

django2-url-robots

Fork of dimka665 https://github.com/dimka665/django-url-robots

Django robots.txt generator. Based on using decorated django.conf.urls.url. It gets urlpatterns and replaces ambiguous parts by *.

Installation & Usage

The recommended way to install django2-url-robots is with pip

  1. Install from PyPI with easy_install or pip:

    pip install django2-url-robots
  2. Add 'django2_url_robots' to your INSTALLED_APPS:

    INSTALLED_APPS = (
        ...
        'django2_url_robots',
        ...
        )
  3. Add django2_url_robots view to your root URLconf:

    urlpatterns += [
        url(r'^robots\.txt$', django2_url_robots.views.robots_txt),
        ]
  4. Describe rules by boolean keyword argument robots_allow using for it django2_url_robots.utils.url instead django.conf.urls.url:

    from django2_url_robots.utils import url
    
    urlpatterns += [
       url('^profile/private$', views.some_view, robots_allow=False),
       ]

django2-url-robots tested with Django-2.0.5+. Encodes unicode characters by percent-encoding.

Settings

In this moment there are only one option to define template of robots.txt file:

urlpatterns += [
    url(r'^robots\.txt$', django2_url_robots.views.robots_txt, {'template': 'my_awesome_robots_template.txt'}),
    ]

Example

robots_template.txt:

User-agent: *
Disallow: /*  # disallow all
{{ rules|safe }}

urls.py:

from django.conf.urls import include

urlpatterns = [
    url(r'^profile', include('django2_url_robots.tests.urls_profile')),
]

urls_profile.py:

from django2_url_robots.utils import url

urlpatterns = [
    url(r'^s$', views.some_view, name='profiles', robots_allow=True),
    url(r'^/(?P<nick>\w+)$', views.some_view),
    url(r'^/(?P<nick>\w+)/private', views.some_view, name='profile_private', robots_allow=False),
    url(r'^/(?P<nick>\w+)/public', views.some_view, name='profile_public', robots_allow=True),
    ]

Resulting robots.txt:

User-agent: *
Disallow: /*  # disallow all
Allow: /profiles$
Disallow: /profile/*/private*
Allow: /profile/*/public*

Metadata

Release files for django2-url-robots 3.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django2-url-robots 3.2.2
File Size Uploaded Provenance Actions
django2-url-robots-3.2.2.tar.gz 4.9 kB Without provenance Details for django2-url-robots-3.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django2-url-robots 3.2.2
File Interpreter ABI Platform Actions
django2_url_robots-3.2.2-py3-none-any.whl Python 3 none any Details for django2_url_robots-3.2.2-py3-none-any.whl

Total release size: 11.7 kB

Release files / django2-url-robots-3.2.2.tar.gz

Download URL django2-url-robots-3.2.2.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
fe8028f242325e3de6ec59c9982b0e04b294f81f145dbe17038be9e7346f0639
BLAKE2b-256 checksum
How to use checksums
8dbd9f307f3ac66a6955041fedb2f8af399dad0be35e521cba8e14c03548c2f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

Release files / django2_url_robots-3.2.2-py3-none-any.whl

Download URL django2_url_robots-3.2.2-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f93f3ca88ac9963dfab1d694ea89564f2e9abbf25e8453c61cb2942b722cb3b3
BLAKE2b-256 checksum
How to use checksums
ed2cef130863c305510646e560933aa9b3e48deabda6228437ddf4ed0f1de1a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

Security for django2-url-robots 3.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page