FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects

feat: make API optional

Merged Dr Rich Wareham requested to merge make-api-optional into master
1 unresolved thread

Add include_api to the cookiecutter context. If set to NO then the api module won't be included. This is mostly useful for tiny "pure Django" apps with the traditional request -> render webapp model.

Tweak the logic surrounding adding Django social auth. In general we assume that apps with UI disabled but API enabled are "pure API" applications and don't need social auth. Any other combination results in social auth being added.

Tested by bootstrapping a new Django project for the Regent House Ballot voting site.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
58 60 "django.contrib.sessions",
59 61 "django.contrib.messages",
60 {%- if cookiecutter.include_ui == 'YES' %}
61 62 "whitenoise.runserver_nostatic", # use whitenoise even in development
62 {%- endif %}
63 63 "django.contrib.staticfiles",
64 {%- if cookiecutter.include_api == 'YES' %}
64 65 "crispy_forms",
65 66 "django_filters",
66 67 "drf_spectacular",
67 68 "rest_framework",
68 69 "rest_framework.authtoken",
69 {%- if cookiecutter.include_ui == 'YES' %}
70 "social_django",
71 70 {%- endif %}
71 "social_django",
  • always include `socialauth`?

  • I don't think it would ever make sense for pure API backends. There's the rare corner-case of enabling the admin for a pure API app as we're doing in org chart but I'd rather people explicitly have to opt-in for that.

    Otherwise we're requiring the faff of making OAuth2 credentials for pure-API applications which are never going to use them.

  • Oh, wait, I see. This is always including the app, even though we claim we aren't. Yes, that's a bug. And I'm surprised that the automated tests didn't catch that.

  • Ah, the pyroject.toml file has the same bug which explains the lack of test suite failure. I'll fix.

  • Now fixed in rev 2 of the MR.

  • Please register or sign in to reply
  • Dr Rich Wareham added 1 commit

    added 1 commit

    Compare with previous version

  • Dr Abraham Martin approved this merge request

    approved this merge request

  • Dr Rich Wareham mentioned in commit 484a381e

    mentioned in commit 484a381e

  • Please register or sign in to reply
    Loading