Re: Why is my Django template not displaying?

2016-06-03 Thread Luis Zárate
Use  plays as a list in form.

You are passing context_list as context object so all variable inside
context_list are available in template but not context_list.

Other option is
return render(request,'live.html',
{"context_list": context_list})


El viernes, 3 de junio de 2016, Dave N 
escribió:
> That absolutely did it James - I thought I was accessing the instance,
but what I needed was to access the template context contents of the
instance. Also, great tip with the django debug toolbar - I've had it
installed, but didn't know how much it actually shows!
>
> On Friday, June 3, 2016 at 8:58:33 AM UTC-7, Dave N wrote:
>>
>> Assuming my model contains data, I have myapp/views.py:
>>
>> from django.template import RequestContext
>> from django.shortcuts import render
>> from .models import History
>> import datetime
>>
>> def live_view(request):
>> context = RequestContext(request)
>> plays_list = History.objects.filter(date=datetime.date(2016,04,22))
>> context_list = {'plays':plays_list}
>> return render(request,'live.html',context_list)
>>
>> myapp/templates/live.html:
>>
>> {% extends 'base.html' %}
>> {% block content %}
>> {% for key, value in context_list.items %}
>> {{ value }}
>> {% endfor %}
>> {% endblock %}
>>
>> myapp/urls.py:
>>
>> from myapp.views import live_view
>> urlpatterns = [url(r'^live/$', live_view, name="live"),]
>>
>> The output is a page that renders only the base.html template, with no
content in the body. What's wrong with my view function or template
rendering? Should I be inheriting from TemplateView?
>
> --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/2dc2c249-66bd-4466-bc45-2d5dee2ba4b9%40googlegroups.com
.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG%2B5VyO1F9pkXF_rMbtPeZayHmui3xtsGnBZhN%3Dri0nsM2zJ7Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why is my Django template not displaying?

2016-06-03 Thread Dave N
That absolutely did it James - I thought I was accessing the instance, but 
what I needed was to access the template context contents of the instance. 
Also, great tip with the django debug toolbar - I've had it installed, but 
didn't know how much it actually shows!

On Friday, June 3, 2016 at 8:58:33 AM UTC-7, Dave N wrote:
>
> Assuming my model contains data, I have myapp/views.py:
>
> from django.template import RequestContextfrom django.shortcuts import 
> renderfrom .models import Historyimport datetime
> def live_view(request):
> context = RequestContext(request)
> plays_list = History.objects.filter(date=datetime.date(2016,04,22))
> context_list = {'plays':plays_list}
> return render(request,'live.html',context_list)
>
> myapp/templates/live.html:
>
> {% extends 'base.html' %}{% block content %}{% for key, value in 
> context_list.items %}
> {{ value }}{% endfor %}{% endblock %}
>
> myapp/urls.py:
>
> from myapp.views import live_view
> urlpatterns = [url(r'^live/$', live_view, name="live"),]
>
>
> The output is a page that renders only the base.html template, with no 
> content in the body. What's wrong with my view function or template 
> rendering? Should I be inheriting from TemplateView?
>
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2dc2c249-66bd-4466-bc45-2d5dee2ba4b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why is my Django template not displaying?

2016-06-03 Thread James Schneider
On Jun 3, 2016 8:58 AM, "Dave N"  wrote:
>
> Assuming my model contains data, I have myapp/views.py:
>
> from django.template import RequestContext
> from django.shortcuts import render
> from .models import History
> import datetime
>
> def live_view(request):
> context = RequestContext(request)
> plays_list = History.objects.filter(date=datetime.date(2016,04,22))
> context_list = {'plays':plays_list}
> return render(request,'live.html',context_list)
>
> myapp/templates/live.html:
>
> {% extends 'base.html' %}
> {% block content %}
> {% for key, value in context_list.items %}
> {{ value }}
> {% endfor %}
> {% endblock %}
>

You probably want {% for key, value in plays.items %} since there probably
isn't a context variable called {{ context_list }}.

Install the Django-debug-toolbar. It'll tell you everything that's
available in the template context and provide what templates were actually
rendered on every page load, along with other cool stuff you didn't even
know you needed to know.

