Jump to content

Why Django Admin Is Not Working On Tommy?


formigol

Recommended Posts

Yes, it seems that the css is not working. Now the site is very simple, basically the same as the djangotest example that i found here: https://www.helionet.org/index/topic/27585-django-on-tommy/

 

If I try to install some of my apps the admin page stops working at all.

 

This is the link to my admin page: http://www.colouredsweat.heliohost.org/colswe/admin/login/?next=/colswe/admin/

 

Thanks a lot for your help!

Link to comment
Share on other sites

Add this line to your apps "django.contrib.staticfiles" as this provides a convenience management command for gathering static files in a single directory so you can serve them easily.

Set the

STATIC_ROOT
setting in the config file (I am unsure where this goes due to it being a while however it is in the file with the main configs) to the directory from which youd like to serve these files, for example:

STATIC_ROOT = "C:/path/to/website/example.com/static/"
Run the collectstatic management command:

$ python manage.py collectstatic
This will copy all files from your static folders, such as the admin page, into the static directory (example.com/static).

 

Now upload. :)

Link to comment
Share on other sites

  • 3 weeks later...

Hello and happy new year!

 

First: Thanks a lot for your help!

 

I'm still having a lot of problems and I'm still not able to deploy my apps on tommy... I'm missing something... when I try to deploy a simple djangotest app (following the instructions online) more or less it works (the css problem that you already told me how to solve) but when I try to install an application that I developed on my PC everything goes crazy and nothing works. I get the following errors:

[Thu Jan 04 15:52:02.260254 2018] [core:info] [pid 14573:tid 140340614858496] [client 93.34.147.76:42047] AH00128: File does not exist: /home/formigol/public_html/500.shtml
[Thu Jan 04 15:52:02.259885 2018] [wsgi:error] [pid 14573:tid 140340614858496] [client 93.34.147.76:42047]   File "/home/formigol/public_html/contacts/models.py", line 29
[Thu Jan 04 15:52:02.259668 2018] [wsgi:error] [pid 14573:tid 140340614858496] [client 93.34.147.76:42047]   File "/home/formigol/public_html/colswe/dispatch.wsgi", line 11, in <module>
[Thu Jan 04 15:52:02.258313 2018] [wsgi:error] [pid 14573:tid 140340614858496] [client 93.34.147.76:42047] mod_wsgi (pid=14573): Exception occurred processing WSGI script '/home/formigol/public_html/colswe/dispatch.wsgi'.
[Thu Jan 04 15:52:02.258227 2018] [wsgi:error] [pid 14573:tid 140340614858496] [client 93.34.147.76:42047] mod_wsgi (pid=14573): Target WSGI script '/home/formigol/public_html/colswe/dispatch.wsgi' cannot be loaded as Python module.
[Thu Jan 04 07:51:59.952735 2018] [wsgi:info] [pid 14573:tid 140340614858496] [client 93.34.147.76:42047] mod_wsgi (pid=14573, process='', application='colouredsweat.heliohost.org|/colswe/dispatch.wsgi'): Loading WSGI script '/home/formigol/public_html/colswe/dispatch.wsgi'.

Do you have any suggestions? The problem is that I really don't understand what's wrong.

Thanks in advance!

Link to comment
Share on other sites

Ah okay, I'm unsure on these exact errors because I abandoned Django. It looks like the file "500.shtml" is missing from "/public_html/" but all you should need to do is create an empty file.

 

However, the "dispatch.wsgi" file seems to be causing more issues. I would google the exact errors you are having (just copy and paste) as other people would have had the same problem. This should bring up a fix after reading maybe one or two posts about it.

 

Sorry I couldn't be of more use.

 

- Bailey

Link to comment
Share on other sites

The best debugging advice for a situation like this is start small and simple. Make sure it works, and then make some small changes and make sure it works again. Unless your home pc is running the exact same os and the exact same versions of everything there are going to be differences when you deploy it.

Link to comment
Share on other sites

Ok. I will write everything I have done until now following a tutorial structure; maybe it will be useful  for future Django users on Heliohost:

 

1. I started the project from scratch using the cookiecutter.

2. Than I uncommented the following commented lines in the project_name/urls.py. That generate an admin log-in page at the URL http://www.your_name.heliohost.org/project_name/admin

from django.conf.urls import url
#from django.contrib import admin

urlpatterns = [
    #url(r'^admin/', admin.site.urls),
]

3. At this point I visited the page and I noticed that the css was not working (see the discussion before)

 

4. I collected all the static files of my project located on my personal computer. To do that:

 

--> first I added the following two lines in my project_name/settings.py file

STATIC_URL = '/static/' # url that django uses to find the static files while the server is running
STATIC_ROOT = '/path/to/my/project/folder/static' #url that says to django were to collect all the statics (on the local host)

--> than in the terminal I typed the following command to collect all the static in the URL_ROOT.

./manage.py collectstatics

--> I made a .tar file and deployed everything on the server.

 

4. The next step is to create a superuser to test the admin application

 and there is were the problems are coming out.

 

--> I created the superuser on my local host. (from now on after every change on my local host I deployed the new version on the server trough filemanager)

./manage.py createsuperuser

Everything worked on the server until I tried to login with my new super user. At this point django show me an error page saying that: Django Attempt to write a read-only database.

