On Thursday, March 12, 2015 at 6:50:23 PM UTC+5:30, John Fabiani wrote:
You have two 'home' functions in views.py.
You have an indent on the first line of the urls.py (could be the paste)
You did not provide the forms.py
Johnf
On 03/12/2015 01:31 AM, sourav mohanty wrote:
...I dont know why but i'm facing a strange problem.. My templates just wouldn't load or show. can you please help me out. I'm using Django version 1.7
It shows the following warning as well in the cmd : C:\Users\Om Computers\PyDisco\venv\ddisco\
signups\forms.py:5: RemovedInDjango18W arning: Creating a ModelForm without either the 'fields' attribute or the 'exclu de' attribute is deprecated - form SignUpForm needs updating class SignUpForm(forms.ModelForm): I have an application called ddisco and an app within it called signups and my templates are stored within the templates folder.
settings.py
""" Django settings for ddisco project. For more information on this file, see https://docs.djangoproject.com/en/1.7/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.7/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.7/howto/deployment/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '' # 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', 'signups', ) MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.checklist/ middleware.SessionMiddleware' , 'django.middleware.common.CommonMiddleware' , 'django.middleware.csrf.CsrfViewMiddleware' , 'django.contrib.auth.middleware. , 'django.contrib.auth.AuthenticationMiddleware' middleware. , 'django.contrib.messages.SessionAuthenticationMiddlewar e' middleware.MessageMiddleware' , 'django.middleware.clickjacking. , ) ROOT_URLCONF = 'ddisco.urls' WSGI_APPLICATION = 'ddisco.wsgi.application' # Database # https://docs.djangoproject.XFrameOptionsMiddleware' com/en/1.7/ref/settings/# DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } # Internationalization # https://docs.djangoproject.databases com/en/1.7/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.7/howto/static-files/ STATIC_URL = '/static/' # Template location TEMPLATE_DIRS = ( os.path.join(BASE_DIR, 'templates'), ) if DEBUG: MEDIA_URL = '/media/' STATIC_ROOT = os.path.join(BASE_DIR, 'staticonly') MEDIA_ROOT = os.path.join(BASE_DIR, 'media') STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), )urls.py
from django.conf.urls import patterns, include, url from django.conf import settings from django.conf.urls.static import static from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', # Examples: url(r'^$', 'signups.views.home', name='home'), url(r'^s/$', 'signups.views.home', name='home'), # url(r'^blog/', include('blog.urls')), url(r'^admin/', include(admin.site.urls)), ) if settings.DEBUG: urlpatterns += static(settings.STATIC_URL,document_root =settings.STATIC_ROOT ) urlpatterns += static(settings.MEDIA_URL,document_root =settings.MEDIA_ROOT)models.py
from django.db import models from django.utils.encoding import smart_unicode # Create your models here. class SignUp(models.Model): first_name = models.CharField(max_length=120 ,null=True,blank=True) last_name = models.CharField(max_length=120 ,null=True,blank=True)< /span> email = models.EmailField() timestamp = models.DateTimeField(auto_now_add =True, auto_now = False) updated = models.DateTimeField(auto_now_add =False, auto_now = True) def __unicode__(self): return smart_unicode(self.email)views.py
from django.shortcuts import render , render_to_response, RequestContext from .forms import SignUpForm # Create your views here. from django.template import Context, Template def home(request): form = SignUpForm(request.POST or None) if form.is_valid(): save_it = form.save(commit=False) save_it.save() return render_to_response( "base.html", locals(),
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cda84ff4-cfa4-4c77-8194-871110f77364%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment