Re: What is the Development Life Cycle of Django App?

2011-07-22 Thread Eyad Al-Sibai
Thanks!

On Sat, Jul 23, 2011 at 4:04 AM, Mike Dewhirst wrote:

> On 23/07/2011 12:31am, Eyad Al-Sibai wrote:
>
>> What is the Development Life Cycle of Django App? Should I start in
>> implementing the models or the urls ... or what exactly?
>>
>
> Best advice I know is in Practical Django Projects by James Bennett
>
>
>  --
>> 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+unsubscribe@**
>> 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+unsubscribe@**
> 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.



Re: Custom Manager

2011-07-22 Thread Eyad Al-Sibai
Thanks a lot!

On Sat, Jul 23, 2011 at 5:08 AM, Matt M  wrote:

> From The Definitive Guide to Django:
>
> "In short, a model’s manager is an object through which Django models
> perform database queries. Each Django model has at least one manager, and
> you can create custom managers to customize database access. There are two
> reasons you might want to create a custom manager: to add extra manager
> methods, and/or to modify the initial QuerySet the manager returns."
>
> The default manager is called '*objects*'. It's the manager you use if you
> don't add custom managers:
>
> Model.*objects*.all()
>
> In a model you can replace the default manager with a custom manager for
> custom access/specialized queries.
>
> You can also add a custom manager into a model after the default one. So
> you will have access to the default manager and the custom manager.
>
> Model.objects.all()
> Model.custom_objects.all()
>
> Model.objects.all() will return all objects for this model
> Model.custom_objects.all() will return all objects as filtered by your
> custom manager.
>
> Hope that helps,
> ~Matt
>
>
>
>
> On Fri, Jul 22, 2011 at 6:35 PM, Andre Terra  wrote:
>
>> Managers operate on your model, so their methods usually call sgl
>> queries on a model's database.
>>
>> As an example, assume a blog app with a Post model which, among other
>> things has a BooleanField called 'draft'.
>>
>> You could then write a custom manager called PublishedManager that
>> subclasses the default manager and overrides the default get_queryset
>> method, so that a .filter(draft=False) is added to every query.
>>
>> Add it to your Post model by setting it as the 'published' attribute
>> and then you could use Post.published.all() to get just the posts with
>> draft=False.
>>
>>
>> Cheers,
>> AT
>>
>> On 7/22/11, Shawn Milochik  wrote:
>> > On 07/22/2011 10:30 AM, Eyad Al-Sibai wrote:
>> >> Hi!
>> >>
>> >> I still do not get the meaning of Manager or Custom Manager in
>> >> Django... I am confused!
>> >>
>> >
>> > If you've used the '.objects' attribute of a model you've used a
>> manager.
>> >
>> > A custom manager would be a subclass of the standard manager. You can
>> > then alter/replace things like all(), filter(), and get(), and add your
>> > own methods.
>> >
>> >
>> > --
>> > 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.
>> >
>> >
>>
>> --
>> 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.
>>
>>
>  --
> 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.



Re: Real Example

2011-07-22 Thread Eyad Al-Sibai
Thanks a lot! I appreciate it

On Sat, Jul 23, 2011 at 5:33 AM, Peter Murphy wrote:

> Eyad,
>
> Well, I'll be damned:
>
> http://www.djangosites.org/with-source/
>
> It's good etiquette to say "thank you" at this point. ;-)
>
> Best regards,
> Peter
>
> On Jul 23, 4:17 am, Phang Mulianto  wrote:
> > you better find books in amazon. .. many ready to learn for you..
> > On Jul 22, 2011 10:41 PM, "Shawn Milochik"  wrote:>
> On 07/22/2011 10:31 AM, Eyad Al-Sibai wrote:
> > >> Hi!
> >
> > >> I want a real example of complete django application with source code
> > >> to understand django better
> >
> > > 1. Search Google, github, and bitbucket.
> >
> > > 2. Read this:https://code.djangoproject.com/wiki/UsingTheMailingList
> >
> > > --
> > > 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.
>
>

-- 
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: Real Example

2011-07-22 Thread Peter Murphy
Eyad,

Well, I'll be damned:

http://www.djangosites.org/with-source/

It's good etiquette to say "thank you" at this point. ;-)

Best regards,
Peter

On Jul 23, 4:17 am, Phang Mulianto  wrote:
> you better find books in amazon. .. many ready to learn for you..
> On Jul 22, 2011 10:41 PM, "Shawn Milochik"  wrote:> On 
> 07/22/2011 10:31 AM, Eyad Al-Sibai wrote:
> >> Hi!
>
> >> I want a real example of complete django application with source code
> >> to understand django better
>
> > 1. Search Google, github, and bitbucket.
>
> > 2. Read this:https://code.djangoproject.com/wiki/UsingTheMailingList
>
> > --
> > 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.



Re: Custom Manager

2011-07-22 Thread Matt M
>From The Definitive Guide to Django:

"In short, a model’s manager is an object through which Django models
perform database queries. Each Django model has at least one manager, and
you can create custom managers to customize database access. There are two
reasons you might want to create a custom manager: to add extra manager
methods, and/or to modify the initial QuerySet the manager returns."

The default manager is called '*objects*'. It's the manager you use if you
don't add custom managers:

Model.*objects*.all()

In a model you can replace the default manager with a custom manager for
custom access/specialized queries.

You can also add a custom manager into a model after the default one. So you
will have access to the default manager and the custom manager.

Model.objects.all()
Model.custom_objects.all()

Model.objects.all() will return all objects for this model
Model.custom_objects.all() will return all objects as filtered by your
custom manager.

Hope that helps,
~Matt



On Fri, Jul 22, 2011 at 6:35 PM, Andre Terra  wrote:

> Managers operate on your model, so their methods usually call sgl
> queries on a model's database.
>
> As an example, assume a blog app with a Post model which, among other
> things has a BooleanField called 'draft'.
>
> You could then write a custom manager called PublishedManager that
> subclasses the default manager and overrides the default get_queryset
> method, so that a .filter(draft=False) is added to every query.
>
> Add it to your Post model by setting it as the 'published' attribute
> and then you could use Post.published.all() to get just the posts with
> draft=False.
>
>
> Cheers,
> AT
>
> On 7/22/11, Shawn Milochik  wrote:
> > On 07/22/2011 10:30 AM, Eyad Al-Sibai wrote:
> >> Hi!
> >>
> >> I still do not get the meaning of Manager or Custom Manager in
> >> Django... I am confused!
> >>
> >
> > If you've used the '.objects' attribute of a model you've used a manager.
> >
> > A custom manager would be a subclass of the standard manager. You can
> > then alter/replace things like all(), filter(), and get(), and add your
> > own methods.
> >
> >
> > --
> > 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.
> >
> >
>
> --
> 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.
>
>

-- 
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: Method call when deleting FK in admin

2011-07-22 Thread Kejun He
try "admins.ModelAdmin"

On Sat, Jul 23, 2011 at 5:07 AM, galgal  wrote:

>
>
> My models:class Spectacle(models.Model):
>
> title = models.CharField(max_length=100)
> slug = models.SlugField(max_length=100 unique=False)
> description = models.TextField()
> class SpectacleGallery(models.Model):
> spectacle = models.ForeignKey(Spectacle)
> image = models.ImageField(upload_to=upload_path_handler, max_length=255,
> help_text=_(u'tylko pliki z rozszerzeniem .jpg'))
> image_thumb = models.CharField(max_length=255, editable=False, blank=True,
> null=True)
> def delete(self, *args, **kwargs):
>
> image_thumb_abs = settings.MEDIA_ROOT + str(self.image_thumb)
>
> # try to delete thumb and image
>
> try:
>
> remove(image_thumb_abs)
>
> except Exception:
>
> pass
>
> try:
>
> self.image.delete()
>
> except Exception:
>
> pass
>
> super(SpectacleGallery, self).delete(*args, **kwargs) # Call the "real"
> delete() method.
>
> #try to delete dir
>
> try:
>
> removedirs(settings.SPECTACLE_GALLERY_UPLOAD_PATH + str(self.spectacle_id))
>
> except:
>
> pass
>
>
> Now in admin, when I delete from SpectacleGallery file is being deleted
> from disk and DB properly. The problem is when I want to delete Spectacle.
> Deletion page is asking if i'm sure to delete Spectacle and all related
> images. I confirm and: all records from database are deleted. Unfortunately
> files from SpectacleGallery are not deleted.I paste print into delete()
> method in SpectacleGallery. Nothing shows so my question is: Why delete
> method is not called when deleting it in that way?
>
> --
> 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/-/6o66VmCVQqMJ.
> 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.



Re: Custom Manager

2011-07-22 Thread Andre Terra
Managers operate on your model, so their methods usually call sgl
queries on a model's database.

As an example, assume a blog app with a Post model which, among other
things has a BooleanField called 'draft'.

You could then write a custom manager called PublishedManager that
subclasses the default manager and overrides the default get_queryset
method, so that a .filter(draft=False) is added to every query.

Add it to your Post model by setting it as the 'published' attribute
and then you could use Post.published.all() to get just the posts with
draft=False.


Cheers,
AT

On 7/22/11, Shawn Milochik  wrote:
> On 07/22/2011 10:30 AM, Eyad Al-Sibai wrote:
>> Hi!
>>
>> I still do not get the meaning of Manager or Custom Manager in
>> Django... I am confused!
>>
>
> If you've used the '.objects' attribute of a model you've used a manager.
>
> A custom manager would be a subclass of the standard manager. You can
> then alter/replace things like all(), filter(), and get(), and add your
> own methods.
>
>
> --
> 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.
>
>

-- 
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: django-admin inspectdb does not detect NULL columns for PostgreSQL database

2011-07-22 Thread Andre Terra
Didn't read the original question, so excuse me for not replying.

And thanks/congrats on the new patch =)

Cheers,
AT

On 7/22/11, Ricardo L. Dani  wrote:
> FYI i fixed that and post a patch in the ticket.
>
> Regards
>
> On Thu, Jul 21, 2011 at 9:21 AM, Ricardo L. Dani 
> wrote:
>> Hi everyone,
>>
>> I have the same problem of this ticket from django trac:
>> https://code.djangoproject.com/ticket/7783
>>
>> The PostgreSQL database introspection does not detect NULL columns,
>> cursor.description does not return the null_ok field, so database
>> introspection does not add null=True to column definitions. The
>> is_nullable column in information_schema.columns does contain this
>> information, however.
>>
>> A patch was subimitted, but i can't apply this 'cause the version of
>> django that's the patch was appliend is different to 1.3 (the version
>> i use).
>>
>> Somebody knows what version of django this patch is applied? Or a
>> other way to solve this problem?
>>
>> Regards
>>
>> --
>> Ricardo Lapa Dani
>>
>
>
>
> --
> Ricardo Lapa Dani
>
> --
> 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.
>
>

-- 
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: What is the Development Life Cycle of Django App?

2011-07-22 Thread Mike Dewhirst

On 23/07/2011 12:31am, Eyad Al-Sibai wrote:
What is the Development Life Cycle of Django App? Should I start in 
implementing the models or the urls ... or what exactly?


Best advice I know is in Practical Django Projects by James Bennett


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



Django + PyPy = ?

2011-07-22 Thread Dmitry Pisklov
Hi all,

Tried to use PyPy to run django and tried following this instructions:
https://code.djangoproject.com/wiki/DjangoAndPyPy

But with no luck - I'm getting this error when trying to run pypy manage.py:

$ pypy manage.py runserver
'import site' failed
Traceback (most recent call last):
  File "app_main.py", line 53, in run_toplevel
  File "manage.py", line 2, in 
from django.core.management import execute_manager
ImportError: No module named django.core


 However, it can find django module:

