Skip to content

Conversation

@alexbainter
Copy link
Collaborator

Closes #175.

Adds Permanent URLs.

Overview

  • Adds the PermanentURL model with fields for url (which stores the full URL) and for linking to either a Schema or a SchemaRef using Django's contenttypes framework.
  • Adds a PERMANENT_URL_HOST setting (so we can use id.schemas.pub in production without completely* breaking other environments.
    • Permanent URLs are always stored without their port number and with https, so they don't quite work right out of the box locally (that is, the full url stored in the local database doesn't quite work as-is, but you can just change it to http and add the port number to get it to resolve locally)
  • Adds a view to catch paths like /o/anything, redirect them to the appropriate object if a matching PermanentURL exists, or 404 otherwise
  • Adds a form for viewing and adding permanent URLs for a schema/schemaref, accessible from the profile page for public schemas only.
  • Updates the schema and schema ref detail pages to show permanent URLs

Assumptions/limitations/future work

  • For now, only users in an organization can create permanent URLs for their schemas.
  • All permanent URLs will be stored with "https", but the server will actually match https or http.

Profile page showing links to permanent URL management form
Screenshot From 2026-02-02 14-46-20
Permanent URL management form with no existing links
Screenshot From 2026-02-02 14-46-43
Permanent URL management form with existing links
Screenshot From 2026-02-02 14-54-54
Permanent links displayed on detail page
Screenshot From 2026-02-02 14-55-24

@alexbainter alexbainter requested a review from lisad February 4, 2026 17:33
('created_by', models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, to=settings.AUTH_USER_MODEL)),
],
options={
'indexes': [models.Index(fields=['content_type', 'object_id'], name='core_perman_content_aa1d0b_idx')],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this index intentional ? If we do want it to make URL lookups fast, wouldn't it be to the URL instead of the object ID?

Together with the unusual dependencies, not just 'core' in the dependencies list above, I wonder if this is necessary?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NM I get it, because it's using the generic foreign key

@alexbainter alexbainter merged commit d14ea00 into main Feb 4, 2026
8 checks passed
@alexbainter alexbainter deleted the alex-175-permalinks branch February 4, 2026 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add persistent URLs

2 participants