Django admin interface for core models

class readthedocs.core.admin.UserAdminExtra(model, admin_site)

Admin configuration for User.

class readthedocs.core.admin.UserProjectFilter(request, params, model, model_admin)

Filter users based on project properties

queryset(request, queryset)

Add filters to queryset filter

PROJECT_ACTIVE and PROJECT_BUILT look for versions on projects, PROJECT_RECENT looks for projects with builds in the last year


Forms for core app.

class readthedocs.core.forms.FacetField(choices=(), required=True, widget=None, label=None, initial=None, help_text=u'', *args, **kwargs)

For filtering searches on a facet.

Has validation for the format of facet values.


Although this is a choice field, no choices need to be supplied.

Instead, we just validate that the value is in the correct format for facet filtering (facet_name:value)

class readthedocs.core.forms.FacetedSearchForm(*args, **kwargs)

Supports fetching faceted results with a corresponding query.

A list of facet names for which to get facet counts
Limit the search to one or more models


Middleware for core app.

class readthedocs.core.middleware.FooterNoSessionMiddleware

Middleware that doesn’t create a session on logged out doc views.

This will reduce the size of our session table drastically.

class readthedocs.core.middleware.ProxyMiddleware

Middleware that sets REMOTE_ADDR based on HTTP_X_FORWARDED_FOR, if the

latter is set. This is useful if you’re sitting behind a reverse proxy that causes each request’s REMOTE_ADDR to be set to Note that this does NOT validate HTTP_X_FORWARDED_FOR. If you’re not behind a reverse proxy that sets HTTP_X_FORWARDED_FOR automatically, do not use this middleware. Anybody can spoof the value of HTTP_X_FORWARDED_FOR, and because this sets REMOTE_ADDR based on HTTP_X_FORWARDED_FOR, that means anybody can “fake” their IP address. Only use this when you can absolutely trust the value of HTTP_X_FORWARDED_FOR.

class readthedocs.core.middleware.SingleVersionMiddleware

Reset urlconf for requests for ‘single_version’ docs.

In settings.MIDDLEWARE_CLASSES, SingleVersionMiddleware must follow after SubdomainMiddleware.

class readthedocs.core.middleware.SubdomainMiddleware

Middleware to display docs for non-dashboard domains


Process requests for unhandled domains

If the request is not for our PUBLIC_DOMAIN, or if PUBLIC_DOMAIN is not set and the request is for a subdomain on PRODUCTION_DOMAIN, process the request as a request a documentation project.


Models for the core app.

class readthedocs.core.models.UserProfile(*args, **kwargs)

Additional information about a User.


Gets the line to put into commits to attribute the author.

Returns a tuple (name, email)


Core views, including the main homepage,

documentation and header rendering, and server errors.

readthedocs.core.views.server_error_404(request, exception, template_name='404.html')

A simple 404 handler so we get media

readthedocs.core.views.server_error_500(request, exception, template_name='500.html')

A simple 500 handler so we get media

This is where custom commands are defined.

Rebuild documentation for all projects

Clean up stable build paths per project version

Import a project’s programming language from GitHub

This builds a basic management command that will set a projects language to the most used one in GitHub.

Requires a GITHUB_AUTH_TOKEN to be set in the environment, which should contain a proper GitHub Oauth Token for rate limiting.

Resync GitHub project for user

Trigger build for project slug

Reindex Elastic Search indexes

Generate metadata for all projects

Update symlinks for projects

Build documentation using the API and not hitting a database.


./ update_api <slug>

Custom management command to rebuild documentation for all projects.

Invoked via ./ update_repos.

class, stderr=None, no_color=False)

Management command for rebuilding documentation on projects

Rebuild documentation for all projects