# Integrating with an existing project

• 1
• 13 May '14

Hello, I really like where you are going with Spirit.

I'm interested in integrating with an existing django 1.5 project that uses a custom user model.
Any tips on what would need to be done to add spirit to an existing project?

Thanks

nitelyEsteban Castro Borsani
• 2
• 13 May '14

It depends on how customized your model is. As long as your model has all the default django user model fields you will be fine

It should be straightforward. Just look at models/user.py, AbstractUser is the perfect example.
That's probably what you have now, right? a model that inherits from (AbstractBaseUser, PermissionsMixin), just add AbstractForumUser to the mix and you are done.

If you are just adding some fields, I'd recommend you to use the Spirit User Model and to extend it. The only difference between the two models (django vs spirit) is the email field which is unique. In that case your model should inherit from AbstractUser.

Make sure to add from spirit.settings import * to the top of your settings.py. Check the spirit/settings.py file, If you are overwriting anything you will have to add whatever change Spirit needs. Or even better, just append to it: ie: MIDDLEWARE_CLASSES += ('myapp.middleware.MyMiddleware, ...).

Let me know how it goes, it can be helpful to other people

nitelyEsteban Castro Borsani
• 16 May '14

@diydan

I'm interested in integrating with an existing django 1.5 project

Sorry, I missed that statement. Spirit requires Django 1.6, It won't work in older versions.

• 13 Jun '14

Hello, I also am quite interested in using Spirit with a django project I have started. I am still fairly new to python/django but this seems to do exactly what I am looking for.

I was wondering if there was a clearly spelled out way to do this. I am running python 2.7 and Django 1.6.5.
But I saw something about needing pillow, markdown, woosh and maybe some other things. And I'm not sure, do I pip those guys or how do I get them?

nitelyEsteban Castro Borsani
• 1
• 13 Jun '14

You will be better of intalling Spirit from pypi. Just run pip install django-spirit then follow the installing guide (you can skip the pip install -r requirements step since pip install Spirit will do that for you)

• 2
• 17 Jun '14

I tried pip install Spirit, but it said it couldn't find any downloads that satisfied the requirement Spirit.

**EDIT: I got it all installed, I just didn't use pip.

But what url will bring me to the 'home' page of the forums? I've never handled a django bit this complex before (only ever used 1 url.py).

**EDIT:EDIT: NEvermind, I got it. Thank you, this forum system is awesome.

nitelyEsteban Castro Borsani
• 17 Jun '14

Sorry, It is pip install django-spirit, I'm glad you got it installed.

• 27 Jun '14

So this time I used pip to install Spirit (my last project got some major issues and I had to scrap it).

When I go to syncdb this in my project I am getting an error:
ImproperlyConfigured("AUTH_USER_MODEL refers to model '%s' that has not been installed" % settings.AUTH_USER_MODEL)
django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers t model 'spirit.user' that has not been installed.

nitelyEsteban Castro Borsani
• 2
• 28 Jun '14

@nickfish

So this time I used pip to install Spirit (my last project got some major issues and I had to scrap it).

So you probably have your own settings.py file (not the one from example/settings.py), right?
Check if this is the same issue (skip to the last comment).

Let me know if that helps.

• 28 Jun '14

Thank you, that worked.. kind of. I now have a fairly serious issue that I suspected was partly caused by the forums last time it happened.

Now that this installs correctly, it basically destroys django's built in user system. It tells me the auth user is stale and needs to be deleted. In my last project this removed all access to it (before I even received this error in the command line). What does this mean?

nitelyEsteban Castro Borsani
• 9
• 28 Jun '14

That's because the old auth.User model gets swapped by the new one (the default in Spirit or your own extending the one in Spirit).
To fix this you can make a datamigration with South.
Then you can manually delete the auth.User table or just let be.

As a side note, you should stop doing from django.contrib.auth.models import User and do from django.contrib.auth import get_user_model followed by User = get_user_model() instead.
Every model that has a user = models.ForeignKey(User) field should be change to user = models.ForeignKey(settings.AUTH_USER_MODEL).
Lastly, every model that has a relationship with settings.AUTH_USER_MODEL will require a South schemamigration. If you want to avoid this, read this
This also applies to third-party apps.

There is a complete migration guide here, the important steps are from #9 onwards.

The following content types are stale and need to be deleted:

auth | user

Any objects related to these content types by a foreign key will also
be deleted. Are you sure you want to delete these content types?
If you're unsure, answer 'no'.

When you receive this message it is ok to write yes. It won't delete the auth.User table or the data.
There's an app called django.contrib.contenttypes that holds a reference to every model/table. By writing yes, django will remove that reference, it's ok since you are no longer using the auth.User.

nitelyEsteban Castro Borsani
• 30 Jun '14

I made a guide on how to migrate an existing (live) project here.
Of course, if your project is new and doesn't has data, you will be better off just dropping the django.contrib.auth app.

tiresP Clap
• 31 Jan '15

Any thoughts or tips on decoupling registration from django-spirit? For instance, I'd like to use django-allauth to handle the registration process since that's what I'm already using. Any thoughts on using an app that handles avatars like django-user-media and django-awesome-avatar instead of pointing users to gravatar? Thanks! This is a very promising app.

• 4 Dec '18

@nickfish said:
So this time I used pip to install Spirit (my last project got some major issues and I had to scrap it).

When I go to syncdb this in my project I am getting an error:
ImproperlyConfigured("AUTH_USER_MODEL refers to model '%s' that has not been installed" % settings.AUTH_USER_MODEL)
django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers t model 'spirit.user' that has not been installed.

lorem ipsum dolor

• Page 1 of 1