I tried to change the permissions of the database (the file called db.sqlite3) to 777 and the django error trasformed into: unable to open database file

 

The complete ERROR OUTPUT:

Environment:


Request Method: POST
Request URL: http://www.colouredsweat.heliohost.org/colswe2/admin/login/?next=/colswe2/admin/

Django Version: 1.11.6
Python Version: 3.6.3
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback:

File "/usr/local/python3.6/lib/python3.6/site-packages/django/db/backends/base/base.py" in ensure_connection
  213.                 self.connect()

File "/usr/local/python3.6/lib/python3.6/site-packages/django/db/backends/base/base.py" in connect
  189.         self.connection = self.get_new_connection(conn_params)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py" in get_new_connection
  198.         conn = Database.connect(**conn_params)

The above exception (unable to open database file) was the direct cause of the following exception:

File "/usr/local/python3.6/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  57.         response = view_func(request, *args, **kwargs)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/contrib/admin/sites.py" in login
  393.         return LoginView.as_view(**defaults)(request)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/views/generic/base.py" in view
  68.             return self.dispatch(request, *args, **kwargs)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapper
  67.             return bound_func(*args, **kwargs)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/views/decorators/debug.py" in sensitive_post_parameters_wrapper
  76.             return view(request, *args, **kwargs)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/utils/decorators.py" in bound_func
  63.                 return func.__get__(self, type(self))(*args2, **kwargs2)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapper
  67.             return bound_func(*args, **kwargs)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapped_view
  149.                     response = view_func(request, *args, **kwargs)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/utils/decorators.py" in bound_func
  63.                 return func.__get__(self, type(self))(*args2, **kwargs2)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapper
  67.             return bound_func(*args, **kwargs)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  57.         response = view_func(request, *args, **kwargs)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/utils/decorators.py" in bound_func
  63.                 return func.__get__(self, type(self))(*args2, **kwargs2)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/contrib/auth/views.py" in dispatch
  90.         return super(LoginView, self).dispatch(request, *args, **kwargs)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/views/generic/base.py" in dispatch
  88.         return handler(request, *args, **kwargs)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/views/generic/edit.py" in post
  182.         if form.is_valid():

File "/usr/local/python3.6/lib/python3.6/site-packages/django/forms/forms.py" in is_valid
  183.         return self.is_bound and not self.errors

File "/usr/local/python3.6/lib/python3.6/site-packages/django/forms/forms.py" in errors
  175.             self.full_clean()

File "/usr/local/python3.6/lib/python3.6/site-packages/django/forms/forms.py" in full_clean
  385.         self._clean_form()

File "/usr/local/python3.6/lib/python3.6/site-packages/django/forms/forms.py" in _clean_form
  412.             cleaned_data = self.clean()

File "/usr/local/python3.6/lib/python3.6/site-packages/django/contrib/auth/forms.py" in clean
  187.             self.user_cache = authenticate(self.request, username=username, password=password)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/contrib/auth/__init__.py" in authenticate
  70.             user = _authenticate_with_backend(backend, backend_path, request, credentials)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/contrib/auth/__init__.py" in _authenticate_with_backend
  115.     return backend.authenticate(*args, **credentials)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/contrib/auth/backends.py" in authenticate
  18.             user = UserModel._default_manager.get_by_natural_key(username)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/contrib/auth/base_user.py" in get_by_natural_key
  48.         return self.get(**{self.model.USERNAME_FIELD: username})

File "/usr/local/python3.6/lib/python3.6/site-packages/django/db/models/manager.py" in manager_method
  85.                 return getattr(self.get_queryset(), name)(*args, **kwargs)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/db/models/query.py" in get
  374.         num = len(clone)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/db/models/query.py" in __len__
  232.         self._fetch_all()

File "/usr/local/python3.6/lib/python3.6/site-packages/django/db/models/query.py" in _fetch_all
  1118.             self._result_cache = list(self._iterable_class(self))

File "/usr/local/python3.6/lib/python3.6/site-packages/django/db/models/query.py" in __iter__
  53.         results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/db/models/sql/compiler.py" in execute_sql
  882.             cursor = self.connection.cursor()

File "/usr/local/python3.6/lib/python3.6/site-packages/django/db/backends/base/base.py" in cursor
  254.         return self._cursor()

File "/usr/local/python3.6/lib/python3.6/site-packages/django/db/backends/base/base.py" in _cursor
  229.         self.ensure_connection()

File "/usr/local/python3.6/lib/python3.6/site-packages/django/db/backends/base/base.py" in ensure_connection
  213.                 self.connect()

File "/usr/local/python3.6/lib/python3.6/site-packages/django/db/utils.py" in __exit__
  94.                 six.reraise(dj_exc_type, dj_exc_value, traceback)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/utils/six.py" in reraise
  685.             raise value.with_traceback(tb)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/db/backends/base/base.py" in ensure_connection
  213.                 self.connect()

File "/usr/local/python3.6/lib/python3.6/site-packages/django/db/backends/base/base.py" in connect
  189.         self.connection = self.get_new_connection(conn_params)

File "/usr/local/python3.6/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py" in get_new_connection
  198.         conn = Database.connect(**conn_params)

Exception Type: OperationalError at /admin/login/
Exception Value: unable to open database file

What do you suggest to solve the problem? Maybe I should use a database provided by heliohost and not the one created on my local host?

 

Thanks in advance for your help!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...