-James

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciWBcwjYbV9s0e8Mjr3BO7GDXCYVUW1qh8zHxDE1u1HNow%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Why is my Django template not displaying?

2016-06-03 Thread Dave N
Assuming my model contains data, I have myapp/views.py:

from django.template import RequestContextfrom django.shortcuts import 
renderfrom .models import Historyimport datetime
def live_view(request):
context = RequestContext(request)
plays_list = History.objects.filter(date=datetime.date(2016,04,22))
context_list = {'plays':plays_list}
return render(request,'live.html',context_list)

myapp/templates/live.html:

{% extends 'base.html' %}{% block content %}{% for key, value in 
context_list.items %}
{{ value }}{% endfor %}{% endblock %}

myapp/urls.py:

from myapp.views import live_view
urlpatterns = [url(r'^live/$', live_view, name="live"),]


The output is a page that renders only the base.html template, with no content 
in the body. What's wrong with my view function or template rendering? Should I 
be inheriting from TemplateView?

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d42cb230-a86d-4efc-bbe6-42c513227784%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django template not displaying

2015-03-12 Thread john

OK the view.py functions are the way Django responds to a browser request.
IOW the browser asks for a page to display and Django checks the URL (in 
the urls.py).  In the urls.py you have  to have an entry something like
url(r'signup/$', 'signup.views.home', name ='signup') and then Django 
excutes the function (in this case signup.views.home).


Where signup is a Django app created when you used 'startapp'.  In the 
signup directory (assuming that's where you placing everything - doesn't 
have to be) there should be a views.py.
In views.py there should be a function 'home'  and in there you should 
render the response - just like you did for the other home.


Beyond that - please read and follow the Django tutorial - pay close 
attention to the way the layout of the code is done.


Johnf

On 03/12/2015 12:03 PM, sourav mohanty wrote:
from  'My templates just wouldn't load or show' , i mean that my 
base.html loads perfectly but signup.html doesn't show up.


On Friday, March 13, 2015 at 12:20:26 AM UTC+5:30, sourav mohanty wrote:

i have revised the views.py :

fromdjango.shortcutsimportrender,render_to_response,RequestContext

# from .forms import SignUpForm
# Create your views here.
fromdjango.templateimportContext,Template


defhome(request):
 # form = SignUpForm(request.POST or None)

 # if form.is_valid():
 # save_it = form.save(commit=False)
 # save_it.save()

 returnrender_to_response("base.html",
   locals(),
   context_instance=RequestContext(request))


defhomeonce(request):
 context = {}
 template ="base.html"
 returnrender(request,template,context)



Render reference is


   {%blocksign%}
  {%endblock%}



base.html :



   
 
 
 
 
 
 

 Homepage

 
 
https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css
  ">

 
 
https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css
  ">

 
 
   

   




   {%blocksign%}
  {%endblock%}


 
   


   

 
 ©Company 2014
 
 


 
 
 https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js  
">
 
 https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js  
">
 
   




signup.html:

{%extends"base.html"%}

{%blocksign%}
{%csrf_token%}
Sign Up

   
 Submit
   
 



{%endblock%}


Please help.. its really out of my hands.. Thank you for your reply..

On Thursday, March 12, 2015 at 9:51:57 PM UTC+5:30, James
Schneider wrote:

You also have two different URL's named 'home', which will
lead to a bad time. Make sure that those are unique.

From what I can tell, none of your views render/reference
'signup.html', so I would never expect that template to be
rendered.

Configure a fields attribute on your form to get rid of the
deprecation warning. This will be required moving forward
through future version of Django:


https://docs.djangoproject.com/en/1.7/topics/forms/modelforms/#selecting-the-fields-to-use



When you say 'My templates just wouldn't load or show', what
exactly is shown in the browser window and/or runserver console?

My suggestion would be to install the django-debug-toolbar, as
you can use it to investigate the templates being used by your
view and where Django is looking to find those templates.

-James


On Thu, Mar 12, 2015 at 6:19 AM, john 
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: C

Re: Django template not displaying

2015-03-12 Thread sourav mohanty
from  'My templates just wouldn't load or show' , i mean that my base.html 
loads perfectly but signup.html doesn't show up.