$ pypy
'import site' failed
Python 2.7.1 (b590cf6de419, Apr 30 2011, 02:00:34)
[PyPy 1.5.0-alpha0 with GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
And now for something completely different: ``"3 + 3 = 8"  Anto in the JIT
talk''
 import django
 django

 

Googling didn't helped me - any ideas?

PS it works well with my default python2.6 installation. My OS is debian, if 
it can help anyhow...

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



Method call when deleting FK in admin

2011-07-22 Thread galgal


My models:class Spectacle(models.Model):

title = models.CharField(max_length=100)
slug = models.SlugField(max_length=100 unique=False)
description = models.TextField()
class SpectacleGallery(models.Model):
spectacle = models.ForeignKey(Spectacle)
image = models.ImageField(upload_to=upload_path_handler, max_length=255, 
help_text=_(u'tylko pliki z rozszerzeniem .jpg'))
image_thumb = models.CharField(max_length=255, editable=False, blank=True, 
null=True)
def delete(self, *args, **kwargs):

image_thumb_abs = settings.MEDIA_ROOT + str(self.image_thumb)

# try to delete thumb and image

try:

remove(image_thumb_abs)

except Exception:

pass

try:

self.image.delete()

except Exception:

pass

super(SpectacleGallery, self).delete(*args, **kwargs) # Call the "real" 
delete() method.

#try to delete dir

try:

removedirs(settings.SPECTACLE_GALLERY_UPLOAD_PATH + str(self.spectacle_id))

except:

pass


Now in admin, when I delete from SpectacleGallery file is being deleted from 
disk and DB properly. The problem is when I want to delete Spectacle. 
Deletion page is asking if i'm sure to delete Spectacle and all related 
images. I confirm and: all records from database are deleted. Unfortunately 
files from SpectacleGallery are not deleted.I paste print into delete() 
method in SpectacleGallery. Nothing shows so my question is: Why delete 
method is not called when deleting it in that way? 

-- 
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/-/6o66VmCVQqMJ.
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.



Question about flatpages + registration required

2011-07-22 Thread eddie
Sorry for the question, but I can't seem to track down a place to
start.

I've got a fairly simple django site that includes flatpages.  I'm
trying to require authentication to view one or two of the flatpages
(like I would with a .htaccess, for instance).  When I go to the
admin, and click the "registration required" checkbox and go to the
flatpage url, I'm still able to access the page when logged out.  I've
included django.contrib.auth and django.contrib.contenttypes as
installed apps, as well.

Can someone let me know what I'm missing here? Is there something more
that I have to do to enable authentication for these pages?

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



limit foreignkey of queryset

2011-07-22 Thread Jonas Geiregat
Hello,

How would I limit the results of a foreign key of a queryset ?
Ie. I have the models Person and Task. I want to get all Person's but only get 
their 2 latest tasks.

Person__task points to Task__name 
It's a ManyToMany Relationship.


Jonas Geiregat
jo...@geiregat.org





-- 
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: Editor de textfield

2011-07-22 Thread Jussiê Vieira Toledo
sorry forgot the rest of the query

correcting:

js = ('/static/grappelli/tinymce/jscripts/tiny_mce/tiny_mce.js','/
static/grappelli/tinymce_setup/tinymce_setup.js',)

On 21 jul, 23:08, Jussiê Vieira Toledo  wrote:
> Hello everybody!
>
> I am wanting to use the TinyMCEeditorautomatically in fields of 
> typeTextField. To know that it is necessary to add a supplement in the
> middle class which is the Admin:
> class Media:
> js =
>
> But where is this middle class physically admin? Not found at all. I'm
> using Grappelli.
>
> There is an adm file that change and in all fields or theeditorwill
> appear in every class I have to add theeditor?
>
> Thank you.

-- 
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: Editor de textfield

2011-07-22 Thread Jussiê Vieira Toledo
sorry forgot the rest of the query

correcting:

js = ('/static/grappelli/tinymce/jscripts/tiny_mce/tiny_mce.js','/
static/grappelli/tinymce_setup/tinymce_setup.js',)

On 21 jul, 23:08, Jussiê Vieira Toledo  wrote:
> Hello everybody!
>
> I am wanting to use the TinyMCEeditorautomatically in fields of 
> typeTextField. To know that it is necessary to add a supplement in the
> middle class which is the Admin:
> class Media:
> js =
>
> But where is this middle class physically admin? Not found at all. I'm
> using Grappelli.
>
> There is an adm file that change and in all fields or theeditorwill
> appear in every class I have to add theeditor?
>
> Thank you.

-- 
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: Real Example

2011-07-22 Thread Phang Mulianto
you better find books in amazon. .. many ready to learn for you..
On Jul 22, 2011 10:41 PM, "Shawn Milochik"  wrote:
> On 07/22/2011 10:31 AM, Eyad Al-Sibai wrote:
>> Hi!
>>
>> I want a real example of complete django application with source code
>> to understand django better
>>
>
> 1. Search Google, github, and bitbucket.
>
> 2. Read this: https://code.djangoproject.com/wiki/UsingTheMailingList
>
>
> --
> 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.



Re: Database Design Question

2011-07-22 Thread nixlists
On Thu, Jul 21, 2011 at 5:35 PM, Marc Aymerich  wrote:
>
> ups, I think it should be:
> contract.products.filter(id=Y).values_list('rebate_pct', flat=True)
> product.contractproduct_set.filter(id=X).values_list('rebate_pct',
> flat=True)

Thanks. The first one does not work since rebate_pct is in the
contractproduct table.

-- 
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: a little help with the urls.py and views.py

2011-07-22 Thread Andre Terra
https://code.djangoproject.com/wiki/UsingTheMailingList

On Fri, Jul 22, 2011 at 11:23 AM, Derick Felsman <
derick.fels...@cbsinteractive.com> wrote:

> bump
>
> On Jul 22, 12:15 am, Derick Felsman
>  wrote:
> > extending from the example found here
> >
> > https://docs.djangoproject.com/en/dev/topics/db/queries/
> >
> > what if i wanted to create a url where i would pass in a list of
> > authors (not necessarily a list but an unspecified number of different
> > authors) and then query for an entry that has all of the specified
> > authors, what would be the best way to go about doing that.
> >
> > urls.py and views.py code examples would be appreciated.  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
> 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.



Re: Recommendations for load testing/profiling a django site server?

2011-07-22 Thread Malcolm Box
On 22 July 2011 13:52, Jacob Kaplan-Moss  wrote:

> On Thu, Jul 21, 2011 at 5:03 PM, br  wrote:
> > I am running on a Linode 768 VPS and may have some stuff going live
> > before too long.  I'm wondering what the best way to guage whether I
> > have enough bandwidth/CPU/memory to handle a significant amount of
> > traffic is and/or to get an idea of the types of loads the site can
> > handle before i need to upgrade.
>
>
TSung and JMeter are both good. Unless you're expecting insanely high loads,
then the best bet is probably JMeter and/or apachebench.

Malcolm

-- 
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: problem with BooleanField form

2011-07-22 Thread ed
Ok. That last one actually worked. Just needed to a browser refresh to
re-load the script.

That's a total noob mistake. My bad. Thanks all :)

On Jul 21, 10:49 am, ed  wrote:
> You mean like this:
>
>         var data = {
>                 url: item.find("#id_url").val(),
>                 title: item.find("#id_title").val(),
>                 tags: item.find("#id_tags").val(),
>                 share: item.find("#id_share").val()
>         };
>
> Tried it. 'share' is still showing up false...
>
> On Jul 21, 1:29 am, Daniel Roseman  wrote:
>
>
>
>
>
>
>
> > On Thursday, July 21, 2011 4:00:55 AM UTC+1, ed wrote:
>
> > > I'm using the following javascript, so I can't check the HTML, can I?
> > > How would I go about debugging this?
>
> > > function bookmark_save() {
> > > var item = $(this).parent();
> > > var data = {
> > > url: item.find("#id_url").val(),
> > > title: item.find("#id_title").val(),
> > > tags: item.find("#id_tags").val()
> > > };
> > > $.post("/save/?ajax", data, function (result) {
> > > if (result != "failure") {
> > > item.before($("li", result).get(0));
> > > item.remove();
> > > $("ul.bookmarks .edit").click(bookmark_edit);
> > > }
> > > else {
> > > alert("Failed to validate bookmark before saving.");
> > > }
> > > });
> > > return false;
> > > }
>
> > > function bookmark_edit() {
> > > var item = $(this).parent();
> > > var url = item.find(".title").attr("href");
> > > item.load(
> > > "/save/?ajax&url=" + encodeURIComponent(url),
> > > null,
> > > function () {
> > > $("#save-form").submit(bookmark_save);
> > > }
> > > );
> > > return false;
> > > }
>
> > > $(document).ready(function () {
> > > $("ul.bookmarks .edit").click(bookmark_edit);
> > > });
>
> > But surely the problem is that you haven't supplied a value for  `share` in
> > your Ajax data.
> > --
> > 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-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: Help on Internationalization

2011-07-22 Thread bruno desthuilliers
On Jul 22, 3:35 pm, Dipo Elegbede  wrote:
> I'm not using views.


Oh yes ? Then how do you serve your content exactly ???

But anyway: this function contains all (well, most of) you need to
know to solve your problem.

-- 
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: What is the Development Life Cycle of Django App?

2011-07-22 Thread bruno desthuilliers


On Jul 22, 4:31 pm, Eyad Al-Sibai  wrote:
> What is the Development Life Cycle of Django App? Should I start in
> implementing the models or the urls ... or what exactly?

You should start with designing your app. Then whatever you implement
first is up to you, and mostly depends on your design and app.

-- 
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: Setting LOGIN_URL dynamically, for different users, based on app?

2011-07-22 Thread Alexey Luchko

On 22.07.2011 17:32, dpapathanasiou wrote:

So you're saying: have the function which handles the post-login
request (i.e., defined in with LOGIN_REDIRECT_URL in settings.py and
in urls.py to some corresponding views.py function) make that type
check of user A/B, and simply redirect accordingly?


You can try redirect twice.  Set fixed LOGIN_REDIRECT_URL to a view that 
makes further redirect based on user permissions.


Or you can try fixed hidden input next in the login templates.

--
Regards,
Alexey.

--
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: django & py2exe (was: import django models without runing the server)

2011-07-22 Thread Alexey Luchko

On 22.07.2011 02:59, Gelonida N wrote:

Another issue, that I had is trying to use django under windows with py2exe.

Management commands are no more found, as django would require the
python source code in order to find existing management commands.

Perhaps there is an easy  work around, but I am not aware of one.


Same here.

I far as I can see it requires some changes to 
django/core/management/__init__.py


You could try a hack filling django.core.management._commands manually in 
your project's manage.py.



But for a project's prototype I've just created a script that imports 
settings and then calls a manage command manually like that:

from django.core.management.commands import syncdb
syncdb.Command().execute()


If one will try to make a solution, count me in.

--
Best regards,
Alexey.

--
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: Real Example

2011-07-22 Thread Shawn Milochik

On 07/22/2011 10:31 AM, Eyad Al-Sibai wrote:

Hi!

I want a real example of complete django application with source code 
to understand django better




1. Search Google, github, and bitbucket.

2. Read this: https://code.djangoproject.com/wiki/UsingTheMailingList


--
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: Custom Manager

2011-07-22 Thread Shawn Milochik

On 07/22/2011 10:30 AM, Eyad Al-Sibai wrote:

Hi!

I still do not get the meaning of Manager or Custom Manager in 
Django... I am confused!




If you've used the '.objects' attribute of a model you've used a manager.

A custom manager would be a subclass of the standard manager. You can 
then alter/replace things like all(), filter(), and get(), and add your 
own methods.



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



What is the Development Life Cycle of Django App?

2011-07-22 Thread Eyad Al-Sibai
What is the Development Life Cycle of Django App? Should I start in
implementing the models or the urls ... or what exactly?

-- 
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: Setting LOGIN_URL dynamically, for different users, based on app?

2011-07-22 Thread dpapathanasiou
Ah, ok, that makes sense -- I'm not sure if that's what Andre meant in
the first place.

So you're saying: have the function which handles the post-login
request (i.e., defined in with LOGIN_REDIRECT_URL in settings.py and
in urls.py to some corresponding views.py function) make that type
check of user A/B, and simply redirect accordingly?

On Jul 22, 10:16 am, Phang Mulianto  wrote:
> with user profile, i translate it this way :
> after user login,app check the profile of user then decide based on the
> profile which page sould user be redirected after login,say a to dashboard
> landing page, b user redirect to console page...
>
> why would create 2 login page for 1 project anyway..

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



Real Example

2011-07-22 Thread Eyad Al-Sibai
Hi!

I want a real example of complete django application with source code to
understand django better

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



Custom Manager

2011-07-22 Thread Eyad Al-Sibai
Hi!

I still do not get the meaning of Manager or Custom Manager in Django... I
am confused!

-- 
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: Setting LOGIN_URL dynamically, for different users, based on app?

2011-07-22 Thread Andre Terra
On Fri, Jul 22, 2011 at 11:08 AM, dpapathanasiou <
denis.papathanas...@gmail.com> wrote:

> Without getting into what's "right" or "wrong", I can explain that the
> two types of users are inherently different, i.e., not inheritable
> from a common base class, so user profiles and permissions will not
> work, because functions in /dashboard views.py should never be
> accessed (or in a position to be accessed) by functions in /console
> views.py and vice versa.
>

This still doesn't explain what's preventing you from writing a check on
each view. With the recent addition of Class-based Views to core, this would
be as easy as writing two different Mixins, one in each views.py and have
each function in the module subclass it.


> (...)
>
> As for your points about site admin, I do not want two login systems;
> I simply want the core login system to redirect to different paths
> when it's dealing with one app's user versus another.
>

Redirecting User A to Path A won't prevent him from manually typing an the
url to Path B and accessing the models.


> I did think about your last point, i.e., writing a custom login/
> authentication routine for one app, but that defeats the purpose of
> using a framework in the first place.
>

The good think about frameworks is that the heavy lifting has already been
done for you.

https://docs.djangoproject.com/en/dev/topics/auth/#writing-an-authentication-backend



Cheers,
AT




>  On Jul 22, 9:54 am, Andre Terra  wrote:
> > No, there is no way to do that. I'm sorry, but your approach is
> convoluted
> > and inherently wrong.
> >
> > Instead of asking "how can I make this solution work?" you should be
> asking
> > "what's the best way to solve my needs?" and the answer to the latter
> will
> > be very different from what you currently have in mind.
> >
> > IDEAS:
> >
> > * There is no reason you will need two login pages. Ideally, users should
> > authenticate against the system as a whole, or you will rewrite the same
> > logic in many places and the code will be huge and hard to maintain.
> > * Navigating through the site (and therefore accessing objects) is the
> part
> > that needs the permission checks.
> > * Working with different models doesn't mean users have to live in two
> > separate system. Again, think about permissions. Don't worry about the
> > models until you get the profile permissions figured out.
> > * What if an admin needs to work on both the dashboard and the console?
> > Where would he login?
> > * Apps should be as pluggable as possible. In that sense, have each app
> > define its own urls and let the project-wide urls handle login.
> > * If you really need to (and I don't see why you would), write custom
> auth
> > backends if you want, and restrict a user's login based on his profile's
> > access level.
> >
> > Regards,
> > AT
> >
> > On Fri, Jul 22, 2011 at 10:35 AM, dpapathanasiou <
> >
> > denis.papathanas...@gmail.com> wrote:
> > > Thanks for your reply, but now that I've read up on custom profile and
> > > permissions, it doesn't seem like a solution.
> >
> > > Here's another way of explaining it: in my urls.py file, I have two
> > > entries inside the urlpatterns definition, like this:
> >
> > > (r'^dashboard/', include('mysite.console.urls')),
> > > (r'^console/', include('mysite.console.urls')),
> >
> > > And then inside the /dashboard/urls.py file I have this:
> >
> > > urlpatterns = patterns('',
> > >   (r'^login/$',
> > >'django.contrib.auth.views.login',
> > >{'template_name': 'dashboard/login.html'}),
> >
> > > [etc]
> > > )
> >
> > > And inside /console/urls.py is this:
> >
> > > urlpatterns = patterns('',
> > >   (r'^login/$',
> > >'django.contrib.auth.views.login',
> > >{'template_name': 'console/login.html'}),
> >
> > > [etc]
> > > )
> >
> > > Basically, since /console and /dashboard provide different
> > > functionality to different types of users, they have different
> > > templates (and their db model definitions are quite different; /
> > > dashboard users are not a type of /console user, nor can they really
> > > be both inherited from the same user profile class).
> >
> > > So, ideally, what I'd like to be able to do is something like this, to
> > > force the built-in authentication to use a different url than the
> > > single LOGIN_URL specified in settings.py:
> >
> > > urlpatterns = patterns('',
> > >   (r'^login/$',
> > >'django.contrib.auth.views.login',
> > >{'template_name': 'dashboard/login.html', LOGIN_URL='/dashboard/
> > > accounts/'}),
> >
> > > [etc]
> > > }
> >
> > > and:
> >
> > > urlpatterns = patterns('',
> > >   (r'^login/$',
> > >'django.contrib.auth.views.login',
> > >{'template_name': 'console/login.html', LOGIN_URL='/console/
> > > profile/'}),
> >
> > > [etc]
> > > }
> >
> > > Is there a way to do that?
> >
> > > On Jul 21, 9:23 pm, Andre Terra  wrote:
> > > > Why not make custom user profiles and write permission checks on your
> > > views?
> >
> > > > Cheers,
> > > > AT

Re: a little help with the urls.py and views.py

2011-07-22 Thread Derick Felsman
bump

On Jul 22, 12:15 am, Derick Felsman
 wrote:
> extending from the example found here
>
> https://docs.djangoproject.com/en/dev/topics/db/queries/
>
> what if i wanted to create a url where i would pass in a list of
> authors (not necessarily a list but an unspecified number of different
> authors) and then query for an entry that has all of the specified
> authors, what would be the best way to go about doing that.
>
> urls.py and views.py code examples would be appreciated.  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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Setting LOGIN_URL dynamically, for different users, based on app?

2011-07-22 Thread Phang Mulianto
with user profile, i translate it this way :
after user login,app check the profile of user then decide based on the
profile which page sould user be redirected after login,say a to dashboard
landing page, b user redirect to console page...

why would create 2 login page for 1 project anyway..
On Jul 22, 2011 9:54 PM, "Andre Terra"  wrote:
> No, there is no way to do that. I'm sorry, but your approach is convoluted
> and inherently wrong.
>
> Instead of asking "how can I make this solution work?" you should be
asking
> "what's the best way to solve my needs?" and the answer to the latter will
> be very different from what you currently have in mind.
>
> IDEAS:
>
> * There is no reason you will need two login pages. Ideally, users should
> authenticate against the system as a whole, or you will rewrite the same
> logic in many places and the code will be huge and hard to maintain.
> * Navigating through the site (and therefore accessing objects) is the
part
> that needs the permission checks.
> * Working with different models doesn't mean users have to live in two
> separate system. Again, think about permissions. Don't worry about the
> models until you get the profile permissions figured out.
> * What if an admin needs to work on both the dashboard and the console?
> Where would he login?
> * Apps should be as pluggable as possible. In that sense, have each app
> define its own urls and let the project-wide urls handle login.
> * If you really need to (and I don't see why you would), write custom auth
> backends if you want, and restrict a user's login based on his profile's
> access level.
>
>
> Regards,
> AT
>
>
> On Fri, Jul 22, 2011 at 10:35 AM, dpapathanasiou <
> denis.papathanas...@gmail.com> wrote:
>
>> Thanks for your reply, but now that I've read up on custom profile and
>> permissions, it doesn't seem like a solution.
>>
>> Here's another way of explaining it: in my urls.py file, I have two
>> entries inside the urlpatterns definition, like this:
>>
>> (r'^dashboard/', include('mysite.console.urls')),
>> (r'^console/', include('mysite.console.urls')),
>>
>> And then inside the /dashboard/urls.py file I have this:
>>
>> urlpatterns = patterns('',
>> (r'^login/$',
>> 'django.contrib.auth.views.login',
>> {'template_name': 'dashboard/login.html'}),
>>
>> [etc]
>> )
>>
>> And inside /console/urls.py is this:
>>
>> urlpatterns = patterns('',
>> (r'^login/$',
>> 'django.contrib.auth.views.login',
>> {'template_name': 'console/login.html'}),
>>
>> [etc]
>> )
>>
>> Basically, since /console and /dashboard provide different
>> functionality to different types of users, they have different
>> templates (and their db model definitions are quite different; /
>> dashboard users are not a type of /console user, nor can they really
>> be both inherited from the same user profile class).
>>
>> So, ideally, what I'd like to be able to do is something like this, to
>> force the built-in authentication to use a different url than the
>> single LOGIN_URL specified in settings.py:
>>
>> urlpatterns = patterns('',
>> (r'^login/$',
>> 'django.contrib.auth.views.login',
>> {'template_name': 'dashboard/login.html', LOGIN_URL='/dashboard/
>> accounts/'}),
>>
>> [etc]
>> }
>>
>> and:
>>
>> urlpatterns = patterns('',
>> (r'^login/$',
>> 'django.contrib.auth.views.login',
>> {'template_name': 'console/login.html', LOGIN_URL='/console/
>> profile/'}),
>>
>> [etc]
>> }
>>
>> Is there a way to do that?
>>
>> On Jul 21, 9:23 pm, Andre Terra  wrote:
>> > Why not make custom user profiles and write permission checks on your
>> views?
>> >
>> > Cheers,
>> > AT
>>
>> --
>> 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.
>

-- 
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: Setting LOGIN_URL dynamically, for different users, based on app?

2011-07-22 Thread dpapathanasiou
Without getting into what's "right" or "wrong", I can explain that the
two types of users are inherently different, i.e., not inheritable
from a common base class, so user profiles and permissions will not
work, because functions in /dashboard views.py should never be
accessed (or in a position to be accessed) by functions in /console
views.py and vice versa.

Other than user models they do share data in common, which is why they
all need to run on one site.

As for your points about site admin, I do not want two login systems;
I simply want the core login system to redirect to different paths
when it's dealing with one app's user versus another.

I did think about your last point, i.e., writing a custom login/
authentication routine for one app, but that defeats the purpose of
using a framework in the first place.

On Jul 22, 9:54 am, Andre Terra  wrote:
> No, there is no way to do that. I'm sorry, but your approach is convoluted
> and inherently wrong.
>
> Instead of asking "how can I make this solution work?" you should be asking
> "what's the best way to solve my needs?" and the answer to the latter will
> be very different from what you currently have in mind.
>
> IDEAS:
>
> * There is no reason you will need two login pages. Ideally, users should
> authenticate against the system as a whole, or you will rewrite the same
> logic in many places and the code will be huge and hard to maintain.
> * Navigating through the site (and therefore accessing objects) is the part
> that needs the permission checks.
> * Working with different models doesn't mean users have to live in two
> separate system. Again, think about permissions. Don't worry about the
> models until you get the profile permissions figured out.
> * What if an admin needs to work on both the dashboard and the console?
> Where would he login?
> * Apps should be as pluggable as possible. In that sense, have each app
> define its own urls and let the project-wide urls handle login.
> * If you really need to (and I don't see why you would), write custom auth
> backends if you want, and restrict a user's login based on his profile's
> access level.
>
> Regards,
> AT
>
> On Fri, Jul 22, 2011 at 10:35 AM, dpapathanasiou <
>
> denis.papathanas...@gmail.com> wrote:
> > Thanks for your reply, but now that I've read up on custom profile and
> > permissions, it doesn't seem like a solution.
>
> > Here's another way of explaining it: in my urls.py file, I have two
> > entries inside the urlpatterns definition, like this:
>
> > (r'^dashboard/', include('mysite.console.urls')),
> > (r'^console/', include('mysite.console.urls')),
>
> > And then inside the /dashboard/urls.py file I have this:
>
> > urlpatterns = patterns('',
> >   (r'^login/$',
> >    'django.contrib.auth.views.login',
> >    {'template_name': 'dashboard/login.html'}),
>
> > [etc]
> > )
>
> > And inside /console/urls.py is this:
>
> > urlpatterns = patterns('',
> >   (r'^login/$',
> >    'django.contrib.auth.views.login',
> >    {'template_name': 'console/login.html'}),
>
> > [etc]
> > )
>
> > Basically, since /console and /dashboard provide different
> > functionality to different types of users, they have different
> > templates (and their db model definitions are quite different; /
> > dashboard users are not a type of /console user, nor can they really
> > be both inherited from the same user profile class).
>
> > So, ideally, what I'd like to be able to do is something like this, to
> > force the built-in authentication to use a different url than the
> > single LOGIN_URL specified in settings.py:
>
> > urlpatterns = patterns('',
> >   (r'^login/$',
> >    'django.contrib.auth.views.login',
> >    {'template_name': 'dashboard/login.html', LOGIN_URL='/dashboard/
> > accounts/'}),
>
> > [etc]
> > }
>
> > and:
>
> > urlpatterns = patterns('',
> >   (r'^login/$',
> >    'django.contrib.auth.views.login',
> >    {'template_name': 'console/login.html', LOGIN_URL='/console/
> > profile/'}),
>
> > [etc]
> > }
>
> > Is there a way to do that?
>
> > On Jul 21, 9:23 pm, Andre Terra  wrote:
> > > Why not make custom user profiles and write permission checks on your
> > views?
>
> > > Cheers,
> > > AT
>
> > --
> > 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.



Re: Setting LOGIN_URL dynamically, for different users, based on app?

2011-07-22 Thread Andre Terra
No, there is no way to do that. I'm sorry, but your approach is convoluted
and inherently wrong.

Instead of asking "how can I make this solution work?" you should be asking
"what's the best way to solve my needs?" and the answer to the latter will
be very different from what you currently have in mind.

IDEAS:

* There is no reason you will need two login pages. Ideally, users should
authenticate against the system as a whole, or you will rewrite the same
logic in many places and the code will be huge and hard to maintain.
* Navigating through the site (and therefore accessing objects) is the part
that needs the permission checks.
* Working with different models doesn't mean users have to live in two
separate system. Again, think about permissions. Don't worry about the
models until you get the profile permissions figured out.
* What if an admin needs to work on both the dashboard and the console?
Where would he login?
* Apps should be as pluggable as possible. In that sense, have each app
define its own urls and let the project-wide urls handle login.
* If you really need to (and I don't see why you would), write custom auth
backends if you want, and restrict a user's login based on his profile's
access level.


Regards,
AT


On Fri, Jul 22, 2011 at 10:35 AM, dpapathanasiou <
denis.papathanas...@gmail.com> wrote:

> Thanks for your reply, but now that I've read up on custom profile and
> permissions, it doesn't seem like a solution.
>
> Here's another way of explaining it: in my urls.py file, I have two
> entries inside the urlpatterns definition, like this:
>
> (r'^dashboard/', include('mysite.console.urls')),
> (r'^console/', include('mysite.console.urls')),
>
> And then inside the /dashboard/urls.py file I have this:
>
> urlpatterns = patterns('',
>   (r'^login/$',
>'django.contrib.auth.views.login',
>{'template_name': 'dashboard/login.html'}),
>
> [etc]
> )
>
> And inside /console/urls.py is this:
>
> urlpatterns = patterns('',
>   (r'^login/$',
>'django.contrib.auth.views.login',
>{'template_name': 'console/login.html'}),
>
> [etc]
> )
>
> Basically, since /console and /dashboard provide different
> functionality to different types of users, they have different
> templates (and their db model definitions are quite different; /
> dashboard users are not a type of /console user, nor can they really
> be both inherited from the same user profile class).
>
> So, ideally, what I'd like to be able to do is something like this, to
> force the built-in authentication to use a different url than the
> single LOGIN_URL specified in settings.py:
>
> urlpatterns = patterns('',
>   (r'^login/$',
>'django.contrib.auth.views.login',
>{'template_name': 'dashboard/login.html', LOGIN_URL='/dashboard/
> accounts/'}),
>
> [etc]
> }
>
> and:
>
> urlpatterns = patterns('',
>   (r'^login/$',
>'django.contrib.auth.views.login',
>{'template_name': 'console/login.html', LOGIN_URL='/console/
> profile/'}),
>
> [etc]
> }
>
> Is there a way to do that?
>
> On Jul 21, 9:23 pm, Andre Terra  wrote:
> > Why not make custom user profiles and write permission checks on your
> views?
> >
> > Cheers,
> > AT
>
> --
> 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.



Re: Help on Internationalization

2011-07-22 Thread Dipo Elegbede
I'm not using views.

On 22 Jul 2011 12:48, "bruno desthuilliers" 
wrote:
> On Jul 22, 10:47 am, Dipo Elegbede  wrote:
>> Hi All,
>>
>> I am working on a project of mine and it is doing very well.
>>
>> I want to give users the options to pick their language of choice using
>> internationalization and that has been a problem for me.
>>
>> I have read through the django documentations but cannot get a way around
>> this, could you please point me to anyy resource on this.
>
> django.views.i18n.set_language doesn't work ?
>
>
https://code.djangoproject.com/browser/django/tags/releases/1.3/django/views/i18n.py#L12
>
> --
> 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.



Re: Setting LOGIN_URL dynamically, for different users, based on app?

2011-07-22 Thread dpapathanasiou
Thanks for your reply, but now that I've read up on custom profile and
permissions, it doesn't seem like a solution.

Here's another way of explaining it: in my urls.py file, I have two
entries inside the urlpatterns definition, like this:

(r'^dashboard/', include('mysite.console.urls')),
(r'^console/', include('mysite.console.urls')),

And then inside the /dashboard/urls.py file I have this:

urlpatterns = patterns('',
   (r'^login/$',
'django.contrib.auth.views.login',
{'template_name': 'dashboard/login.html'}),

[etc]
)

And inside /console/urls.py is this:

urlpatterns = patterns('',
   (r'^login/$',
'django.contrib.auth.views.login',
{'template_name': 'console/login.html'}),

[etc]
)

Basically, since /console and /dashboard provide different
functionality to different types of users, they have different
templates (and their db model definitions are quite different; /
dashboard users are not a type of /console user, nor can they really
be both inherited from the same user profile class).

So, ideally, what I'd like to be able to do is something like this, to
force the built-in authentication to use a different url than the
single LOGIN_URL specified in settings.py:

urlpatterns = patterns('',
   (r'^login/$',
'django.contrib.auth.views.login',
{'template_name': 'dashboard/login.html', LOGIN_URL='/dashboard/
accounts/'}),

[etc]
}

and:

urlpatterns = patterns('',
   (r'^login/$',
'django.contrib.auth.views.login',
{'template_name': 'console/login.html', LOGIN_URL='/console/
profile/'}),

[etc]
}

Is there a way to do that?

On Jul 21, 9:23 pm, Andre Terra  wrote:
> Why not make custom user profiles and write permission checks on your views?
>
> Cheers,
> AT

-- 
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: Django AJAX polling: Best practice?

2011-07-22 Thread Shawn Milochik

On 07/22/2011 02:35 AM, PyPal wrote:

Hi Shawn,

I think you were referring to the APE ( http://www.ape-project.org/ )
framework as the 'gorilla' thingy...




Yes, thanks! I did some Google searching but couldn't find it. Someone 
on the list said they were going to give it a shot, but I haven't heard 
of anyone using it in production yet.


I think I'll give them another look also. I have a Hookbox project 
half-finished that I haven't had time to go back to. It's long overdue.


--
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: django-admin inspectdb does not detect NULL columns for PostgreSQL database

2011-07-22 Thread Ricardo L. Dani
FYI i fixed that and post a patch in the ticket.

Regards

On Thu, Jul 21, 2011 at 9:21 AM, Ricardo L. Dani  wrote:
> Hi everyone,
>
> I have the same problem of this ticket from django trac:
> https://code.djangoproject.com/ticket/7783
>
> The PostgreSQL database introspection does not detect NULL columns,
> cursor.description does not return the null_ok field, so database
> introspection does not add null=True to column definitions. The
> is_nullable column in information_schema.columns does contain this
> information, however.
>
> A patch was subimitted, but i can't apply this 'cause the version of
> django that's the patch was appliend is different to 1.3 (the version
> i use).
>
> Somebody knows what version of django this patch is applied? Or a
> other way to solve this problem?
>
> Regards
>
> --
> Ricardo Lapa Dani
>



-- 
Ricardo Lapa Dani

-- 
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: Changes from 1.2.5 to 1.4 pre-alpha?

2011-07-22 Thread Jacob Kaplan-Moss
On Fri, Jul 22, 2011 at 4:36 AM, Rodney Topor  wrote:
> I've been away from Django for over 6 months.  Previously I was using
> 1.2.5.  Now I'll be using 1.4 pre-alpha.
>
> Can someone please point me to a good summary of the main changes made
> between these two versions?

See https://docs.djangoproject.com/en/dev/releases/1.3/ and
https://docs.djangoproject.com/en/dev/releases/1.4/.

Jacob

-- 
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: Recommendations for load testing/profiling a django site server?

2011-07-22 Thread Jacob Kaplan-Moss
On Thu, Jul 21, 2011 at 5:03 PM, br  wrote:
> I am running on a Linode 768 VPS and may have some stuff going live
> before too long.  I'm wondering what the best way to guage whether I
> have enough bandwidth/CPU/memory to handle a significant amount of
> traffic is and/or to get an idea of the types of loads the site can
> handle before i need to upgrade.

A few options I've used:

* Siege (http://www.joedog.org/index/siege-home) - fairly simple but
powerful HTTP load tester.

* JMeter (http://jakarta.apache.org/jmeter/) - much more complex (with
an ugly Java GUI), but can test multiple protocols, distribute load
testing across multiple machines, and has excellent reporting tools.

* Tsung (http://tsung.erlang-projects.org/) - can be used a lot like
Siege, but Tsung's real strength is that it's easy to extend (in
Erlang, for better or worse) for custom load testing tasks.

* Bees With Machine Guns
(http://blog.apps.chicagotribune.com/2010/07/08/bees-with-machine-guns/)
- OK, I'm mostly just mentioning this because it's got the Best Name
EVER. Useful to simulate traffic from multiple "directions" (uses
AWS).

Good luck!

Jacob

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



Static Files on IIS7

2011-07-22 Thread The Ape
Hi,

I am running Django (1.3) with PyISAPIe (Python 2.6.6) on IIS7.
I am using the Django tutorial pages as test sites. Now when I am
trying to access the adminsite,
the site is loaded without the static files (loaded via IIS7).
When I use the Django development server the site is rendered
perfectly.  Templates are found...

Hope someone can help me.

Thanks!

my settings look like this:

STATIC_ROOT = ''
STATIC_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/static/admin/'
STATICFILES_DIRS = (
)

STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

TEMPLATE_DIRS = (
"C:/PATH/Django Pages/templates".
)

My ISAPI config:

from django.core.handlers.wsgi import WSGIHandler as DjangoHandler
os.environ["DJANGO_SETTINGS_MODULE"] = "mysite.settings"
os.environ["django.root"] = "/mysite"

sys.path.append(r'C:\PATH\django')
sys.path.append(r'C:\PATH\django\contrib\admin')
sys.path.append(r'C:\PATH\Django Pages')
sys.path.append(r'C:\PATH\Django Pages\mysite')
sys.path.append(r'C:\PATH\Django Pages\mysite\polls')
sys.path.append(r'C:\PATH\Django Pages\templates')
sys.path.append(r'C:\PATH\Django Pages\static')
ROOT_URLCONF = 'mysite.urls'


-- 
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: Help on Internationalization

2011-07-22 Thread bruno desthuilliers
On Jul 22, 10:47 am, Dipo Elegbede  wrote:
> Hi All,
>
> I am working on a project of mine and it is doing very well.
>
> I want to give users the options to pick their language of choice using
> internationalization and that has been a problem for me.
>
> I have read through the django documentations but cannot get a way around
> this, could you please point me to anyy resource on this.

django.views.i18n.set_language doesn't work ?

https://code.djangoproject.com/browser/django/tags/releases/1.3/django/views/i18n.py#L12

-- 
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: Still on Internationalisation

2011-07-22 Thread Baurzhan Ismagulov
On Fri, Jul 22, 2011 at 10:25:04AM +0100, Dipo Elegbede wrote:
> $ django-admin.py makemessages -l de
> processing language de
> Error: errors happened while running xgettext on __init__.py
> 'xgettext' is not recognized as an internal or external command,
> operable program or batch file.

You need to install xgettext separately and have it in PATH. Look at
cygwin or mingw.

With kind regards,
-- 
Baurzhan Ismagulov
http://www.kz-easy.com/

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



Still on Internationalisation

2011-07-22 Thread Dipo Elegbede
I was trying to run a makemessages command and got the following error; can
you please help?

$ django-admin.py makemessages -l de
processing language de
Error: errors happened while running xgettext on __init__.py
'xgettext' is not recognized as an internal or external command,
operable program or batch file.

-- 
Elegbede Muhammed Dipo
TimbaObjects Co.,
+2348033299270
+2348077682428

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



Help on Internationalization

2011-07-22 Thread Dipo Elegbede
Hi All,

I am working on a project of mine and it is doing very well.

I want to give users the options to pick their language of choice using
internationalization and that has been a problem for me.

I have read through the django documentations but cannot get a way around
this, could you please point me to anyy resource on this.

Thank you for your help.

-- 
Elegbede Muhammed Dipo
TimbaObjects Co.,
+2348033299270
+2348077682428

-- 
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: Django AJAX polling: Best practice?

2011-07-22 Thread PyPal
Hi Shawn,

I think you were referring to the APE ( http://www.ape-project.org/ )
framework as the 'gorilla' thingy...


On Jul 3, 8:01 am, Shawn Milochik  wrote:
> On 07/01/2011 05:05 PM, Andreas Pfrengle wrote:
>
> > Thanks so far for showing me that I was on the completely wrong
> > track ;-)
>
> > I found that there is really not much official information available
> > about Hookbox:. That doesn't make an easy
> > decision for Hookbox.
>
> > Has anyone experience with socket.io and gevent instead? Looks
> > interesting at first glance:
> >  > and-gevent/>
> > 
>
> There are other options, such as Orbited, and another on I can't
> remember the name of but I think 'gorilla' had something to do with it.
>
> Hookbox was presented at PyCon this year, and although hookbox.org seems
> to be having an issue the github page shows activity from March of this
> year, and has active forks, including this 
> one:https://github.com/raikage/hookbox

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



Editor de textfield

2011-07-22 Thread Jussiê Vieira Toledo
Hello everybody!

I am wanting to use the TinyMCE editor automatically in fields of type
TextField. To know that it is necessary to add a supplement in the
middle class which is the Admin:
class Media:
js =

But where is this middle class physically admin? Not found at all. I'm
using Grappelli.

There is an adm file that change and in all fields or the editor will
appear in every class I have to add the editor?

Thank you.

-- 
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: Changes from 1.2.5 to 1.4 pre-alpha?

2011-07-22 Thread bruno desthuilliers
On Jul 22, 11:36 am, Rodney Topor  wrote:
> I've been away from Django for over 6 months.  Previously I was using
> 1.2.5.  Now I'll be using 1.4 pre-alpha.
>
> Can someone please point me to a good summary of the main changes made
> between these two versions?

You may want to start with reading the what's new for 1.3.x and port
to it ?
https://docs.djangoproject.com/en/dev/releases/1.3/

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



Changes from 1.2.5 to 1.4 pre-alpha?

2011-07-22 Thread Rodney Topor
I've been away from Django for over 6 months.  Previously I was using
1.2.5.  Now I'll be using 1.4 pre-alpha.

Can someone please point me to a good summary of the main changes made
between these two versions?

I've noticed that some of my projects no longer run, reporting
(a) ADMIN_MEDIA_PREFIX deprecation warnings and
(b) "Error importing template source loader" ImproperlyConfigured
exceptions.

Many thanks.

Rodney

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



a little help with the urls.py and views.py

2011-07-22 Thread Derick Felsman
extending from the example found here

https://docs.djangoproject.com/en/dev/topics/db/queries/

what if i wanted to create a url where i would pass in a list of
authors (not necessarily a list but an unspecified number of different
authors) and then query for an entry that has all of the specified
authors, what would be the best way to go about doing that.

urls.py and views.py code examples would be appreciated.  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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



questionnaire

2011-07-22 Thread Coulson Thabo Kgathi
guys i want to tell my view that if a certail choice is selected end
the questionnaire or skip to a certain question but i am failing tho
retrieve the answer in the database  here are my views and other files
below.

so below i want to access the "if_this_answer_go_to_page" field and
check if there is a value there if the value exist then go to a page
where the question i want to go to exist.

#views.py

from django.shortcuts import get_object_or_404, render_to_response
from django.http import HttpResponseRedirect, HttpResponse
from django.core.urlresolvers import reverse
from django.template import RequestContext
from questions.models import Choice, Question

def index(request):
latest_question_list = Question.objects.all()
return render_to_response('questions/index.html',
{'latest_question_list': latest_question_list})

def detail(request, question_id):
x = int(question_id)+1
p = get_object_or_404(Question, pk=x)
return render_to_response('questions/detail.html', {'question': p},
 
context_instance=RequestContext(request))

def results(request, question_id):
p = get_object_or_404(Question, pk=question_id)
return render_to_response('questions/results.html', {'question': p})

def saveQuestion(request, question_id):
p = get_object_or_404(Question, pk=question_id)
try:
selected_choice = p.choice_set.get(pk=request.POST['choice'])
except (KeyError, Choice.DoesNotExist):
# Redisplay the question form.
return render_to_response('questions/detail.html', {
'question': p,
'error_message': "You didn't select an answer.",
}, context_instance=RequestContext(request))
else:


selected_choice.save()

if Choice.if_this_answer_go_to_page:
return
HttpResponseRedirect(reverse('questions.views.results',args=(Choice.if_this_answer_go_to_page,)))
else:
return 
HttpResponseRedirect(reverse('questions.views.detail',
args=(p.id,)))

# Always return an HttpResponseRedirect after successfully
dealing
# with POST data. This prevents data from being posted twice
if a
# user hits the Back button.


#models.py


from django.db import models
import datetime

class Question(models.Model):
quest = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
page_number =models.IntegerField(max_length=10)
def was_published_today(self):
return self.pub_date() == datetime.date.today()

def __unicode__(self):
return self.quest

class Choice(models.Model):
question = models.ForeignKey(Question)
choice = models.CharField(max_length=200)
if_this_answer_go_to_page = models.CharField(max_length = 10,
blank = True,
null = True,
)


def __unicode__(self):
return self.choice

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