Re: Accidentally creating a model with "def unicode(self):" will crash django with no stack trace

2008-10-23 Thread Jeff FW

That's because when you define unicode(), inside the scope of that
function, the name "unicode" is now bound to the function you just
defined.  So, the line "date = unicode(self.dated)" is calling
Letter.unicode() instead of Python's builtin unicode(), and you get an
(almost) infinite recursive loop--"almost" because Python is smart
enough to die after a while (usually with: "RuntimeError: maximum
recursion depth exceeded").

-Jeff

On Oct 23, 8:54 am, Brian <[EMAIL PROTECTED]> wrote:
> I should be more precise. :) Here's a simplified excerpt of the
> problematic code - when a Django (1.0) template tries to turn it into
> text with its default unicode function, Python (2.5.1) crashes (on Mac
> OS X 10.5):
>
>   from django.db import models
>   from people import Person
>
>   class Letter(models.Model):
>       to = models.ManyToManyField(Person, related_name="%
> (class)s_related")
>       author = models.ForeignKey(Person)
>       content = models.TextField()
>
>       def unicode(self):
>           date = unicode(self.dated)
>           author = self.author
>           to = ", ".join([ unicode(r) for r in self.to.all()])
>           return "Letter dated %s from %s to %s" % (date, author, to)
>
>       @models.permalink
>       def get_absolute_url(self):
>           return ('letter_detail', [self.pk])
>
> The fix being, of course, changing "unicode" to "__unicode__".
>
> On Oct 22, 10:14 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
> > On Wed, Oct 22, 2008 at 9:45 PM, Brian <[EMAIL PROTECTED]> wrote:
>
> > > This might seem obvious, and I just spend a couple hours straining
> > > over it, so I thought I'd share.
>
> > > If you have a model, e.g.:
>
> > > def MyModel(models.Model):
> > >    # ...
> > >    # with a unicode function likeso:
> > >    def unicode(self):
> > >       return 'something'
>
> > > This will crash Django, without a stack trace.
>
> > > Of course, the function is supposed to be "def __unicode__(self):",
> > > but it'd have been awful nice to be able to figure that out without
> > > rehashing the entire codebase (it seems like such an innocuous
> > > addition to the model at the time haha).
>
> > > Hopefully this will save someone some pain. :)
>
> > It will crash when you do what?  I don't see a crash, I just see models
> > reverting to being reported as "xzy object" in the Admin.
>
> > 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: variable tag / filter

2008-10-23 Thread Jeff FW

To my knowledge, no, it's not possible to do that.  Even if it was,
however, I would strongly argue against it, as it would make your
templates unreadable--how would you know what filter/tag would be
called without mucking through the rest of your code? Maybe there's a
better way to get the effect you want--what are you trying to achieve?

-Jeff

On Oct 23, 6:59 am, ramya <[EMAIL PROTECTED]> wrote:
> Is it possible to have variable tags / filters
>
> {{ my_value | my_filter }}
> where c['my_filter'] = 'formatDateTime'
> formatDateTime is the actual filter function defined in templatetags
>
> similarly
>
> {{ my_tag my_filter }}
> where c['my_tag'] = 'formatDateTime'
> formatDateTime is the actual tag function defined in templatetags
>
> say in both the cases  formatDateTime is registered tag/filter and has
> been loaded
>
> Regards,
> ~ramyak/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: variable tag / filter

2008-10-24 Thread Jeff FW

Write one base template, and have as many as you need extend from it,
overriding whatever blocks you need.  The "child" templates could be
as simple as one or two lines.  There's no harm in having more,
smaller templates--in fact, it makes it more flexible and easier to
change in the future.

-Jeff

On Oct 24, 1:01 am, ramya <[EMAIL PROTECTED]> wrote:
> I wanted to write one all purpose generic template..
>
> Now I have split that and extended multiple specific templates.. :(
>
> Thanks,
> ~ramyak/
>
> On Oct 23, 6:34 pm, Jeff FW <[EMAIL PROTECTED]> wrote:
>
> > To my knowledge, no, it's not possible to do that.  Even if it was,
> > however, I would strongly argue against it, as it would make your
> > templates unreadable--how would you know what filter/tag would be
> > called without mucking through the rest of your code? Maybe there's a
> > better way to get the effect you want--what are you trying to achieve?
>
> > -Jeff
>
> > On Oct 23, 6:59 am, ramya <[EMAIL PROTECTED]> wrote:
>
> > > Is it possible to have variable tags / filters
>
> > > {{ my_value | my_filter }}
> > > where c['my_filter'] = 'formatDateTime'
> > > formatDateTime is the actual filter function defined in templatetags
>
> > > similarly
>
> > > {{ my_tag my_filter }}
> > > where c['my_tag'] = 'formatDateTime'
> > > formatDateTime is the actual tag function defined in templatetags
>
> > > say in both the cases  formatDateTime is registered tag/filter and has
> > > been loaded
>
> > > Regards,
> > > ~ramyak/
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: why not django's default server?

2008-10-25 Thread Jeff FW

And you don't need root access to install/run Apache either.  It might
be a pain to install w/o root, depending on your OS, but running it
wouldn't be too hard, as long as you pick a port above 1024.  One very
good reason (I think) to avoid using Django's development server is
the inability to use SSL.  Also, it doesn't provide nearly the same
level of logging.

On Oct 25, 9:18 am, "Alex Ezell" <[EMAIL PROTECTED]> wrote:
> On Sat, Oct 25, 2008 at 12:27 AM, gniquil <[EMAIL PROTECTED]> wrote:
> > The reason I don't want to use apache is primarily due to 1. restarts
>
> Why not use Apache with mod_wsgi? Then, you just touch a file to
> reload your new code. No restart needed.
>
> /alex
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is there a way to use the Cut Filter to only do the first instance?

2008-10-31 Thread Jeff FW

If you know the length of the string that you want to cut off the
beginning, you could use slice:
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#slice

Really, though, you might be going about this in a strange way.  It
might be better to use the url tag to get the correct URL that you
want in the first place.  But then, I don't know what you're trying to
do.

-Jeff

On Oct 31, 12:06 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Fri, Oct 31, 2008 at 11:55 AM, Frank Peterson
> <[EMAIL PROTECTED]>wrote:
>
>
>
> > I am using the following
> > {{ section.get_absolute_url|cut:"/news/" }}
> > on a string that is
> > /news/new-york-jets/news/
>
> > I need to remove the first /news but the CUT filter removes all
> > instances of it, is there a way for me to remove on the first "/news"?
>
> No, there's no way to make the existing cut filter do this, and I don't see
> another built-in filter that does what you ask.  However if you look at the
> implementation of cut here:
>
> http://code.djangoproject.com/browser/django/tags/releases/1.0/django...
>
> and the doc for Python's string replace method you can pretty easily write
> your own cut_first filter.
>
> 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Keeping track of online users

2008-11-02 Thread Jeff FW

Can you be more specific?  What are you trying to do?

-Jeff

On Nov 1, 3:52 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> I have found some post of 2007 on this argument but maybe with django
> 1.0 something is changed.
>
> how do you do that ?
>
> thanks everyone :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: creating django middleware

2008-11-12 Thread Jeff FW

I also wrote middleware for SQLAlchemy--I'd post it, but it depends on
other libraries that I wrote that I can't really share.  What I found
is that, at least while using the dev server, the process_response
method would get called when serving media files, even if the
process_request hadn't.  So, simple solution: wrap the session_destroy
call in a try/except block.  Here's mine:

def process_response(self, request, response):
try:
request.db_session.commit()
request.db_session.close()
except AttributeError:
pass
return response

Also, may I suggest adding a process_exception method?  Here's mine:

def process_exception(self, request, exception):
request.db_session.rollback()
request.db_session.close()

-Jeff

On Nov 12, 7:18 am, ershadul <[EMAIL PROTECTED]> wrote:
> Dear all,
> please consider the following code-block:
>
> class SQLAlchemySessionMiddleware(object):
>     """
>     This class instantiates a sqlalchemy session and destroys
>     """
>     def process_request(self, request):
>         request.db_session = session()
>         return None
>
>     def process_response(self, request, response):
>         session_destroy(request.db_session)
>         return response
>
> Consider that session() is method that returns a new object sqlalchemy
> session.
> I want to inject it before view is processed and destroy it upon
> exiting the view.
>
> I have added the path of this middleware class before XView
> middleware in settings.py.
> But i got a error that
> request has not attribute 'db_session' ( process_response function)
> How can i do it?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using Admin From a Sub-Directory

2008-11-16 Thread Jeff FW

You need a trailing slash after /myapp/media/admin.  The final URL
will then come out to:
http://localhost/media/admin/css/dashboard.css

-Jeff

On Nov 16, 11:37 am, Chris <[EMAIL PROTECTED]> wrote:
> I'm trying to setup my app so it's accessible from a /myapp sub-
> directory. I defined BASEURL = '/myapp' in settings.py, and created a
> context preprocessor so this variable is available to all templates. I
> then insert this variable at the beginning of all paths for js/css
> includes, links, etc.
>
> Everything seems to work fine, except for admin, which has broken css
> links. Admin's css links are using /media/admincss 
> (e.g.http://localhost/media/admincss/dashboard.css). Is this dervived from
> ADMIN_MEDIA_PREFIX? I've tried changing this to /myapp/media/admin,
> but it has no effect, and I just get 404 errors.
>
> How do I get admin fully working from a application-wide sub directory?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Custom Select widget choices - how to reuse choices?

2008-11-21 Thread Jeff FW

You could define the CHOICES as a member of your model class, like so:

class Movie( Relic ):
CHOICES=((u'1','one'), (u'2',u'two'))
disk_type = models.CharField( 'Type', max_length=8,
choices=CHOICES)

Then, in your form:

class MovieForm( BasicRelicForm ):
disk_type = forms.CharField( widget = choicewidget
( choices=Movie.CHOICES ))
class Meta:
model = Movie

That seems, to me, to be the cleanest way to do it.

You can also access the choices like this, but I wouldn't recommend
it:
choices = Movie._meta.get_field('disk_type').choices

-Jeff

On Nov 21, 4:09 am, Donn <[EMAIL PROTECTED]> wrote:
> On Friday, 21 November 2008 08:06:32 urukay wrote:
>
> > easy way how to solve it is to put definition of your choices out of model
> > definition:
>
> Yeah, that's what I call a 'global', but is there no way to get the choices
> from the field in the model class?
>
> \d
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Usage opinion wanted

2008-11-25 Thread Jeff FW

Saurabh,

I have spent the past year developing a GUI application (using
wxPython) that communicates with a server (using Twisted), which
connects to a PostgresQL database (using SQLAlchemy.)  It has been a
very rewarding experience learning and using all of these tools.
However, the learning curve was quite steep--especially getting all of
the libraries to work with each other.

I've also worked on a number of Django web applications in the same
time.  Having written web sites/applications since the early days of
the web, I can safely say that Django is the best tool for doing so.
Period.  It makes me regret the years I spent working with PHP.

You obviously have serious programming experience--C++ (especially
graphics work) is much harder than anything you'll be dealing with for
this application.  So really, it depends on what set of tools you
*want* to learn.  HTML, CSS and (basic) Javascript are very easy to
pick up--almost negligible when compared with learning a GUI toolkit
and networking library (or dealing with connections manually, which is
very painful.)

Another thing to consider are deploying the application.  With a GUI
app, you'd need a way of deploying and updating for every machine it
runs on.  With a web app--make your change on the server and you're
done.  How many people would be using the app?

Then there's the matter of how complicated of an interface you really
need.  What does the application need to *do*? For most things, a web
app would suffice.  I went with a desktop app because (eventually) the
app will need to incorporate a very UI-intensive scheduling module.
If most of your app will be simple forms, and displaying lists of
data--go with Django.

I started writing this e-mail with the intent of giving a balanced
opinion, but it seems that I think you should go with Django.  If you
can tell me more about your app and what it will need to do, I can try
to give you some better advice, but really, it boils down to this:
writing a GUI app will take *much* longer than writing the equivalent
with Django.  However, you may have to sacrifice some usability.

-Jeff

On Nov 24, 8:24 pm, "Saurabh Agrawal" <[EMAIL PROTECTED]> wrote:
> Hi group:
>
> I hope that you good people here could help me with a decision I am finding
> hard to make.
>
> I am about to develop a MIS type application for a Non for profit
> organization teaching young children in India.
>
> I am trying to use this opportunity to make myself learn python, and if
> required the whole web based development paradigm using django.
>
> I have experience of c++ graphical algorithms development.
>
> Now obviously this application would be database based and database
> manipulation would be the major part. It would be mostly used across desktop
> computers in the organization running Windows XP. The decision which I am
> unable to make is that should I use django for this project? My issues are:
>
> 1. This application would be run on desktops, so GUI toolkits such as PyQT
> might suffice.
> 2. Making good interfaces for web would require additional learning on my
> part such as HTML, CSS and Javascript, an area  in which I have absolutely
> no expertise, just a very basic idea.
>
> So what do you guys suggest? If learning the above things would still give
> me an edge( in terms of time required for development) over PyQt based
> interfaces, in terms of automated databse manipulation tools such as the
> admin interface, I would go for it and it might be a good experience for me.
>
> Thanks for reading this slightly incoherent and maybe off-topic mail.
>
> All suggestions are welcome and I would be grateful for them.
>
> Regards,
> Saurabh Agrawal.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: multi field validation

2008-11-25 Thread Jeff FW

Alessandro,

I'm not exactly sure what you're asking, but I think you want to know
how to check multiple fields (possibly against each other) when
submitting a form in the admin.  Let me know if I'm off-base here.

Take a look at:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#adding-custom-validation-to-the-admin

You can do multi-field validation by adding a clean() method that will
run after every clean_FIELDNAME() method, and can do any checking you
need, and raise a ValidationError if it fails.

-Jeff

On Nov 25, 4:29 am, "Alessandro Ronchi" <[EMAIL PROTECTED]>
wrote:
> It's not possible to validate a model in admin checking multiple forms
> conditions?
>
> is there any example or code snippet ?
>
> --
> Alessandro Ronchi
> Skype: aronchihttp://www.alessandroronchi.net
>
> SOASI Soc.Coop. -www.soasi.com
> Sviluppo Software e Sistemi Open Source
> Sede: Via Poggiali 2/bis, 47100 Forlì (FC)
> Tel.: +39 0543 798985 - Fax: +39 0543 579928
>
> Rispetta l'ambiente: se non ti è necessario, non stampare questa mail
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Compare Lists for Unique Items

2008-11-26 Thread Jeff FW

If you already have a unique key on the project's name field, then
you're good to go--no duplicates will ever get inserted.  No need to
do any filtering ahead of time--just put each save() in a try/except
block that catches the error you get and does nothing.

-Jeff

On Nov 25, 4:53 pm, "Alex Jillard" <[EMAIL PROTECTED]> wrote:
> Thanks for the replies Jeff and Rajesh.  I'll look int both of those options
> and see what I can come up with.  My model is set to have the name of the
> project to be unique, so it was throwing an error if a duplicate was added.
>
> Jeff, unfortunatly the initial list of CVS projects is just a string that
> I'm splitting, so I can't do it as I build that list.
>
> Thanks again
>
> On Tue, Nov 25, 2008 at 4:38 PM, Rajesh Dhawan <[EMAIL PROTECTED]>wrote:
>
>
>
> > Hi Alex,
>
> > > Here is the code that I use.  Output_list is from CVS and
> > current_projects
> > > is from the database.  Is there a faster way to do this, or a built in
> > > method in Python?  This code works fine now, but I can see it getting
> > slow.
>
> > > for b in output_list:
> > >         found = False
> > >         for i in current_projects:
> > >             if i.name == b:
> > >                 found = True
> > >         if not found:
> > >             new_projects.append(b)
>
> > Try converting the two project name lists into Python sets and take a
> > difference:
>
> > full_list = set(output_list)
> > db_list = set([i.name for i in current_projects])
> > new_projects = full_list - db_list
>
> > You should also add a unique=True attribute to your project.name
> > field.
>
> > -Rajesh D
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Usage opinion wanted

2008-11-26 Thread Jeff FW

This sounds, to me, like a great candidate for using Django.  Each of
the separate modules you described could be a distinct application
within your project.  Actually, you could make it even more granular
than that, as a lot of the parts within each module could be separate
apps.

The Django permission system will probably already be able to handle
what you need--with no tweaking--and the automatic admin interface
might handle almost all of your app's needs.  It looks like you'd want
a "public" side for the teacher aspect, but you could still put that
behind a login.

As for the networking--in the case of my app, I didn't want to give
each client direct access to the database server.  The server that I
wrote is the only thing that connects to the database, and it handles
permissions.  You should *never* rely on the client apps to do the
"right thing", as you have no real control over them.  You can lock
access down to specific users or groups (in postgres), but that can be
a very arduous, and doesn't always work for your business logic.

-Jeff

On Nov 25, 11:45 am, "Saurabh Agrawal" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Thanks for the wonderful inputs.
>
> All right, I will give you the actual scenario and maybe you  guys can help
> me further:
>
> I think the application should have 4 modules, interconnected with each
> other and accessible via proper user perms:
>
> 1. The front office: This will have all student records, their results,
> records of staff etc. + Fee/Donation collection, salary distribution modules
> etc.
>
> 2. The academic administrator: This will have all academic records of
> students +  managing academic calender + this might also have certain
> modules for *building up* question/activity bank for students etc.
>
> 3. Manager: This will have financial records + inventory + bus management
> system etc.
>
> 4. Teacher: This will have all basic info + academic records of students +
> *viewing* question/activity bank.
> (This module might be accessed via 2-3 PCs kept in staff room)
>
> I want to have good UI for creating & viewing question + activity bank and
> also managing academic calender, as that will be used by people who are not
> much computer savvy. Rest I guess, would be mostly data manipulation.
>
> I think not much networking is involved here, right, apart of course from
> accessing the database server?
>
> I guess, now that I have read your emails and have noted down my
> requirements, I would rather go with django, right?
>
> Thanks once again!
>
> Regards,
> Saurabh.
>
>
>
> On Tue, Nov 25, 2008 at 9:40 PM, Jeff FW <[EMAIL PROTECTED]> wrote:
>
> > Saurabh,
>
> > I have spent the past year developing a GUI application (using
> > wxPython) that communicates with a server (using Twisted), which
> > connects to a PostgresQL database (using SQLAlchemy.)  It has been a
> > very rewarding experience learning and using all of these tools.
> > However, the learning curve was quite steep--especially getting all of
> > the libraries to work with each other.
>
> > I've also worked on a number of Django web applications in the same
> > time.  Having written web sites/applications since the early days of
> > the web, I can safely say that Django is the best tool for doing so.
> > Period.  It makes me regret the years I spent working with PHP.
>
> > You obviously have serious programming experience--C++ (especially
> > graphics work) is much harder than anything you'll be dealing with for
> > this application.  So really, it depends on what set of tools you
> > *want* to learn.  HTML, CSS and (basic) Javascript are very easy to
> > pick up--almost negligible when compared with learning a GUI toolkit
> > and networking library (or dealing with connections manually, which is
> > very painful.)
>
> > Another thing to consider are deploying the application.  With a GUI
> > app, you'd need a way of deploying and updating for every machine it
> > runs on.  With a web app--make your change on the server and you're
> > done.  How many people would be using the app?
>
> > Then there's the matter of how complicated of an interface you really
> > need.  What does the application need to *do*? For most things, a web
> > app would suffice.  I went with a desktop app because (eventually) the
> > app will need to incorporate a very UI-intensive scheduling module.
> > If most of your app will be simple forms, and displaying lists of
> > data--go with Django.
>
> > I started writing this e-mail with the intent of giving a balanced
> > opinion, but it seems that I think you should go wi

Re: Compare Lists for Unique Items

2008-11-27 Thread Jeff FW

Yes, the performance would be worse.  Would you ever notice it?  I'd
seriously doubt it.  You mentioned running it in a cron job; you'd
never see the effects of the lowered performance.  The lack of added
complexity might be worth it--less code (in this case) means easier to
maintain.  If you're worried about performance, you could always
benchmark it--but I'd doubt it would make enough of a difference to
worry about.

On Nov 26, 9:11 am, "Alex Jillard" <[EMAIL PROTECTED]> wrote:
> Wouldn't that give me worse performance though?  Filtering the two lists
> verses making 300+ save()'s in a try/except, 90% of which won't be committed
> to the database?
>
> On Wed, Nov 26, 2008 at 9:00 AM, Jeff FW <[EMAIL PROTECTED]> wrote:
>
> > If you already have a unique key on the project's name field, then
> > you're good to go--no duplicates will ever get inserted.  No need to
> > do any filtering ahead of time--just put each save() in a try/except
> > block that catches the error you get and does nothing.
>
> > -Jeff
>
> > On Nov 25, 4:53 pm, "Alex Jillard" <[EMAIL PROTECTED]> wrote:
> > > Thanks for the replies Jeff and Rajesh.  I'll look int both of those
> > options
> > > and see what I can come up with.  My model is set to have the name of the
> > > project to be unique, so it was throwing an error if a duplicate was
> > added.
>
> > > Jeff, unfortunatly the initial list of CVS projects is just a string that
> > > I'm splitting, so I can't do it as I build that list.
>
> > > Thanks again
>
> > > On Tue, Nov 25, 2008 at 4:38 PM, Rajesh Dhawan <[EMAIL PROTECTED]
> > >wrote:
>
> > > > Hi Alex,
>
> > > > > Here is the code that I use.  Output_list is from CVS and
> > > > current_projects
> > > > > is from the database.  Is there a faster way to do this, or a built
> > in
> > > > > method in Python?  This code works fine now, but I can see it getting
> > > > slow.
>
> > > > > for b in output_list:
> > > > >         found = False
> > > > >         for i in current_projects:
> > > > >             if i.name == b:
> > > > >                 found = True
> > > > >         if not found:
> > > > >             new_projects.append(b)
>
> > > > Try converting the two project name lists into Python sets and take a
> > > > difference:
>
> > > > full_list = set(output_list)
> > > > db_list = set([i.name for i in current_projects])
> > > > new_projects = full_list - db_list
>
> > > > You should also add a unique=True attribute to your project.name
> > > > field.
>
> > > > -Rajesh D
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Usage opinion wanted

2008-11-27 Thread Jeff FW

Saurabh,

No problem--happy to help.  And I won't ignore your last question.
The server I was referring to was, indeed, a layer of insulation--but
not for Django.  Its purpose is to avoid giving the GUI clients direct
access to the database, by delivering objects back and forth across
the network, while also providing a system of permissions.

Django does all this for you--it handles the database access, and
sends across the network to the client (in this case, a web browser)
only what the client should be allowed to see.  So, if you go with
Django, you don't have to write any such thing.

Hope that helps,
Jeff

On Nov 26, 9:23 am, "Saurabh Agrawal" <[EMAIL PROTECTED]> wrote:
> Hi Jeff,
>
> Thanks again for all the info.
>
> Can I trouble you a little more, for something which in fact, might not be
> Django related at all? You can choose to completely ignore this message, of
> course.
>
> I just want to know what is this server you are talking about? Is that some
> kind of insulation layer between your django app and the database server?
> What exactly is its purpose? If you could direct me to some document, I can
> read that too.
>
> Thanks a ton.
>
> Saurabh.
>
> On Wed, Nov 26, 2008 at 7:39 PM, Jeff FW <[EMAIL PROTECTED]> wrote:
>
> > This sounds, to me, like a great candidate for using Django.  Each of
> > the separate modules you described could be a distinct application
> > within your project.  Actually, you could make it even more granular
> > than that, as a lot of the parts within each module could be separate
> > apps.
>
> > The Django permission system will probably already be able to handle
> > what you need--with no tweaking--and the automatic admin interface
> > might handle almost all of your app's needs.  It looks like you'd want
> > a "public" side for the teacher aspect, but you could still put that
> > behind a login.
>
> > As for the networking--in the case of my app, I didn't want to give
> > each client direct access to the database server.  The server that I
> > wrote is the only thing that connects to the database, and it handles
> > permissions.  You should *never* rely on the client apps to do the
> > "right thing", as you have no real control over them.  You can lock
> > access down to specific users or groups (in postgres), but that can be
> > a very arduous, and doesn't always work for your business logic.
>
> > -Jeff
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django 1.0 no longer prints higher ASCII?

2008-11-30 Thread Jeff FW

What do you mean by "disappears"?  How are you trying to output it?
There's nothing special about the string that line generates, and I
doubt anything would have changed between versions of Django that
would stop that string from doing something it used to do.

-Jeff

On Nov 30, 10:56 am, Log0 <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> This string :
>
> data = ''.join( [ chr(i) for i in xrange(256) ] )
>
> In Django 0.96, this string prints well.
> In Django 1.0, this string simply disappears before going to Apache,
> and the data is never transmitted to the client or even apache.
>
> Why?
> Any fix?
>
> Thanks a lot.
>
> ---
>
> Best Regards,
> Log0
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How can I report a new user?

2008-12-06 Thread Jeff FW

Do you mean when a user is added via the admin interface, or when a
user registers on the site through a view you have set up?  If it's
through a view you've made, then just add the call to send_mail() in
the view.  For the admin site, you'll want to look at signals:
http://docs.djangoproject.com/en/dev/topics/signals/

-Jeff

On Dec 6, 1:26 pm, Patricio Palma <[EMAIL PROTECTED]> wrote:
> I have a model user
>
> class User(models.Model):
>     name = models.CharField(_("name"), max_length=40)
>     paternals = models.CharField(max_length=40)
>     maternals = models.CharField(max_length=40)
>     email = models.EmailField("e-mail")
>     phone = models.IntegerField(_("phone number"))
>     rol = models.IntegerField(_("company number"))
>
> I need to know when a new user is added to the system, and send a e-
> mail report,
>
> I know how send a mail. but I don't know where or when do it
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: using settings in templates

2008-12-06 Thread Jeff FW

You can pass the settings object into your context when you render
your template, or you can write a context processor that adds the
settings object to the template's context.  Take a look at the docs on
context processors, especially the section about writing your own:
http://docs.djangoproject.com/en/dev/ref/templates/api/?#id1

-Jeff

On Dec 6, 1:17 pm, barracuda <[EMAIL PROTECTED]> wrote:
> Hello,
> How can I use a configuration in settings in templates?
> For e.g , I would like to use the DATE_FORMAT configured in settings
> to format the database datetime in a template
> Here: {{db_time|date:"D d M Y" }} I want to get the format from
> settings.
>
> Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: range-like template tag?

2008-12-07 Thread Jeff FW

You could write a very simple filter to do this.  Something like
(untested):

def range(top):
return xrange(0, top)

then use {% for i in someInt|range %}

I think it would still be better to pass it in the context--why can't
you do that?

-Jeff

On Dec 7, 5:12 pm, Berco Beute <[EMAIL PROTECTED]> wrote:
> Is there a template tag to turn an int into a sequence (like 'range')?
> What I want to do is populate a select widget with the numbers up to
> the int, like:
>
> ==
> 
>     {% for i in someInt.range %}
>         {{i}}
>     {% endfor %}
> 
> ==
>
> Passing the sequence through the context is not an option in my
> particular case.
>
> 2B
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: "Legal" way to have foreign key field in the custom form

2008-12-09 Thread Jeff FW

To get the plus icon back, you need to wrap the field in a
RelatedFieldWidgetWrapper.  Here's an example from my code--obviously,
you'll have to adapt it to fit your situation.

class CategoryChoiceField(forms.ModelChoiceField):

def __init__(self, *args, **kwargs):
super(CategoryChoiceField, self).__init__(*args, **kwargs)
self.widget = widgets.RelatedFieldWidgetWrapper(
widgets.CategorySelect(
categories=models.Category.objects.order_by('parent',
'list_order')),
models.Category._meta.get_field('parent').rel,
admin.site,
)

-Jeff

On Dec 9, 6:50 am, Eugene Mirotin <[EMAIL PROTECTED]> wrote:
> Well, looks that the ModelChoiceField solves the problem except of the
> plus icon
>
> On Dec 9, 12:34 pm, Eugene Mirotin <[EMAIL PROTECTED]> wrote:
>
> > Hello. I'm working on the custom admin page  that will serve batch
> > items creation based on the uploaded file.
> > All these items should be linked to the single foreign key item.
> > This item should be selected on the form.
> > Of course, I can investigate the inner structure of the rendered admin
> > pages and mimic it my template, but it doesn't look DRY.
> > So I want to {% include %} the fieldset.html and pass the variable to
> > it that will make it to render the standard ForeignKey control (with
> > "+" icon).
> > Is there a legal way to do it?
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using random.random() while running on server

2008-12-09 Thread Jeff FW

Chris,

It depends on where you're calling random.random().  If you're trying
to do it in a model definition, then you're always going to have the
value it chose when it first executed the model's class definition--
when the server starts up.  In that case, you should be able to pass
an argument of default=random.random in the definition.  If it's
somewhere else you're trying to call it, let us know.

-Jeff

On Dec 9, 5:32 am, Chris <[EMAIL PROTECTED]> wrote:
> Hello,
> when django is running on a server, I want to make a call to:
> random.random().  When I make a call to this again, I can't. I think
> this related to a similar issue datetime.datetime.now() where you
> leave off the () to get a current date each time each time you call
> it. If you dont do that, datetime.datetime.now() will give you the
> date to which the server was instantiated instead of current
> datetime.
>
> Is there a similar way that I can do this for random so that I can get
> a new number each time I call this instead of the number that it
> created when the server was instantiated?
>
> Thanks in advance!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using random.random() while running on server

2008-12-09 Thread Jeff FW

Can you show me exactly what you're trying to do?  That would make it
much easier to help you.

-Jeff

On Dec 9, 1:19 pm, Chris <[EMAIL PROTECTED]> wrote:
> I found this snippet:http://www.djangosnippets.org/snippets/814/and
> noticed that it does not work as intended do to the issue that I
> described. I tried passing it as default instead of using the save
> method but does not work and since I am not passing random to default
> directly, I cannot do this default=random.random. Any Ideas how I can
> fix this? thanks.
>
> On Dec 9, 6:00 am, Jeff FW <[EMAIL PROTECTED]> wrote:
>
> > Chris,
>
> > It depends on where you're calling random.random().  If you're trying
> > to do it in a model definition, then you're always going to have the
> > value it chose when it first executed the model's class definition--
> > when the server starts up.  In that case, you should be able to pass
> > an argument of default=random.random in the definition.  If it's
> > somewhere else you're trying to call it, let us know.
>
> > -Jeff
>
> > On Dec 9, 5:32 am, Chris <[EMAIL PROTECTED]> wrote:
>
> > > Hello,
> > > when django is running on a server, I want to make a call to:
> > > random.random().  When I make a call to this again, I can't. I think
> > > this related to a similar issue datetime.datetime.now() where you
> > > leave off the () to get a current date each time each time you call
> > > it. If you dont do that, datetime.datetime.now() will give you the
> > > date to which the server was instantiated instead of current
> > > datetime.
>
> > > Is there a similar way that I can do this for random so that I can get
> > > a new number each time I call this instead of the number that it
> > > created when the server was instantiated?
>
> > > Thanks in advance!
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using random.random() while running on server

2008-12-09 Thread Jeff FW

Also, as an aside to all of that--what you're generating is in no way
guaranteed to be unique.  If you really need a unique string, use a
UUID or hash of the primary key.

On Dec 9, 3:48 pm, bruno desthuilliers <[EMAIL PROTECTED]>
wrote:
> On 9 déc, 11:32, Chris <[EMAIL PROTECTED]> wrote:
>
> > Hello,
> > when django is running on a server, I want to make a call to:
> > random.random().  When I make a call to this again, I can't. I think
> > this related to a similar issue datetime.datetime.now() where you
> > leave off the () to get a current date each time each time you call
> > it.
>
> I _very_ strongly suggest you take some time learning Python. In this
> case, the parens are actually the call operator. Not applying this
> operator results in getting a reference to the function (or whatever
> callable).
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Index page using flatpages

2008-12-09 Thread Jeff FW

Do you have CommonMiddleware enabled in your settings.py?

http://docs.djangoproject.com/en/dev/ref/middleware/#module-django.middleware.common

On Dec 9, 7:29 pm, Nuno Machado <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm using flatpages to display some static content in a site. The
> "about" page is working flawlessly (URL = mysite.com/about) but now
> I'm trying to define the index (URL = mysite.com) using flatpages.
>
> I'm having troubles defining the URL in the administration panel:
>
> If I put / in the URL field, I need to write "mysite.com//" to get
> access to my index page. This is not good for visitors!
>
> Your help is much appreciated.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Index page using flatpages

2008-12-10 Thread Jeff FW

Nuno,

"Yes, I do. It's a default setting."  Never hurts to check--just
because it's default, doesn't mean you haven't unset it :-)

I just ran a very simple test, using a project that I use for testing
Django apps--which I had never used flatpages in.  I added the
FlatpageMiddleware, added flatpages to INSTALLED_APPS, synced the
database, then created a page with a URL of just /, and created a
default template.  It worked fine--I can go to localhost:8000/ and get
correct page--and I can also go to localhost:8000 and get redirected
to the first URL.

Perhaps you have something in your urls.py that's overriding what
flatpages should be handling?

-Jeff

On Dec 10, 5:33 am, Nuno Machado <[EMAIL PROTECTED]> wrote:
> Hi Jeff,
>
> Yes, I do. It's a default setting.
>
> I've been thinking about the 'django.contrib.flatpages' and the
> 'django.contrib.sites' modules and in some cases, they are worse than
> good.
>
> Maybe I'm facing one of those cases, so I should get ride of those
> modules and deploy an "extras" application with just views and
> templates but no models (no database).
>
> If someone has some other hints, I'll be glad to listen. Thank you.
>
> On Dec 10, 4:08 am, Jeff FW <[EMAIL PROTECTED]> wrote:
>
> > Do you have CommonMiddleware enabled in your settings.py?
>
> >http://docs.djangoproject.com/en/dev/ref/middleware/#module-django.mi...
>
> > On Dec 9, 7:29 pm, Nuno Machado <[EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > I'm using flatpages to display some static content in a site. The
> > > "about" page is working flawlessly (URL = mysite.com/about) but now
> > > I'm trying to define the index (URL = mysite.com) using flatpages.
>
> > > I'm having troubles defining the URL in the administration panel:
>
> > > If I put / in the URL field, I need to write "mysite.com//" to get
> > > access to my index page. This is not good for visitors!
>
> > > Your help is much appreciated.
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: can't get new model to show up in admin

2008-12-11 Thread Jeff FW

Possibly a silly question--but did you run syncdb after adding
staticimage2 to your INSTALLED_APPS?

-Jeff

On Dec 10, 9:49 pm, Norm Aleks <[EMAIL PROTECTED]> wrote:
> I'm using Django 1.0.2 (on Dreamhost, if that matters) and having
> trouble getting a new model to show up.  I'm cringing a little because
> I know this has been a FAQ -- know that I *have* put some effort into
> Googling this problem, and I read up on the changes to the admin setup
> between 0.96 and 1.0.  What's more, I even got it right once on a test
> model that *does* show up in the admin interface, but even though I
> seem to be setting up the new model completely identically, it's not
> showing.
>
> So, here's what I have.  "root.staticimages" is the app that does show
> up in admin, and "root.staticimages2" is the one that does not.
>
> First, Django is running under dispatch.fcgi.  When I make changes to
> the configuration, I kill any running Python processes and also touch
> dispatch.fcgi.  If I make errors in the configuration, I do get the
> standard Django error pages.
>
> Now, my application is named "root" ...
>
> root/settings.py:
> 
> [...]
> INSTALLED_APPS = (
>     'django.contrib.auth',
>     'django.contrib.contenttypes',
>     'django.contrib.sessions',
>     'django.contrib.sites',
>     'treemenus',
>     'root.staticimages',
>     'root.staticimages2',
>     'django.contrib.admin',
>     'django.contrib.admindocs',
> )
>
> root/urls.py:
> 
> from django.contrib import admin
> from views import *
> from root.songs.models import Artist
>
> admin.autodiscover()
>
> urlpatterns = patterns('',
>     (r'^$', main),
>     (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>     (r'^admin/(.*)', admin.site.root),
> )
>
> root/staticimages/models.py:
> 
> from django.db import models
>
> class StaticImage(models.Model):
>     image = models.ImageField(upload_to='static_image',
> height_field='T', width_field='T')
>     altText = models.TextField()
>
>     def __unicode__(self):
>         return self.image.name
>
> root/staticimages/admin.py:
> 
> from django.contrib import admin
> from root.staticimages.models import StaticImage
>
> class StaticImageAdmin(admin.ModelAdmin):
>     pass
>
> admin.site.register(StaticImage, StaticImageAdmin)
>
> root/staticimages2/models.py:
> 
> from django.db import models
>
> class StaticImage2(models.Model):
>     image = models.ImageField(upload_to='static_image',
> height_field='T', width_field='T')
>     altText = models.TextField()
>
>     def __unicode__(self):
>         return self.image.name
>
> root/staticimages2/admin.py:
> 
> from django.contrib import admin
> from root.staticimages2.models import StaticImage2
>
> class StaticImage2Admin(admin.ModelAdmin):
>     pass
>
> admin.site.register(StaticImage2, StaticImage2Admin)
>
> Any help at all would be appreciated, even if it's a suggestion for a
> better Google search.
>
> Thanks,
>
> Norm Aleks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: can't get new model to show up in admin

2008-12-11 Thread Jeff FW

Well, here's another possibly silly question--are you logging into the
admin as an admin user?  Otherwise, it's possible you don't have
privileges to see the new model.  My coworker did that--took a long
time for us to figure out what he was doing wrong ;-)

Other than that... I dunno.

On Dec 11, 11:37 am, Norm Aleks  wrote:
> Thanks, it's not silly.  Yes, I did that (and tables were created, so
> the models files at least got seen).
> Something else I should have mentioned is that the problem still
> occurs when I'm using the internal development server, so I feel like
> it's unlikely to be a Dreamhost issue.
> Norm
>
> On Dec 11, 6:11 am, Jeff FW  wrote:
>
> > Possibly a silly question--but did you run syncdb after adding
> > staticimage2 to your INSTALLED_APPS?
>
> > -Jeff
>
> > On Dec 10, 9:49 pm, Norm Aleks  wrote:
>
> > > I'm using Django 1.0.2 (on Dreamhost, if that matters) and having
> > > trouble getting a new model to show up.  I'm cringing a little because
> > > I know this has been a FAQ -- know that I *have* put some effort into
> > > Googling this problem, and I read up on the changes to the admin setup
> > > between 0.96 and 1.0.  What's more, I even got it right once on a test
> > > model that *does* show up in the admin interface, but even though I
> > > seem to be setting up the new model completely identically, it's not
> > > showing.
>
> > > So, here's what I have.  "root.staticimages" is the app that does show
> > > up in admin, and "root.staticimages2" is the one that does not.
>
> > > First, Django is running under dispatch.fcgi.  When I make changes to
> > > the configuration, I kill any running Python processes and also touch
> > > dispatch.fcgi.  If I make errors in the configuration, I do get the
> > > standard Django error pages.
>
> > > Now, my application is named "root" ...
>
> > > root/settings.py:
> > > 
> > > [...]
> > > INSTALLED_APPS = (
> > >     'django.contrib.auth',
> > >     'django.contrib.contenttypes',
> > >     'django.contrib.sessions',
> > >     'django.contrib.sites',
> > >     'treemenus',
> > >     'root.staticimages',
> > >     'root.staticimages2',
> > >     'django.contrib.admin',
> > >     'django.contrib.admindocs',
> > > )
>
> > > root/urls.py:
> > > 
> > > from django.contrib import admin
> > > from views import *
> > > from root.songs.models import Artist
>
> > > admin.autodiscover()
>
> > > urlpatterns = patterns('',
> > >     (r'^$', main),
> > >     (r'^admin/doc/', include('django.contrib.admindocs.urls')),
> > >     (r'^admin/(.*)', admin.site.root),
> > > )
>
> > > root/staticimages/models.py:
> > > 
> > > from django.db import models
>
> > > class StaticImage(models.Model):
> > >     image = models.ImageField(upload_to='static_image',
> > > height_field='T', width_field='T')
> > >     altText = models.TextField()
>
> > >     def __unicode__(self):
> > >         return self.image.name
>
> > > root/staticimages/admin.py:
> > > 
> > > from django.contrib import admin
> > > from root.staticimages.models import StaticImage
>
> > > class StaticImageAdmin(admin.ModelAdmin):
> > >     pass
>
> > > admin.site.register(StaticImage, StaticImageAdmin)
>
> > > root/staticimages2/models.py:
> > > 
> > > from django.db import models
>
> > > class StaticImage2(models.Model):
> > >     image = models.ImageField(upload_to='static_image',
> > > height_field='T', width_field='T')
> > >     altText = models.TextField()
>
> > >     def __unicode__(self):
> > >         return self.image.name
>
> > > root/staticimages2/admin.py:
> > > 
> > > from django.contrib import admin
> > > from root.staticimages2.models import StaticImage2
>
> > > class StaticImage2Admin(admin.ModelAdmin):
> > >     pass
>
> > > admin.site.register(StaticImage2, StaticImage2Admin)
>
> > > Any help at all would be appreciated, even if it's a suggestion for a
> > > better Google search.
>
> > > Thanks,
>
> > > Norm Aleks
>
>
--~--~-~--~~~---~--~~
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: can't get new model to show up in admin

2008-12-11 Thread Jeff FW

Glad to help :-)  I know that problem messed us (my coworker and I)
for a while, so I'm glad to see that our fumbling around led to
someone else's solved problem.

-Jeff

On Dec 11, 1:58 pm, Norm Aleks  wrote:
> THANK YOU THANK YOU THANK YOU!!  Oh man, oh man, was that frustrating,
> but hopefully now it won't bite me again.  Yes, I had made a "root"
> user and a "norm" user, I was logged in as norm, and norm's not an
> admin.
>
> All set now!  Thanks again!
>
> Norm
>
> On Dec 11, 10:13 am, Jeff FW  wrote:
>
> > Well, here's another possibly silly question--are you logging into the
> > admin as an admin user?  Otherwise, it's possible you don't have
> > privileges to see the new model.  My coworker did that--took a long
> > time for us to figure out what he was doing wrong ;-)
>
> > Other than that... I dunno.
>
> > On Dec 11, 11:37 am, Norm Aleks  wrote:
>
> > > Thanks, it's not silly.  Yes, I did that (and tables were created, so
> > > the models files at least got seen).
> > > Something else I should have mentioned is that the problem still
> > > occurs when I'm using the internal development server, so I feel like
> > > it's unlikely to be a Dreamhost issue.
> > > Norm
>
> > > On Dec 11, 6:11 am, Jeff FW  wrote:
>
> > > > Possibly a silly question--but did you run syncdb after adding
> > > > staticimage2 to your INSTALLED_APPS?
>
> > > > -Jeff
>
> > > > On Dec 10, 9:49 pm, Norm Aleks  wrote:
>
> > > > > I'm using Django 1.0.2 (on Dreamhost, if that matters) and having
> > > > > trouble getting a new model to show up.  I'm cringing a little because
> > > > > I know this has been a FAQ -- know that I *have* put some effort into
> > > > > Googling this problem, and I read up on the changes to the admin setup
> > > > > between 0.96 and 1.0.  What's more, I even got it right once on a test
> > > > > model that *does* show up in the admin interface, but even though I
> > > > > seem to be setting up the new model completely identically, it's not
> > > > > showing.
>
> > > > > So, here's what I have.  "root.staticimages" is the app that does show
> > > > > up in admin, and "root.staticimages2" is the one that does not.
>
> > > > > First, Django is running under dispatch.fcgi.  When I make changes to
> > > > > the configuration, I kill any running Python processes and also touch
> > > > > dispatch.fcgi.  If I make errors in the configuration, I do get the
> > > > > standard Django error pages.
>
> > > > > Now, my application is named "root" ...
>
> > > > > root/settings.py:
> > > > > 
> > > > > [...]
> > > > > INSTALLED_APPS = (
> > > > >     'django.contrib.auth',
> > > > >     'django.contrib.contenttypes',
> > > > >     'django.contrib.sessions',
> > > > >     'django.contrib.sites',
> > > > >     'treemenus',
> > > > >     'root.staticimages',
> > > > >     'root.staticimages2',
> > > > >     'django.contrib.admin',
> > > > >     'django.contrib.admindocs',
> > > > > )
>
> > > > > root/urls.py:
> > > > > 
> > > > > from django.contrib import admin
> > > > > from views import *
> > > > > from root.songs.models import Artist
>
> > > > > admin.autodiscover()
>
> > > > > urlpatterns = patterns('',
> > > > >     (r'^$', main),
> > > > >     (r'^admin/doc/', include('django.contrib.admindocs.urls')),
> > > > >     (r'^admin/(.*)', admin.site.root),
> > > > > )
>
> > > > > root/staticimages/models.py:
> > > > > 
> > > > > from django.db import models
>
> > > > > class StaticImage(models.Model):
> > > > >     image = models.ImageField(upload_to='static_image',
> > > > > height_field='T', width_field='T')
> > > > >     altText = models.TextField()
>
> > > > >    

Re: model string reprentations

2008-12-12 Thread Jeff FW

Sure do:  it should be __str__() with two underscores on either side,
not one.

-Jeff

On Dec 12, 7:33 am, ben852  wrote:
> Hi,
> I am new to django and programming.
> I have a problem with the method _str_( ).
> Following the tutorial, I edited my models.py file in mysite/books and
> wrote:
>
> class Publisher(models.Model):
>       name = models.Charfield(max_length=30)
>       address = models.Charfield(max_length=30)
>       website = models.URLField()
>
>                   def _str_(self):
>                            return self.name
>
> then python manage.py shell
>
> from books.models import Publisher
> publisher_list = Publisher.objects.all ( )
> publisher_list
>
> [, ]  #
> p1.save ( ) and p2.save ( )
>
> The _str_ method doesn't work.
> Do you have an idea?
--~--~-~--~~~---~--~~
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: "Legal" way to have foreign key field in the custom form

2008-12-12 Thread Jeff FW

You're passing your queryset in, but you're never using it in your
widget.  In my code, see how I have:

widgets.CategorySelect(
categories=models.Category.objects.order_by('parent',
'list_order')
),

I don't have the code on hand for my CategorySelect widget, but I
remember that it takes "categories", and turns it into a list of
choices, which then get passed to Select.__init__() as "choices".
Since you're just using a Select() directly, you'd want to pass the
choices in there.  Here's a simple list comprehension that you may
have to adapt a little to do that:

[(t.id, unicode(t)) for t in queryset.all()]

That assumes that you add "queryset" as an argument to __init__(),
which you should probably do.

-Jeff

On Dec 12, 1:06 pm, Eugene Mirotin  wrote:
> I was busy for several days and could give it a try only now. Thank
> you for the answer, but I still can't make it work.
> I have the model called Tournament and the model called
> TournamentResult which has foreign keys Team and Tournament.
>
> What I'm doing is a page for bulk upload of the results for the
> specific tournament that should be selected from the drop-down
>
> At the moment my code looks like this:
>
> class TournamentChoiceField(forms.ModelChoiceField):
>     def __init__(self, *args, **kwargs):
>         super(TournamentChoiceField, self).__init__(*args, **kwargs)
>         self.widget = admin_widgets.RelatedFieldWidgetWrapper(
>             forms.Select(),
>             TournamentResult._meta.get_field('tournament').rel,
>             admin.site,
>         )
>
> class UploadFormInitial(forms.Form):
>     tournament = TournamentChoiceField(Tournament.objects.all())
>
> But I don't see any values in the drop-down list.
>
> On Dec 9, 3:55 pm, Jeff FW  wrote:
>
> > To get the plus icon back, you need to wrap the field in a
> > RelatedFieldWidgetWrapper.  Here's an example from my code--obviously,
> > you'll have to adapt it to fit your situation.
>
> > class CategoryChoiceField(forms.ModelChoiceField):
>
> >     def __init__(self, *args, **kwargs):
> >         super(CategoryChoiceField, self).__init__(*args, **kwargs)
> >         self.widget = widgets.RelatedFieldWidgetWrapper(
> >             widgets.c(
> >                 categories=models.Category.objects.order_by('parent',
> > 'list_order')),
> >             models.Category._meta.get_field('parent').rel,
> >             admin.site,
> >         )
>
> > -Jeff
>
> > On Dec 9, 6:50 am, Eugene Mirotin  wrote:
>
> > > Well, looks that the ModelChoiceField solves the problem except of the
> > > plus icon
>
> > > On Dec 9, 12:34 pm, Eugene Mirotin  wrote:
>
> > > > Hello. I'm working on the custom admin page  that will serve batch
> > > > items creation based on the uploaded file.
> > > > All these items should be linked to the single foreign key item.
> > > > This item should be selected on the form.
> > > > Of course, I can investigate the inner structure of the rendered admin
> > > > pages and mimic it my template, but it doesn't look DRY.
> > > > So I want to {% include %} the fieldset.html and pass the variable to
> > > > it that will make it to render the standard ForeignKey control (with
> > > > "+" icon).
> > > > Is there a legal way to do it?
>
>
--~--~-~--~~~---~--~~
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: "Legal" way to have foreign key field in the custom form

2008-12-13 Thread Jeff FW

Glad to help.

That's strange that you had to add that JS to your template--it should
be included automatically.  Looking at the admin default options:
http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/options.py#L202
it should be on every object add/edit page.

Maybe you defined a Media class in your admin class? Or you overrode
the wrong block in your template?  If you're overriding the block
"extrahead", make sure to put a {{ block.super }} in there, so it
includes anything that's been defined by parent templates.

-Jeff

On Dec 12, 2:32 pm, Eugene Mirotin  wrote:
> Thank you very much for the help. It have finally solved the problem.
>
> BTW, one issue was left - the plus icon redirected to the creation
> page instead of opening popup.
> I've solved it by including the
> 
> directly in my template, but it's strange since my template extends
> the "admin/change_form.html".
>
> On Dec 12, 9:05 pm, Jeff FW  wrote:
>
> > You're passing your queryset in, but you're never using it in your
> > widget.  In my code, see how I have:
>
> > widgets.CategorySelect(
> >     categories=models.Category.objects.order_by('parent',
> > 'list_order')
> > ),
>
> > I don't have the code on hand for my CategorySelect widget, but I
> > remember that it takes "categories", and turns it into a list of
> > choices, which then get passed to Select.__init__() as "choices".
> > Since you're just using a Select() directly, you'd want to pass the
> > choices in there.  Here's a simple list comprehension that you may
> > have to adapt a little to do that:
>
> > [(t.id, unicode(t)) for t in queryset.all()]
>
> > That assumes that you add "queryset" as an argument to __init__(),
> > which you should probably do.
>
> > -Jeff
>
> > On Dec 12, 1:06 pm, Eugene Mirotin  wrote:
>
> > > I was busy for several days and could give it a try only now. Thank
> > > you for the answer, but I still can't make it work.
> > > I have the model called Tournament and the model called
> > > TournamentResult which has foreign keys Team and Tournament.
>
> > > What I'm doing is a page for bulk upload of the results for the
> > > specific tournament that should be selected from the drop-down
>
> > > At the moment my code looks like this:
>
> > > class TournamentChoiceField(forms.ModelChoiceField):
> > >     def __init__(self, *args, **kwargs):
> > >         super(TournamentChoiceField, self).__init__(*args, **kwargs)
> > >         self.widget = admin_widgets.RelatedFieldWidgetWrapper(
> > >             forms.Select(),
> > >             TournamentResult._meta.get_field('tournament').rel,
> > >             admin.site,
> > >         )
>
> > > class UploadFormInitial(forms.Form):
> > >     tournament = TournamentChoiceField(Tournament.objects.all())
>
> > > But I don't see any values in the drop-down list.
>
> > > On Dec 9, 3:55 pm, Jeff FW  wrote:
>
> > > > To get the plus icon back, you need to wrap the field in a
> > > > RelatedFieldWidgetWrapper.  Here's an example from my code--obviously,
> > > > you'll have to adapt it to fit your situation.
>
> > > > class CategoryChoiceField(forms.ModelChoiceField):
>
> > > >     def __init__(self, *args, **kwargs):
> > > >         super(CategoryChoiceField, self).__init__(*args, **kwargs)
> > > >         self.widget = widgets.RelatedFieldWidgetWrapper(
> > > >             widgets.c(
> > > >                 categories=models.Category.objects.order_by('parent',
> > > > 'list_order')),
> > > >             models.Category._meta.get_field('parent').rel,
> > > >             admin.site,
> > > >         )
>
> > > > -Jeff
>
> > > > On Dec 9, 6:50 am, Eugene Mirotin  wrote:
>
> > > > > Well, looks that the ModelChoiceField solves the problem except of the
> > > > > plus icon
>
> > > > > On Dec 9, 12:34 pm, Eugene Mirotin  wrote:
>
> > > > > > Hello. I'm working on the custom admin page  that will serve batch
> > > > > > items creation based on the uploaded file.
> > > > > > All these items should be linked to the single foreign key item.
> > > > > > This item should be selected on the form.
> > > > > > Of course, I can investigate the inner structure of the rendered 
> > > > > > admin
> > > > > > pages and mimic it my template, but it doesn't look DRY.
> > > > > > So I want to {% include %} the fieldset.html and pass the variable 
> > > > > > to
> > > > > > it that will make it to render the standard ForeignKey control (with
> > > > > > "+" icon).
> > > > > > Is there a legal way to do it?
--~--~-~--~~~---~--~~
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: del session variables

2008-12-17 Thread Jeff FW

You've got a space in between "HttpResponseRedirect" and "('../
shop')" .

On Dec 17, 2:44 pm, Bobby Roberts  wrote:
> > Have a look at theflush() method; I believe that might well be close to
> > what you are after.
>
> > Regards,
> > Malcolm
>
> I'm trying to call the view below:
>
> def DoSessionReset(request):
>     request.session.flush()
>     return HttpResponseRedirect ('../shop')
>
> I'm getting this error:
>
> TypeError at /shop/start-new-order/
> 'str' object is not callable
--~--~-~--~~~---~--~~
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 with batch processing

2008-12-20 Thread Jeff FW

Check out:
http://www.doughellmann.com/PyMOTW/contents.html

He's got tutorials on quite a lot of the python stdlib--very handy
resource. csv and zipfile are on there.

-Jeff

On Dec 19, 9:40 pm, Brandon Taylor  wrote:
> I've been looking at the methods from those libs. Glad to know I'm on
> the right track.
>
> Thanks,
> b
>
> On Dec 19, 7:27 pm, Masklinn  wrote:
>
> > On 19 déc. 08, at 23:50, Brandon Taylor   
> > wrote:
>
> > > Hi everyone,
>
> > > My client needs some batch processing capabilities that I haven't
> > > coded in Python/Django yet, and I need advice on the best way to read
> > > images contained in a .zip file. I'm pretty comfortable extending
> > > Django admin, just not working with files this way.
>
> > > I will need to:
>
> > > 1. Read and parse a .csv file. (this I can do)
> > > 2. Unpack a .zip into a directory
> > > 3. Find files with names that correspond to a column in my .csv
> > > 4. Update my database with values from the .csv and the images
>
> > > Advice greatly appreciated!
> > > - Brandon
>
> > It shouldn't be too hard to do what you need with the csv and zipfile  
> > modules from the python stdlib
--~--~-~--~~~---~--~~
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 Session Variables

2008-12-20 Thread Jeff FW

Looking at
http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/__init__.py#L46
it doesn't look like it clears the session.  It *does* generate a new
key, but that shouldn't affect anything.  It should only take you
about two minutes to test it though--just try it out.

-Jeff

On Dec 19, 6:18 pm, "j...@zigzap.com"  wrote:
> Does django maintain session variables when logging in or does it
> generate a new session when you use the built in authentication.
> Essentially I want to be able to assign session values to an Anonymous
> User and be able to carry them through when they log in.
--~--~-~--~~~---~--~~
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: newie, django and apache, somethings are not working

2008-12-20 Thread Jeff FW

> the last line of the error is
>
> *
> OperationalError: unable to open database file
> **
>
> NOtes: I have put the complete path for the DB /home/XXX/djangoProys/
> mysite2/DBmysite2, and I tried change permissions for database file

Make sure that apache can read and write the database file *and* the
directory that the file is in.  It took me while to figure that one
out, but SQLite requires that.

> When I usehttp://127.0.1.1/mysite2/polls    or    
> http://127.0.1.1/mysite2/polls/1
>
> they works fine
>
> 2) except when I send the form to check for results from the poll, the
> error is
> *
> Not Found. The requested URL /polls/2/vote/ was not found on this
> server.
> *
>

It looks like you're directing the user to the wrong URL--it should
be:
/mysite2/polls/2/vote/

I'm assuming that you're hardcoding your URLs in your templates/views
--use the {% url %} tag and reverse() instead.

http://docs.djangoproject.com/en/dev/topics/http/urls/#reverse

-Jeff
--~--~-~--~~~---~--~~
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: del session variables

2008-12-20 Thread Jeff FW

Wow, you're right.  I've been programming Python for years, and I
somehow never noticed that.  I'll be quiet not :-)

On Dec 17, 6:33 pm, Malcolm Tredinnick 
wrote:
> On Wed, 2008-12-17 at 15:09 -0800, Jeff FW wrote:
> > You've got a space in between "HttpResponseRedirect" and "('../
> > shop')" .
>
> Which is perfectly legal and unambiguous in Python. That isn't a
> problem.
>
> Regards,
> 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: urls.py password reset view.

2008-12-20 Thread Jeff FW

That error is occuring because you don't have a URL defined for
password_reset_done, which, presumably, is being referred to in your
forgotpassword.html in a {% url %} tag.  Check out this brief
tutorial, it's rather handy:

http://www.rkblog.rk.edu.pl/w/p/password-reset-django-10/

-Jeff

On Dec 20, 12:01 pm, kev  wrote:
> Hello,
> I have the following entry in urls.py file:
>
>         (r'^forgotpassword/$', password_reset, {
>                 'template_name': 'users/forgotpassword.html',
>                 'email_template_name': 'users/forgotpassword_template.html'
>         }),
>
> Whenever i try to load it, i get:
> Reverse for '' with
> arguments '()' and keyword arguments '{}' not found.
>
> I have reinstalled a clean version of django and tried everything but
> i cannot seem to get it to work. I have searched other posts but none
> were helpful.
>
> Any help would be great!
>
> Kevin
>
> P.S. Im new to django so im trying to learn my way around :)
--~--~-~--~~~---~--~~
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: dynamically instantiate a model at run time

2008-12-24 Thread Jeff FW

I think you've got a small typo in the code there, that might be
confusing to the OP--shouldn't the get_model() call have quotes around
"tag"?  Like so:
model_class = get_model("test", "tag")

-Jeff

On Dec 23, 5:03 pm, bruno desthuilliers
 wrote:
> On 23 déc, 20:23, "dick...@gmail.com"  wrote:
>
> > i'm trying to do some instantiation of models, based on run time
> > parameters. i'm new to django/python so not sure the term, but the
> > relative java term is reflection.
>
> The term in Python is... well, it isn't. With a dynamic language, it's
> just daily programming, you know ?-)
>
> (ok, nitpicking, sorry. Please don't hold it against me - or at least
> read the practical solution at the bottom before).
>
>
>
> > for example, if i have a model, in my django models.py:
>
> > class Foo(models.Model):
> >     name = models.CharField(max_length=20)
>
> > now in some views.py code, i'm given, say some xml that defines a new
> > Foo object, so i want to dynamically create a new Foo object and save
> > it.  bar
>
> > i've tried a few things below, but namely, what i'm trying to do is
> > parse the xml, see that i need to create "Foo" and set it's name to
> > bar:
>
> > tag = "Foo"
> > key = "name"
> > value = "bar"
>
> >  _temp = __import__('project.test.models', globals(), locals(),
> > ['Foo'], -1)
> >  createobj = getattr(_temp, tag)
>
> This returns a class object, not an instance.
>
> > setattr(createobj, key, value)
>
> This sets the "name" attribute of *class* Foo to "bar".
>
> > createobj.save()
>
> > i'm getting unbound method on save,
>
> Not surprinsing since you're calling it on a class object... An
> unbound method (IOW: an instance method looked up on the class) takes
> an instance as first param - you know, the (in)famous  'self'
> argument ?
>
> 
> What is defined (using the 'def' statement) in a class statement is
> _really_ a function. It only becomes a "method" (in fact just a thin
> wrapper around the class, instance and function - name it, a partial
> evaluation of the function) when looked up on an instance - and an
> "unbound method" (same thing modulo the instance) when looked up on
> the class.
>
> IOW and to make a long story short:
>
> instance.method(arg)
> # is equivalent to
> cls.method(instance, arg)
> # which - if and only if "method" is defined in "cls"  (_not_
> inherited)
> # is equivalent to:
> cls.__dict__['method'](instance, arg)
>
> If you want to learn more about it, google for python+descriptor
> +protocol. It's the same thing that powers computed attributes (aka
> properties), and it's something worth learning about.
> 
>
> > and tried various ways to save.
> > but i'm thinking it is in the class instantiation where the problem
> > is.
>
> Indeed. You didn't create a Foo instance.
>
> Ok, now for the solution(s):
>
> # 1/ Django's models are all loaded at startup and cached.
> #    To get a model by appname/model, just use:
>
> from db.models.loading import get_model
> model_class = get_model("test", tag)
>
> # NB : at this point, "model_class" is what you named "createobj"
>
> # 2/ once you have the class, you need an instance:
>
> instance = model_class()
>
> # 3/ then you can set the attribute and save the instance:
>
> setattr(instance, key, value)
> instance.save()
>
> # ALT 1
> # you can save on typing, using keyword args
> # to instanciate your model:
>
> from db.models.loading import get_model
> model_class = get_model("test", tag)
> instance = model_class(**{key:value})
> instance.save()
>
> # ALT2
> #  and save even more typing using the
> #  model's manager "create" method:
>
> from db.models.loading import get_model
> model_class = get_model("test", tag)
> # create and save the instance in one step
> instance = model_class.objects.create(**{key:value})
>
> HTH.
>
> Oh, and welcome onboard BTW - we all hope you'll enjoy the trip !-)
--~--~-~--~~~---~--~~
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 forms usage with mutliple rows

2009-01-06 Thread Jeff FW

Yup, that's exactly what formsets are for.  You essentially take the
form you've already written, and pass it to formset_factory() to
create a list of identical forms.

http://docs.djangoproject.com/en/dev/topics/forms/formsets/#topics-forms-formsets