On Friday, March 13, 2015 at 12:20:26 AM UTC+5:30, sourav mohanty wrote:
>
> i have revised the 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(),
>   context_instance=RequestContext(request))
>
>
> def homeonce(request):
> context = {}
> template = "base.html"
> return render(request, template, context)
>
>
>
> Render reference is 
>
> 
>   {% block sign %}
>  {% endblock %}
> 
>
>
> base.html :
>
>
> 
> 
>   
> 
> 
> 
> 
> 
> 
>
> Homepage
>
> 
>  href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css";>
>
> 
>  href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css";>
>
> 
> 
>   
>
>   
>
>
> 
> 
>   {% block sign %}
>  {% endblock %}
> 
>
> 
>   
>
>   
>
> 
> © Company 2014
> 
>  
>
>
> 
> 
>  src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js";>
> 
>  src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js";>
> 
>   
> 
>
>
> signup.html:
>
> {% extends "base.html" %}
>
> {% block sign %}
> {% 
> csrf_token%}
>Sign Up
>
>   
> Submit
>   
> 
>
>
>
> {% endblock %}
>
>
> Please help.. its really out of my hands.. Thank you for your reply..
>
> On Thursday, March 12, 2015 at 9:51:57 PM UTC+5:30, James Schneider wrote:
>
> You also have two different URL's named 'home', which will lead to a bad 
> time. Make sure that those are unique.
>
> From what I can tell, none of your views render/reference 'signup.html', 
> so I would never expect that template to be rendered.
>
> Configure a fields attribute on your form to get rid of the deprecation 
> warning. This will be required moving forward through future version of 
> Django: 
>
>
> https://docs.djangoproject.com/en/1.7/topics/forms/modelforms/#selecting-the-fields-to-use
>
> When you say 'My templates just wouldn't load or show', what exactly is 
> shown in the browser window and/or runserver console?
>
> My suggestion would be to install the django-debug-toolbar, as you can use 
> it to investigate the templates being used by your view and where Django is 
> looking to find those templates.
>
> -James
>
>
> On Thu, Mar 12, 2015 at 6:19 AM, john  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, 
> seehttps://docs.djangoproject.com/en/1.7/topics/settings/
>
> For the full list of settings and their values, 
> seehttps://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/checklist/
> # 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 = (
>  

Re: Django template not displaying

2015-03-12 Thread sourav mohanty
I thank you for your reply and time.. But please help me..

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, 
> seehttps://docs.djangoproject.com/en/1.7/topics/settings/
>
> For the full list of settings and their values, 
> seehttps://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/checklist/
> # 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.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware',)
>
> ROOT_URLCONF = 'ddisco.urls'
>
> WSGI_APPLICATION = 'ddisco.wsgi.application'
>
> # Database# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.sqlite3',
> 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
> }}
> # Internationalization# https://docs.djangoproject.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 settingsfrom 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 modelsfrom 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)
>  

Re: Django template not displaying

2015-03-12 Thread sourav mohanty
i have revised the 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(),
  context_instance=RequestContext(request))


def homeonce(request):
context = {}
template = "base.html"
return render(request, template, context)



Render reference is 


  {% block sign %}
 {% endblock %}



base.html :




  







Homepage


https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css";>


https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css";>



  

  




  {% block sign %}
 {% endblock %}



  

  


© Company 2014

 




https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js";>

https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js";>

  



signup.html:

{% extends "base.html" %}

{% block sign %}
{% 
csrf_token%}
   Sign Up
   
  
Submit
  

   
   

{% endblock %}


Please help.. its really out of my hands.. Thank you for your reply..

