Forums

Syntax Error from django.contrib import admin

Hello everybody, i'm newbie in pythonanywhere, i follow the tutorial (https://www.pythonanywhere.com/wiki/DjangoTutorial) to start my project , but I can't access http://anthraxp.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 am seeing this Error when saving urls.py Please Suggest me What to do. I am stuck, I have taken all steps carefully Please help me admins

Where's the syntax error? That looks like you have a working Django app.

When I am opening the file urls.py at line number 4 I seek a Cross mark.

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

# Uncomment the next two lines to enable the admin:
 from django.contrib import admin   #i am seeing error here
 admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    #url(r'^$', 'AskQuestion.views.home', name='home'),
    #url(r'^AskQuestion/', include('AskQuestion.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)),
)

I am also not able to open admin area http://anthraxp.pythonanywhere.com/admin/ Shows this Message

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 AskQuestion/settings.py. Start your first app by running python AskQuestion/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 have done all the steps well from tutorial Till Defining your urls

edit by admin for formatting

I noticed this when I edited your post to include the Python formatting: If your code block above is a direct copy of your urls.py, then you have indentation problems on the line of the error and the one that follows it. In Python, whitespace is important and you have a space at the start of those 2 lines.

Thank you for your support but now i am getting this error message while loading this domain: http://anthraxp.pythonanywhere.com/ ViewDoesNotExist at / Could not import AskQuestion.views. Error was: No module named views and long page of details load But i have created a view in askquestions/myapp/views.py Please tell what to do?

I can see several possible sources of the problem: 1. The error mentions AskQuestion.views (with caps), but you give the path to the file as askquestions (lowercase and with an s) 2. Your path includes myapp in the path, but the view that could not be found does not

Check that the modules you import agree with the folder structure.