-Jeff

On Jan 6, 1:02 am, "Kottiyath Nair"  wrote:
> Hi,
>     Since I am a newbie in HTML and Django, there might be a completely
> different way to do this. If somebody can point that also, it would be
> helpful.
>
>     I want to send multiple rows of data from a datagrid to a django server.
>
>     Currently, I am doing it in a single form inside a page with the
> parameters as array. Please note that this value can change from 1 row to 25
> rows.
> The example get statement for 3 rows would look like:
> ../send_multiple_values_through_one_form.html?foo[secret]=my+hidden+value&foo[product-id]=1&bar[secret]=my+hidden+value&bar[product-id]=2&baz[secret]=my+hidden+value&baz[product-id]=3
>
> Now, I want to use Django forms to validate this data.
> class UploadQueryForm(forms.Form):
>     secret = forms.IntegerField()
>     product_id = forms.CharField(max_length=50)
>
> But this can be used to handle only one row . How can I use this for
> multiple rows? Is Django Formsets used for this purpose?
> Please note that I am not averse to other ideas - (say multiple forms etc),
> but I cannot think of any other way to implement this from HTML perspective
> itself.
>
> Regards
> K
--~--~-~--~~~---~--~~
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: creating formset is very slow

2009-01-06 Thread Jeff FW

Post the code for DataForm--I'll bet it's hitting the database a
number of times.  That would be the only reason I can think of that it
would take that long.  I just created a formset containing simple
forms, and it instantiated almost instantly--even with 2000 forms.

-Jeff

On Jan 6, 3:21 pm, "Kottiyath Nair"  wrote:
> I tried with 500 forms instead of 25. Now the time is becoming appaling.---
> 117 seconds. Second time it hung.
>
> 2009-01-07 01:42:13,812 INFO Start - 4.46984183744e-006
> 2009-01-07 01:42:13,812 INFO Formset Class created- 0.000422958783868
> 2009-01-07 01:44:11,703 INFO Created new formset- 117.90750668
> 2009-01-07 01:44:17,203 INFO All forms done - 123.39991647
> 2009-01-07 01:44:17,217 INFO Start - 123.416734808
> 2009-01-07 01:44:17,217 INFO Formset Class created- 123.41704658
>
> Regards
> K
>
> On 1/7/09, Kottiyath Nair  wrote:
>
>
>
> > Hi all,
> >    My web application sends a medium size data grid (20 elements). I was
> > using formsets for the same.
> >    The issue I am facing is that the formset instantiation is very very
> > slow. I timed it and it is taking ~4-7 seconds for it to instantiate.
> >    Is there someway the speed can be increased?
>
> > There are no files sent. I am planning to, later.
> > The code:
> >             logging.info('Start - %s' %time.clock())
> >             DataFormSet = formset_factory(DataForm, extra=25)
> >             logging.info('Formset Class created- %s' %time.clock())
> >             formset = DataFormSet(request.POST, request.FILES)
> >             logging.info('Created new formset- %s'%time.clock())
>
> > From my logs:
> > 2009-01-06 22:53:30,671 INFO Start - 0
> > 2009-01-06 22:53:30,671 INFO Formset Class created- 0.000403403225829
> > 2009-01-06 22:53:34,296 INFO Created new formset- 3.62182316468
> >   or later
> > 2009-01-06 22:56:37,500 INFO Start - 186.836136716
> > 2009-01-06 22:56:37,500 INFO Formset Class created- 186.836445135
> > 2009-01-06 22:56:43,108 INFO Created new formset- 192.440754621
>
> >    Please note that I am running the whole thing under the django
> > development server in my laptop itself and not a server.
--~--~-~--~~~---~--~~
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: Putting pieces back together again

2009-01-12 Thread Jeff FW

Mark,

You should really use Forms and FormSets--they'll make this problem
essentially go away.

http://docs.djangoproject.com/en/dev/topics/forms/#topics-forms-index
http://docs.djangoproject.com/en/dev/topics/forms/formsets/

-Jeff

On Jan 12, 12:46 am, Mark Jones  wrote:
> I have some fields on my page that have more than one attribute for
> simplification, lets say two attributes
>
> answer = {'txt':'something', 'allowblank':0}
>
> laid out on the page as:
> {% for answer in quiz_question.answers %}
>   
>    value="{{ answer.allowblank }}" />
> {% endfor %}
>
> the first is pulled from an input field, and if !allowblank, needs to
> have some text.
>
> I write some OnSubmit() javascript on my page to check this field, and
> if it is blank, check the allowblank attribute in the following hidden
> field to see if this is OK.  If is isn't ok, I ask the user "you sure
> you wanna leave this field blank?"  If the user says "YES, I want to
> leave it blank, the JS changes allowblank to 1 and we submit the form.
>
> If the backend gets the form and the field is blank, but the
> allowblank is true, then I know the user said OK, no problem, I let it
> be blank, otherwise I validate it on the server side (in case they use
> noscript like I do) and if allowblank=0 and the field is blank, I send
> the form back to them with a checkbox like this
>
> {% for answer in question.answers %}
>   
>    value="{{ answer.allowblank }}" /> I
> really want to leave this field blank
> {% endfor %}
>
> My problem comes about because a nice list of dict objects has been
> broken apart by the html form and needs to be reassembled.  While I
> can do this like so:
>
>           for i in range(len(qqanswers)-1,0, -1):
>               qqanswers[i] = {'txt':answers[i], 'allowblank':int
> (allowblank[i])}
>               if answers[i] == '' and allowblank[i]:
>                   del qqanswers[i]
>
> I don't like how ugly this looks.  I tried changing the names of the
> input objects to:
>
> answers.txt and answers.allowblank, but that didn't work, I got POST
> lists back that were names answers.txt and answers.allowblank that
> looked like:
>
>  u'answers.answer': [u'1', u'2', u'3', u'4']}>
>
> of course all of this ignores the fact that checkboxes that aren't
> checked aren't sent back to the server anyway which is where the need
> for a more elegant solution comes from in the first place..
>
> Is there a nice elegant way to solve this, or does it just have to be
> done the way I've done it..
--~--~-~--~~~---~--~~
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: Frankenstein App (or: dynamic subtemplates)

2009-01-20 Thread Jeff FW

What you're looking for is explained in the documentation on writing
your own template tags:
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/

Specifically, I'd look into inclusion tags:
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#inclusion-tags

-Jeff

On Jan 20, 1:49 pm, pistacchio  wrote:
> Hi to all! I'm a long time python developer. For my web application
> needs I've been relying on PHP, but I'm trying to switch to Django.
> I'm in the learning phase.
>
> A thing that is puzzling me is how to compose various apps like a
> puzzle with "main" pages. An example. Suppose that I have a home page
> with some recent news, a column with the latest posts from the forum,
> an ajax chat and a login / register form. What I see is a main, parent
> application (the homepage itself) made of little templates exposed by
> other applications (forum, news, chat, userAdmin).
>
> In PHP and my template system of choice (tinybutstrong) i can call a
> template from a "view" (a script) and work on a template level.
> Withing this main/index homepage i can embed tags calling other
> templates (latest from the forum, last 5 news etc). Those subtemplates
> can not only be static pages (or subtemplates recursively containing
> other sub templates) but can also be calls to scripts, so that i can
> effectively embed into a page the output of a script.
>
> What is the best way in Django to assemble bits of dinamic
> subtemplates into a main template? I suspect that the Django way is
> gathering data from the various apps and yell it to the template via a
> main view. Is there a way to work template-level? It think it is more
> convenient to design a page *requesting* data, also because a change
> only requires adding / deleting some rows in a template, while working
> on a view-level requires changin the view (and its includes) *and* the
> template.
>
> Any help from you Django experts?
> Thanks in advance,
> Gustavo
--~--~-~--~~~---~--~~
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: Has anyone looked into writing an SSH backend for file uploads?

2009-01-30 Thread Jeff FW

Instead of trying to get Django to do something like that, have you
looked into using sshfs?  That would make it essentially transparent--
all Django would know is that it's saving a file to a filesystem.

http://en.wikipedia.org/wiki/SSHFS

On Jan 29, 9:05 am, Andrew Ingram  wrote:
> On Jan 29, 1:19 pm, Christian Joergensen  wrote:
>
> > What if one of the machines was unresponsive at the time of the upload?
>
> One option would be to have all the files uploaded locally, but the
> handler would additionally copy to the other locations. The other
> would just to be to have some exception handling. File uploads aren't
> a site user task for us, so short periods of broken upload
> capabilities are tolerable.
--~--~-~--~~~---~--~~
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: Has anyone looked into writing an SSH backend for file uploads?

2009-01-30 Thread Jeff FW

Or Samba, too.  I suggested sshfs because the OP said "over SSH".
Also, it takes *no* set-up on the server--just have ssh running.  Not
that NFS is hard to set up, of course--just requires some actual
work.  And who wants to do that?

On Jan 30, 11:29 am, Alex Robbins 
wrote:
> It might be even easier to just set up an NFS mount of the other
> machines. It would be a lot like Jeff's idea, but NFS is pretty tried
> and true. (I don't know anything about SSHFS, it might be really good
> too.)
>
> On Jan 30, 9:54 am, Jeff FW  wrote:
>
> > Instead of trying to get Django to do something like that, have you
> > looked into using sshfs?  That would make it essentially transparent--
> > all Django would know is that it's saving a file to a filesystem.
>
> >http://en.wikipedia.org/wiki/SSHFS
>
> > On Jan 29, 9:05 am, Andrew Ingram  wrote:
>
> > > On Jan 29, 1:19 pm, Christian Joergensen  wrote:
>
> > > > What if one of the machines was unresponsive at the time of the upload?
>
> > > One option would be to have all the files uploaded locally, but the
> > > handler would additionally copy to the other locations. The other
> > > would just to be to have some exception handling. File uploads aren't
> > > a site user task for us, so short periods of broken upload
> > > capabilities are tolerable.
--~--~-~--~~~---~--~~
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: html italic tag hinders search code

2009-02-06 Thread Jeff FW

The issue has nothing to do with your templates--it has to do with
your data, and how you're searching it.  In the database, you have
stored "Survival of Shigella".  If you do a regular text
search (field__contains, or similar) for "Survival of Shigella",
you'll never get a match, because those strings don't match.

There are a few ways to deal with this, but I think one of the
cleanest would be to actually store *two* versions of the fields you
need to search: one with whatever HTML you need, and one with all of
the tags stripped out.  Then, you perform the searches on the stripped
field(s), but display the "real" field.  You can override your model's
save() method to actually set the stripped field.

-Jeff

On Feb 6, 1:12 pm, May  wrote:
> In the database I need to italics species names ex.  Survival of
> Shigella
> In the search template I use the following:
>
> 
>     Search for Publications: 
>     
>     
>   
>
> When a user types in "Survival of Shigella" the search code finds no
> record, because I think the  tags are hindering the search
> somehow.   When I type in Shigella the search finds the record.   I
> have changed the
> value = {{query|safe}} to all combinations (escape, force_escape,
> escapejs, iriencode, urlencode) and I still can't get the search to
> work.  Anyone have a suggestion on one; either using different html
> tags for italics or two; suggest how to get the search to strip the
> tags?
>
> Thanks,
>
> May
--~--~-~--~~~---~--~~
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: html italic tag hinders search code

2009-02-10 Thread Jeff FW

Yes, that's what I was suggesting.  Sorry for not being more clear.

As for storing the field twice, unless you're planning to have huge
amounts of records, you wouldn't really noticed any difference at
all.  Also, you can have the admin interface set to *not* display the
stripped version, so your users don't even have to know it exists.

-Jeff

On Feb 6, 3:54 pm, May  wrote:
> Creating a duplicate field without tags looks like it might be the way
> to go, then.  I just hate the redundancy of two fields of data.
>
> Thanks to both you and Jeff!
>
> May
>
> On Feb 6, 12:30 pm, Karen Tracey  wrote:
>
> > On Fri, Feb 6, 2009 at 3:05 PM, May  wrote:
>
> > > I have data entry clerks typing the data, so I cannot have them type
> > > the titles twice.
>
> > I'm quite sure Jeff wasn't suggesting having anyone type the titles in
> > twice.  Rather, when something with a title is saved, you have code (maybe
> > in a save() override) that automatically populates a "stripped" version of
> > your title field, based on the value of the title that was entered.  (There
> > is a simple strip_tags function in django.utils.html.)  Then, in the
> > database, you have both the field you have now (which contains html tags
> > like ) and a stripped version, and it is the stripped version that you
> > search, since people aren't going to be entering the html tags when they are
> > searching.
>
> > > Is there a command where I could strip the tags out
> > > after the keywords are typed but before python goes to the database to
> > > search?
>
> > ? From what you've said the  tags are in the data stored in the
> > database, not in the query keywords.  There's no way to strip the tags from
> > the database data in order to do a search.
>
> > 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-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: Bizarre sqlite3 / apache2 behaviour

2009-02-10 Thread Jeff FW

You need to make sure that the user apache is running as (usually
"apache") has write access to the database file *and* the directory
that the database file is in.

The development server would work because *you* probably have write
access to those paths.

As for the sqlite3 version, run python, then:
>>> import sqlite3
>>> sqlite3.version

-Jeff

On Feb 9, 12:10 pm, lazyant  wrote:
> Hello,
>
> I installed yesterday Django 1.0.2 (current downloadable version) on a
> new Ubuntu 8.10 machine with python 2.5.2. I wrote a toy application
> and it works and shows fine with both the built-in development server
> and Apache 2 (2.2.9). The database is sqlite3, it came with python
> (btw, how do I get the sqlite3 version from python/the Linux command
> line?).
>
> Anyways, yesterday everything was working fine, including the admin
> application served by Apache. Today I only worked on templates,
> restarting apache frequently (I know about setting MaxRequestsPerChild
> 1 but anyways) but after a while I went to the admin application
> (served by apache) and I got an error: "OperationalError: attempt to
> write a readonly database", which is strange since it was working
> before and I haven't made today any changes to file or directory
> permissions or fiddled with the settings file.
>
> I looked up this error and I only see tips regarding permissions
> problems, bad path in the setting file or perhaps a sqlite version
> issue. I think none of that applies to me (since it was working
> yesterday)  but I double-checked just in case.
>
> I tried different things for troubleshooting, including dropping the
> data with "manage.py sqlclear" and renaming the db file and re-
> creating it with "manage.py reset" and "manage.py syncdb" (I suspected
> perhaps the file was corrupted), but nothing I tried worked. I also
> checked the server (it wasn't rebooted recently etc).
>
> Here's a twist: if I start the development server and I log in, then
> the admin app in apache works fine (!), I can edit & save records etc.
> As soon as I log out of the development server, then apache gives me
> the readonly error.
>
> I'm ruling out client-side issues (cookies etc) since I tried with
> different browsers and computers, deleting session and cookies etc.
>
> Any ideas?
>
> 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: user defined model

2009-02-10 Thread Jeff FW

As much as I hate to suggest it, this sounds like a good time to use
XML.  Store each report as XML (in a file, or in a database row), then
use templates to render the data.

-Jeff

On Feb 9, 3:24 pm, Dids  wrote:
> > This is extremely unlikely to work, not to mention very inefficient.
> > Can you let us know why you want to do this - what's your use case? We
> > might be able to suggest a better way of doing it.
> > --
> > DR.
>
> Users define a set of data they're interested in. Give a mean to get
> the data (script, sql ...). The system goes and get the data at
> regular interval (save by date)
> The user can then review the data (table, charts , trends etc...)
> See it as a basic monitoring system where I currently have no idea
> what data the users will be interested in.
>
> I guess I can skip the table cration for each entity but I'm worried
> the code for data retrieval might get messy. Not to mention the
> templates ...
>
> Thanks for your input.
>
> Dids,
--~--~-~--~~~---~--~~
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 outputting date in template as timestamp

2009-02-20 Thread Jeff FW

I just tried running the code that the "U" date-formatting parameter
uses, and for me, it was off by about 11.5 days.  According to the
documentation, the "U" parameter is not implemented:
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#now

According to this ticket, someone might change the documentation soon,
so you might want to get a word in beforehand:
http://code.djangoproject.com/ticket/9850

I'd do it, but you already have the lovely test case :-)

-Jeff

On Feb 20, 12:46 pm, Sean Brant  wrote:
> > I asked a similar question a while ago... turns out the server i'm
> > using from godaddy was set for Arizona and was an additional 20 some
> > minutes off...
>
> I checked my server and the timezone is set to US/CENTRAL and my
> settings file is set to America/Chicago. So that should be the same.
> Plus the time is off by ~14 days.
--~--~-~--~~~---~--~~
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: Aggregating Ignores Slicing?

2009-03-03 Thread Jeff FW

The behavior is there because you can't limit an aggregate function in
(AFAIK) SQL in that way.  It just doesn't make sense--what would this
actually mean?

select sum(price) from product limit 100;

Really, you'd be limiting the number of *rows* of sum returned, which,
unless you're using GROUP, is going to be 1.  To do what you want,
you'd need a subselect, which (correct me if I'm wrong,) you'd have to
manually write in SQL.  Like so:

select sum(price) from (select price from product order by price desc
limit 100) as q;

(That's postgres; your DB may vary.)

I could be completely off-base here, as I haven't delved very far into
the aggregate code, but from what I can tell, this is the case.

-Jeff

On Mar 3, 11:08 am, Alex Gaynor  wrote:
> On Tue, Mar 3, 2009 at 8:55 AM, Ross  wrote:
>
> > I have started using aggregation, but it seems to ignore any slicing I
> > do on a QuerySet before calling aggregate. This is what I'm doing:
>
> > Product.objects.order_by("-price")[:100].values("price").aggregate(Max
> > ("price"), Min("price"))
>
> > I want the maximum and minimum price for the products with the top 100
> > largest prices. The aggregate function, however, returns the maximum
> > and minimum price for all Products--it ignores the [:100] slice.
>
> > Is this an improper use of aggregation, or am I doing something wrong
> > with my query?
>
> Before an aggregation is preformed all limits are removed, so you are seeing
> expected behavior.  I can't remember why this behavior exists though :/
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
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: Aggregating Ignores Slicing?

2009-03-03 Thread Jeff FW

Responded too quickly :-)

If you're already getting a list of the top 100 products (and
displaying them, I assume, in a loop,) then totalling up the prices in
Python really won't hurt at all.  I'd only suggest going with my
*previous* suggestion if you *weren't* already fetching the top 100
products.

-Jeff

