24

I installed the registration module, added it to settings.py. When I tried to run syncdb (% python sitename/manage.py syncdb --settings sitename.devsettings)

It gave me "Error: No module named registration"

The same setup works (using the same files for everything) fine on the server. This happens on my local machine running OS X.

I checked the sys.path, the path where registration module resides is listed, and the actual module is in place as well. Since there is not much else being outputted, I am not sure how to debug further. What could be causing this problem?

16 Answers 16

30

Since this page ranks nicely in Google, it seems like a good place for a general answer that might help. Sometimes the folder name in svn/git is different than the folder name in settings.py -- a trap for the unwary.

So, if INSTALLED_APPS references your stuff as mywhatever.someapp then it is likely you want settings.py to be in the "mywhatever" folder, with a subfolder "someapp" that contains an __init__.py file.

3
  • +1 - This will likely help other newbies like myself. Thanks!
    – sage
    Sep 2, 2012 at 2:11
  • I always forget to do this when I create an "apps" folder and I pull my hair out (well, I have no hair, but you get the point) until I remember to put an init.py file in the apps folder. Oct 3, 2012 at 4:10
  • INSTALLED_APPS seems to list all of the pip packages used by the Django app. None of those have folders directly in the Django project where settings.py is?
    – Hack-R
    Nov 11, 2016 at 18:35
15

You mention sys.path so you might have tried this, however this was my problem and I'm sure some people reading this have it too.

open the command prompt and enter (with the trailing slash):

export PYTHONPATH=pathto/myproject/

then enter:

export DJANGO_SETTINGS_MODULE=settings

This allows me to edit the settings.py file to list the INSTALLED_APPS like this:

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'myapp',
    'registration',
 )

instead of:

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'myproject.myapp',
    'myproject.registration',
)
1
  • '...myproject.settings'
    – Josh
    Oct 5, 2018 at 9:31
11

I was simply missing a comma after the 'registration' entry in the settings.py file. Once I added the comma after 'registration', Syncdb worked for me.

1
  • Im embarrassed to say this was my problem too
    – Trevor
    Jul 31 at 1:33
8

There may be Python errors in your registration models. Try starting a shell and importing them, instantiating them, etc.

7

just do this in your virtualenv

pip install django-registration

1
  • also check to make sure you didn't install dif v of registration (i.e. django-registration-redux, et. all)
    – azochz
    Jun 7, 2017 at 1:05
5

Fixed! I had the same problem, I was trying to register submodules, like:

project
 organization
    categories

In my settings file I added

> INSTALLED_APPS = (
>     'django.contrib.admin',
>     'django.contrib.auth',
>     'django.contrib.contenttypes',
>     'django.contrib.sessions',
>     'django.contrib.sites',
>     ...
>     'organization.categories',  )

When you generate a module in the folder categories you have a init.pyc I copied this file into "organization" folder, then I execute the following commands:

sudo python manage.py makemigrations
sudo ./manage.py syncdb

And it works file!

4

I had this problem. I had saved the app in the project folder (as in, the same folder as manage.py), but referenced to "projectname.appname" instead of just "appname" in INSTALLED_APPS in settings.py.

2

I had this on SX with virtualenv too, after installing with PIP as per the docs. I did another install using easy_install and after that, it all worked.

easy_install -Z django-registration
2

I've faced this problem until a figured out that the enviroment was not activated.

Check if your Virtualenv is activated. If not, run in the shell

source .<enviroment name>/bin/activate 
1
  • And also check if the environment you wanted is activated
    – hiroorih
    Apr 14, 2021 at 18:40
1

Make sure you have an entry in installed_apps, And you have the minimum 4 files in your apps. init.py, urls.py, models.py, and views.py

0

My first guess would be you haven't added 'registration' into installed apps in the settings.py file.

Perhaps you are using a different settings.py (Or localsettings.py) on the server.

1
  • That wouldn't give that error. Anyway, he specifically states he has added it to settings.py. Jun 8, 2009 at 17:02
0

Just try this

1) Put down the registration app inside your project as an app

and do the syncdb


do the below for finding out the exact cause of error

1.go to you project directory
2.python manage.py dbshell
3.in shell
4.import registration   
5.if you get error here which means your registration module is  not
there on the python path (or) some problem in finding that one.
if it works then some other problem like improper compilation .............
0
0

If this happens to you on Windows and while using virtualenv, it's possibly because of virtualenv.

Install that package on the local (non virtualenv) environment and it should work.

I had the same problem with django-crispy-forms.

0

When I've installed django-registration to my virtual env, I've had the same error. Don't know how it worked exactly, but when I've installed this lib to the main Python directory (not virtual env) the error has disappeared.

Maybe It will help to someone.

0

I had the same issue, was following old course, it creates a folder that has '-' in its name and puts all the modules in it.

the name was like "portfolio-project" but I change it to "portfolio_project", solved the problem with importing

import portfolio_project.jobs.views

not

import jobs.views
-1

I ran into this problem because I was messing up with my virtualenv.

I had two windows open:

  1. Running the server
  2. Running my commands

I had successfully installed the Django-registration package into my venv on my Windows computer:

$ . venv/Scripts/activate
$ pip install Django-registration-redux==2.0

But my server was not in the venv, so it could not find the package.

Stopped the server, entered venv in that window, then restarted the server and all is good.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.