Re: Django admin templates not loading
Hi Karen, Thank you for pointing this out. I followed your advise and it works beautifully. As you see, I am a newbie to all these. On another subject, is there a preferred location to put the production website(s) files/directories on Linux? Is it right to put them in /var/www/ or should I put them in /Users/my_name/??? How should I set the permission of the files/ directories under the production sites' directories? Should I set the user/group to be apache, root, or just under my_name? Please advise. Simon On Sep 9, 7:52 pm, Karen Tracey wrote: > On Wed, Sep 9, 2009 at 7:23 AM, Simon Lee wrote: > > > Hi All, > > > I am following the tutorial in the Django website (writing your first > > django app) and get it to work on the development server. However, > > when I port to Apache, the admin template is not loaded and thus I > > could not get the nice Django UI with Apache. I try copying the > > default django admin templates into my project root and add the path > > to the TEMPLATE_DIRS in settings.py but still cannot get the django UI > > in the login page and the admin dashboard. > > > Below is my settings: > > > OS: Fedora 11 > > Apache: 2.2 with mod_wsgi > > Django: 1.1 > > > [snip] > > Settings.py > > > [snip] > > # URL prefix for admin media -- CSS, JavaScript and images. Make sure > > to use a > > # trailing slash. > > # Examples: "http://foo.com/media/";, "/media/". > > ADMIN_MEDIA_PREFIX = '/media/' > > > [snip] > > When I typed inhttp://127.0.0.1:8000/myapp/adminin the browser when> the > development server runs the code. The output is perfect. > > > When the development server is not running and I typed in > >http://localhost/myapp/admin, it prompt me the login page but without > > all the styling as before. I can login and go to the admin dashboard > > page but again the display is not with the django admin template. > > Missing styling means missing CSS, and has nothing to do with templates. > The fact that the pages are getting delivered without template not found > exceptions means there is not a problem with templates (and you should un-do > copying the admin templates into your own tree as that is likely just to > cause confusion down the road.) > > You need to set up your Apache server to serve the admin media files (which > will have urls starting with ADMIN_MEDIA_PREFIX). These are static files > and so not served by Django, except when you are running the development > server there is an admin media server that automagically serves them out of > the Django source tree. The files are located under > django/contrib/admin/media. The doc for setting up static file serving with > mod_wsgi is here: > > http://docs.djangoproject.com/en/dev/howto/deployment/modwsgi/#servin... > > Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django admin templates not loading
On Wed, Sep 9, 2009 at 7:23 AM, Simon Lee wrote: > > Hi All, > > I am following the tutorial in the Django website (writing your first > django app) and get it to work on the development server. However, > when I port to Apache, the admin template is not loaded and thus I > could not get the nice Django UI with Apache. I try copying the > default django admin templates into my project root and add the path > to the TEMPLATE_DIRS in settings.py but still cannot get the django UI > in the login page and the admin dashboard. > > Below is my settings: > > OS: Fedora 11 > Apache: 2.2 with mod_wsgi > Django: 1.1 > > [snip] > Settings.py > > [snip] > # URL prefix for admin media -- CSS, JavaScript and images. Make sure > to use a > # trailing slash. > # Examples: "http://foo.com/media/";, "/media/". > ADMIN_MEDIA_PREFIX = '/media/' > > [snip] When I typed in http://127.0.0.1:8000/myapp/admin in the browser when > the development server runs the code. The output is perfect. > > When the development server is not running and I typed in > http://localhost/myapp/admin, it prompt me the login page but without > all the styling as before. I can login and go to the admin dashboard > page but again the display is not with the django admin template. > > Missing styling means missing CSS, and has nothing to do with templates. The fact that the pages are getting delivered without template not found exceptions means there is not a problem with templates (and you should un-do copying the admin templates into your own tree as that is likely just to cause confusion down the road.) You need to set up your Apache server to serve the admin media files (which will have urls starting with ADMIN_MEDIA_PREFIX). These are static files and so not served by Django, except when you are running the development server there is an admin media server that automagically serves them out of the Django source tree. The files are located under django/contrib/admin/media. The doc for setting up static file serving with mod_wsgi is here: http://docs.djangoproject.com/en/dev/howto/deployment/modwsgi/#serving-media-files Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django admin templates not loading
Hi All, I am following the tutorial in the Django website (writing your first django app) and get it to work on the development server. However, when I port to Apache, the admin template is not loaded and thus I could not get the nice Django UI with Apache. I try copying the default django admin templates into my project root and add the path to the TEMPLATE_DIRS in settings.py but still cannot get the django UI in the login page and the admin dashboard. Below is my settings: OS: Fedora 11 Apache: 2.2 with mod_wsgi Django: 1.1 -- Projects/App: /var/www/mysite/ apache/ myapp.wsgi polls/ admin.py __init__.py models.py tests.py templates/ admin/ base_site.html __init__.py manage.py settings.py urls.py -- Settings.py # Django settings for mysite project. DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Your Name', 'your_em...@domain.com'), ) MANAGERS = ADMINS DATABASE_ENGINE = 'postgresql_psycopg2' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. DATABASE_NAME = 'mytestdb' # Or path to database file if using sqlite3. DATABASE_USER = 'postgres' # Not used with sqlite3. DATABASE_PASSWORD = '' # Not used with sqlite3. DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name # although not all choices may be available on all operating systems. # If running in a Windows environment this must be set to the same as your # system time zone. TIME_ZONE = 'America/Chicago' # 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 # Absolute path to the directory that holds media. # Example: "/home/media/media.lawrence.com/" MEDIA_ROOT = '' # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash if there is a path component (optional in other cases). # Examples: "http://media.lawrence.com";, "http://example.com/media/"; MEDIA_URL = '' # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a # trailing slash. # Examples: "http://foo.com/media/";, "/media/". ADMIN_MEDIA_PREFIX = '/media/' # Make this unique, and don't share it with anybody. SECRET_KEY = 'rg+av$-m5%#hs47_^24c54wi!*gauqz4ya1o*^0vjo7&xh3=n&' # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.load_template_source', 'django.template.loaders.app_directories.load_template_source', # 'django.template.loaders.eggs.load_template_source', ) MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', ) ROOT_URLCONF = 'mysite.urls' TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/ django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. '/var/www/mysite/templates', ) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'mysite.polls', 'django.contrib.admin' ) -- myapp.wsgi import os import sys sys.path.append('/var/www') os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() --- urls.py from django.conf.urls.defaults import * from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', (r'^admin/', include(admin.site.urls)), ) --- When I typed in http://127.0.0.1:8000/myapp/admin in the browser when the development server runs the code. The output is perfect. When the development server is not running and I typed in http://localhost/myapp/admin, it prompt me the login page but without all the styling as before. I can login and go to the admin dashboard page but again the display is not with the django admin template. I try leaving the TEMPLATE_DIRS in the settings.py blank but still the same output. I changed the user/group for all the files/directories inside my project to "apache" hoping that this is a permission issue but it does not help either. Please tell me what I am missing. Many thanks. Simon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Grou