On Mar 3, 11:34 am, Jeff FW  wrote:
> The behavior is there because you can't limit an aggregate function in
> (AFAIK) SQL in that way.  It just doesn't make sense--what would this
> actually mean?
>
> select sum(price) from product limit 100;
>
> Really, you'd be limiting the number of *rows* of sum returned, which,
> unless you're using GROUP, is going to be 1.  To do what you want,
> you'd need a subselect, which (correct me if I'm wrong,) you'd have to
> manually write in SQL.  Like so:
>
> select sum(price) from (select price from product order by price desc
> limit 100) as q;
>
> (That's postgres; your DB may vary.)
>
> I could be completely off-base here, as I haven't delved very far into
> the aggregate code, but from what I can tell, this is the case.
>
> -Jeff
>
> On Mar 3, 11:08 am, Alex Gaynor  wrote:
>
> > On Tue, Mar 3, 2009 at 8:55 AM, Ross  wrote:
>
> > > I have started using aggregation, but it seems to ignore any slicing I
> > > do on a QuerySet before calling aggregate. This is what I'm doing:
>
> > > Product.objects.order_by("-price")[:100].values("price").aggregate(Max
> > > ("price"), Min("price"))
>
> > > I want the maximum and minimum price for the products with the top 100
> > > largest prices. The aggregate function, however, returns the maximum
> > > and minimum price for all Products--it ignores the [:100] slice.
>
> > > Is this an improper use of aggregation, or am I doing something wrong
> > > with my query?
>
> > Before an aggregation is preformed all limits are removed, so you are seeing
> > expected behavior.  I can't remember why this behavior exists though :/
>
> > Alex
>
> > --
> > "I disapprove of what you say, but I will defend to the death your right to
> > say it." --Voltaire
> > "The people's good is the highest law."--Cicero
>
>
--~--~-~--~~~---~--~~
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: Aggregating Ignores Slicing?

2009-03-03 Thread Jeff FW

This time I didn't, apparently, read what you wanted exactly.  Here I
was, talking about sums, when all you want are the minimum and
maximum.  Apparently, I shouldn't answer mailing lists in the
morning.

Anyway, *most* of what I said holds true, as min and max work pretty
much the same way as sum--in Python, and in SQL.

On Mar 3, 11:36 am, Jeff FW  wrote:
> Responded too quickly :-)
>
> If you're already getting a list of the top 100 products (and
> displaying them, I assume, in a loop,) then totalling up the prices in
> Python really won't hurt at all.  I'd only suggest going with my
> *previous* suggestion if you *weren't* already fetching the top 100
> products.
>
> -Jeff
>
> On Mar 3, 11:34 am, Jeff FW  wrote:
>
> > The behavior is there because you can't limit an aggregate function in
> > (AFAIK) SQL in that way.  It just doesn't make sense--what would this
> > actually mean?
>
> > select sum(price) from product limit 100;
>
> > Really, you'd be limiting the number of *rows* of sum returned, which,
> > unless you're using GROUP, is going to be 1.  To do what you want,
> > you'd need a subselect, which (correct me if I'm wrong,) you'd have to
> > manually write in SQL.  Like so:
>
> > select sum(price) from (select price from product order by price desc
> > limit 100) as q;
>
> > (That's postgres; your DB may vary.)
>
> > I could be completely off-base here, as I haven't delved very far into
> > the aggregate code, but from what I can tell, this is the case.
>
> > -Jeff
>
> > On Mar 3, 11:08 am, Alex Gaynor  wrote:
>
> > > On Tue, Mar 3, 2009 at 8:55 AM, Ross  wrote:
>
> > > > I have started using aggregation, but it seems to ignore any slicing I
> > > > do on a QuerySet before calling aggregate. This is what I'm doing:
>
> > > > Product.objects.order_by("-price")[:100].values("price").aggregate(Max
> > > > ("price"), Min("price"))
>
> > > > I want the maximum and minimum price for the products with the top 100
> > > > largest prices. The aggregate function, however, returns the maximum
> > > > and minimum price for all Products--it ignores the [:100] slice.
>
> > > > Is this an improper use of aggregation, or am I doing something wrong
> > > > with my query?
>
> > > Before an aggregation is preformed all limits are removed, so you are 
> > > seeing
> > > expected behavior.  I can't remember why this behavior exists though :/
>
> > > Alex
>
> > > --
> > > "I disapprove of what you say, but I will defend to the death your right 
> > > to
> > > say it." --Voltaire
> > > "The people's good is the highest law."--Cicero
>
>
--~--~-~--~~~---~--~~
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: opposite of icontains

2009-03-04 Thread Jeff FW

You'd have to split() the string (probably on spaces, though I don't
know exactly what you're going for,) then build a query that checks
for each piece OR'd with every other piece.  That would probably be
the best way--check out:
http://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects

A simpler way (also naive) would be this:
Entry.objects.filter(headline__in='Today Lennon Honoured'.split())

If you decide to go with the first approach, let me know--I can help
you with the syntax.

-Jeff

On Mar 4, 8:01 am, koranthala  wrote:
> Hi,
>      How do I implement a substring query?
>      Please find the example below.
> From Django Documentation:
>   Entry.objects.get(headline__icontains='Lennon')
>   => This matches the headline 'Today lennon honoured'
>
> My query is the opposite:
>    I have the string 'Lennon' inside my DB, and I have to match 'Today
> Lennon honoured'
> Say:
> Entry.objects.get(headline__isubstring='Today Lennon Honoured')
> should return headline 'Lennon'.
>
>     I checked iregex too, but I cannot seem to solve it myself. If
> somebody has solved this, could you please help me out.
--~--~-~--~~~---~--~~
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: Why serializing to JSON doesn't work?

2009-03-04 Thread Jeff FW

The serializers are for serializing querysets/models.  I'm surprised
you're not getting an error message there--are you catching all
exceptions?

What you want is in django.utils.simplejson:

from django.utils.simplejson import encoder
encoder.JSONEncoder().encode(ret)

-Jeff

On Mar 4, 6:55 pm, Marek Wawrzyczek  wrote:
> Hello,
>
> I've got the code like this:
>
>     from django.core import serializers
>     ...
>
>     ret = { }
>     ret['a'] = 'b'
>     json_serializer = serializers.get_serializer("json")()
>     serialized = json_serializer.serialize(ret, ensure_ascii=False)
>     print serialized
>
> and this doesn't print serialized. What do I do wrong ?
> I'm using Python 2.5.2, Django 1.0.2.
>
> Thanks in advance,
> Marek
--~--~-~--~~~---~--~~
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: opposite of icontains

2009-03-05 Thread Jeff FW

Well, then, that is quite a strange use case :-)  Nevermind my simple
methods.  Malcom's suggestion of an extension for postgres seems like
a good idea--writing functions in various languages (like Python!) is
_really_ easy in postgres.

Just out of curiosity (for either of you,) what is a search like that
used for?  I've had a lot of strange requests from a lot of (generally
strange) clients, but that's a pretty weird one.

On Mar 5, 12:14 am, koranthala  wrote:
> Thank you very much Jeff and Malcolm for the extremely helpful
> replies.
> Jeff, the substring match is not based on spaces. Rather, the string
> can start anywhere and end anywhere.
> So, I cannot think of a way to do it, as Malcolm said.
> I had also done the same thing as Malcolm, i.e. pulled every tuple to
> memory (luckily I dont expect more than 200 odd tuples for this
> particular scenario) and am comparing individually - except for the
> fact that I was stopping at the first substring match. -  I guess I
> should be doing the "longest common substring" as Malcolm mentioned.
> Again, thank you Jeff and Malcolm.
>
> On Mar 5, 6:18 am, Malcolm Tredinnick 
> wrote:
>
> > On Wed, 2009-03-04 at 05:01 -0800,koranthalawrote:
> > > Hi,
> > >      How do I implement a substring query?
> > >      Please find the example below.
> > > From Django Documentation:
> > >   Entry.objects.get(headline__icontains='Lennon')
> > >   => This matches the headline 'Today lennon honoured'
>
> > > My query is the opposite:
> > >    I have the string 'Lennon' inside my DB, and I have to match 'Today
> > > Lennon honoured'
> > > Say:
> > > Entry.objects.get(headline__isubstring='Today Lennon Honoured')
> > > should return headline 'Lennon'.
>
> > >     I checked iregex too, but I cannot seem to solve it myself. If
> > > somebody has solved this, could you please help me out.
>
> > This isn't the type of searching operating that is going to be standard
> > outside of specialised packages. It's actually a really hard problem
> > (not impossible, there are solutions, but hard) in general. The
> > complexity comes from the fact that the match could start anywhere and
> > involve any number of characters. So to do this efficiently requires
> > some special datastructures (with suffix trees and some other
> > structures, you can the search in about O(total length of text)).
>
> > Now, I'm sure it wouldn't be impossible to write, say, an extension for,
> > say, PostgreSQL (picking that database because of its excellent support
> > for extensions) that supported this kind of searching, but it would be a
> > fair bit of work. It would require a particular sort of index structure
> > to support the searches. I don't know any package off the top of my head
> > that does this for databases. Might be a fun project for somebody with a
> > bit of time and curiosity.
>
> > I've done this kind of thing in the past for a couple of clients and
> > I've always pulled the text to be searched into memory. Create a data
> > structure of all the headlines to be searched (using your example) and
> > then match the search string against them to find the longest common
> > substring match. There's a lot of literature on this sort of stuff, and
> > searching for things like "longest common substring" will give you a
> > place to start.
>
> > Regards,
> > 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: Why serializing to JSON doesn't work?

2009-03-05 Thread Jeff FW

You know what's weird?  I've used simplejson.dumps() plenty of times
in my own code... not sure why that one just slipped out of my
memory.  I should just stop responding to things :-)

Anyway, since you're serializing a model, you *should* be using your
originally posted method.  Use the way Marek said for anything other
than models (of course, the object has to be serializable.)

If that doesn't work, post the full (relevant) code.

-Jeff

On Mar 5, 7:01 am, Marek Wawrzyczek  wrote:
> Thomas Guettler wrote:
>
> > Jeff FW schrieb:
>
> >> The serializers are for serializing querysets/models.  I'm surprised
> >> you're not getting an error message there--are you catching all
> >> exceptions?
>
> >> What you want is in django.utils.simplejson:
>
> >> from django.utils.simplejson import encoder
> >> encoder.JSONEncoder().encode(ret)
>
> > Or this:
>
> >>>> from django.utils import simplejson
> >>>> simplejson.dumps(...)
>
> > But unfortunately this does not encode datetime objects.
>
> >   Thomas
>
> Thanks for your responses. Now when I try
>
>      ret = { }
>      ret['a'] = 'b'
>      serialized = encoder.JSONEncoder().encode(ret)
>      print serialized
>
> then It works.
>
> But now I have another problem. I have a class "State":
>
> class State(models.Model):
>     state = models.CharField(max_length = 30)
>
>     def __unicode__(self):
>         return self.state
>
> Throutht the admin page I create a state called "Slaskie".      
> Then the code :
>
>             ret['b'] = State.objects.all()
>             print 'ret: %' % ret
>             try:
>                 serialized = encoder.JSONEncoder().encode(ret)
>             except Exception, e:
>                 print 'exception: %s' % e
>
> returns the output:
>
>     {'b': []}
>     [] is not JSON serializable
>
> At the 
> pagehttp://docs.djangoproject.com/en/dev/topics/serialization/#id2there's
> written something about unicode and lazy translation. I tried to use
>
>     le = LazyEncoder()       #lazy encoder is a given class from the
> link above
>     serialized = le.encode(ret)
>
> and then the exception was:
>     Circular reference detected
>
> when I tried
>
>     le = LazyEncoder (ensure_ascii = False)
>
> the exception was the same:
>     Circular reference detected
>
> What's going on with this lazy translation and unicode ? How can I
> serialize the data correctly ?
>
> Regards,
> Marek
--~--~-~--~~~---~--~~
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: opposite of icontains

2009-03-06 Thread Jeff FW

Clearly, you get to work on cooler projects than I :-)  I had thought
of the keywords/phrases case, but the other ones are far more
interesting.  Thanks for the explanation!

-Jeff

On Mar 5, 7:02 pm, Malcolm Tredinnick 
wrote:
> On Thu, 2009-03-05 at 12:54 -0800, Jeff FW wrote:
> > Well, then, that is quite a strange use case :-)  Nevermind my simple
> > methods.  Malcom's suggestion of an extension for postgres seems like
> > a good idea--writing functions in various languages (like Python!) is
> > _really_ easy in postgres.
>
> > Just out of curiosity (for either of you,) what is a search like that
> > used for?  I've had a lot of strange requests from a lot of (generally
> > strange) clients, but that's a pretty weird one.
>
> It's not that weird at all. It simply depends on the domains you're
> working in. No idea how it might apply to article headlines, although
> finding "related matches" could well use something like this.
>
> It's very common for finding overlaps in sequences of strings, though.
> The almost "standard" example is DNA sequences where you're trying to
> find if one sequenced set of data (bases extracted from a genetic
> sample) correspond to anything else already in the database. Since there
> can be damage at the extremeties of extractions, or even in the middle
> (or mutations), finding the longest common substring is the standard
> approach. There's a whole related area of reasearch in finding the
> longest palindrome sequences, too, for similar matching and folding
> purposes.
>
> Plagarism or even "similar article" testing is another case like this.
> Finding all "reasonably long" common sequences between a set of source
> documents and a candidate document is a start.
>
> One case I built something for was a compressed storage and
> transmissiong system for PDF and ODF documents. That required doing,
> essentially, a context-aware diff'ing process and pulling out any large
> chunks of commonality was the first step.
>
> Finally, not quite the same problem, but highly related, is the issue
> of, say, quickly finding all tags or other keywords or phrases that
> appear in a collection documents. Sometimes partial matching is an
> appropriate place for generating new phrases, so a modified Aho-Corasick
> search (just to give you a term to search on if you care) is a starting
> point.
>
> This whole domain is a very interesting area for algorithms and
> implementation.
>
> Regards,
> 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: Why serializing to JSON doesn't work?

2009-03-06 Thread Jeff FW

Keep the way you're serializing the querysets, add each one to a
dictionary, and then:

return dict((k, simplejson.dumps(v)) for k, v in ret_val.iteritems())

-Jeff

On Mar 6, 10:49 am, Marek Wawrzyczek  wrote:
> Thanks for your responses, they helped :)
>
> In the code below:
>
>        ret['b'] = State.objects.all()
>             print 'ret: %' % ret
>             try:
>                 serialized = encoder.JSONEncoder().encode(ret)
>             except Exception, e:
>                 print 'exception: %s' % e
>
> I was doing the following mistake - I wanted to serialize query set in a
> dictionary directly, and the exception was thrown, I think because
> encoder.JSONEncoder() can't encode a QuerySet.
>
> While using code like this:
>
>          ret = State.objects.all()
>          json_serializer = serializers.get_serializer("json")()
>          serialized_model = json_serializer.serialize(ret, ensure_ascii = 
> False)
>          ret_val['b'] = serialized_model
>          serialized = encoder.JSONEncoder().encode(ret_val)
>
> then it doesn't throw exception, but code above just creates a
> serialized dicionary of serialized model, so when I try to decode it
> with JSON parser on a page, i get a dictionary of strings. I can create
> a JSON response manually by:
>
>     serialized = '{"b":%s}'% serialized_model
>
> but it's a little annoying while serializing a few models.
>
> Is there any way to serialize dictionary of QuerySets without creating
> json response manually?
>
> Regards,
> Marek
>
> > You know what's weird?  I've used simplejson.dumps() plenty of times
> > in my own code... not sure why that one just slipped out of my
> > memory.  I should just stop responding to things  :-)
>
> > Anyway, since you're serializing a model, you *should* be using your
> > originally posted method.  Use the way Marek said for anything other
> > than models (of course, the object has to be serializable.)
>
> > If that doesn't work, post the full (relevant) code.
>
> > -Jeff
>
> > On Mar 5, 7:01 am, Marek Wawrzyczek  wrote:
>
> >> > Thomas Guettler wrote:
>
> >>> > > Jeff FW schrieb:
>
> >>>> > >> The serializers are for serializing querysets/models.  I'm surprised
> >>>> > >> you're not getting an error message there--are you catching all
> >>>> > >> exceptions?
>
> >>>> > >> What you want is in django.utils.simplejson:
>
> >>>> > >> from django.utils.simplejson import encoder
> >>>> > >> encoder.JSONEncoder().encode(ret)
>
> >>> > > Or this:
>
> >>>>>> > >>>> from django.utils import simplejson
> >>>>>> > >>>> simplejson.dumps(...)
>
> >>> > > But unfortunately this does not encode datetime objects.
>
> >>> > >   Thomas
>
> >> > Thanks for your responses. Now when I try
>
> >> >      ret = { }
> >> >      ret['a'] = 'b'
> >> >      serialized = encoder.JSONEncoder().encode(ret)
> >> >      print serialized
>
> >> > then It works.
>
> >> > But now I have another problem. I have a class "State":
>
> >> > class State(models.Model):
> >> >     state = models.CharField(max_length = 30)
>
> >> >     def __unicode__(self):
> >> >         return self.state
>
> >> > Throutht the admin page I create a state called "Slaskie".      
> >> > Then the code :
>
> >> >             ret['b'] = State.objects.all()
> >> >             print 'ret: %' % ret
> >> >             try:
> >> >                 serialized = encoder.JSONEncoder().encode(ret)
> >> >             except Exception, e:
> >> >                 print 'exception: %s' % e
>
> >> > returns the output:
>
> >> >     {'b': []}
> >> >     [] is not JSON serializable
>
> >> > At the 
> >> > pagehttp://docs.djangoproject.com/en/dev/topics/serialization/#id2there's
> >> > written something about unicode and lazy translation. I tried to use
>
> >> >     le = LazyEncoder()       #lazy encoder is a given class from the
> >> > link above
> >> >     serialized = le.encode(ret)
>
> >> > and then the exception was:
> >> >     Circular reference detected
>
> >> > when I tried
>
> >> >     le = LazyEncoder (ensure_ascii = False)
>
> >> > the exception was the same:
> >> >     Circular reference detected
>
> >> > What's going on with this lazy translation and unicode ? How can I
> >> > serialize the data correctly ?
>
> >> > Regards,
> >> > Marek
>
>
--~--~-~--~~~---~--~~
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: how to create bigint ?

2009-03-13 Thread Jeff FW

Especially since international phone numbers can start with 0--try
storing that in an integer field, and you'll immediately run into
problems.

On Mar 13, 8:43 am, Ozan Onay  wrote:
> As Karen pointed out, you should consider a phone number to be a
> string, not an integer. Integers are there to do mathematical
> operations on, which I can't imagine you requiring for a phone number
> (what's the relevance of my phone no. + 5?). Also anything that you
> would want to do with a phone number would be attained more naturally
> through string methods. Say you wanted to retrieve the last 4 digits -
> using phone_str[-4:] makes more sense than phone_int % 1.
>
> Don't be fooled by the fact that that phone numbers have numerals in
> them - phone "numbers" could well have used alphabetical characters,
> or colors, or anything else that could map to a series of frequencies.
--~--~-~--~~~---~--~~
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: Trying to understand Django and Python from a C++ perspective

2009-06-30 Thread Jeff FW

You can actually do something like it fairly simply, by using the
classmethod decorator, like so:

class Thing:

@classmethod
def do_something(cls, some_arg):
# do something with some_arg

Then you could call it:
Thing.do_something(3)

Notice that you don't pass the "cls" argument--Python does that for
you, in the same way that it passes "self" automatically for instance
methods.  You can also use the staticmethod decorator, which does
essentially the same thing as classmethod, except that it doesn't pass
the class as an argument; I tend to find this less useful in
practice.

-Jeff

On Jun 29, 6:25 pm, Mark Jones  wrote:
> Yea, I'm not wanting to use stuff.objects, but I'm wanting to pull
> some of the same voodoo, probably not safe for a python novice like
> myself :-)
>
> On Jun 29, 5:24 pm, Alex Gaynor  wrote:
>
> > On Mon, Jun 29, 2009 at 5:19 PM, Mark Jones  wrote:
>
> > > I can't seem to reason out why/how this works.
>
> > > I have a class Named Stuff
>
> > > I can say Stuff.objects.filter(.) and that will return valid set
> > > of data.
>
> > > What I can't understand is what exactly is objects, and why is it I
> > > can call it with Stuff.objects, but I can't call it with stuff.objects
> > > (an instance of Stuff).
>
> > > >>> dir(Stuff) shows me 'objects'
> > > >>> dir(stuff) shows me 'objects'
>
> > > >>> type(Stuff.objects)
> > > 
> > > >>> type(stuff.objects)
> > > Traceback (most recent call last):
> > >  File "", line 1, in 
> > >  File "...manager.py", line 151, in __get__
> > > AttributeError: Manager isn't accessible via Stuff instances
>
> > > What is the python Magic going on here to make this possible?
>
> > > I'm asking because I want to make something like 'objects' in that it
> > > doesn't need an instance, but it is scoped within the model of Stuff.
>
> > > My background is C++ and these look like methods/objects that are
> > > static to the class, not part of the instances.  I just can't figure
> > > out how to declare and instantiate them in python.
>
> > Django uses an advanced python feature called descriptors in order to
> > prevent you from accessing a manager (which is what "objects" is) from an
> > instance.  My understanding of the reason for this is somewhat conceptual:
> > asking for all the objects that are "Stuff"s makes sense, but asking for all
> > the objects that are "some object" doesn't make as much sense.
>
> > Alex
>
> > --
> > "I disapprove of what you say, but I will defend to the death your right to
> > say it." --Voltaire
> > "The people's good is the highest law."--Cicero
>
>
--~--~-~--~~~---~--~~
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: sorting different in postgres than in sqlite

2009-06-30 Thread Jeff FW

Any reason not to make the total 0 instead of None?  Null in database
(or None in Python) has a special meaning, and it doesn't always make
sense to sort a list of (mostly) integers with some null values.

-Jeff

On Jun 30, 2:01 am, J  wrote:
> Hello,
>
> I developed an app for an online contest.
>
> In this app, I requested a queryset with totals from a related table,
> and wanted to display the top ten participants. So, I sorted the
> queryset on the totals field, descending. Some participants didn't have
> any items, so the total for these was "None".
>
> When using sqlite, this appeared as I wanted, with the objects having
> "None" at the bottom, and thus not included in the top ten.
>
> However, after uploading this app to the production site, which has a
> postgres db, the None participants appeared at the top of the list (!),
> and THEN came the largest items successively decreasing as expected. My
> top-ten program failed.
>
> Any ideas?
>
> Thanks,
> J
>
> PS: Examples:
>
> Developement, sqlite, working:
> AR003   147
> CH005   69
> CO001   50
> CO031   50
> CH029   49
> AR004   None
> AR029   None
>
> Production, postgres, not working:
> CO217   None
> CO024   3000
> PE017   1400
> VE025   988
> CO013   930
> PE203   628
> CH016   523
--~--~-~--~~~---~--~~
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: Why PostgreSQL?

2008-06-20 Thread Jeff FW

I haven't yet used Django's dumpdata and loaddata, but I've used
mysqldump about a million times.  (That's mostly what we use at my
job, though I've been slowly pushing us towards postgres.)  Try
adding:

/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS,
FOREIGN_KEY_CHECKS=0 */;

at the top of the file, and:

/*!40014 SET [EMAIL PROTECTED] */;

at the bottom.  That *should* do it.  Sorry if I'm suggesting
something you've tried already.

As for the original poster's question of why PosgresQL is better (and
it certainly is), and ignoring the *really* important things that
others have already said:
 * much better authentication/authorization
 * ability to *easily* create your own datatypes
 * ability to write functions in several languages (like Python!)
 * much better command line interface (yes, that's just icing on the
cake, but it really is so helpful)

