Python Django:恐怖;没有名为URL的模块

Python Django:恐怖;没有名为URL的模块,python,django,python-2.7,Python,Django,Python 2.7,我是Django的完全初学者,我尝试创建第一个Django网页,上面只写着“Hello world”,但没有成功。我花了几个小时试图通过上网来解决我的问题,但没有一个解决方案对我有效。这是我的代码:我希望我能在这里得到帮助 这是我的目录树: /项目: AppliPageArbre arbre.dbinit.py manage.py ProjetArbre /ProjetArbre/AppliPageArbre: admin.pyinit.py models.py tests.py views.p

我是Django的完全初学者,我尝试创建第一个Django网页,上面只写着“Hello world”,但没有成功。我花了几个小时试图通过上网来解决我的问题,但没有一个解决方案对我有效。这是我的代码:我希望我能在这里得到帮助

这是我的目录树:

/项目: AppliPageArbre arbre.dbinit.py manage.py ProjetArbre

/ProjetArbre/AppliPageArbre: admin.pyinit.py models.py tests.py views.py admin.pycinit.pyc models.pyc url.py

/ProjetArbre/ProjetArbre: init.py settings.py url.py wsgi.py init.pyc settings.pyc url.pyc wsgi.pyc

以下是ProjetArbre/AppliPageArbre/url.py:

from django.conf.urls.defaults import patterns,url
from views import home

urlpatterns=patterns('',
    url(r'^home/$',home,name="home")
)
from django.conf.urls import patterns, include, url
from django.contrib import admin

admin.autodiscover()

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

    url(r'^admin/', include(admin.site.urls)),
    url(r'^AppliPageArbre/', include('ProjetArbre.AppliPageArbre.urls')),
)
ProjetArbre/AppliPageArbre/views.py:

from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def home(request) :
    #return HttpResponse("HelloWorld")
    print 'HelloWorld'
ProjetArbre/url.py:

from django.conf.urls.defaults import patterns,url
from views import home

urlpatterns=patterns('',
    url(r'^home/$',home,name="home")
)
from django.conf.urls import patterns, include, url
from django.contrib import admin

admin.autodiscover()

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

    url(r'^admin/', include(admin.site.urls)),
    url(r'^AppliPageArbre/', include('ProjetArbre.AppliPageArbre.urls')),
)
最后是ProjetArbre/ProjetArbre/settings.py:

""" Django settings for ProjetArbre project.

For more information on this file, see https://docs.djangoproject.com/en/1.6/topics/settings/

For the full list of settings and their values, see https://docs.djangoproject.com/en/1.6/ref/settings/ """

# Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os BASE_DIR = os.path.dirname(os.path.dirname(__file__))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'v%!t3(w*fr)0n_!98=se_o_+@+o2(_0*d0&pu19@z5g1hxz13^'

# SECURITY WARNING: don't run with debug turned on in production! DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'AppliPageArbre', )

MIDDLEWARE_CLASSES = (
    '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', )

ROOT_URLCONF = 'urls' #simplement urls ?

WSGI_APPLICATION = 'ProjetArbre.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'arbre.db'),
    } }

# Internationalization
# https://docs.djangoproject.com/en/1.6/topics/i18n/

LANGUAGE_CODE = 'fr-fr'

TIME_ZONE = 'Europe/Paris'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/

STATIC_URL = '/static/'
我遇到的错误是:

我正在使用Django 1.6
提前感谢您的帮助……

我通过阅读另一篇关于Django 1.10的教程来解决这个问题。谢谢:)

现在,我有另一个问题:例如,在models.py中,我有以下类:

class Profil(models.Model):
    sexe = models.CharField(max_length=1, choices=genre_choix,default="N")
    id_profil = models.AutoField(auto_created=True, primary_key=True, serialize=False)
    famille = models.ForeignKey(Famille, default=0, blank=True,unique=False,null=True)
    prenom = models.CharField(max_length=30)
    prenom2 = models.CharField(max_length=30,blank=True)
    nom_famille = models.CharField(max_length=30)
    nom_jeune_fille = models.CharField(max_length=30,blank=True)
    Date_anniv = models.DateField(blank=True, null=True)
    mort = models.DateField(blank=True, null=True)
    travail = models.CharField(max_length=25, default="", blank=True)
    information = models.TextField(default="", blank=True)
    profil_picture = models.FileField(blank=True)

    def __str__(self):
        return str(self.prenom)



class Couple(models.Model):
    p1 = models.ForeignKey("Profil", related_name='+')
    p2 = models.ForeignKey("Profil", related_name='+')
    marriage = models.DateField(default="", blank=True,null=True)
    divorce = models.DateField(default="", blank=True,null=True)

    def __str__(self):
        return str(self.p1.prenom+"<3"+self.p2.prenom)
class profile(models.Model):
sexe=models.CharField(max_length=1,choices=genre_choix,default=“N”)
id\u profile=models.AutoField(auto\u created=True,primary\u key=True,serialize=False)
famille=models.ForeignKey(famille,默认值=0,blank=True,unique=False,null=True)
prenom=models.CharField(最大长度=30)
prenom2=models.CharField(最大长度=30,空白=True)
nom_famille=models.CharField(最大长度=30)
nom_jeune_fille=models.CharField(max_length=30,blank=True)
Date\u anniv=models.DateField(空=True,空=True)
mort=models.DateField(blank=True,null=True)
阵痛=models.CharField(最大长度=25,默认为“”,空白=True)
information=models.TextField(默认为“”,blank=True)
profil_picture=models.FileField(空白=真)
定义(自我):
返回str(self.prenom)
类耦合(models.Model):
p1=型号。外键(“Profil”,相关名称='+'))
p2=型号。外键(“Profil”,相关名称='+'))
marriation=models.DateField(默认为“”,blank=True,null=True)
离婚=models.DateField(默认为“”,空白为真,空为真)
定义(自我):

返回str(self.p1.prenom+"由于您刚刚开始使用django,您应该使用受支持的版本,因此此特定错误存在多个副本,当您尝试其解决方案时发生了什么?为什么在最新版本为1.10时使用django 1.6?1.6非常过时,不再受支持的版本,您应该使用最新版本,因为它具有更多功能,更少的bug,更容易使用,因此更少的痛苦,也将在互联网上获得更多的帮助和资料。你会发现,使用1.6来学习,你是在自讨苦吃,因为django在1.6和1.7之间对其数据库ORM的使用有了巨大的变化。设置应该有
ROOT_URLCONF='ProjetArbre.url'
.P请另找一本至少支持Django 1.8的书或教程。否则你会遇到很多问题。你永远不应该这样做,不要更新你的答案,只说“谢谢,我找到了”,因为其他搜索问题的人找不到答案。请解释你是如何找到答案的。此外,不要用另一个完全不同的问题回答你自己的问题。