Forums

SOS, admin Django doesn't work!!!

Hello everybody, i'm newbie in pythonanywhere, i follow the tutorial (http://tutorial.pythonanywhere.com/django) to start my project , but I can't access http://kieuanh.pythonanywhere.com/admin/ il shows always:


It worked! Congratulations on your first Django-powered page.

Of course, you haven't actually done any work yet. Here's what to do next:

If you plan to use a database, edit the DATABASES setting in mysite/settings.py.
Start your first app by running python mysite/manage.py startapp [appname].

You're seeing this message because you have DEBUG = True in your Django settings file and you haven't configured any URLs. Get to work!


I purposely set DEBUG = Flase, and go on the Web tab in dashboard to reload my website (i suppose that means i do some kind of "sudo service apache2 restart" when i program on my computer)

But nothing i still have You're seeing this message because you have DEBUG = True in your Django settings file and you haven't configured any URLs. Get to work!

And no admin at all! Please help me, I have been stalled for two days

I suspect you haven't enabled the admin correctly.

Have a careful look at the section in the tutorial that switches on the admin site:

http://tutorial.pythonanywhere.com/django#configuring-the-database-and-enabling-the-admin-interface

To enable the admin, you need to do two things:

  • add the admin app in settings.py
  • add the admin URLs inside urls.py

Check that you've done both?

thanks for your response. I did these modifications, in my settings.py INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', # Uncomment the next line to enable the admin: 'django.contrib.admin', 'polls', # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs', )

in my urls.py

from django.conf.urls.defaults import patterns, include, url

Uncomment the next two lines to enable the admin:

from django.contrib import admin admin.autodiscover()

urlpatterns = patterns('', # Examples: # url(r'^$', 'mysite.views.home', name='home'), # url(r'^mysite/', include('mysite.foo.urls')),

# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),

)

if it does not bother you to cast a glance on my project I can share my console, just give me your email address. My project is simple, I followed the tutorial of https://docs.djangoproject.com, So i just do something very simple.

Gosh. That took a while. I don't know how you managed it, but you'd made a copy of your project folder (mysite) inside /var/www/, which was overriding the one at /home/kieuanh/mysite/. I moved it into /tmp, and now things are working a little better:

http://kieuanh.pythonanywhere.com/admin/

Great, thank you very much. Since I started with django, I was told to create my project in / var / www /, so I wanted to have the same structure on pythonanywhere, but I did not know it's a mistake. so just for the last stupid question:

I must always create my project in /home/kieuanh/ ?

NB: You saved my life, thank you again

Hi kieuanh,

You can create your project wherever you like, but /home/kieuanh/somewhere-or-other is probably the most convenient...

/var/www is a bit of a special-case, and it will cause problems if you have two projects with the same name, one in /var/www, one in /home/kieuanh/

thanks for your response. I've problem once again,

url(r'^$', direct_to_template, {'template': 'base_gestion.html'}),

url(r'^poudres/', 'mysite.poudres.views.accueil_poudre'),

these 2 url do the same thing, but with the first one, my page is displayed with css and every things in /static/ (to see it please type http://kieuanh.pythonanywhere.com/ ) the second one, i have just html without css and javascript, (to see it please type http://kieuanh.pythonanywhere.com/poudres/ )

in these 2 case i use the same template : base.html

Here is my accueil_poudre() def accueil_poudre(request): return render_to_response('base.html')

Here is the head of my base.html, just show how i import staticfiles

<!DOCTYPE html> <html lang="en"> <head> {% block head %} <title>{{ PAGE_TITLE }} - {{ WEBSITE_TITLE }}</title> <meta charset="utf-8"> {% block css %} {% endblock %} <link rel="stylesheet" href="{{ STATIC_URL }}jquery-ui-1.10.3/themes/base/jquery.ui.dialog.css" media="screen"/> <link rel="stylesheet" href="{{ STATIC_URL }}css/reset.css" type="text/css" media="screen"/> <link rel="stylesheet" href="{{ STATIC_URL }}css/style.css" type="text/css" media="screen"/> <link rel="stylesheet" href="{{ STATIC_URL }}css/grid.css" type="text/css" media="screen"/> <link rel="stylesheet" type="text/css" media="all" href="{{ STATIC_URL }}css/base.css" /> <link rel="stylesheet" type="text/css" media="all" href="{{ STATIC_URL }}jquery-ui-1.10.3/themes/base/jquery-ui.css"/>

<script src="{{ STATIC_URL }}jquery-1.10.2.min/jquery-1.10.2.min.js" ></script>
<script src="{{ STATIC_URL }}jquery-ui-1.10.3/ui/jquery-ui.js" ></script>
<script src="{{ STATIC_URL }}js/script.js" type="text/javascript" ></script>
<script src="{{ STATIC_URL }}js/easyTooltip.js" type="text/javascript"></script>

{% endblock %} <script> $(function() { $("#menu").menu(); }); function opendialog(e,url,titre) { $(e).dialog({ //autoOpen: true, title: titre, position: 'top', width:'auto', show: "slide", hide: "puff", modal: true, resizable: false

        });
        $.get(url, function(data) {
            $(e).html(data);
        });
}

As newbie, I see that pythonanywhere it is more complicated than my aptana and apache :( in some way

You're using relative paths to your css and javascript. So your first page is looking at /{{STATIC_URL}} for the css and js and the second page is looking at /poudres/{{STATIC_URL}}.

thanks, i will use absolute path

I'm trying to acces the admin, and I see the log page but I can't log (I'm typing the correct username and password)

hi buenviaje,

Did you fiddle with this and figure it out? From your log files, I see that you have instead moved on to writing a view/using templates and you are having a template importing error.

Conrad

I'm going to reupload the templates, but I don't thing this fix the problem.

I reupload the templates and nothing I still can't log in

do you have any other information about this that we'd be able to work off of to debug?

Well, I programmed it. The exact problem I'm having is that when I go to http://buenviaje.pythonanywhere.com/admin/ and I try to log in it doesn't do anything. The username is carlos and the password is c

Well, I programmed it. The exact problem I'm having is that when I go to http://buenviaje.pythonanywhere.com/admin/ and I try to log in and it doesn't do anything. The username is carlos and the password is c

Some sort of problem with the url config maybe? We can't really help you debug issues with django, just issues specific to our platform...

I don't know, the url.py seems to be ok. I'm reading the log's but I can't find anything unusual. The line in urls.py where the admin appears is url(r'^admin/', include(admin.site.urls)), I have no idea what's going on

I've solved the problem. It was a tricky one: In my setttings.py I had, SESSION_COOKIE_DOMAIN = "http://buenviaje.pythonanywhere.com/" which seems to be incorrect, I changed to SESSION_COOKIE_DOMAIN = "buenviaje.pythonanywhere.com" and problem solved. Thanks a lot for the help!

Ah, that makes sense. Thanks for letting us know!