Parent module adsite.adsiteviews.mainhanlder does not exist

Discussion in 'Python' started by Nick Dong, Jan 18, 2013.

  1. Nick Dong

    Nick Dong Guest

    I created a django project using django 1.4.2. There is one 'app'(adsite) in this project. And It works. But when I copied some 'py' files into the 'app' folder, I got "Parent module adsite.adsiteviews.mainhanlder does not exist." Should I register the new files to __init__ in the 'app'? Did new coped files break the "import" rules?

    views.py

    from django.http import HttpResponse
    from django.template import Context, loader
    from adsite.models import UserInfo

    def showusers(request):
    userlist = UserInfo.objects.all()
    c = Context({
    'userlist':userlist,
    })
    t = loader.get_template('users.html')

    return HttpResponse(t.render(c))

    copied file: adsiteviews.py

    class mainhanlder(TemplateView)
    def get(self):
    """ """
    variables = {
    'user': self.get_current_user(),
    'mchosts' : MCHOSTS,
    'servers' : servers}

    index_templ = tmpl_lookup.get_template("index.html")
    body = index_templ.render(**variables)
    self.write(body)

    urls.py

    urlpatterns = patterns('',
    # Examples:
    url(r'^$', 'adsite.adsiteviews.mainhandler.as_View()'),
    url(r'^users/$', 'adsite.views.showusers'),

    I have no clues about this problem. any suggestions would be appreciated. thx for your time.
    Nick Dong, Jan 18, 2013
    #1
    1. Advertising

  2. > I created a django project using django 1.4.2. There is one 'app'(adsite)in this project. And It works. But when I copied some 'py' files into the 'app' folder, I got "Parent module adsite.adsiteviews.mainhanlder does not exist." Should I register the new files to __init__ in the 'app'? Did new coped files break the "import" rules?

    I do not know if this is your problem, and I know little about django,
    but is "mainhanlder" a typographical error?
    Jason Friedman, Jan 20, 2013
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bill Johnson
    Replies:
    0
    Views:
    1,225
    Bill Johnson
    Jul 8, 2005
  2. Y.S.
    Replies:
    3
    Views:
    986
    strajan
    Sep 17, 2003
  3. LT
    Replies:
    7
    Views:
    2,078
    Phlip
    Jul 25, 2004
  4. Bill Johnson

    CS0234 Global does not exist ... but it genuinely does

    Bill Johnson, Jul 8, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    186
    Bill Johnson
    Jul 8, 2005
  5. Markus Mohr
    Replies:
    7
    Views:
    229
    Thomas 'PointedEars' Lahn
    Nov 28, 2003
Loading...

Share This Page