On Thursday, March 12, 2015 at 9:51:57 PM UTC+5:30, James Schneider wrote:
>
> You also have two different URL's named 'home', which will lead to a bad 
> time. Make sure that those are unique.
>
> From what I can tell, none of your views render/reference 'signup.html', 
> so I would never expect that template to be rendered.
>
> Configure a fields attribute on your form to get rid of the deprecation 
> warning. This will be required moving forward through future version of 
> Django: 
>
>
> https://docs.djangoproject.com/en/1.7/topics/forms/modelforms/#selecting-the-fields-to-use
>
> When you say 'My templates just wouldn't load or show', what exactly is 
> shown in the browser window and/or runserver console?
>
> My suggestion would be to install the django-debug-toolbar, as you can use 
> it to investigate the templates being used by your view and where Django is 
> looking to find those templates.
>
> -James
>
>
> On Thu, Mar 12, 2015 at 6:19 AM, john > 
> 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, 
> seehttps://docs.djangoproject.com/en/1.7/topics/settings/
>
> For the full list of settings and their values, 
> seehttps://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/checklist/
> # 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.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware',)
>
> ROOT_URLCONF = 'ddisco.urls'
>
> WSGI_APPLICATION = 'ddisco.wsgi.application'
>
> # Database# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
>
> DATABASES = 

Re: Django template not displaying

2015-03-12 Thread sourav mohanty
i have changed the 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(),
  context_instance=RequestContext(request))


def homeonce(request):
context = {}
template = "base.html"
return render(request, template, context)



The indentation is a result of pasting..
forms.py(i have commented it for the moment, but still no luck.)

# from django import forms
#
# from .models import SignUp
#
#
# class SignUpForm(forms.ModelForm):
# class Meta:
# model = SignUp


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, 
> seehttps://docs.djangoproject.com/en/1.7/topics/settings/
>
> For the full list of settings and their values, 
> seehttps://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/checklist/
> # 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.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware',)
>
> ROOT_URLCONF = 'ddisco.urls'
>
> WSGI_APPLICATION = 'ddisco.wsgi.application'
>
> # Database# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.sqlite3',
> 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
> }}
> # Internationalization# https://docs.djangoproject.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 settingsfrom 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 modelsfrom django.utils.encoding import 

Re: Django template not displaying

2015-03-12 Thread James Schneider
You also have two different URL's named 'home', which will lead to a bad
time. Make sure that those are unique.

>From what I can tell, none of your views render/reference 'signup.html', so
I would never expect that template to be rendered.

Configure a fields attribute on your form to get rid of the deprecation
warning. This will be required moving forward through future version of
Django:

https://docs.djangoproject.com/en/1.7/topics/forms/modelforms/#selecting-the-fields-to-use

When you say 'My templates just wouldn't load or show', what exactly is
shown in the browser window and/or runserver console?

My suggestion would be to install the django-debug-toolbar, as you can use
it to investigate the templates being used by your view and where Django is
looking to find those templates.

-James


On Thu, Mar 12, 2015 at 6:19 AM, john  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, 
> seehttps://docs.djangoproject.com/en/1.7/topics/settings/
>
> For the full list of settings and their values, 
> seehttps://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/checklist/
> # 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.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware',)
>
> ROOT_URLCONF = 'ddisco.urls'
>
> WSGI_APPLICATION = 'ddisco.wsgi.application'
>
> # Database# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.sqlite3',
> 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
> }}
> # Internationalization# https://docs.djangoproject.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 settingsfrom 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 modelsfrom django.utils.encoding import 
> smart_unicode
> # Create your models here.class SignUp(models.Model):
> first_name = models.CharField(max_length=

Re: Django template not displaying

2015-03-12 Thread john

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/checklist/

# 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.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF=  'ddisco.urls'

WSGI_APPLICATION=  'ddisco.wsgi.application'


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

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

# Internationalization
# https://docs.djangoproject.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.urlsimport  patterns,  include,  url

from  django.confimport  settings
from  django.conf.urls.staticimport  static


from  django.contribimport  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.dbimport  models
from  django.utils.encodingimport  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)
 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.shortcutsimport  render,  render_to_response,  RequestContext

from  .formsimport  SignUpForm
# Create your views here.
from  django.templateimport  Context,  Template

def  home(request):
 form=  SignUpForm(request.POSTor  None)

 if  form.is_valid():
 save_it=  form.save(commit=False)
 save_it.save()

 return  render_to_response(   "base.html",
 locals(),
 context_instance=RequestContext(request))


def  home(request):   
 context=  {}

 template=  "base.html"
 r

Django template not displaying

