2012-12-10 4 views
2

내가 관리자 페이지를 보려고 할 때이 오류가 무엇입니까 :장고 MongoDB를 SITE_ID 오류

InvalidId at /admin/ 

AutoField (default primary key) values must be strings representing an ObjectId on MongoDB (got u'1' instead). Please make sure your SITE_ID contains a valid ObjectId string. 

Request Method:  GET 
Request URL: http://127.0.0.1:8000/admin/ 
Django Version:  1.3 
Exception Type:  InvalidId 
Exception Value:  

AutoField (default primary key) values must be strings representing an ObjectId on MongoDB (got u'1' instead). Please make sure your SITE_ID contains a valid ObjectId string. 
... 

그래서 내가 주위를 봤와 나는 그래서 추가

./manage.py tellsiteid 
The default site's ID is u'50c5766e62f11f41f0332e65'. To use the sites framework, add this line to settings.py: 
SITE_ID=u'50c5766e62f11f41f0332e65' 

다음을 수행해야한다는 생각을 그것 내 내 settings.py :

DEBUG = True 
TEMPLATE_DEBUG = DEBUG 
SITE_ID = u'50c5766e62f11f41f0332e65' 
... 

나는 여전히 같은 오류 메시지가 나타납니다. syncdb을 실행하거나 서버를 다시 시작해야합니까? 왜냐하면 나는 둘 다했기 때문에 여전히 같은 오류가 발생하고 있습니다. 내가 파이썬 쉘에서 SITE_ID의 값을보고했는데, 확실히 충분히 한

편집 ...

$ python manage.py shell 
Python 2.7.3 (default, Aug 1 2012, 05:14:39) 
[GCC 4.6.3] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
(InteractiveConsole) 
>>> from concepts.settings import * 
>>> SITE_ID 
1 

그러나 git diff 명확하게, 내가 설정 파일을 변경 한 것을 보여줍니다 권리?

$ git diff 
diff --git a/settings.py b/settings.py 
index 586ea3a..bb069ed 100644 
--- a/settings.py 
+++ b/settings.py 
@@ -2,6 +2,7 @@ 

DEBUG = True 
TEMPLATE_DEBUG = DEBUG 
+SITE_ID = u'50c5766e62f11f41f0332e65' 

ADMINS = (
    # ('Your Name', '[email protected]'), 
... 

여기서 내가 뭘 잘못하고 있니?

답변

5

Ohhhh 바보. 코드의이 라인은 settings.py 이후에 나타나

# Language code for this installation. All choices can be found here: 
# http://www.i18nguy.com/unicode/language-identifiers.html 
LANGUAGE_CODE = 'en-us' 

SITE_ID = 1 

# If you set this to False, Django will make some optimizations so as not 
# to load the internationalization machinery. 
USE_I18N = True 
... 

그래서 나는 단순히 u'50c5766e62f11f41f0332e65'에 거기에 하나를 변경하고 지금은 작동한다!

0

동일한 문제가 있었지만 내 settings.py에서 SITE_ID를 변경해도 문제가 해결되지 않았습니다. 나는 INSTALLED_APPS에서 line 'django.contrib.sites'에 주석을 달았고 syncdb는 올바르게 끝났다. (사이트 애플리케이션은 거의 아무도 필요하지 않을 것 같은 어플리케이션으로 보인다.) 그래서