{"id":13502702,"url":"https://github.com/raiderrobert/django-multiurl","last_synced_at":"2025-04-06T05:15:17.537Z","repository":{"id":7807009,"uuid":"9177536","full_name":"raiderrobert/django-multiurl","owner":"raiderrobert","description":"Have you ever wanted multiple views to match to the same URL? Now you can.","archived":false,"fork":false,"pushed_at":"2023-08-24T18:31:14.000Z","size":63,"stargazers_count":274,"open_issues_count":4,"forks_count":30,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-05-01T13:42:18.181Z","etag":null,"topics":["404","django","exception-handling","python","routing","url"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raiderrobert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2013-04-02T19:00:15.000Z","updated_at":"2024-03-20T20:21:23.000Z","dependencies_parsed_at":"2024-01-18T07:57:04.768Z","dependency_job_id":"8e2662a2-8e09-480b-b3e0-be5c965e2adf","html_url":"https://github.com/raiderrobert/django-multiurl","commit_stats":{"total_commits":62,"total_committers":12,"mean_commits":5.166666666666667,"dds":0.4838709677419355,"last_synced_commit":"e0163cdd3c5ec6c8d843223b95de58a90250c63a"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raiderrobert%2Fdjango-multiurl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raiderrobert%2Fdjango-multiurl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raiderrobert%2Fdjango-multiurl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raiderrobert%2Fdjango-multiurl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raiderrobert","download_url":"https://codeload.github.com/raiderrobert/django-multiurl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247436284,"owners_count":20938533,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["404","django","exception-handling","python","routing","url"],"created_at":"2024-07-31T22:02:22.847Z","updated_at":"2025-04-06T05:15:17.401Z","avatar_url":"https://github.com/raiderrobert.png","language":"Python","readme":"# django-multiurl\n\n\nHave you ever wanted multiple views to match to the same URL? Now you can.\n\nYou may once have tried something like this::\n\n    urlpatterns = [\n        url('/app/(\\w+)/$', app.views.people),\n        url('/app/(\\w+)/$', app.views.place),\n    ]\n\nHowever, if you try this, ``/app/san-francisco/`` will only map to\n``app.views.people``. Raising an ``Http404`` from ``app.views.people`` doesn't\nhelp: you only get a 404 in the browser because Django stops resolving\nURLs at the first match.\n\nWell, ``django-multiurl`` solves this problem. Just \n``pip install django-multiurl``, then do this::\n\n    from multiurl import multiurl\n\n    urlpatterns = [\n        multiurl(\n            url('/app/(\\w+)/$', app.views.people),\n            url('/app/(\\w+)/$', app.views.place),\n        )\n    ]\n\nNow in your views, raise ``multiurl.ContinueResolving`` anywhere you'd like\nto break out of the view and keep resolving. For example, here's what\n``app.views.people`` might look like::\n\n    from multiurl import ContinueResolving\n\n    def people(request, name):\n        try:\n            person = Person.objects.get(name=name)\n        except Person.DoesNotExist:\n            raise ContinueResolving\n        return render(...)\n\nThat's it! ``ContinueResolving`` will cause ``multiurl`` to continue onto the\nnext view (``app.views.place``, in this example).\n\nA few notes to round things out:\n\n* If you don't want to use ``ContinueResolving`` -- perhaps you'd rather\n  continue using ``get_object_or_404``, or you're using third-party views\n  that you can't modify to raise ``ContinueResolving``, you can pass a\n  ``catch`` argument into ``multiurl`` to control which exceptions are\n  considered \"continue\" statements. For example, to allow ``Http404``\n  exceptions to continue resolving, do this::\n\n        urlpatterns = [\n            multiurl(\n                url('/app/(\\w+)/$', app.views.people),\n                url('/app/(\\w+)/$', app.views.place),\n                catch = (Http404, ContinueResolving)\n            )\n        ]\n\n  As you can see, ``catch`` should be a tuple of exceptions. It's probably a\n  good idea to always include ``ContinueResolving`` in the tuple.\n\n* If the last view in a ``multiurl`` raises ``ContinueResolving`` (or another\n  \"continuing\" exception), a 404 will be raised instead. That is, if resolving\n  \"falls off the end\" of some multi-urls, you'll get the 404 you expect.\n\n* Reverse URL resolution just works as expected. Name your sub-URLs and then\n  reverse your heart out.\n\nContributing\n------------\n\nDevelopment takes place\n`on GitHub \u003chttp://github.com/jacobian/django-multiurl\u003e`_; pull requests are\nwelcome. Run tests with `tox \u003chttp://tox.readthedocs.org/\u003e`_.\n","funding_links":[],"categories":["Python","\u003ca name=\"Python\"\u003e\u003c/a\u003ePython"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraiderrobert%2Fdjango-multiurl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraiderrobert%2Fdjango-multiurl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraiderrobert%2Fdjango-multiurl/lists"}