2015-03-12 Thread sourav mohanty


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/checklist/
# 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.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',)

ROOT_URLCONF = 'ddisco.urls'

WSGI_APPLICATION = 'ddisco.wsgi.application'

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

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}}
# Internationalization# https://docs.djangoproject.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 settingsfrom 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 modelsfrom 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)
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(),
context_instance=RequestContext(request))

def home(request):  
context = {}
template = "base.html"
return render(request, template, context)

base.html


  







Homepage


https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css";>


https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css";>



  

  


  {% block sign%}
  {%endblock%}

 

Re: Template not displaying validation errors [solved]

2010-05-05 Thread mhulse
Hi Karen! Thanks so much for your quick reply, I really appreciate
it. :)

> form.is_valid() is what annotates the existing form with error information
> in the case where there are errrors. However, if form.is_valid() returns
> False, the code here immediately overwrites the existing (now annotated with
> error information) form and replaces it with a newly-created blank form, so
> there will be no errors for the template to display. Get rid of that else
> leg.

Eureka! That did the trick!!!

I swear that every example I looked at today returned an unbound
form. :D

Onward!

Thanks again Karen. You rock!

Cheers,
Micky

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Template not displaying validation errors

2010-05-05 Thread Karen Tracey
On Wed, May 5, 2010 at 6:04 PM, mhulse  wrote:

>if form.is_valid(): # All validation rules pass.
>
># Q objects/pagination here...
>
>else:
>
>form = SearchForm()
>


form.is_valid() is what annotates the existing form with error information
in the case where there are errrors. However, if form.is_valid() returns
False, the code here immediately overwrites the existing (now annotated with
error information) form and replaces it with a newly-created blank form, so
there will be no errors for the template to display. Get rid of that else
leg.

Karen

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Template not displaying validation errors

2010-05-05 Thread mhulse
Hi,

I have spent half the day googling and testing my code with no luck
getting an error message to appear via my template. I am hoping ya'll
could provide a little assistance. :)

forms.py:



