IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Django Python Discussion :

Page not found (404)


Sujet :

Django Python

  1. #1
    Membre à l'essai
    Homme Profil pro
    marketeur
    Inscrit en
    Janvier 2018
    Messages
    48
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : marketeur

    Informations forums :
    Inscription : Janvier 2018
    Messages : 48
    Points : 24
    Points
    24
    Par défaut Page not found (404)
    d'après moi mon code django est correcte mais il y a une erreur je n'ai pas trouver la quel voilà mon code est l'erreur j'ai effacer le secret key exprès merci de toute aide
    sitting
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    import os
     
    # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
     
     
    # Quick-start development settings - unsuitable for production
    # See <a href="https://docs.djangoproject.com/en/2....ent/checklist/" target="_blank">https://docs.djangoproject.com/en/2....ent/checklist/</a>
     
     
    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',
    ]
     
    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',
    ]
     
    ROOT_URLCONF = 'mangemange.urls'
     
    TEMPLATES = [
    {
    'BACKEND': 'django.template.backends.django.DjangoTemplates',
    'DIRS': ['templates'],
    'APP_DIRS': True,
    'OPTIONS': {
    'context_processors': [
    'django.template.context_processors.debug',
    'django.template.context_processors.request',
    'django.contrib.auth.context_processors.auth',
    'django.contrib.messages.context_processors.messages',
    ],
    },
    },
    ]
     
    WSGI_APPLICATION = 'mangemange.wsgi.application'
     
     
    # Database
    # <a href="https://docs.djangoproject.com/en/2....ngs/#databases" target="_blank">https://docs.djangoproject.com/en/2....ngs/#databases</a>
     
    DATABASES = {
    'default': {
    'ENGINE': 'django.db.backends.sqlite3',
    'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
    }
     
     
    # Password validation
    # <a href="https://docs.djangoproject.com/en/2....ord-validators" target="_blank">https://docs.djangoproject.com/en/2....ord-validators</a>
     
    AUTH_PASSWORD_VALIDATORS = [
    {
    'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
    'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
    'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
    'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
    ]
     
     
    # Internationalization
    # <a href="https://docs.djangoproject.com/en/2.1/topics/i18n/" target="_blank">https://docs.djangoproject.com/en/2.1/topics/i18n/</a>
     
    LANGUAGE_CODE = 'fr-fr'
     
    TIME_ZONE = 'UTC'
     
    USE_I18N = True
     
    USE_L10N = True
     
    USE_TZ = True
     
     
    # Static files (CSS, JavaScript, Images)
    # <a href="https://docs.djangoproject.com/en/2..../static-files/" target="_blank">https://docs.djangoproject.com/en/2..../static-files/</a>
     
    STATIC_URL = '/static/'
    views 
    def home(request):
    return render(request, 'home.html')
    home.html
    <h1>hello word</h1>
    l'erreur
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    Page not found (404)
    Request Method:	GET
    Request URL:	<a href="http://127.0.0.1:8000/" target="_blank">http://127.0.0.1:8000/</a>
    Using the URLconf defined in mangemange.urls, Django tried these URL patterns, in this order:
     
    home/$
    admin/
    The empty path didn't match any of these.
     
    You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.

  2. #2
    Membre extrêmement actif
    Profil pro
    Développeur
    Inscrit en
    Mars 2012
    Messages
    1 969
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Mars 2012
    Messages : 1 969
    Points : 3 375
    Points
    3 375
    Par défaut
    Perso je trouve que cette instruction sent pas bon: BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

    2 dirname l'un après l'autre, youhouuuu!

    Ton erreur est probablement ici:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    def home(request):
    return render(request, 'home.html')
    Ton return doit avoir 4 espaces devant et faire partie de la fonction home()
    Si la réponse vous a aidé, pensez à cliquer sur +1

  3. #3
    Membre à l'essai
    Homme Profil pro
    marketeur
    Inscrit en
    Janvier 2018
    Messages
    48
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : marketeur

    Informations forums :
    Inscription : Janvier 2018
    Messages : 48
    Points : 24
    Points
    24
    Par défaut
    ça BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) je le change par quoi il y a les quatre espaces mais j'ai copier coller c'est apparue sans espace

  4. #4
    Expert éminent sénior
    Homme Profil pro
    Architecte technique retraité
    Inscrit en
    Juin 2008
    Messages
    21 287
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Architecte technique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2008
    Messages : 21 287
    Points : 36 776
    Points
    36 776
    Par défaut
    Citation Envoyé par hotcryx Voir le message
    Perso je trouve que cette instruction sent pas bon: BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    C'est juste le cut&paste de ce qui est documenté dans Django.

    - W
    Architectures post-modernes.
    Python sur DVP c'est aussi des FAQs, des cours et tutoriels

  5. #5
    Membre à l'essai
    Homme Profil pro
    marketeur
    Inscrit en
    Janvier 2018
    Messages
    48
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : marketeur

    Informations forums :
    Inscription : Janvier 2018
    Messages : 48
    Points : 24
    Points
    24
    Par défaut
    personne peut m'aider ?

  6. #6
    Membre régulier
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Juillet 2018
    Messages
    16
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France, Eure et Loir (Centre)

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux

    Informations forums :
    Inscription : Juillet 2018
    Messages : 16
    Points : 88
    Points
    88
    Par défaut
    Salut
    Ton message est clair ... ou pas
    home/$
    admin/
    The empty path didn't match any of these.
    Quand tu appelles http://127.0.0.1:8000/
    il faut que dans le fichier urls.py tu es une ligne du genres

    une explication simple est que ton URL pour DJANGO http://127.0.0.1:8000/ c'est plutôt http://127.0.0.1:8000/{VIDE}
    et l expression régulière du url r'^$ c'est pour décrire le vide "rien devant rien derriere"

    Bon dev

  7. #7
    Membre à l'essai
    Homme Profil pro
    marketeur
    Inscrit en
    Janvier 2018
    Messages
    48
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : marketeur

    Informations forums :
    Inscription : Janvier 2018
    Messages : 48
    Points : 24
    Points
    24
    Par défaut
    désoler j'ai oublier que je l'ai mis

Discussions similaires

  1. Bonsoir,est ce que vous pouvez m'aider a résoudre l"exrcice suivant et merci d'avance
    Par sipo7amed dans le forum SIG : Système d'information Géographique
    Réponses: 0
    Dernier message: 16/02/2012, 02h11

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo