Django 1.4 admin. Calendar widget appears for DateTimeField but not DateField

2012-08-16 Thread grimmus
I have checked for missing resources (jquery etc.) but all external assets 
are being loaded correctly. It's just that nothing appears beside the 
textbox for the DateField !

Anyone any ideas why this might be happening ?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/1PJeTlXPX_4J.
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.



Avoiding code repetition in views

2012-06-28 Thread grimmus
Hi,

I am doing a site for a DJ that lists upcoming gigs on each page. There's 
an include file in each page template to output the list of gigs.

I am wondering how i can pass the gig information to every page without 
having to repeat the code in every page view.

I hope i have been clear

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/naTvLr9T_3MJ.
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: Displaying events by month

2012-06-24 Thread grimmus
Thank you Nikolas. Works perfect :)

On Wednesday, June 20, 2012 11:21:28 PM UTC+1, Nikolas Stevenson-Molnar 
wrote:
>
>  First, order by date in your query:
>
> events = Event.objects.order_by('date')
>
> Then in your template, use the ifchanged tag (
> https://docs.djangoproject.com/en/1.4/ref/templates/builtins/#ifchanged):
>
> {% for event in events %}
> {% ifchanged event.date.month event.date.year %}
> month here
> {% endifchanged %}
> item here
> {% endfor %}
>
> _Nik
>
> On 6/20/2012 2:22 PM, grimmus wrote:
>  
> Hi, 
>
>  I am trying to output upcoming events in the following format
>
>  *June 2012*
> 12th - Event 1
> 15th - Event 2
>
>  *July 2012*
> 1st - Event 3
>
>  *August 2012*
> 20th - Event 4
>
>  My model is very simple with just a title and dateTime field. I am 
> unsure how i could output the months followed by the events in the style 
> above. I guess nested loops would be necessary but would i need a separate 
> loop for each month output ?
>
>  Thanks for any tips.
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/django-users/-/RHAvjD4cKqUJ.
> 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.
>
>
>
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/77AAh4wEiBkJ.
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.



Displaying events by month

2012-06-20 Thread grimmus
Hi,

I am trying to output upcoming events in the following format

*June 2012*
12th - Event 1
15th - Event 2

*July 2012*
1st - Event 3

*August 2012*
20th - Event 4

My model is very simple with just a title and dateTime field. I am unsure 
how i could output the months followed by the events in the style above. I 
guess nested loops would be necessary but would i need a separate loop for 
each month output ?

Thanks for any tips.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/RHAvjD4cKqUJ.
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: Year dropdown in Django admin

2012-02-20 Thread grimmus
Excellent,

Thanks very much

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/VfjSLhXCkPcJ.
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.



Year dropdown in Django admin

2012-02-20 Thread grimmus
Hi,

I have a car model that contains many fields including a 'year' field. I 
need the dropdown for this field to display the current year as the first 
option and also display the previous 25 years as individual options.

I was thinking i could create a list object and then populate the list 
based on the current year and work my way back to 25 years earlier.

I am not sure how to implement this so it would work in the Django admin 
area.

Could someone please point me in the right direction with this ?

Thank you in advance.


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/NUO22GxW7UEJ.
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: Looking For A Solid Learning Tutorial

2011-04-14 Thread grimmus
I just found a site full of great tutorials - 
http://www.lightbird.net/dbe/index.html

Learning lots of things and new techniques too !

On Apr 13, 5:49 pm, 小白  wrote:
> Yes I think "Practical Django Projects" is very good for newbie, after
> reading that i
> start my own job using Django to setup a CMS.
>
>
>
>
>
>
>
> On Wed, Apr 13, 2011 at 9:55 PM, Shawn Milochik  wrote:
> > Try James Bennett's book, "Practical Django Projects."
>
> > It walks you step-by-step through creating full apps.
>
> > Shawn
>
> > --
> > 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.

-- 
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.



Determining profile completeness

2011-04-14 Thread grimmus
Hi,

I am interested in extending the User object and implementing
functionality that determines how complete the users profile is.

So, if they have filled in 5 of 10 fields the profile is 50% complete.
But, some fields are more important than others so i was thinking of
weighting each field (a weight of 1 add's 10% to the profile
completeness and a weight of 3 adds 5%).

Has anyone tried to implement something similar to this using Django
or another framework ?

Thank you for any advice/tips.

-- 
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.



list out of range error

2010-09-20 Thread grimmus
Hi,

On the homepage of my website i list 1 random ad in the right column.
In my view i retrieve it like so:

side_ad = SideAd.objects.filter(active=1).order_by("?")[0]

If all ad's are inactive no object's will be returned thus creating an
IndexError : list out of range

I tried to wrap the above in a try/except block but it's still the
same error:

try:
 side_ad = SideAd.objects.filter(active=1).order_by("?")[0]
except (KeyError,SideAd.DoesNotExist):
 side_ad = None

I still pass side_ad back in the context.

Could someone tell me what I'm doing wrong ?

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-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: 'unicode' object has no attribute '_committed'

2010-08-10 Thread grimmus
I just found out Modeltranslation does not support ImageField :-(

http://code.google.com/p/django-modeltranslation/issues/detail?id=30

On Aug 10, 10:01 pm, grimmus <graham.col...@gmail.com> wrote:
> I am doing it in the admin area, so i dont have any custom code.
>
> The issue might be with the Modeltranslation module. It creates extra
> columns for the different translations, so, for example, title has
> title, title_en, title_fr as rows in the DB. This applies to the image
> field too.
>
> Thanks for any further guidance.
>
> On Aug 10, 9:55 pm, wayne <wayne.tuxro...@gmail.com> wrote:
>
> > What is the code that you are using to save instances of the model
> > with?

-- 
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: 'unicode' object has no attribute '_committed'

2010-08-10 Thread grimmus
I am doing it in the admin area, so i dont have any custom code.

The issue might be with the Modeltranslation module. It creates extra
columns for the different translations, so, for example, title has
title, title_en, title_fr as rows in the DB. This applies to the image
field too.

Thanks for any further guidance.

On Aug 10, 9:55 pm, wayne  wrote:
> What is the code that you are using to save instances of the model
> with?

-- 
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: 'unicode' object has no attribute '_committed'

2010-08-10 Thread grimmus
Thanks for the reply, below is my Project model

from django.db import models

class Project(models.Model):
title = models.CharField(max_length=100)
path = models.CharField(max_length=100,help_text='This should be
the folder name')
image = models.ImageField(upload_to='/images/projects/')
date = models.DateField(help_text='The projects are ordered by
date')
active = models.BooleanField()

def __unicode__(self):
return u'%s' %(self.title)

On Aug 10, 9:24 pm, wayne  wrote:
> > When i try and add a project  in the admin i get the error: 'unicode'
> > object has no attribute '_committed' . I'm quite certain it's an issue
> > with the image field.
>
> Well, not to be coy, but you have a unicode string somewhere whose
> _committed value you are trying to access.  Problem is, the unicode
> string does not have this particular value/method.
>
> That's what I'm guessing without seeing the code, anyway.
>
> Wayne

-- 
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.



'unicode' object has no attribute '_committed'

2010-08-10 Thread grimmus
Hi,

I am using Django 1.2.1

I have a model called Project that contains a char field and an image
field.

My project used Modeltranslation so i can have an English and French
version of the 2 fields.

When i try and add a project  in the admin i get the error: 'unicode'
object has no attribute '_committed' . I'm quite certain it's an issue
with the image field.

Does anyone know what might be going wrong ?

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-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.



Calling some javascript for new visitors only

2010-07-07 Thread grimmus
Hi,

I need to show a javascript lightbox popup for new visitors to my
site.

I presume using a cookie is the best way to achieve this. But how can
i check whether the cookie exists in my template, so i can call some
javascript code if it's a new visitor ?

I hope i have been clear,

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-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: best translation solution for my project

2010-07-01 Thread grimmus
Thanks for the reply.

I settled on django-modeltranslation, it's easy to install, well
documented and fits into the admin area.

Thanks again.

On Jul 1, 3:46 pm, bruno desthuilliers <bruno.desthuilli...@gmail.com>
wrote:
> On 1 juil, 10:18, grimmus <graham.col...@gmail.com> wrote:
>
>
>
> > Hi,
>
> > Sorry if this has been asked before, but i only seem to be finding
> > bit's and pieces for what i am after.
>
> > I have a simple website that needs to be available in English and
> > French.
>
> > I am using locale-url so all pages can have an independent url ( e.g.
> > en/page and fr/page)
>
> > There is a locale folder in my project that contains the .po and .mo
> > files, all this is working correctly when i switch languages.
>
> > The question is, how can my client translate the model fields in the
> > admin area ? For example, there is a client list page that uses a
> > model with a title and a body text. If they initially entered the
> > client list in English, how would they add it in French ?
>
> > I have heard about something called Rosetta but have not looked too
> > much into it yet.
>
> > Thanks for any advice on what solution would be best based on my
> > requirements.
>
> Rosetta can be helpful for all the .po/.mo stuff, but won't help for
> your model-based content.
>
> We're using currently using Transmetta on one of projects - the first
> that had this requirement - and it works fine so far. One of the nice
> points is that it has very minimal impact on your existing code AND
> data so you can add it afterwards without much pain.
>
> http://code.google.com/p/django-transmeta/

-- 
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: Newby Question: template system doesn't render form html

2010-07-01 Thread grimmus
You dont seem to be closing your input tags, add > to the end of them

On Jul 1, 4:47 am, Gene  wrote:
> When I put a form into my template it comes back blank. Does anyone
> know why?
>
> what is in my template
>
> 
>
>     
>     
> 
> 
>
> what I get in my browser
>
> 

-- 
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.



best translation solution for my project

2010-07-01 Thread grimmus
Hi,

Sorry if this has been asked before, but i only seem to be finding
bit's and pieces for what i am after.

I have a simple website that needs to be available in English and
French.

I am using locale-url so all pages can have an independent url ( e.g.
en/page and fr/page)

There is a locale folder in my project that contains the .po and .mo
files, all this is working correctly when i switch languages.

The question is, how can my client translate the model fields in the
admin area ? For example, there is a client list page that uses a
model with a title and a body text. If they initially entered the
client list in English, how would they add it in French ?

I have heard about something called Rosetta but have not looked too
much into it yet.

Thanks for any advice on what solution would be best based on my
requirements.

-- 
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.



ordering objects in the admin area

2010-06-08 Thread grimmus
Hi,

I have a staff app that lists staff photos and their names. The client
would like to be able to re-order these in the admin area easily.
Ideally there would be a dropdown where the user could select between
1 and n which object should appear in what position in the list.

I could add an extra integer field to the model, but how would i
initially populate it with a value ? And how would the dropdown work
in the admin area ?

Thank you for any tips/advice.

-- 
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.



Session not working as i had hoped

2010-05-26 Thread grimmus
Hi,

When the user enters a site for the first time they should see a flash
version of the logo. All other times they should see a gif image. My
home view looks like:

if request.session.get('has_visited',True):
visited = True
else:
visited = False

t = loader.get_template('static/home.html')
c = RequestContext(request,{
'visited': visited,
})
return HttpResponse(t.render(c))

request.session['has_visited'] = True

So, i set the value of the session after the page has been served.

Then in my template i have

{% if visited %}
visited already, show gif logo
{% else %}
new user, show flash logo
{% endif %}

It seems the Session is always True, even when i clear all browser
info, restart etc.

Could someone tell me what i am doing wrong ?

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-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: Deleted blog posts not disappearing

2010-03-30 Thread grimmus
Thanks for the replies.

I am using generic date based views for the page, so i am passing
other things through the extra_context :

My code is here http://dpaste.com/hold/177740/

Thanks for any more info.

On Mar 26, 4:06 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Fri, Mar 26, 2010 at 9:32 AM, grimmus <graham.col...@gmail.com> wrote:
> > In the view:
>
> > diary = Entry.objects.filter(status=1).order_by('-pub_date')[:5]
>
> > t = loader.get_template('cms/page.html')
> > c = RequestContext(request,{
> >     'diary':diary,
> > })
> > return HttpResponse(t.render(c))
>
> Is that diary = line really inside your view function? Since you have not
> shown the actual view function definition it is hard to be sure. Based on
> the behavior you describe it sounds like that line is not inside the view
> function definition, and therefore possibly only executed once, when
> views.py is loaded. If you want it to be executed when the view function is
> called, it needs to be inside the view function itself.
>
> 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.



Re: Deleted blog posts not disappearing

2010-03-26 Thread grimmus
In the view:

diary = Entry.objects.filter(status=1).order_by('-pub_date')[:5]

t = loader.get_template('cms/page.html')
c = RequestContext(request,{
 'diary':diary,
})
return HttpResponse(t.render(c))

And the template


{% for entry in diary %}

{{entry.title}}

{% endfor %}


Thanks

On Mar 26, 12:59 pm, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Mar 26, 11:25 am, grimmus <graham.col...@gmail.com> wrote:
>
>
>
> > Hi,
>
> > I have a website with 5 pages and a blog.
>
> > At the bottom of every page is a list of recent blog posts.
>
> > When i delete some blog posts they still appear in the recent posts
> > list.
>
> > I am not using any caching.
>
> > If i restart the local dev server then they disappear.
>
> > Could anyone tell me why this is happening ?
>
> > Thanks
>
> Not without seeing the code that is generating the list.
> --
> DR.

-- 
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.



Deleted blog posts not disappearing

2010-03-26 Thread grimmus
Hi,

I have a website with 5 pages and a blog.

At the bottom of every page is a list of recent blog posts.

When i delete some blog posts they still appear in the recent posts
list.

I am not using any caching.

If i restart the local dev server then they disappear.

Could anyone tell me why this is happening ?

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-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.



Multiple querysets for dictionary

2010-03-25 Thread grimmus
Hi,

For my xml sitemap i would like to show blog posts and pages from the
CMS. How can i pass 2 querysets to the dictionary ?

What i have so far is below, it's obviously wrong :-(

info_dict = {
'queryset': Page.objects.filter(active=1),
'queryset': Entry.objects.filter(status=1),
'date_field': 'pub_date',
}

Thanks for any help

-- 
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: Remove session on browser close

2010-03-22 Thread grimmus
Basically all i want to do is the following :

Have a newsletter signup form. When the user signs up successfully the
area where the form was has a thanks message instead of the form.

The form or thanks message is displayed on every page of the site, so
I thought using a session would be the best way handle whether to show
the form or the thanks message.

Here is my form



{% if form.errors %}
Please enter a valid email address.
{% endif %}
{% if form.thanks %}
Thanks for signing up
{% endif %}
{% if form.alreadyexists %}
The email address already exists
{% endif %}
{% if not form.thanks %}
  
  
{% endif %}

  

And my view

if request.POST:
form = SignUp(request.POST)

if form.is_valid():

email = request.POST.get('email', '')

try:
entry = MailingList.objects.get(email=email)

form.alreadyexists = True

except (KeyError, MailingList.DoesNotExist):

entry = MailingList()
entry.email = email
entry.date_added = datetime.now()
entry.save()

request.session['signed_up'] = True
form.thanks = True

return HttpResponseRedirect(request.get_full_path())

else:
print form.errors

else:

form = SignUp()

t = loader.get_template('home/page.html')
c = RequestContext(request,{
'form':form,
})

if request.session.get('signed_up', True):
form.thanks = True

return HttpResponse(t.render(c))


Any help is greatly appreciated.

On Mar 22, 3:13 pm, Bill Freeman  wrote:
> And if the user disables javascript, or kills the browser without
> normal exit, or loses
> his connection, or pulls the ethernet cable, or has a power failure?
>
> On Mon, Mar 22, 2010 at 10:06 AM, Wiiboy  wrote:
> > Couldn't you use Javascript for this? For example, on the
> > onbeforeunload event, delete the sessionid cookie?
>
> > --
> > 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 
> > athttp://groups.google.com/group/django-users?hl=en.

-- 
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.



Remove session on browser close

2010-03-22 Thread grimmus
Hi,

I have a simple newsletter signup form. If the user submits the form
and there are no errors then i set the session:

request.session['signed_up'] = True

Then, for all other page requests i check if the session exists

if request.session.get('signed_up', True):
form.thanks = True

form.thanks shows some HTML in the template.

How can i remove the session when the user closes the site ?

I tried SESSION_EXPIRE_AT_BROWSER_CLOSE = True but it does not seem to
do anything.

Thanks for any advice

-- 
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: Form submission show 'thanks' message

2010-03-19 Thread grimmus
Excellent, thanks for the reply

On Mar 19, 3:49 pm, Tom Evans <tevans...@googlemail.com> wrote:
> On Fri, Mar 19, 2010 at 2:08 PM, grimmus <graham.col...@gmail.com> wrote:
> > Hi,
>
> > When the form is submitted i would like to show a message above the
> > form. Much like the way if there are form errors you can print
> > form.errors
>
> > So, in my template i have entered
>
> >                    {% if form.thanks %}
> >                    thanks for submitting the form
> >                    {% endif %}
>
> > Then in the view i have
>
> >                entry.save()
> >                print form.thanks
>
> > In my Form Model i have
>
> > class SignUp(ModelForm):
>
> >    class Meta:
> >        model = MailingList
> >        exclude = ('ip_address','active','date_added')
>
> >    def thanks():
> >        return 'thanks'
>
> > I guess i am doing something wrong
>
> > Thanks for any tips
>
> Try like this instead (adjust for how your views code actually works):
>
> view:
>   if form.is_valid():
>     form.save()
>     form.thanks = True
>
> Remove the thanks method from your ModelForm, and leave your template as it 
> is.
>
> Cheers
>
> Tom

-- 
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.



Form submission show 'thanks' message

2010-03-19 Thread grimmus
Hi,

When the form is submitted i would like to show a message above the
form. Much like the way if there are form errors you can print
form.errors

So, in my template i have entered

{% if form.thanks %}
thanks for submitting the form
{% endif %}

Then in the view i have

entry.save()
print form.thanks

In my Form Model i have

class SignUp(ModelForm):

class Meta:
model = MailingList
exclude = ('ip_address','active','date_added')

def thanks():
return 'thanks'

I guess i am doing something wrong

Thanks for any tips

-- 
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.



Shared views

2010-03-14 Thread grimmus
Hi,

I have a site with a blog area and 5 pages powered by a simple cms.

On every page i show event information in the right column and social
media info in the left column.

I am wondering what view should contain the info for the left and
right column ? I would like to keep it separate from the blog and cms
views so i can re-use it in both places.

Any advice is appreciated. I hope i have been clear.

-- 
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: Django with Jquery

2010-03-01 Thread grimmus
link to the Google jQuery instead of a local file (it's really fast
too)

  http://google.com/jsapi"; />