class SearchForm(forms.Form):
q = forms.CharField(
max_length = 128,
min_length = 2,
label = 'Keywords',
help_text = 'This is a required field'
)
def clean_q(self):
cd = self.cleaned_data['q']
if not cd:
raise forms.ValidationError("Please enter a search 
term.")
return cd
# More fields defined here 



views.py:



def search(request):

pg = request.GET.get('page', '1')
results = ''
form = SearchForm()

if request.method == 'GET': # If the form has been submitted...

form = SearchForm(request.GET) # A form bound to the GET data.

if form.is_valid(): # All validation rules pass.

# Q objects/pagination here...

else:

form = SearchForm()

return render_to_response(
'folder/search.html',
{
'form': form,
'results': results,
}
)



search.html (nothing is output in any of the below tags):



{{ form.non_field_errors }}
{% if form.errors %}
{{ form.errors|pluralize }}
{% endif %}
{% for field in form %}
{{ field.error }}
{{ field.field.error }}
{% endfor %}



I must be missing something really obvious here! :D

Almost all of the examples of django forms and validation use POST
data... Is there something about GET data that makes error handling
different?

TIA!

Cheers,
Micky

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Template not displaying

2009-11-10 Thread Denis Bahati

Hi all, am using xampp as webserver with django 1.1,when i access the
browser the template does not work. The media is in
c:/xampp/htdocs/adc/media/ where i put the css,img and js folders. I
set admin_media_prefix='http:/127.0.0.1/adc/media/' the same to
media_url. The template is at c:/xampp/htdocs/adc/templates/. Please
any idea on how to make the templates working?

-- 
Sent from my mobile device

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Template Not Displaying INPUT FIELD

2007-01-29 Thread johnny

Thank you.  It worked.

john

On Jan 29, 2:58 pm, "Collin Grady" <[EMAIL PROTECTED]> wrote:
> DateTimeFields have two inputs, not one. You need to use
> {{ form.start_at_date }} and {{ form.start_at_time }}
>
> In addition, you cannot use the date or time filters on a form field.
>
> On Jan 28, 3:16 pm, "johnny" <[EMAIL PROTECTED]> wrote:
>
> > In my template, I am not getting a input field for start_at.  In my
> > MySQL,
> > I have the following:
> > --+---+--+-+-
> > ++
> >  Field| Type  | Null | Key | Default |
> > Extra  |
> > --+---+--+-+-
> > ++
> >  start_at | datetime  | NO   | | NULL
> > ||
>
> > In the model I have the following:
> > start_at = models.DateTimeField('Start At')
>
> > In my template I have the following:
> > 
> > Start At: {{ form.start_at|
> > date:"F j, Y" }}
> > {% if form.start_at.errors %}*** {{ form.start_at.errors|join:",
> > " }}{% endif %}
> > 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Template Not Displaying INPUT FIELD

2007-01-29 Thread Collin Grady

DateTimeFields have two inputs, not one. You need to use 
{{ form.start_at_date }} and {{ form.start_at_time }}

In addition, you cannot use the date or time filters on a form field.

On Jan 28, 3:16 pm, "johnny" <[EMAIL PROTECTED]> wrote:
> In my template, I am not getting a input field for start_at.  In my
> MySQL,
> I have the following:
> --+---+--+-+-
> ++
>  Field| Type  | Null | Key | Default |
> Extra  |
> --+---+--+-+-
> ++
>  start_at | datetime  | NO   | | NULL
> ||
>
> In the model I have the following:
> start_at = models.DateTimeField('Start At')
>
> In my template I have the following:
> 
> Start At: {{ form.start_at|
> date:"F j, Y" }}
> {% if form.start_at.errors %}*** {{ form.start_at.errors|join:",
> " }}{% endif %}
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Template Not Displaying INPUT FIELD

2007-01-28 Thread johnny

In my template, I am not getting a input field for start_at.  In my 
MySQL,
I have the following:
--+---+--+-+-
++
 Field| Type  | Null | Key | Default | 
Extra  |
--+---+--+-+-
++
 start_at | datetime  | NO   | | NULL
||

In the model I have the following:
start_at = models.DateTimeField('Start At')

In my template I have the following:

Start At: {{ form.start_at|
date:"F j, Y" }}
{% if form.start_at.errors %}*** {{ form.start_at.errors|join:", 
" }}{% endif %}



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: datetime in template not displaying

2006-11-13 Thread [EMAIL PROTECTED]

actually, I came across this link that did the trick...


http://groups.google.com/group/django-users/browse_thread/thread/b958a059b6dca44e/67cc4c2f05719a65?lnk=gst&q=datetimeshortcuts&rnum=6#67cc4c2f05719a65


thanks!


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: datetime in template not displaying

2006-11-13 Thread [EMAIL PROTECTED]

Thank you for the reponse.

I tried that before, but I continue to get an error message...


DateTimeShortcuts.calendars[num].drawCurrent is not a function

I have this at the top of my code.









and this in the middle of the web page.


Today's Date: {{
form.todayDate_date}} {{ form.todayDate_time }}



Thanks,
Mike


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: datetime in template not displaying

2006-11-13 Thread Guillermo Fernandez Castellanos

Check this:
http://www.djangoproject.com/documentation/forms/#c1576

I had the same error a few weeks ago :-)

Hope it helps,

G

On 11/13/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hi!
>
> I have "models.DateTimeField defined in my model as "date_today".
>
> date_today  = models.DateTimeField('todays date')
>
>
> On my form submission template page, i have...
>
> Today's Date: {{
> form.date_today }}
>
> Whenever I try to load this page, it never displays a field, either a
> textfield or a calendar popup with information on how to submit this
> data.
>
> I was wondering, how can I get the web page to display a box to submit
> today's date/time information?
>
>
> Thanks in advance!
>
>
> >
>

--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



datetime in template not displaying

2006-11-13 Thread [EMAIL PROTECTED]

Hi!

I have "models.DateTimeField defined in my model as "date_today".

date_today  = models.DateTimeField('todays date')


On my form submission template page, i have...

Today's Date: {{
form.date_today }}

Whenever I try to load this page, it never displays a field, either a
textfield or a calendar popup with information on how to submit this
data.

I was wondering, how can I get the web page to display a box to submit
today's date/time information?


Thanks in advance!


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---