Log in

Clarifications about how to integrate Spirit in an existent project ?

FredericFrédéric Bentz

Hi,
I read the installation steps, but this is unclear, you say absolutely nothing about how to integrate Spirit in an existent project. While this is certainly the most frequent case.

1 - Install Spirit -> OK
2 - Start your site -> This is the first problem, my site is already started...
Should I run the command spirit startproject mysite and if so, where ? from the root folder ?
3 - Set up the database -> Is this compatible whit the django model already in place ?
4- Create an administrator account: This was already done for the Project itself. Should I do something more ?

I would greatly appreciate detailed explanations for all of this steps to avoid some unwelcome surprises.
Thx

nitelyEsteban Castro Borsani

[...] integrate Spirit in an existent project [...] is certainly the most frequent case.

Not really, but ok.

2 - Start your site -> This is the first problem, my site is already started...
Should I run the command spirit startproject mysite and if so, where ? from the root folder ?

You should start a new project, then add all the spirit settings and urls into your existing project. There are no docs for this because settings change and I don't like updating docs.

3 - Set up the database -> Is this compatible whit the django model already in place ?

Once spirit is installed, and step 2 is done, run the spiritinstall command in your existing project (which runs django migrations and collect static assets). Spirit uses all Django built-in contrib apps, and it expects the standard models, for example if you have done weird things like overriding the user model or used your own user model then it won't work, but otherwise it will work just fine.

4- Create an administrator account: This was already done for the Project itself. Should I do something more ?

A superuser is all you need. The migrations take care of creating the Spirit profiles.

nitelyEsteban Castro Borsani
  • 22 Jul

There is one last thing, Spirit usernames are case-insensitive by default. If you existing site has many users, you may want to disable this, otherwise the migrations will fail if there are clashing usernames. You will get an error message explaining this. To make usernames case-sensitive set ST_CASE_INSENSITIVE_USERNAMES setting to False.

Also, you may want to use your own auth app (login, register, etc), that should be fine. Spirit will use whatever the LOGIN_URL is.

ojophilipOjo Philip Odeniyi
  • 29 Jul

Thanks for prompt responses. Your reply about adding spirit settings into existing project is not well understood by me. My concern is about the setting that came with the project, will that be deleted? Also , can the spirit settings be merged into a single file

nitelyEsteban Castro Borsani
  • 29 Jul

will that be deleted?

No. You'd open both Spirit (base.py) and your project settings files in a text editor (VSCode, Pycharm, etc) and manually copy/paste the spirit settings into your project. For example you'd add all django.contrib apps, spirit.core, spirit.admin, etc to your project INSTALLED_APPS; same with every other setting in there. Basically, merge both settings files into one.

You need to do this with urls.py as well.

base.py is your regular Django settings.py file. It's called "base" because I prefer it that way. I use several environments and settings (tests, dev, and prod), and import base from those, that way I can easily pick whatever setting I want to use without duplicating all settings in every file.

ojophilipOjo Philip Odeniyi
  • 30 Jul

Thanks very much, I will give it a try

ojophilipOjo Philip Odeniyi
  • 30 Jul

I got the following error when I ran spiritinstall command.

ModileNotFoundError: no module name debug_toolbar.

How do I solve this issue. Thanks

ojophilipOjo Philip Odeniyi

Thanks I've solved it by removing debug_toolbar from installed apps

I second that it would be nice to have a page that lists some basic instructions on how to get it up and running as an app in an existing django site. There are lots of high quality, 100% open source "forum in a box" apps out there (discourse, etc.) so it would seem that spirit could occupy the 'would rather just have one deployment' niche for django sites... Maybe a .md file that you only accept PRs for and never have to update yourself? A page on the Github wiki?

Reply