-Jeff

On Jun 18, 6:23 pm, AmanKow <[EMAIL PROTECTED]> wrote:
> I have to disagree that Django supports these backends equally well.
> I've just been bitten badly by the 'dumpdata ' 'loaddata '
> problems with MySQL and innodb.  I originally decided to go with MySQL
> (familiarity, for the most part).  Using MyIsam tables is not an
> option for me, I need the transaction support.
>
> In an app with no circular references or anything scary, I have a
> model with several foreign keys.  When I dumpdata, the created fixture
> dumps that model first, followed by the referenced tables.  As innodb
> doesn't support deferment of foreign key constraint checking until the
> end of the transaction, loaddata fails.  I must go in and edit the
> fixture to move the data for the referencing table after the data for
> the referenced tables to get loaddata to work.
>
> Of course, it quickly becomes obvious that editing the output of
> dumpdata is a bear with any significant amount of data or an app of
> any complexity.  As there is no way to specify the order of tables for
> dumpdata, and apparently dumpdata doesn't attempt to dump referenced
> tables first, this is quite a problem for MySQL users.
>
> Dumpdata and loaddata are just too important to forgo, especially when
> setting up test implementations and evolving a database.  Speaking of
> evolving, django-evolution has many issues with MySQL versus
> postgress.  I've therfore decided to bite the bullet and switch to
> postgres...
>
> For me that has it's own implications... While it is installed on the
> server, my host does not support it officially, and thus I am on my
> own administering it.  Now, at a point where I am hard-pressed for
> time, I am explaining to my clients that I've needed to make a change
> to the backend, and am hustling to become proficient enough in
> postgres to get the project back on track.
>
> In short, I don't think it is fair to say that Django supports all db
> backends equally.  I wish that early on, when choosing Django, I had
> been led definitively down the postgres path.
>
> On Jun 18, 11:46 am, "Jacob Kaplan-Moss" <[EMAIL PROTECTED]>
> wrote:
>
> > On Wed, Jun 18, 2008 at 9:55 AM, xhenxhe <[EMAIL PROTECTED]> wrote:
> > > This may be a loaded question, but I was reading a blog post that
> > > postgresql is the preferred database for Django. Is this true? If so,
> > > why?
>
> > Not exactly. Django works equally well with all the databases we
> > support -- we wouldn't claim support for a database that didn't work
> > somehow. Nor is Django itself "opinionated" in this manner; neither
> > the software nor its developers give a hoot what database you use.
> > Engrave all your data in stone tablets; doesn't bother me!
>
> > That said, many of the Django core developers -- me included -- do
> > prefer Postgres for our own work. Its emphasis on data integrity and
> > SQL standards along with the radically open development model I think
> > appeal to our feelings about software design and Open Source.
>
> > 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why PostgreSQL?

2008-06-21 Thread Jeff FW

On Jun 21, 12:46 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On Fri, Jun 20, 2008 at 9:14 PM, Jeff FW <[EMAIL PROTECTED]> wrote:
>
> > I haven't yet used Django's dumpdata and loaddata, but I've used
> > mysqldump about a million times.  (That's mostly what we use at my
> > job, though I've been slowly pushing us towards postgres.)  Try
> > adding:
>
> > /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS,
> > FOREIGN_KEY_CHECKS=0 */;
>
> > at the top of the file, and:
>
> > /*!40014 SET [EMAIL PROTECTED] */;
>
> > at the bottom.  That *should* do it.  Sorry if I'm suggesting
> > something you've tried already.
>
> AFAICT, that's the same idea suggested on #3615. The discussion on
> that ticket describes why it's not the final solution.
>
> Yours,
> Russ Magee %-)

