jijo-paulose / django-profile

Automatically exported from code.google.com/p/django-profile
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Import from django.settings insteed of importing from just settings. #7

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Running a fresh copy from the svn, raise an ImportError: "No module named
settings"

To solve, change in the line 5 from the profile/models.py

5# from settings import MEDIA_URL
to:
5# from django.settings import MEDIA_URL

Original issue reported on code.google.com by marioces...@gmail.com on 12 Apr 2008 at 11:46

Attachments:

GoogleCodeExporter commented 9 years ago
This is a better fix to use:
#5 from django.conf.settings import MEDIA_URL

Original comment by marioces...@gmail.com on 12 Apr 2008 at 11:52

GoogleCodeExporter commented 9 years ago
The same issue for the urls.py

The definitive fix would be import the settings as:

> from django.conf import settings

And call, the MEDIA_URL and APIKEY as:

> settings.MEDIA_URL
> settings.APIKEY

Original comment by marioces...@gmail.com on 12 Apr 2008 at 11:59

GoogleCodeExporter commented 9 years ago
Hi, the variables MEDIA_URL and APIKEY must reside in the project settings.py 
file.
On your patch you're refering to this variables on the global settings.py file, 
and
this is not a good solution.

You must have the project directory on your PYTHONPATH so it can find 
settings.APIKEY
and settings.MEDIA_URL when it needs it.

Look at the "demo" project, is really simple and you can get a closer look of 
how
this is done.

Original comment by david.ru...@gmail.com on 14 Apr 2008 at 9:09

GoogleCodeExporter commented 9 years ago
I am with the last SVN version of Django, I don't know if this is the problem. 
But
django-profile doesn't work as the demo says.

On the django oficial docs, I read: 
from django.conf.settings import DEBUG  # Won't work.

And as for example on profile/models.py you import like this:
from settings import MEDIA_URL

I am quite confuse as you can see:(
I change the above line to:
from django.conf import settings

As many others apps do, and works well, I am using Apache+modpython and have 
many
others apps, so I import the DJANGO_SETTINGS for each project on a .htaccess, 
like
django docs recommend.

I am not quite sure, if Am I wrong or note, I notes you ver confident with 
this. So
If this is a bug or not, I would like to understand it. 

Best regards from Bolivia.

Original comment by marioces...@gmail.com on 14 Apr 2008 at 5:34

GoogleCodeExporter commented 9 years ago
Mario, you were right and I was wrong.

The correct method to import a setting is like you say.

The django documentation says it clearly:

http://www.djangoproject.com/documentation/settings/#using-settings-in-python-co
de

I'm going to correct it on the SVN. 

Thanks for the report.

Original comment by david.ru...@gmail.com on 15 Apr 2008 at 2:14

GoogleCodeExporter commented 9 years ago

Original comment by david.ru...@gmail.com on 14 Jun 2008 at 11:21