Ah, I didn't see that ticket link there.  Good call.  Assuming the
data in a dumpfile is correct (which, of course, I know you can't), it
is a valid solution.  Meaning, maybe it could be a command-line flag
for the loaddata command.  If I *know* my data is valid, (say I just
dumped it from a working database using foreign keys), then why not
let me disable the checks when I load in the data? Running the script
linked in the ticket afterwards would certainly be an improvement, but
not essential in all cases.

As for ordering the tables in the dumpfile: I agree that it might not
be a general solution, as couldn't there be cycles in the foreign
keys?  Or is that not allowed?

Anyway, it's certainly a better quickfix for AmanKow's situation than
editing the dumpfile and rearranging the order of tables.

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



Re: Why PostgreSQL?

2008-06-21 Thread Jeff FW

I, apparently, need to learn to actually look at code before opening
my mouth.  I had never actually used the dumpdata command (I usually
just used the database server's dump feature), so I didn't realize
that it doesn't actually dump just straight SQL.  Of course, had I
thought about it (instead of just babbling), I would have realized
that would be a very naive way of doing things.  I should have known
to expect better from Django :-)

So, sorry for wasting your time.  I still think having a command-line
flag for turning checks off (with nice, big warnings on it) might be a
help, but I'll be quiet.

And yes, ordering the tables certainly couldn't hurt, and would be
quite nice.  I would submit a patch, but clearly, I need to actually
have a clue as to what I'm taking about first.

-Jeff

On Jun 21, 10:59 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On Sat, Jun 21, 2008 at 10:19 PM, Jeff FW <[EMAIL PROTECTED]> wrote:
>
> > On Jun 21, 12:46 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
> > wrote:
> >> AFAICT, that's the same idea suggested on #3615. The discussion on
> >> that ticket describes why it's not the final solution.
>
> > Ah, I didn't see that ticket link there.  Good call.  Assuming the
> > data in a dumpfile is correct (which, of course, I know you can't), it
> > is a valid solution.  Meaning, maybe it could be a command-line flag
> > for the loaddata command.  If I *know* my data is valid, (say I just
> > dumped it from a working database using foreign keys), then why not
> > let me disable the checks when I load in the data? Running the script
> > linked in the ticket afterwards would certainly be an improvement, but
> > not essential in all cases.
>
> The problem is that the cost of being wrong is so high. I might be
> absolutely sure that I don't have any problems in my data, but I could
> be wrong. If I'm right, there's no problem, but if I'm wrong, I can
> get the database into an invalid state, and the first time I'll know
> about it is when everything goes to hell because I try to follow an
> invalid reference.
>
> > As for ordering the tables in the dumpfile: I agree that it might not
> > be a general solution, as couldn't there be cycles in the foreign
> > keys?  Or is that not allowed?
>
> Cycles are certainly both possible and allowed. Hence the problems
> with finding a general solution based on model ordering.
>
> > Anyway, it's certainly a better quickfix for AmanKow's situation than
> > editing the dumpfile and rearranging the order of tables.
>
> Completely aside from the 'it might help some MySQL fixture loading"
> angle, there's a cosmetic angle - at the moment, fixtures are dumped
> in dictionary order - which is to say, no order at all. Sorting
> fixture output (both by model, and internally by key) would make the
> dumped output much nicer to spelunk through manually.
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: method="POST" form problems. Help required

2008-06-21 Thread Jeff FW

Looks like you forgot a return statement in the if statement.  Not
sure if that would cause what you're seeing, but it certainly couldn't
help.

-Jeff

On Jun 21, 6:46 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I forgot to post the problem. After clicking the 'Login' button,
> Httprequest is submitted with method GET instead of POST. When I tried
> to view the local variables, I am getting the form variables in GET
> data and I am getting POST data as No data.
>
> Sorry for the trouble.
>
> Thanks,
> Priyank
>
> On Jun 21, 3:41 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > Hi,
>
> > I am having problems with POST. I am aware of this newbie 
> > mistakehttp://code.djangoproject.com/wiki/NewbieMistakes#POSTtoviewslosesPOS...
>
> > Could someone help me out.
>
> > --
> > My view is
>
> > lass  LoginForm( forms.Form):
> >         loginName = forms.CharField()
> >         password = forms.CharField(widget=forms.PasswordInput)
>
> > def base_page(request):
> >         if request.method == 'POST':
> >                 render_to_response('logged_in.html', locals())
> >         else:
> >             loginForm = LoginForm()
> >             return render_to_response('login.html', locals())
>
> > -
> > My urls.py is
>
> >      (r'^login/$', base_page),
>
> > 
> > login.html
>
> >    
> >         
> >                 {{loginForm.as_table}}
> >         
> >         
> >    
>
> > I am not sure where I am doing the mistake. Everything looks right for
> > me. Could some one help me out of this.
>
> > Thanks,
> > Priyank
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: url views problem

2008-06-24 Thread Jeff FW

The regex you're using has a trailing /, so you need to have that in
your link as well:
/shows/1/

The other option is to make the trailing slash optional like so:
r'^shows/(?P\d{1})[/]?$'

On Jun 24, 7:09 am, sebey <[EMAIL PROTECTED]> wrote:
> it works but  (thanks for the tips) it still is getting the same feed
> for local/shows/1/ and local/show/2 help please
>
> everyone who has helped so far thank you
>
> On Jun 24, 12:06 pm, sebey <[EMAIL PROTECTED]> wrote:
>
> > ok fixed that yeah i saw that after I posted but here is what it looks
> > like now
>
> > from django.conf.urls.defaults import *
>
> > urlpatterns = patterns('',
> >     # Example:
> >     # (r'^ubermicro/', include('ubermicro.foo.urls')),
>
> >     # Uncomment this for admin:
> >     (r'^admin/', include('django.contrib.admin.urls')),
> >     #temp only fo dev proposes
> >     (r'^shows/(?p\d{1})/
> > $','ubermicro.shows.views.show_page')
> > )
>
> > thanks some please
>
> > On Jun 24, 11:46 am, Tye <[EMAIL PROTECTED]> wrote:
>
> > > Why does the /shows/ etc url string end with
>
> > > /s'
>
> > > ?
>
> > > Typo?
>
> > > Sent from my iPhone
>
> > > On Jun 24, 2008, at 3:23, sebey <[EMAIL PROTECTED]> wrote:
>
> > > > I have gotten this traceback
>
> > > > Traceback (most recent call last):
> > > > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
> > > > site-packages/django/core/handlers/base.py" in get_response
> > > >  68. callback, callback_args, callback_kwargs =
> > > > resolver.resolve(request.path)
> > > > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
> > > > site-packages/django/core/urlresolvers.py" in resolve
> > > >  160. for pattern in self.urlconf_module.urlpatterns:
> > > > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
> > > > site-packages/django/core/urlresolvers.py" in _get_urlconf_module
> > > >  177. self._urlconf_module = __import__(self.urlconf_name, {}, {},
> > > > [''])
> > > > File "/Users/sebey/Sites/ubermicro/../ubermicro/urls.py" in
> > > >  10. (r'^shows/(?p\d{1})/
> > > > s','ubermicro.shows.views.show_page') # .* does not work
> > > > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
> > > > site-packages/django/conf/urls/defaults.py" in patterns
> > > >  18. pattern_list.append(RegexURLPattern(regex, prefix and (prefix +
> > > > '.' + view_or_include) or view_or_include, *default_kwargs))
> > > > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
> > > > site-packages/django/core/urlresolvers.py" in __init__
> > > >  96. self.regex = re.compile(regex)
> > > > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
> > > > re.py" in compile
> > > >  180. return _compile(pattern, flags)
> > > > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
> > > > re.py" in _compile
> > > >  233. raise error, v # invalid expression
>
> > > >  error at /shows/1/
> > > >  unexpected end of pattern
>
> > > > here is what I have done to the urls
>
> > > > from django.conf.urls.defaults import *
>
> > > > urlpatterns = patterns('',
> > > >    # Example:
> > > >    # (r'^ubermicro/', include('ubermicro.foo.urls')),
>
> > > >    # Uncomment this for admin:
> > > >    (r'^admin/', include('django.contrib.admin.urls')),
> > > >    #temp only fo dev proposes
> > > >    (r'^shows/(?p\d{1})/
> > > > s','ubermicro.shows.views.show_page') # .* does not work
> > > > )
>
> > > > can anyone help?
> > > > On Jun 24, 10:34 am, sebey <[EMAIL PROTECTED]> wrote:
> > > >> cool thats great thanks anymore suggestions would be great thanks
>
> > > >> On Jun 23, 7:48 pm, phillc <[EMAIL PROTECTED]> wrote:
>
> > > >>>http://www.djangoproject.com/documentation/url_dispatch/
>
> > > >>> look at the regular expressions used in the examples, and the  
> > > >>> section
> > > >>> "named groups"
>
> > > >>> On Jun 23, 9:22 am, sebastian stephenson <[EMAIL PROTECTED]> wrote:
>
> > >  ok so I have in my data base a colium of rss feeds and I am  
> > >  parseing
> > >  them via feedparser and I am having a touble getting one feed to  
> > >  have
> > >  like "local/show/1" and another feed have "local/show/2" but how do
> > >  you do this here is the urls.py in its current state:
>
> > >  from django.conf.urls.defaults import *
>
> > >  urlpatterns = patterns('',
> > >       # Example:
> > >       # (r'^ubermicro/', include('ubermicro.foo.urls')),
>
> > >       # Uncomment this for admin:
> > >       (r'^admin/', include('django.contrib.admin.urls')),
> > >       #temp only fo dev proposes
> > >       (r'^shows/','ubermicro.shows.views.show_page') # .* does not  
> > >  work
> > >  )
>
> > >  then views.py:
>
> > >  from django.http import HttpResponse
> > >  import feedparser
> > >  from ubermicro.shows.models import show
> > >  from django.template import Context, loader
>
> > >  def show_page(request):
> > >       """this

Re: url views problem

2008-06-25 Thread Jeff FW

You've now passed in the variable (which you can check by throwing a
"print show_feed" at the top of the function), but now you actually
need to *do* something with it.  I'm assuming (not really knowing what
you want out of this) that you'd want to add an order_by clause to
order your podcasts (?) by *something*, then do some slicing to limit
the results.

Read:
http://www.djangoproject.com/documentation/db-api/#limiting-querysets

-Jeff

On Jun 25, 4:58 am, sebey <[EMAIL PROTECTED]> wrote:
> yes i have that set up it now looks like this
>
> def show_page(request,show_feed):
>     """this is where we take what we need form the rss feeds in the
> data base"""
>     query = show.objects.filter(show_feed__contains="http://";)
>     for s in query:
>         podcast = feedparser.parse(s.show_feed)
>         if  podcast.entries:
>             elements = {'show_about':
> podcast.feed.summary,'show_latest_title':
> podcast.entries[0].title,'show_latest': podcast.entries[0].summary}
>     e = elements
>     t = loader.get_template('shows/show_page_base.html')
>     return  HttpResponse(t.render(Context(e)))
>
> but it still in not working so help please thank you for trying
>
> On Jun 24, 3:07 pm, phillc <[EMAIL PROTECTED]> wrote:
>
> > you did not readhttp://www.djangoproject.com/documentation/url_dispatch/
>
> > your method, show_page, is now passed a parameter called show_feed.
> > you need to use it accordingly
>
> > On Jun 24, 10:02 am, sebey <[EMAIL PROTECTED]> wrote:
>
> > > either way its still the same thanks though but it still is not
> > > working
>
> > > On Jun 24, 1:44 pm, Jeff FW <[EMAIL PROTECTED]> wrote:
>
> > > > The regex you're using has a trailing /, so you need to have that in
> > > > your link as well:
> > > > /shows/1/
>
> > > > The other option is to make the trailing slash optional like so:
> > > > r'^shows/(?P\d{1})[/]?$'
>
> > > > On Jun 24, 7:09 am, sebey <[EMAIL PROTECTED]> wrote:
>
> > > > > it works but  (thanks for the tips) it still is getting the same feed
> > > > > for local/shows/1/ and local/show/2 help please
>
> > > > > everyone who has helped so far thank you
>
> > > > > On Jun 24, 12:06 pm, sebey <[EMAIL PROTECTED]> wrote:
>
> > > > > > ok fixed that yeah i saw that after I posted but here is what it 
> > > > > > looks
> > > > > > like now
>
> > > > > > from django.conf.urls.defaults import *
>
> > > > > > urlpatterns = patterns('',
> > > > > >     # Example:
> > > > > >     # (r'^ubermicro/', include('ubermicro.foo.urls')),
>
> > > > > >     # Uncomment this for admin:
> > > > > >     (r'^admin/', include('django.contrib.admin.urls')),
> > > > > >     #temp only fo dev proposes
> > > > > >     (r'^shows/(?p\d{1})/
> > > > > > $','ubermicro.shows.views.show_page')
> > > > > > )
>
> > > > > > thanks some please
>
> > > > > > On Jun 24, 11:46 am, Tye <[EMAIL PROTECTED]> wrote:
>
> > > > > > > Why does the /shows/ etc url string end with
>
> > > > > > > /s'
>
> > > > > > > ?
>
> > > > > > > Typo?
>
> > > > > > > Sent from my iPhone
>
> > > > > > > On Jun 24, 2008, at 3:23, sebey <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > I have gotten this traceback
>
> > > > > > > > Traceback (most recent call last):
> > > > > > > > File 
> > > > > > > > "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
> > > > > > > > site-packages/django/core/handlers/base.py" in get_response
> > > > > > > >  68. callback, callback_args, callback_kwargs =
> > > > > > > > resolver.resolve(request.path)
> > > > > > > > File 
> > > > > > > > "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
> > > > > > > > site-packages/django/core/urlresolvers.py" in resolve
> > > > > > > >  160. for pattern in self.urlconf_module.urlpatterns:
> > > > > &

Re: How do I get the value of a disabled Select widget?

2008-07-03 Thread Jeff FW

Why do you need to put the value back into a form?  I'm assuming that
this is on the second page of a multi-part form, or something along
those lines.  A safer way to do it might be to store the value in the
session, and not rely on the data coming back from the form to be
correct.  (The user can always modify the HTML of a page, and POST it
back to you.)

But then, I'm not sure what you're trying to do, so that might not
help at all.

-Jeff

On Jul 2, 11:30 am, Huuuze <[EMAIL PROTECTED]> wrote:
> I figured out the puzzle:
>
> self.fields['state'] = forms.CharField(required=False,
> widget=forms.HiddenInput(), initial=self.instance.state)
>
> Still open to feedback since I'm new to Django.
>
> On Jul 2, 11:19 am, Huuuze <[EMAIL PROTECTED]> wrote:
>
> > I use the following code to disable a ModelForm field in a custom
> > __init__:
>
> > self.fields['state'] =
> > USStateField(widget=widgets.Select({'class':'disabled', 'disabled':'',
> > 'tabindex':'-1',}, choices=STATE_CHOICES), required=False)
>
> > Unfortunately, this presents a problem.  When I post the form with a
> > "disabled" Select field, the form is no longer valid since it expects
> > a value associated with State.  Under non-Django conditions, I'd add a
> > hidden field that contains the value of the Select field and give it
> > the same name as the Select field.  However, I'm having trouble
> > figuring out how to retrieve the value of the Select field to place
> > into a InputHidden field.  This is operating under the assumption that
> > there isn't a better way to do this.  :)
>
> > For the sake of argument, here is my ModelForm:
>
> > class BookForm(forms.ModelForm):
> >   class Meta:
> >       model = Book
>
> >     def __init__(self, *args, **kwargs):
> >         super(BookForm, self).__init__(*args, **kwargs)
> >         ... some other stuff happens here 
> >         self.fields['state'] =
> > USStateField(widget=widgets.Select({'class':'disabled', 'disabled':'',
> > 'tabindex':'-1',}, choices=STATE_CHOICES), required=False)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: deleting a session

2008-07-03 Thread Jeff FW

I haven't tried this (I'll try it when I get home), but looking at the
session code shows that you should be able to call:
request.session.delete()
to delete the whole session at once.

On Jul 3, 3:52 am, Daniel Hepper <[EMAIL PROTECTED]> wrote:
> Try:
>
> for key in request.session.keys():
>     del request.session[key]
>
> Regards,
> Daniel Hepper
>
> Am Mittwoch, den 02.07.2008, 20:57 -0700 schrieb Bobby Roberts:
>
> > > for key in request.session:
> > >     del request.session[key]
>
> > I get the following error:
>
> > Exception Type:    KeyError
> > Exception Value:   0
> > Exception Location:        /usr/lib/python2.5/site-packages/django/contrib/
> > sessions/backends/base.py in __getitem__, line 31
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: elusive Post error

2008-07-08 Thread Jeff FW

Are you getting a particular error code, like 501 (not implemented)?
I would check Apache's error logs, as the issue might be happening
before Django ever gets the request.  If nothing useful shows up in
those logs, try increasing the logging level.

Oh, just a note--you may want to strip secret data out of your config
files before posting them.  In fact, I'd suggest changing those
passwords quickly, just in case.

-Jeff

On Jul 8, 11:45 am, Adam Fraser <[EMAIL PROTECTED]> wrote:
> I was wondering if anyone else has ever run into this problem...
>
> When filling out a form, I click submit and get a POST error claiming
> that the page does not support POST.  However, if I refresh the error
> page, the request goes through, and all is happy.
>
> I don't have much experience with web applications, so I'm not sure
> where to start here.  We're running on Apache and using SSL for
> authentication, but I disabled SSL and the problem persists.
>
> Here's my settings file anyway... any ideas?
>
> -Adam
>
> # Django settings for ProjectProfiler project.
>
> import posix  # for getuid
> import pwd    # for getpwuid
>
> DEBUG = True
> TEMPLATE_DEBUG = DEBUG
>
> ADMINS = (
>     # ('Your Name', '[EMAIL PROTECTED]'),
> )
>
> MANAGERS = ADMINS
>
> DATABASE_ENGINE = 'mysql'                    # 'postgresql_psycopg2',
> 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
>
> # Check whether to use the test or production version of the DB
> if (pwd.getpwuid(posix.getuid())[0] == "imageweb") :
>     DATABASE_NAME = 'projectprofiler'        # Or path to database
> file if using sqlite3.
> else :
>     DATABASE_NAME = 'projectprofilertest'    # Or path to database
> file if using sqlite3.
>
> DATABASE_USER = 'cpuser'                     # Not used with sqlite3.
> DATABASE_PASSWORD = 'cPus3r'                 # Not used with sqlite3.
> DATABASE_HOST = 'imgdb01.broad.mit.edu'      # Set to empty string for
> localhost. Not used with sqlite3.
> DATABASE_PORT = ''                           # Set to empty string for
> default. Not used with sqlite3.
>
> TIME_ZONE = 'America/New_York'
> LANGUAGE_CODE = 'en-us'
> SITE_ID = 1
> USE_I18N = True
> MEDIA_ROOT = '/home/radon01/afraser/projectprofiler/trunk/
> projectprofiler/media/'
> MEDIA_URL = 'http://127.0.0.1:8000/projectprofiler/media/'
> ADMIN_MEDIA_PREFIX = '/projectprofiler/media/admin/'
> SECRET_KEY = '&[EMAIL PROTECTED]&a886+2(2w9fu$6=-'
>
> TEMPLATE_LOADERS = (
>     'django.template.loaders.filesystem.load_template_source',
>     'django.template.loaders.app_directories.load_template_source',
> #     'django.template.loaders.eggs.load_template_source',
> )
>
> MIDDLEWARE_CLASSES = (
>     'django.middleware.common.CommonMiddleware',
>     'django.contrib.sessions.middleware.SessionMiddleware',
> #    'django.contrib.auth.middleware.AuthenticationMiddleware',
>     'projectprofiler.sslauth.middleware.SSLAuthMiddleware',
>     'django.middleware.doc.XViewMiddleware',
>     'projectprofiler.middleware.threadlocals.ThreadLocals',
> )
>
> ROOT_URLCONF = 'projectprofiler.urls'
>
> TEMPLATE_DIRS = (
>     '/home/radon01/afraser/projectprofiler/trunk/projectprofiler/
> templates',
>     '/imaging/analysis/People/imageweb/projectprofiler/trunk/
> projectprofiler/templates',
>     '/Users/ljosa/research/projectprofiler/projectprofiler/trunk/
> projectprofiler/templates',
> )
>
> INSTALLED_APPS = (
>     'django.contrib.auth',
>     'django.contrib.contenttypes',
>     'django.contrib.sessions',
> #    'django.contrib.sites',
>     'projectprofiler.sslauth',
>     'projectprofiler.projects',
>     'django.contrib.admin',
> )
>
> AUTHENTICATION_BACKENDS = (
>     'projectprofiler.sslauth.backends.SSLAuthBackend',
> #    'django.contrib.auth.backends.ModelBackend',
> )
>
> def myusernamegen(ssl_info):
>     import re
>     return re.sub('[EMAIL PROTECTED]', '', ssl_info.subject_email)
>
> SSLAUTH_CREATE_USER_CALLBACK = myusernamegen
> SSLAUTH_CREATE_USER = True
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: modify select widget

2008-07-13 Thread Jeff FW

I recently had to do something similar.  The way I went about it (and
I'm not sure this is the best way) is to select all of the categories,
then iterate through them and build a tree, using each category's
parent_id to figure out where in the tree it fits.

Then, once you've got a tree, you have to recurse through all of the
nodes (categories).  You can do this in your template, if you find a
good "recurse" template tag (I saw a few on djangosnippets a while
ago).

Or you can do what I did, and recurse through the tree beforehand,
building a flattened list of all the nodes, making sure to save what
"level" each particular node is at.  You can then output that in a
template, using the level to set each li's class.

Let me know if you need more help--I can send some code if you want,
though I can't promise it's very good :-)

-Jeff

On Jul 12, 11:57 am, Nenillo <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm doing an app with a category model. That category model has an
> autoreference field, to do multiple category levels.  I'm using
> models.ForeignKey('self',
> null=True, blank=True) for that. The problem is that the select is
> shown in a plain way and I wan to do something like:
>
> Cat1
> - Subcat1-1
> - Subcat1-2
> Cat2
> - Subcat2-1
>
> Is there any easy way to do that? O are hint on how to do it?
>
> Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: modify select widget

2008-07-13 Thread Jeff FW

Misspoke in that last post--if you want a select tag, obviously you
won't be using li tags.  You'd use option tags, and maybe throw in
some text in front of each option to indicate the level.  Everything
else still applies the same.

-Jeff

On Jul 12, 11:57 am, Nenillo <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm doing an app with a category model. That category model has an
> autoreference field, to do multiple category levels.  I'm using
> models.ForeignKey('self',
> null=True, blank=True) for that. The problem is that the select is
> shown in a plain way and I wan to do something like:
>
> Cat1
> - Subcat1-1
> - Subcat1-2
> Cat2
> - Subcat2-1
>
> Is there any easy way to do that? O are hint on how to do it?
>
> Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Help with Forms (Dynamic Fields)

2008-07-15 Thread Jeff FW

You have to pass the data into the form when instantiating it, eg:
form = MyForm(request.POST)

However, that means (for your example), the fields wouldn't exist yet--
move them into __init__ instead.

Some other things to note: you don't need to "title" and "email" to
the form dynamically--might as well put them in the MyForm class
definition.  Unless you're planning to upload files, you don't need
the enctype attribute in the form tag.

-Jeff

On Jul 15, 9:54 am, Srik <[EMAIL PROTECTED]> wrote:
> Hi Djangoers,
>
> I'm trying to generate a form dynamically using MyForm (Form class),
> but I'm stuck with validating or populating data.
>
> Form Class, View and template Code here:http://dpaste.com/65080/(not
> too many lines I guess :) )
>
> Good thing is I can see form (generating dynamically, based on the
> category I chose as expected), but I'm not able to do anything after
> that .
>
> When I submit form with empty values, its returning empty form no
> matter I enter data or not and also it won't throw any errors(like
> field required)
>
> Thanks,
> Srikanth
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Help with Forms (Dynamic Fields)

2008-07-16 Thread Jeff FW

In __init__, where you call form.Form's __init__, you need to pass
data, *not* None.  Also, you shouldn't try to duplicate all of the
arguments.  This should work better:

def __init__(self, cat_slug, data=None, *args, **kwargs):
forms.Form.__init__(self, data=data, *args, **kwargs)

Also, I'm not sure if you modified your view, but you have to pass
request.POST when you instantiate the form in order for that to
actually work.

-Jeff

On Jul 16, 6:01 am, Srik <[EMAIL PROTECTED]> wrote:
> Hi Jeff,
>
> I did try to move __init__ but the problem still exists.
>
> I tried to keep title and email along with other fields so that they
> will be appear in same order in Form.
>
> class MyForm(forms.Form):
>
>         def __init__(self, cat_slug, data=None, files=None, auto_id='id_%s',
> prefix=None, initial=None, error_class=ErrorList, label_suffix=':'):
>                 forms.Form.__init__(self,data=None, files=None, 
> auto_id='id_%s',
> prefix=None, initial=None, error_class=ErrorList, label_suffix=':') #
> Took those extra fileds from BaseForm class.
>                 cat = Category.objects.get(slug=cat_slug)
>                 self.fields['title'] = forms.CharField(max_length=50)
>                 self.fields['email'] = forms.EmailField()
>                 if cat.attributes.all():
>                         for i in cat.attributes.all():
>                                 self.fields[i.name] = 
> forms.CharField(label=i.name)
>
> Regards,
> Srikanth
>
> On Jul 15, 7:14 pm, Jeff FW <[EMAIL PROTECTED]> wrote:
>
> > You have to pass the data into the form when instantiating it, eg:
> > form = MyForm(request.POST)
>
> > However, that means (for your example), the fields wouldn't exist yet--
> > move them into __init__ instead.
>
> > Some other things to note: you don't need to "title" and "email" to
> > the form dynamically--might as well put them in the MyForm class
> > definition.  Unless you're planning to upload files, you don't need
> > the enctype attribute in the form tag.
>
> > -Jeff
>
> > On Jul 15, 9:54 am, Srik <[EMAIL PROTECTED]> wrote:
>
> > > Hi Djangoers,
>
> > > I'm trying to generate a form dynamically using MyForm (Form class),
> > > but I'm stuck with validating or populating data.
>
> > > Form Class, View and template Code here:http://dpaste.com/65080/(not
> > > too many lines I guess :) )
>
> > > Good thing is I can see form (generating dynamically, based on the
> > > category I chose as expected), but I'm not able to do anything after
> > > that .
>
> > > When I submit form with empty values, its returning empty form no
> > > matter I enter data or not and also it won't throw any errors(like
> > > field required)
>
> > > Thanks,
> > > Srikanth
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Quick question about switching to newforms-admin branch....

2008-07-16 Thread Jeff FW

According to:
http://code.djangoproject.com/wiki/VersionOneRoadmap#must-have-features
newforms-admin is a high priority.

If you haven't already, take a look at:
http://code.djangoproject.com/wiki/NewformsAdminBranch
http://code.djangoproject.com/wiki/NewformsHOWTO

They're both *really* helpful, but not the easiest to find.

-Jeff

On Jul 15, 4:55 pm, Jon Brisbin <[EMAIL PROTECTED]> wrote:
> I assumed that trunk would be moving in the newforms-admin direction,  
> so I've switched already. I would rather do it now than have to  
> backport stuff later...
>
> Thanks!
>
> Jon Brisibnhttp://jbrisbin.com
>
> On Jul 15, 2008, at 3:50 PM, Dan wrote:
>
> > Should I start with the nfa branch or with trunk and update the code  
> > when it is merged? Is there risks of breakage in nfa? Other issues?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Unique Case Sensitivity

2008-07-16 Thread Jeff FW

Check out:
http://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html

However, instead of dealing with it that way, you could also use this:
http://www.djangoproject.com/documentation/db-api/#iexact

-Jeff

On Jul 16, 5:54 am, "Peter Melvyn" <[EMAIL PROTECTED]> wrote:
> On Wed, Jul 16, 2008 at 3:06 AM, Russell Keith-Magee
>
> <[EMAIL PROTECTED]> wrote:
> > I strongly suspect that the problem here is MySQL - in particular, the
> > collation on your text field. There are certain default setups for
> > MySQL which will result in all text fields being case insensitive.
> > This doesn't just affect unique constraints - it affects case
> > sensitive matching as well.
>
> Not only default setups. 
> Seehttp://dev.mysql.com/doc/refman/5.0/en/charset-unicode-sets.html
> for available collations - all collations are case insensitive except
> the xxx_bin one.
>
> You can try in...
>
> Peter
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Field representation in n-f-admin

2008-07-18 Thread Jeff FW

If you just want to apply the formatting in the change_list view, then
define a method in the class in question that returns the formatted
string you want.  Then, in the corresponding Admin class, put the name
of that function in list_display, and that's it.

If you're talking about modifying it in the change view, then you
might need something like (but not exactly) this:
http://code.djangoproject.com/wiki/NewformsHOWTO#Q:HowdoIchangetheattributesforawidgetonasinglefieldinmymodel.

-Jeff

On Jul 17, 4:51 am, "Alex Rades" <[EMAIL PROTECTED]> wrote:
> Hi,
> I have a field (a XMLField) which I'd like to format somehow before
> presenting it into the admin change_list page.
> How do i alter the string representation of a field in django?
>
> Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Custom validation

2008-07-21 Thread Jeff FW

Sounds like you're looking at the oldforms documentation--that's all
been deprecated.  Read this instead:
http://www.djangoproject.com/documentation/newforms/

Especially this part:
http://www.djangoproject.com/documentation/newforms/#custom-form-and-field-validation

-Jeff

On Jul 21, 8:14 am, "Alex Rades" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> First of all, I'm using trunk :)
>
> I have a couple of models like:
>
> class User(model.Model):
>     group = models.ForeignKey(Group)
>
> Class Group(model.Model):
>     interest = models.ForeignKey(Interests)
>
> Basically i want to be possible to change in the admin the interest of
> a Group *only if*:
>
> self.user_set.count() == 0
>
> The documentation is not very about custom validation, it says to pass
> validator_list to the field definition, so i've tried with:
>
> interest = models.ForeignKey(interests, validator_list = [ myvalidator ])
>
> But it seems the custom validators are not called at all. Is this
> possible? How do I perform custom validation on a specific form? Doing
> it into the save() method of the model is not suitable (I want to
> raise an error which is specific to a field and is displayed next to
> the field itself)
>
> Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ANNOUNCE: Django 1.0 released

2008-09-04 Thread Jeff FW

Thank you all, yet again, for making it feel like the past decade or
so that I've been using other languages/frameworks was completely
wasted :-)  Keep it up, please.

-Jeff

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



Re: Need suggestions on subversion structure for project

2008-09-05 Thread Jeff FW

On Sep 5, 12:28 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Fri, 2008-09-05 at 07:09 +0530, Kenneth Gonsalves wrote:
>
> [...]
>
> > anyway, putting settings.py under version control is tantamount to  
> > suicide,
>
> I'm sorry, but this is just very bad advice. It's very standard practice
> to version control as much as possible in many organisations. It helps
> with audits as to what was rolled out when and ensures the right
> settings are matched to the right code.
>
> Regards,
> Malcolm

The way I've always handled this (and this is totally language
independent--I use it in PHP a lot [ugh])--is to make use of
subversion's "svn:ignore" property.

First, edit the property of the directory where your settings.py file
lives:
svn propedit svn:ignore my_project
In there, add a line with just:
settings.py
and save it.

Then, copy your settings file to something like
"settings.py.template", and svn add it.  In that file, put some sane/
useful defaults, then commit.   Now, anytime you check out a new copy,
settings.py.template will get pulled in, but settings.py won't, so
just copy settings.py.template to settings.py, and make any local
changes.  Since the svn:ignore property is set, your settings.py file
will never get overwritten (by subversion, at least).

As long as you're careful to put any new settings in the template
file, this is a great way of keeping track of your settings, without
having to worry about overwriting your production environment's
settings (something none of us have ever done, right?)

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



Re: Django bug that should be addressed: Idle timeouts do not clear session information

2009-03-16 Thread Jeff FW

It's not a bug.  When a cookie expires, the browser stops sending it
with its requests--therefore, there is *no* way for Django to know
that the cookie (and therefore, the session) has expired.  There is no
"timeout" happening on the server side, so the session can't get
cleared out.  Hence, why the documented method for clearing out old
sessions.

Maybe you're used to something like PHP's behavior, which cleans old
old sessions automatically.  However, it only does this by deciding to
clear out the old sessions (by default) 1 out of every 100 requests--
which is kind of a nasty thing to do that 100th person.

-Jeff

On Mar 16, 6:38 pm, Jacob Kaplan-Moss 
wrote:
> On Mon, Mar 16, 2009 at 4:46 PM, Huuuze  wrote:
> > Does anyone else agree with my viewpoints on this matter?  If so,
> > please post your comments in the ticket.
>
> Actually, the right way to get your viewpoint heard is to take the
> matter to the django-developers mailing list, where topics related to
> Django's development are discussed. You'll have more luck posting
> suggestions and criticism there than here or on the ticket tracker.
>
> However, please keep in mind that we're currently running up to Django
> 1.1, so it's likely that anything that's not an outright bug might be
> left by the wayside while we close bugs for the final release. If you
> don't get an immediate response, be patient and wait until a bit after
> the release when we all have a bit more time.
>
> 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: Django bug that should be addressed: Idle timeouts do not clear session information

2009-03-16 Thread Jeff FW

When you say "audit"--what do you mean?  By that, I mean, what do you
plan to do with the data?  Do you need to know the second someone
times out, or can you check later?

If you need to know immediately, I think you may need to do something
terrible with JavaScript.  If not, or you can at least wait a little
while--run a cron job (every minute, if you'd like) that finds all of
the sessions that are past their expiration date.  You can log them as
you'd like, and then clear them out.

-Jeff

On Mar 16, 8:56 pm, Huuuze  wrote:
> Jeff (and Jacob)...
>
> I appreciate your responses and I stand corrected.  With that being
> said, are either of you (or anyone reading this) aware of a method
> that would allow me to track idle session timeouts?  I'd like to audit
> when a user has been logged out due to a timeout.
>
> Huuuze
>
> On Mar 16, 7:49 pm, Jeff FW  wrote:
>
> > It's not a bug.  When a cookie expires, the browser stops sending it
> > with its requests--therefore, there is *no* way for Django to know
> > that the cookie (and therefore, the session) has expired.  There is no
> > "timeout" happening on the server side, so the session can't get
> > cleared out.  Hence, why the documented method for clearing out old
> > sessions.
>
> > Maybe you're used to something like PHP's behavior, which cleans old
> > old sessions automatically.  However, it only does this by deciding to
> > clear out the old sessions (by default) 1 out of every 100 requests--
> > which is kind of a nasty thing to do that 100th person.
>
> > -Jeff
>
> > On Mar 16, 6:38 pm, Jacob Kaplan-Moss 
> > wrote:
>
> > > On Mon, Mar 16, 2009 at 4:46 PM, Huuuze  wrote:
> > > > Does anyone else agree with my viewpoints on this matter?  If so,
> > > > please post your comments in the ticket.
>
> > > Actually, the right way to get your viewpoint heard is to take the
> > > matter to the django-developers mailing list, where topics related to
> > > Django's development are discussed. You'll have more luck posting
> > > suggestions and criticism there than here or on the ticket tracker.
>
> > > However, please keep in mind that we're currently running up to Django
> > > 1.1, so it's likely that anything that's not an outright bug might be
> > > left by the wayside while we close bugs for the final release. If you
> > > don't get an immediate response, be patient and wait until a bit after
> > > the release when we all have a bit more time.
>
> > > 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: Django bug that should be addressed: Idle timeouts do not clear session information

2009-03-18 Thread Jeff FW

My original suggestion would still work--run a cron job every minute
(or so) that finds all of the sessions that have an expiration date
since the last time the script was run--delete those, then log an
entry in your audit table.  Seems pretty simple to me, and I can't see
any reason why it wouldn't work.

Also, to back up Malcom, Jacob, and everyone else that's been trying
to help you--you *have* been a bit difficult, and the wording you use
*is* very important.   You attract more flies with honey--not that
anyone here is a fly.

-Jeff

On Mar 18, 12:13 am, "huu...@gmail.com"  wrote:
> On Mar 17, 10:45 pm, Jacob Kaplan-Moss 
> wrote:
>
>
>
> > On Tue, Mar 17, 2009 at 8:55 PM, Huuuze  wrote:
> > > 7.  Django detects the missing cookie
>
> > I think this is where you're getting hung up. Django doesn't "detect"
> > a "missing" cookie; Django sees a request from a browser that doesn't
> > include a cookie. Nothing's missing; it's just a new browser without a
> > cookie.
>
> > To Django, there's *no difference* between a user browsing a site
> > until his cookie expires then coming back, and the same user browsing
> > until the cookie expires and then a *second* user visiting without a
> > cookie. There's no "I used to have a cookie but now I don't" header;
> > there's either a session cookie, or there isn't.
>
> > Huuuze, I can appreciate that this is an infuriating aspect of HTTP --
> > statelessness is a real bitch sometimes. But you need to accept that
> > you're asking the impossible here and move on.
>
> Jacob, as you can see in my previous post (where I stated "And I agree
> with you: I don't think this can be done..."), I have moved on.  There
> is no need for the condescending tone in your previous post and lest
> we forget this is a *support* group.  I do understand the limitations
> and, in the case of my description of Step 7, I simply chose the wrong
> words.  Regardless, thank you again for assisting and setting me on
> the right path.
>
>
>
> > 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: Modifu request.user

2009-03-31 Thread Jeff FW

Changing request.user.id doesn't make sense--that would be trying to
change the id of the user object itself.  I think what you're trying
to do is change the user that is actually logged in... right?  If
that's true, then you need to set request.user *not* request.user.id--
but that seems like a very bad idea, and it won't (I think) change it
in the session.  What are you trying to accomplish?

-Jeff

On Mar 31, 2:35 am, Masarliev  wrote:
> I have a application but i have error in base logic and I need to
> change request.user.id.
> Is it posible to do that
> I tried request.user.id =  but with no result
--~--~-~--~~~---~--~~
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: How to handle the Browser Close ?

2009-04-01 Thread Jeff FW

http://docs.djangoproject.com/en/dev/topics/http/sessions/#session-expire-at-browser-close

On Apr 1, 2:26 am, veeravendhan  wrote:
> Say a user is logged in to the system,  If he closes the browser how
> will I handle the Logout for that user ? Any idea ??
--~--~-~--~~~---~--~~
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: Basic RSS in Django

2009-04-15 Thread Jeff FW

It looks like you're missing (or at least, didn't mention) the
templates. In documentation:

http://docs.djangoproject.com/en/dev/ref/contrib/syndication/#ref-contrib-syndication

make sure to read the paragraph starting with "One thing's left to do"
under "A simple example".

-Jeff

On Apr 15, 8:30 am, Oto Brglez  wrote:
> Hi all you Django users and developers!
>
> I have a question about RSS framework in Django. I want basic RSS.
> Nothing custom nothing advanced. Just RSS from my model for last 10
> imports in model. This is what i got:
>
> # Model:
>
> class Koda(models.Model):
>         naslov = models.CharField(max_length=50)
>         slug = models.SlugField(max_length=255,blank=True,null=True)
>         koda = models.TextField()
>         dodano = models.DateTimeField(default=datetime.datetime.now ,
> blank=True)
>         avtor = models.ForeignKey(User)
>
>         @permalink
>         def get_absolute_url(self):
>                 return ('koda_view', [self.slug])
>
>         def __unicode__(self):
>                 return self.jezik.ime + ' / '+ self.naslov
>
> #  RSS Model:
>
> class SvezaKoda(Feed):
>         title = "Rss title..."
>         link = "/rss/"
>         description = "Description..."
>
>         def items(self):
>                 return Koda.objects.order_by('-dodano')[:10]
>
>         def item_link(self,item):
>                 return '/'+ item.jezik.slug + '/' + item.slug
>
>         def item_author_name(self,item):
>                 return item.avtor
>
>         def item_pubdate(self,item):
>                 return item.dodano
>
> # URLs:
>
> feeds = {
>     'koda': SvezaKoda,
>
> }
>
> urlpatterns = patterns('',
>         (r'^rss/(?P.*)/$', 'django.contrib.syndication.views.feed',
> {'feed_dict': feeds}),
> ...
>
> ---
>
> Now. This works. But in content field i don't get content that i want.
> I want the field "koda" to be shown inside RSS content field. Insted
> of the content inside rss item i get value of __unicode__
>
> Can someone please help me.
>
> Oto
--~--~-~--~~~---~--~~
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: login decorator losing POST data

2009-05-15 Thread Jeff FW

If the form is just a single button, why not use GET and not have to
deal with POST at all?

-Jeff

On May 14, 11:28 am, aa56280  wrote:
> Tim,
>
> Thanks for the fantastic insight into the browser issues with 307
> redirects. I'll explore this a bit further and see which route I want
> to take.
>
> Given that the form in question is simply a button that says "Join
> network," I may be inclined to just let the user login, come back to
> the page and submit the form again. An annoying experience (IMHO), but
> one that eliminates all this hassle.
>
> Thanks again.
--~--~-~--~~~---~--~~
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: login decorator losing POST data

2009-05-15 Thread Jeff FW

Sure--those are totally reasonable in most cases.  However, the OP
just said that all that's in the form is a single button, meaning most
of those won't be an issue in this case.

-Jeff

On May 15, 10:03 am, Tim Chase  wrote:
> > If the form is just a single button, why not use GET and not have to
> > deal with POST at all?
>
> Multiple reasons:
>
> * By spec, GET can be cached by intermediary proxies, POST
> results aren't.  Caching may change application behavior.  (Yes,
> there are workarounds that involve HTTP cache-control headers)
>
> * GET shouldn't perform any write-action on the server, while
> POST can
>
> * POST can transmit large volumes of data (textareas and files in
> particular) which can't be sent via GET which has size limits
> (depends on both browser and server but 2kb is a good rule of
> thumb for "too big", as I believe that's the limit imposed by IE
> for the entire URL length)
>
> * GET requests often get saved in URL histories, leaving things
> like passwords open to prying eyes
>
> Those are my first-pass list of reasons (there may be more) that
> POST->GET translation isn't usually a good idea.
>
> -tim
--~--~-~--~~~---~--~~
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: IOError: request data read error (revisited)

2009-05-21 Thread Jeff FW

I've had the same problem, and can't figure out how to resolve it.  It
seems to have nothing to do with the amount of data being transfered:
it happens occasionally on the smallest of page requests/responses.
It also doesn't seem to be related to browser, unless several
different versions of IE *and* Safari have the same problem.  I tried
disabling keepalives for Safari at least, and it doesn't seem to have
helped.  I'd prefer not to disable keepalives in general, if I can
avoid it.

All of the error messages I've received have shown in the traceback
that they're coming through this function:
http://code.djangoproject.com/browser/django/trunk/django/core/handlers/wsgi.py#L131

It seems to me like there's an easy workaround (I'm sure the actual
fix has to be much lower level, in WSGI or Apache [or even lower])
that would at least stop my users from getting 500 errors: wrap the
contents of that function in a try block, and *don't* raise the
exception.

Otherwise, I'd have to wrap every view that uses POST in that, which
would be very annoying.  Or maybe write middleware that just peeks at
POST before anything else gets it, so that I could catch it there.

Thoughts?

Thanks,
Jeff

On Mar 31, 6:40 pm, Graham Dumpleton 
wrote:
> On Apr 1, 1:34 am, akaihola  wrote:
>
> > We ran into the same issue Chunlei Wu described in January[1]. A user
> > was trying to upload large files and all we got were 500 errors by e-
> > mail:
>
> >   File "/home/citedesarts/src/django/django/http/multipartparser.py",
> > line 406, inread
> >IOError:requestdatareaderror
>
> > The user was on a public library computer with IE7. We're running
> > Apache 2.2.9 andmod_wsgi2.3 as packaged in Debian 5.0 Lenny.
>
> > I'm wondering about the HTTP_VIA header, could that have contributed
> > to the problem?
>
> The presence of the header itself is not likely to cause the issue,
> but its presence does indicate that therequestwent via a proxy or
> other sort of software. That proxy may have been killing off requests
> which took too long.
>
> The basic problem remains that the connection to the HTTP server was
> dropped before alldatacould beread.
>
> Graham
>
> > [1]http://groups.google.fi/group/django-users/browse_thread/thread/
> > 946936f69c012d96
>
> > 
>
> > Below is the WSGIRequest dump from the 500 e-mail:
>
> >  > GET:,
> > POST:,
> > COOKIES:{'sessionid': '83bc617fed936487b17f7d14848d245c'},
> > META:{'CONTENT_LENGTH': '30977474',
> >  'CONTENT_TYPE': 'multipart/form-data;
> > boundary=---7d9c0903da',
> >  'DOCUMENT_ROOT': '/home/mysite/media',
> >  'GATEWAY_INTERFACE': 'CGI/1.1',
> >  'HTTP_ACCEPT': 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
> > application/x-shockwave-flash, application/vnd.ms-excel, application/
> > vnd.ms-powerpoint, application/msword, */*',
> >  'HTTP_ACCEPT_LANGUAGE': 'fi',
> >  'HTTP_CACHE_CONTROL': 'no-cache',
> >  'HTTP_CONNECTION': 'Keep-Alive',
> >  'HTTP_COOKIE': 'sessionid=83bc617fed936487b17f7d14848d245c',
> >  'HTTP_HOST': 'mysite.com',
> >  'HTTP_REFERER': 'http://mysite.com/myform/',
> >  'HTTP_UA_CPU': 'x86',
> >  'HTTP_USER_AGENT': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT
> > 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)',
> >  'HTTP_VIA': '1.1 EDUISAIMA',
> >  'PATH': '/usr/local/bin:/usr/bin:/bin',
> >  'PATH_INFO': u'/myform/',
> >  'PATH_TRANSLATED': '/home/mysite/deploy/mysite/myform/',
> >  'QUERY_STRING': '',
> >  'REMOTE_ADDR': '194.xxx.xxx.xxx',
> >  'REMOTE_PORT': '26205',
> >  'REQUEST_METHOD': 'POST',
> >  'REQUEST_URI': '/myform/',
> >  'SCRIPT_FILENAME': '/home/mysite/deploy/mysite.wsgi',
> >  'SCRIPT_NAME': u'',
> >  'SERVER_ADDR': '78.xxx.xxx.xxx',
> >  'SERVER_ADMIN': 'ad...@mysine.com',
> >  'SERVER_NAME': 'mysite.com',
> >  'SERVER_PORT': '80',
> >  'SERVER_PROTOCOL': 'HTTP/1.1',
> >  'SERVER_SIGNATURE': 'Apache/2.2.9 (Debian)mod_wsgi/2.3
> > Python/2.5.2 Server at mysite.com Port 80\n',
> >  'SERVER_SOFTWARE': 'Apache/2.2.9 (Debian)mod_wsgi/2.3 Python/2.5.2',
> >  'mod_wsgi.application_group': 'mysite.com|',
> >  'mod_wsgi.callable_object': 'application',
> >  'mod_wsgi.listener_host': '',
> >  'mod_wsgi.listener_port': '80',
> >  'mod_wsgi.process_group': 'mysite',
> >  'mod_wsgi.reload_mechanism': '1',
> >  'mod_wsgi.script_reloading': '1',
> >  'wsgi.errors': ,
> >  'wsgi.file_wrapper':  > object at 0x24aeeb8>,
> >  'wsgi.input': ,
> >  'wsgi.multiprocess': True,
> >  'wsgi.multithread': True,
> >  'wsgi.run_once': False,
> >  'wsgi.url_scheme': 'http',
> >  'wsgi.version': (1, 0)}>
--~--~-~--~~~---~--~~
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: IOError: request data read error (revisited)

2009-05-24 Thread Jeff FW

Thanks for your response. Sorry I didn't respond earlier--been quite
busy.

I don't know for certain that anyone's seeing a 500 response--I get an
e-mail from Django (traceback below) and an error in the Apache logs
(below).  I've never received an actual error report from a user (and
most of my users aren't the most technically inclined...) so I don't
know what they see.

I've never been able to duplicate this myself; it happens on average
once or twice a week, although it seems to occasionally happen to the
same person a couple of times within the span of a few minutes.  Also,
mod_wsgi is configured in daemon mode, with 1 process and 1 thread, if
that matters.

I haven't had a chance to try the debugging recipe you provided yet;
it's a production site, so I'm rather loathe to mess with it, if I can
avoid it.  Not to say that I won't try that, if it comes to it.
Thanks.

Apache log and traceback (both anonymized):

[Sat May 16 21:54:10 2009] [error] [client 75.33.xx.xx] (70014)End of
file found: mod_wsgi (pid=25650): Unable to get bucket brigade for
request., referer: https://domain.com/account/store/178/manage/item/create/
[Sat May 16 17:54:10 2009] [error] [client 75.33.xx.xx] mod_wsgi
(pid=18243): Exception occurred processing WSGI script '/var/www/
domain.com/django.wsgi'.
[Sat May 16 17:54:10 2009] [error] [client 75.33.xx.xxx] IOError:
client connection closed

(ignore the time difference--the server is on GMT, but Django is on
EST)

Traceback (most recent call last):

 File "/var/lib/python-support/python2.5/django/core/handlers/
base.py", line 86, in get_response
   response = callback(request, *callback_args, **callback_kwargs)

 File "/var/www/domain.com/domain/djangologging/decorators.py", line
10, in decorated
   response = func(*args, **kwargs)

 File "/var/www/domain.com/domain/store/views.py", line 137, in
random_items_ajax
   if not request.POST or 'count' not in request.POST:

 File "/var/lib/python-support/python2.5/django/core/handlers/
wsgi.py", line 169, in _get_post
   self._load_post_and_files()

 File "/var/lib/python-support/python2.5/django/core/handlers/
wsgi.py", line 149, in _load_post_and_files
   self._post, self._files = http.QueryDict(self.raw_post_data,
encoding=self._encoding), datastructures.MultiValueDict()

 File "/var/lib/python-support/python2.5/django/core/handlers/
wsgi.py", line 203, in _get_raw_post_data
   size=content_length)

 File "/var/lib/python-support/python2.5/django/core/handlers/
wsgi.py", line 69, in safe_copyfileobj
   buf = fsrc.read(min(length, size))

IOError: request data read error


,
POST:,
COOKIES:{'sessionid': 'xxx'},
META:{'CONTENT_LENGTH': '7',
 'CONTENT_TYPE': 'application/x-www-form-urlencoded; charset=UTF-8',
 'DOCUMENT_ROOT': '/var/www/domain.com/domain/www',
 'GATEWAY_INTERFACE': 'CGI/1.1',
 'HTTP_ACCEPT': '*/*',
 'HTTP_ACCEPT_ENCODING': 'gzip, deflate',
 'HTTP_ACCEPT_LANGUAGE': 'en-us',
 'HTTP_CACHE_CONTROL': 'no-cache',
 'HTTP_CONNECTION': 'Keep-Alive',
 'HTTP_COOKIE': 'sessionid=xxx',
 'HTTP_HOST': 'domain.com',
 'HTTP_REFERER': 'http://domain.com/page/how_to_sell/',
 'HTTP_USER_AGENT': 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT
6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506;
yie8)',
 'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest',
 'PATH': '/usr/local/bin:/usr/bin:/bin',
 'PATH_INFO': u'/ajax/random_items/',
 'PATH_TRANSLATED': '/var/www/domain.com/django.wsgi/ajax/
random_items/',
 'QUERY_STRING': '',
 'REMOTE_ADDR': 'xx.xx.xx.xx',
 'REMOTE_PORT': '50355',
 'REQUEST_METHOD': 'POST',
 'REQUEST_URI': '/ajax/random_items/',
 'SCRIPT_FILENAME': '/var/www/domain.com/django.wsgi',
 'SCRIPT_NAME': u'',
 'SCRIPT_URI': 'http://domain.com/ajax/random_items/',
 'SCRIPT_URL': '/ajax/random_items/',
 'SERVER_ADDR': 'xx.xx.xx.xx',
 'SERVER_ADMIN': '[no address given]',
 'SERVER_NAME': 'domain.com',
 'SERVER_PORT': '80',
 'SERVER_PROTOCOL': 'HTTP/1.1',
 'SERVER_SIGNATURE': 'Apache/2.2.9 (Ubuntu) mod_ssl/2.2.9
OpenSSL/0.9.8g mod_wsgi/2.3 Python/2.5.2 Server at domain.com Port 80\n',
 'SERVER_SOFTWARE': 'Apache/2.2.9 (Ubuntu) mod_ssl/2.2.9 OpenSSL/
0.9.8g mod_wsgi/2.3 Python/2.5.2',
 'mod_wsgi.application_group

Re: IOError: request data read error (revisited)

2009-05-26 Thread Jeff FW

Well, that sounds reasonable.  The traffic to my site should
(hopefully) be growing over the next few months--I'll just wait and
see if it happens more often.  I guess if the users aren't getting an
error message (and thus thinking that there's something wrong with the
site, or that they did something wrong,) then I'm not too worried
about it.  I guess I won't know what they see until it happens to me,
though :-)

Thanks for your help,
Jeff

On May 25, 6:59 am, Graham Dumpleton 
wrote:
> On May 25, 4:53 am, Jeff FW  wrote:
>
> > Thanks for your response. Sorry I didn't respond earlier--been quite
> > busy.
>
> > I don't know for certain that anyone's seeing a 500 response--I get an
> > e-mail from Django (traceback below) and an error in the Apache logs
> > (below).  I've never received an actual error report from a user (and
> > most of my users aren't the most technically inclined...) so I don't
> > know what they see.
>
> > I've never been able to duplicate this myself; it happens on average
> > once or twice a week, although it seems to occasionally happen to the
> > same person a couple of times within the span of a few minutes.  Also,
> > mod_wsgi is configured in daemon mode, with 1 process and 1 thread, if
> > that matters.
>
> If it is only happening once or twice a week, then I wouldn't be
> terribly concerned. Clients killing off connections abruptly before
> request content received is just one of those things that can happen.
> The nature of how WSGI and web applications work generally means that
> it is never dealt with cleanly and so you just end up with an
> unexpected error.
>
> Django could try and recognise an IOError on failure to read, but what
> is it going to do if it isn't going to propagate the error back. It is
> also entirely possible that different WSGI hosting mechanisms may not
> always raise an IOError as the WSGI specification doesn't say what
> should happen.
>
> Graham
>
> > I haven't had a chance to try the debugging recipe you provided yet;
> > it's a production site, so I'm rather loathe to mess with it, if I can
> > avoid it.  Not to say that I won't try that, if it comes to it.
> > Thanks.
>
> > Apache log and traceback (both anonymized):
>
> > [Sat May 16 21:54:10 2009] [error] [client 75.33.xx.xx] (70014)End of
> > file found: mod_wsgi (pid=25650): Unable to get bucket brigade for
> > request., referer:https://domain.com/account/store/178/manage/item/create/
> > [Sat May 16 17:54:10 2009] [error] [client 75.33.xx.xx] mod_wsgi
> > (pid=18243): Exception occurred processingWSGIscript '/var/www/
> > domain.com/django.wsgi'.
> > [Sat May 16 17:54:10 2009] [error] [client 75.33.xx.xxx] IOError:
> > client connection closed
>
> > (ignore the time difference--the server is on GMT, but Django is on
> > EST)
>
> > Traceback (most recent call last):
>
> >  File "/var/lib/python-support/python2.5/django/core/handlers/
> > base.py", line 86, in get_response
> >    response = callback(request, *callback_args, **callback_kwargs)
>
> >  File "/var/www/domain.com/domain/djangologging/decorators.py", line
> > 10, in decorated
> >    response = func(*args, **kwargs)
>
> >  File "/var/www/domain.com/domain/store/views.py", line 137, in
> > random_items_ajax
> >    if not request.POST or 'count' not in request.POST:
>
> >  File "/var/lib/python-support/python2.5/django/core/handlers/wsgi.py", 
> > line 169, in _get_post
> >    self._load_post_and_files()
>
> >  File "/var/lib/python-support/python2.5/django/core/handlers/wsgi.py", 
> > line 149, in _load_post_and_files
> >    self._post, self._files = http.QueryDict(self.raw_post_data,
> > encoding=self._encoding), datastructures.MultiValueDict()
>
> >  File "/var/lib/python-support/python2.5/django/core/handlers/wsgi.py", 
> > line 203, in _get_raw_post_data
> >    size=content_length)
>
> >  File "/var/lib/python-support/python2.5/django/core/handlers/wsgi.py", 
> > line 69, in safe_copyfileobj
> >    buf = fsrc.read(min(length, size))
>
> > IOError: request data read error
>
> >  > GET:,
> > POST:,
> > COOKIES:{'sessionid': 'xxx'},
> > META:{'CONTENT_LENGTH': '7',
> >  'CONTENT_TYPE': 'application/x-www-form-urlencoded; charset=UTF-8',
> >  'DOCUMENT_ROOT': '/var/www/domain.com/domain/www',
> >  'GATEWAY_INTERFAC

Re: Can a form have select box and be filled in at the same time?

2009-05-29 Thread Jeff FW

Have a choice of "Other", and provide a separate field for the user to
type in their own data.  That's a pretty standard way to handle that.
If you wanted to make it fancier, you could even have javascript to
only show the "other" text box if they've chosen the "Other" option.

-Jeff

On May 29, 2:22 am, sandwich  wrote:
> I want to use choices in Django to save common-use choices for the
> purpose of convenience.
> But at the same time, I want the user to fill their own choices when
> their choices are not in the select box.
> It seems that it will limit choices to the choices given once using
> choice in Django.
>
> ?_?
> So how can I solve my problem please.
--~--~-~--~~~---~--~~
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: Not displaying the data after space

2009-06-11 Thread Jeff FW

Take a look in the database itself (use the sqlite3 shell) and see if
the full phrase is being stored.  If it is, then there is an issue
with how you are pulling the data out and displaying it in the form;
if it isn't, then there is an issue with how you are saving the data
in the first place.

Without more information on what you're doing, that's the best I can
give you.  Check on that, and reply.

-Jeff

On Jun 11, 10:29 am, Nalini  wrote:
> Hi,
>
> I am using jvascript, python and django for my web page with Sqllite3
> at database.
>
> When i enter some data in a textfield, for example "this is an
> instrument" it is getting saved accurately into the database, the
> problem is when i try to view the data in the database , the data that
> is getting displayed in the frontend textfield is only "this" and the
> remaining data "is an instrument" is not getting displayed .
>
> I have declared that variable in models.py as
>
> description = models.TextField('Description', max_length=256)
>
> can anyone help me out where i went wrong?
>
> Thanks and Regards,
> Nalini
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---