Re: DATE FORMAT ISSUE AGAIN.

2007-03-14 Thread mralokkp

Kindly  execute the code that i wish to do from django it self



# Simplyfied date format change that I wish to use in django
import datetime
t = datetime.date.today()
print t.strftime("%Y,%m,%d")
print "My Required Date Format is "
print t.strftime("%d,%m,%Y")

Can't i call this program to django to change the date format. if yes
then let me know.

Regards
Alok





On Mar 15, 11:27 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Thu, 2007-03-15 at 05:58 +, mralokkp wrote:
> > Thanks James but the spaces had been removed
> > If Spaces it gives template error.
> > If not it gives the former error
> > says
> > AttributeError at /registration/
> > 'FormFieldWrapper' object has no attribute 'month'
> > had resolved
>
> Reading the error message gives a clue as to what is going wrong here:
> you are not formatting a datetime object, you are trying to call thefilteron 
> a FormFieldWrapper object, which won't work. It sounds like
> you are getting confused about the types of variables in your template
> -- maybe you are accidently calling two things by the same name in your
> view function or something like that.
>
> Trim your problem down to a very small example. Make it a template that
> only displays this one thing. Then make sure the error still occurs (if
> not, introduce more things until it happens again). Then start removing
> things from your view so that you are only passing the single variable
> into the template, checking that the error occurs each time. At some
> point, you will find the error goes away, so you will have more
> information about what the critical line of code is.
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: DATE FORMAT ISSUE AGAIN.

2007-03-14 Thread Malcolm Tredinnick

On Thu, 2007-03-15 at 05:58 +, mralokkp wrote:
> Thanks James but the spaces had been removed
> If Spaces it gives template error.
> If not it gives the former error
> says
> AttributeError at /registration/
> 'FormFieldWrapper' object has no attribute 'month'
> had resolved

Reading the error message gives a clue as to what is going wrong here:
you are not formatting a datetime object, you are trying to call the
filter on a FormFieldWrapper object, which won't work. It sounds like
you are getting confused about the types of variables in your template
-- maybe you are accidently calling two things by the same name in your
view function or something like that.

Trim your problem down to a very small example. Make it a template that
only displays this one thing. Then make sure the error still occurs (if
not, introduce more things until it happens again). Then start removing
things from your view so that you are only passing the single variable
into the template, checking that the error occurs each time. At some
point, you will find the error goes away, so you will have more
information about what the critical line of code is.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: DATE FORMAT ISSUE AGAIN.

2007-03-14 Thread mralokkp

Thanks James but the spaces had been removed
If Spaces it gives template error.
If not it gives the former error
says
AttributeError at /registration/
'FormFieldWrapper' object has no attribute 'month'
had resolved

But not able to change the date format still



I tryed to poke the source code of django

that have a file json.py
at line number 35 their is a class stated as
class DateTimeAwareJSONEncoder(simplejson.JSONEncoder):
"""
JSONEncoder subclass that knows how to encode date/time types
"""

DATE_FORMAT = "%Y-%m-%d"
TIME_FORMAT = "%H:%M:%S"

Does it makes any sense. sience I have already installed the django. I
don't guess that should work here.do i reinstall the django with the
DATE_FORMAT Change to "%d/%m%Y"

?


Stuck Guys Help me












Although after reading this
http://groups.google.com/group/django-users/browse_thread/thread/f0e7d503401a7186/a20885d604dcad7a?lnk=gst=%7Cdate%3A%22Y+m+d%22=2#a20885d604dcad7a
I changed the date field to datetime field
The

On Mar 15, 12:58 am, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 3/14/07, mralokkp <[EMAIL PROTECTED]> wrote:
>
> > Could not parse the remainder: |date: "F j Y"
>
> No spaces before or after the bar, no spaces before or after the colon:
>
> {{ somvar|date:"F j y" }}
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."


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



Copying objects in admin

2007-03-14 Thread Mark Jarecki

Hi guys

When you click the "Save and Add Another button" in the Admin, the  
values are cleared and all need to be re-entered for the new object.

How would I go about saving that existing object and then  
transferring the field values to the new object. This would save a  
lot of time for some models, as the data largely stays the same, bar  
a couple of fields.

And thanks Malcolm for your previous help, trying to implement things  
differently...

Cheers



--~--~-~--~~~---~--~~
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: Please add to the Django Tutorials list

2007-03-14 Thread Rubic

On Mar 14, 7:27 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> I've just added an entire page to the wiki about tutorials
> (http://code.djangoproject.com/wiki/Tutorials), with subcategories etc.

Very nice, especially the categories.  Thanks!

--
Jeff Bauer
Rubicon, Inc.


--~--~-~--~~~---~--~~
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: Playing with fixtures and django serializers -> Errors...

2007-03-14 Thread Russell Keith-Magee

On 3/14/07, Jens Diemer <[EMAIL PROTECTED]> wrote:
>
> Here some information: I'm rewrite PyLucid CMS: http://www.pylucid.org
> The emphasis is thereby: Using PyLucid in a shared Webhosting
> environment. So I implement a complete Web-Based installation.
>
> I write a "init DB data" routine:

First off, for clarification - you're not using the Django native
fixtures. The Cookbook code your code is based off is not the same as
the Django fixtures that are documented as part of the test framework.

> The source fixture file is a dump from a MySQL DB.

As a warning - using MySQL will cause you some problems with the
serializers. MySQL doesn't support forward references if you use the
InnoDB backend, and it doesn't support row-referential integrity or
transactions if you use the MyISAM backend.

> The current fixture file, can you see here:
> http://pylucid.net/trac/browser/branches/0.8%28django%29/PyLucid/fixtures/initial_data.xml?rev=925=raw

Ok; the error you reported previously (app_label, model not unique) is
being caused when deserializing the contenttype model in the
contenttypes application. This model requires that the fields
app_label and model are a unique pair. The error will be generated
either because:

1) your data file contains a duplicate entry, or
2) you aren't flushing the existing data before inserting the new
data, so when you deserialize, you are duplicating data in the
database.

> I have some open questions: How am I to store the data?
> I tried:
> - file(fixture_filename, "w")
> - file(fixture_filename, "wb")
> - codecs.open(fixture_filename, "w", "utf-8")
> (reading accordingly)

You will need to read the file in the same mode as which it was
written, but other than that, the answer depends entirely on what you
are saving. In your case, you have unicode characters in your data, so
using unicode files would be appropriate.

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



Method problem with .save()

2007-03-14 Thread DuncanM

I have 2 classes:


# 
# SquadSelector Class
# 

class SquadSelector(models.Model):
  fixture = models.ForeignKey(Fixture, verbose_name="Fixture",
core=True, help_text="Fixture to select squad for.")
  gk = models.ForeignKey(Player, verbose_name="Goal Keeper",
related_name="gk", core=True, help_text="Name of Goal Keeper.")
  rb = models.ForeignKey(Player, verbose_name="Right Back",
related_name="rb", core=True, help_text="Name of Right Back.")
  cb1 = models.ForeignKey(Player, verbose_name="Centre Back",
related_name="cb1", core=True, help_text="Name of First Centre Back.")
  cb2 = models.ForeignKey(Player, verbose_name="Centre Back",
related_name="cb2", core=True, help_text="Name of Second Centre
Back.")
  lb = models.ForeignKey(Player, verbose_name="Left Back",
related_name="lb", core=True, help_text="Name of Left Back.")
  rw = models.ForeignKey(Player, verbose_name="Right Wing",
related_name="rw", core=True, help_text="Name of Right Winger.")
  cm1 = models.ForeignKey(Player, verbose_name="Centre Midfield",
related_name="cm1", core=True, help_text="Name of First Centre
Midfielder.")
  cm2 = models.ForeignKey(Player, verbose_name="Centre Midfield",
related_name="cm2", core=True, help_text="Name of Second Centre
Midfielder.")
  lw = models.ForeignKey(Player, verbose_name="Left Wing",
related_name="lw", core=True, help_text="Name of Left Winger.")
  cf1 = models.ForeignKey(Player, verbose_name="Centre Forward",
related_name="cf1", core=True, help_text="Name of First Centre
Forward.")
  cf2 = models.ForeignKey(Player, verbose_name="Centre Forward",
related_name="cf2", core=True, help_text="Name of Second Centre
Forward.")
  sub1 = models.ForeignKey(Player, verbose_name="Sub 1",
related_name="sub1", blank=True, null=True, help_text="Name of 1st
Sub.")
  sub2 = models.ForeignKey(Player, verbose_name="Sub 2",
related_name="sub2", blank=True, null=True, help_text="Name of 2nd
Sub.")
  sub3 = models.ForeignKey(Player, verbose_name="Sub 3",
related_name="sub3", blank=True, null=True, help_text="Name of 3rd
Sub.")
  sub4 = models.ForeignKey(Player, verbose_name="Sub 4",
related_name="sub4", blank=True, null=True, help_text="Name of 4th
Sub.")
  sub5 = models.ForeignKey(Player, verbose_name="Sub 5",
related_name="sub5", blank=True, null=True, help_text="Name of 5th
Sub.")
  class Admin:
pass
list_display = ('fixture', )
list_filter = ['fixture',]
search_fields = ['fixture']

  # 
  # Accessor
  # 

  #String method
  def __str__ (self):
return str(self.gk)



  def save(self):
   # Instead of iterarting manually through all the players,
   # we use self.__dict__ and remove the stuff we don't need.
   squad = self.__dict__.copy()
   try:
 squad.pop('_fixture_cache')
   except KeyError:
 pass
   try:
 squad.pop('fixture_id')
   except KeyError:
 pass

   for player_id in squad.values():
 if player_id is not None:
   appearance = Appearance()
   appearance.player_id = player_id
   appearance.result = self.fixture.result
   appearance.save()





# 
# Appearance Class
# 

class Appearance(models.Model):
  player = models.ForeignKey(Player, verbose_name="Player", core=True,
help_text="Name of player.")
  result = models.ForeignKey(Result, verbose_name="Result",
edit_inline=models.TABULAR, num_in_admin=15, num_extra_on_change=3,
core=True, help_text="Result they played in.")
  class Admin:
pass
list_display = ('result', 'player',)
list_filter = ['result', 'player',]
search_fields = ['player']

  # 
  # Accessor
  # 

  #String method
  def __str__ (self):
return str(self.result)

  def count(self,fieldname="*"):
return self.get_query_set().countAppearance(player)

  #Counts number of goals a player has scored - this is a patch as
support for it is still in development
  def countAppearance(self,fieldsname="*"):
counter = self.clone
counter._order_by = ()
counter._offset = None
counter._limit = None
counter._select_related = False
select, sql, params = counter._get_sql_clause()
if fieldname == '*':
  column = '*'
else:
  column = self.model._meta.get_field(fieldname).column
cursor = connection.cursor()
cursor.execute("SELECT COUNT(*)" + sql, params)
cursor.execute("SELECT COUNT(%s)" % (column) + sql, params)
return cursor.fetchone()[0]




When I add a "squad selector" I get the following error:


DoesNotExist at /admin/teams/squadselector/add/
Result matching query does not exist.
Request Method: POST
Request URL:http://duncanm.webfactional.com/admin/teams/squadselector/add/
Exception Type: DoesNotExist
Exception Value:Result matching query does not exist.
Exception Location: /home2/duncanm/lib/python2.4/django/db/models/
query.py in get, line 213
Traceback (innermost last)
Switch back to interactive view

* 

Re: Deployment with Subversion

2007-03-14 Thread Kenneth Gonsalves


On 14-Mar-07, at 10:46 PM, [EMAIL PROTECTED] wrote:

> how do people deploy Django projects with subversion?  We did a simple
> checkout at a client's and when we need to do updates, we copy his
> settings.py file somewhere outside the directory, do the svn update,
> we copy the settings.py

never ever put settings.py under version control - the risk of it  
showing up on some trac or other gui and exposing your passwords is  
too great. Most of us keep a dummy file like settings.default in the  
repo and manually maintain the settings.py file. Anyway, there will  
be differences between your development copy of settings.py and the  
production copy.

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/



--~--~-~--~~~---~--~~
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: Deployment with Subversion

2007-03-14 Thread Ned Batchelder
Also, keep in mind that you can tell svn to ignore a particular file 
even though it is located in a working directory.  We keep a settings.py 
under svn control, and have it import a local.py which is ignored.  This 
way, each developer can make local modifications without fear of 
accidentally polluting the common pool.

--Ned.

Malcolm Tredinnick wrote:
> On Wed, 2007-03-14 at 17:16 +, [EMAIL PROTECTED] wrote:
>   
>> Hello,
>>
>> how do people deploy Django projects with subversion?  We did a simple
>> checkout at a client's and when we need to do updates, we copy his
>> settings.py file somewhere outside the directory, do the svn update,
>> we copy the settings.py file back in and do a graceful restart of
>> Apache.
>>
>> Does anyone have tricks to make this process a bit more efficient and
>> not catastrophic in case we forget to copy the settings.py file?
>> 
>
> There's no compulsion to have settings.py inside the project directory
> (it also doesn't have to be called settings.py, so you can put the
> settings files for a number of projects in the same directory if you
> name them carefully).
>
> For my personal work, I keep my settings.py files for production
> settings outside of the project directory so that I can just untar the
> new version of the code, update a symlink to the latest version and
> reload the webserver process, without needing to remember to update the
> settings file.
>
> Regards,
> Malcolm
>
>
> >
>
>
>
>   

-- 
Ned Batchelder, http://nedbatchelder.com


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



Please add to the Django Tutorials list

2007-03-14 Thread [EMAIL PROTECTED]

Hello Djuggernauts,

I've just added an entire page to the wiki about tutorials (http://
code.djangoproject.com/wiki/Tutorials), with subcategories etc.

Please add any that I've missed to this page (and feel free to put
them into two or more subcategories if warrented).

Thanks!
Simon


--~--~-~--~~~---~--~~
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: Saving a model instance multiple times

2007-03-14 Thread Malcolm Tredinnick

On Thu, 2007-03-15 at 11:07 +1100, Mark Jarecki wrote:
> Hi,
> 
> I was wondering how you would go about saving a model instance  
> multiple times (having seperate db entries) while changing just one  
> or two fields each time. I'm wanting to use a single series of inputs  
> that define the parameters to create/save multiple event objects to  
> the database.
> 
> Just to give you a better idea of what im trying to do:
> 
> class Schedule(models.Model)
> ...
> date = models.DateField()
> ...
> def save(self):
>date_list = [..]
>for d in date_list:
>   self.date = d
>   super(Schedule, self).save()
> 
> Any suggestions, example code would be much appreciated,

Create a new copy each time. For example (untested, but should come
close):

def save(self):
...
for d in date_list:
new_obj = Schedule(**self.__dict__)
new_obj.date = d
new_obj.save()

The uses the fact that you can create a new model using the field names
as keyword arguments to __init__ and that the __dict__ attribute will
(for a typical model) contain only the field attributes. 

My only slight qualm here would be that it's a bit weird to use one
model's save method to do almost everything but save that instance of
the model: it makes lots of new objects and saves those. Still, that
could be argued as being a matter of taste, so it's not a technical
obstacle. You probably do want to make sure you also save "self" at some
point in the above method, otherwise there would be no way to do it.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Saving a model instance multiple times

2007-03-14 Thread Mark Jarecki

Hi,

I was wondering how you would go about saving a model instance  
multiple times (having seperate db entries) while changing just one  
or two fields each time. I'm wanting to use a single series of inputs  
that define the parameters to create/save multiple event objects to  
the database.

Just to give you a better idea of what im trying to do:

class Schedule(models.Model)
...
date = models.DateField()
...
def save(self):
   date_list = [..]
   for d in date_list:
  self.date = d
  super(Schedule, self).save()

Any suggestions, example code would be much appreciated,

Cheers

--~--~-~--~~~---~--~~
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 install on mac osx 10.4.8

2007-03-14 Thread Jay Parlar

On 3/14/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hi everybody,
>
> hope you're all good out there.
>
> I did a few progress with my install.
> i installed python 2.4.
>
> with this install instead of the latest one i could install django
> with the sudo python setup.py install command.
>
> but now i can't seem to start a project.
> when i do the import django line in the terminal i do not have any
> error message again
> but when i try the
>
>  django-admin.py start-project testsite
>
> i get a syntax error message
>
>   File "", line 1
> django-admin.py start-project testsite
> ^
> SyntaxError: invalid syntax


Don't run that command from within the Python interpreter, just do it
from a Terminal command line.

Jay P.

--~--~-~--~~~---~--~~
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 models, detect whether value comes from db, or has explicitly been supplied.

2007-03-14 Thread Malcolm Tredinnick

On Thu, 2007-03-15 at 08:37 +1100, Malcolm Tredinnick wrote:
> On Wed, 2007-03-14 at 20:26 +, Norjee wrote:
> > Imagine the following model:
> > 
> > class Article(models.Model):
> > title = models.IntegerField()
> > 
> > Then when you do case 1):
> > art = Article.objects.get(pk=1)
> > art.title = "New title"
> > art.save()
> > 
> > or case 2):
> > art = Article.objects.get(pk=1)
> > art.save()
> > 
> > Is there a way that the model, before saving, knows whether the title
> > (or any other field) has been reassigned? I need to know because for a
> > datefield I want to use now if no explicit date is given, otherwise
> > the given date.
> 
> There's no one-line method, but it's pretty easy to do: write a custom
> save() method on the Article class that retrieves the instance again and
> compares the fields. Something like
> 
> def save(self):
> if self.id:
> original = Article.objects.get(id=self.id)
> # Compare fields you care about
> super(Article, self).save()

It just occurred to me that there's another way to do this if you're
going to need it fairly often...

Write your own __init__() method on the Article class and make sure you
call Model.__init__ (or super(Article, self).__init__) as the very first
thing. The Model __init__ will initialise your class by loading any data
into the attributes. Then your own __init__ code can copy those original
values to another attribute somewhere in the object. Inside your save()
method, you compare the attributes you are saving to the ones you copied
aside in the __init__ method to work out any differences.

Normally we don't need to write __init__ methods on models, so I wasn't
thinking along these lines. Whilst pushing the vacuum cleaner around the
living room just now I realised I'd missed something obvious.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Nested edit_inline?

2007-03-14 Thread Adrian Holovaty

On 3/14/07, Daniel Ellison <[EMAIL PROTECTED]> wrote:
> Is there a way to have nested inline editing? For example, I have a Poll
> model which can have multiple Questions - which, of course, can have
> multiple Answers. I tried adding edit_inline=models.TABULAR to both the
> Question and Answer models, but of course, it didn't work.

Hi Daniel,

No, this isn't currently possible.

Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.com

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



Re: Django models, detect whether value comes from db, or has explicitly been supplied.

2007-03-14 Thread Norjee

Thanks, I was hoping I was overlooking some Django internals, but
apparently not ;) I'll just stick to using two queries.


--~--~-~--~~~---~--~~
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: URLpattern kwargs becoming corrupted over time

2007-03-14 Thread Malcolm Tredinnick

On Wed, 2007-03-14 at 21:39 +, Jeff Forcier wrote:
> Greets all,
> 
> Been having the most bizarre issue for quite some time now; it seems
> as if the 'kwargs' portion of various URLpattern objects/views are
> 'bleeding' into one another once the server has been under moderate
> load for at least a short period.
> 
> I will have e.g. a specific view that displays/processes a form, whose
> template context will intermittently become corrupted and contain
> information that belongs in *other views' contexts*. For example, the
> context contains a couple objects, such as session username and object
> being edited, but then it will sometimes end up with those objects *in
> addition to* an object_list that comes from a list view, or a
> 'no_javascript' boolean that I set in some views to disable a template
> level Dojo include.
> 
> This problem only crops up after the server has handled at least a few
> dozen requests, and even then is only intermittent - I can load the
> same form a dozen times and the incorrect context appears 2-3 times,
> sometimes with different sets of incorrect info.
> 
> I have debugged the issue as best I can and it appears to reside in
> django.core.urlresolvers.RegexURLPattern - these objects set up their
> 'default_args' attribute when initialized (always correct at that
> point), and then refer to that value in their 'resolve()' method (at
> which point the corruption appears).
> 
> I can't find any bug reports or mailing list posts about this issue,
> and while I plan to file a ticket I wanted to post to see if anyone
> had any other bright ideas. This issue occurs with 0.91 and 0.95.1,
> with mod_python as well as the development runserver, always Python2.4
> (on varying Gentoo systems, fwiw).

Can you post an example of the sort of urlpatterns -- with the arguments
-- you have that are failing, please?

There's nothing in urlresolvers.py that should be causing this problem
(all the default argument use is thread-safe) but I'm wondering if you
are using mutable types as your default arguments and then modifying
them in place (the equivalent of "def foo(somearg = []):..."), which is
a bad idea for just the reasons you are seeing.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Starting a new, external process

2007-03-14 Thread Malcolm Tredinnick

On Wed, 2007-03-14 at 19:08 +, Henrik Lied wrote:
> Hi there!
> 
> I have a model which allows people to upload videos.
> In the save-method I run os.system("mencoder *variables"), which
> converts the uploaded video to a flash file.
> 
> I don't want the user to have to wait until the conversion is done
> before he can go on with his business. I've tried the Thread-module,
> but the current job still waits for the background process to finish..
> 
> Does anyone have a good idea (with a full example) on how I should go
> on? :-)

I'm not going to give you a full example, but this problem is raised
here fairly regularly (the most recent time being yesterday). The normal
solution is that the Django view queues the request to do the extra work
somewhere (e.g. a field in the model to say "needs encoding") and
another, external process comes along and does the work. The external
process might be triggered by a cronjob, for example -- it can check if
there is any work requests in the queue and handle them, otherwise just
exit immediately. The point is that the external process is not
triggered by a view or anything else that is tied to requests, so no
user's experience is affected.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



URLpattern kwargs becoming corrupted over time

2007-03-14 Thread Jeff Forcier

Greets all,

Been having the most bizarre issue for quite some time now; it seems
as if the 'kwargs' portion of various URLpattern objects/views are
'bleeding' into one another once the server has been under moderate
load for at least a short period.

I will have e.g. a specific view that displays/processes a form, whose
template context will intermittently become corrupted and contain
information that belongs in *other views' contexts*. For example, the
context contains a couple objects, such as session username and object
being edited, but then it will sometimes end up with those objects *in
addition to* an object_list that comes from a list view, or a
'no_javascript' boolean that I set in some views to disable a template
level Dojo include.

This problem only crops up after the server has handled at least a few
dozen requests, and even then is only intermittent - I can load the
same form a dozen times and the incorrect context appears 2-3 times,
sometimes with different sets of incorrect info.

I have debugged the issue as best I can and it appears to reside in
django.core.urlresolvers.RegexURLPattern - these objects set up their
'default_args' attribute when initialized (always correct at that
point), and then refer to that value in their 'resolve()' method (at
which point the corruption appears).

I can't find any bug reports or mailing list posts about this issue,
and while I plan to file a ticket I wanted to post to see if anyone
had any other bright ideas. This issue occurs with 0.91 and 0.95.1,
with mod_python as well as the development runserver, always Python2.4
(on varying Gentoo systems, fwiw).

Thanks for any help,
Jeff F.


--~--~-~--~~~---~--~~
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 models, detect whether value comes from db, or has explicitly been supplied.

2007-03-14 Thread Rubic

Assuming you've got a 'mydate' attribute:

  mydate = models.DateField(null=True)

You can conditionally assign it if null:

  import datetime
  art = Article.objects.get(pk=1)
  if not art.mydate:
  art.mydate = datetime.date.today()
  art.save()

--
Jeff Bauer
Rubicon, Inc.


--~--~-~--~~~---~--~~
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 models, detect whether value comes from db, or has explicitly been supplied.

2007-03-14 Thread Malcolm Tredinnick

On Wed, 2007-03-14 at 20:26 +, Norjee wrote:
> Imagine the following model:
> 
> class Article(models.Model):
> title = models.IntegerField()
> 
> Then when you do case 1):
> art = Article.objects.get(pk=1)
> art.title = "New title"
> art.save()
> 
> or case 2):
> art = Article.objects.get(pk=1)
> art.save()
> 
> Is there a way that the model, before saving, knows whether the title
> (or any other field) has been reassigned? I need to know because for a
> datefield I want to use now if no explicit date is given, otherwise
> the given date.

There's no one-line method, but it's pretty easy to do: write a custom
save() method on the Article class that retrieves the instance again and
compares the fields. Something like

def save(self):
if self.id:
original = Article.objects.get(id=self.id)
# Compare fields you care about
super(Article, self).save()

The reason this can't really be done any more simply than that is that
the attributes on an Article instance are just normal Python attributes
-- there is nothing Field-like about them until you do the saving.
Python has no automatic way to tell if a class's attributes have changed
between two points in time.

Reagrds,
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Deployment with Subversion

2007-03-14 Thread Malcolm Tredinnick

On Wed, 2007-03-14 at 17:16 +, [EMAIL PROTECTED] wrote:
> Hello,
> 
> how do people deploy Django projects with subversion?  We did a simple
> checkout at a client's and when we need to do updates, we copy his
> settings.py file somewhere outside the directory, do the svn update,
> we copy the settings.py file back in and do a graceful restart of
> Apache.
> 
> Does anyone have tricks to make this process a bit more efficient and
> not catastrophic in case we forget to copy the settings.py file?

There's no compulsion to have settings.py inside the project directory
(it also doesn't have to be called settings.py, so you can put the
settings files for a number of projects in the same directory if you
name them carefully).

For my personal work, I keep my settings.py files for production
settings outside of the project directory so that I can just untar the
new version of the code, update a symlink to the latest version and
reload the webserver process, without needing to remember to update the
settings file.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: models.ForeignKey problem

2007-03-14 Thread Malcolm Tredinnick

On Wed, 2007-03-14 at 21:16 +0100, Roland Hedberg wrote:
> Hi Rubic,
> 
> Rubic wrote:
> > Roland,
> > 
> > The error message isn't the most helpful.  ;-)
> 
> I'll second that !
> 
> > I had a similar problem back in January and tracked it
> > down to ticket #2536.  My workaround was changing
> > the name of the ForeignKey attribute -- in your case
> > 'project' -- to another name.
> 
> Lo and behold it actually worked !
> 
> Seems like magic :-)

Are you using a recent svn checkoutof the code? Because I'm pretty sure
we fixed this problem last week. If you are seeing it with something
less than a week old, it looks like we haven't quite nailed it. If you
are using an older version, rest assured that in the latest code you
could use the original names without conflict.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: WHAT IS DJANGO?

2007-03-14 Thread Todd O'Bryan

The Django you're looking for is here:

http://webpages.charter.net/django/

It's apparently a program for printing tablature for various fretted
instruments.

This Django is a framework for writing applications on the web.

On Wed, 2007-03-14 at 13:51 -0700, DICK wrote:
> I AM NEW TO THIS SITE AND THE REASON I AM POSTING THIS IS BECAUSE I
> WANTED TO DOWLOAD SOME SHEET MUSIC AND TABLATURE AT THIS LINK:
> 
> cbsr26.ucr.edu/wlkfiles/Publications/JohnDowland/JohnDowland.html
> 
> HOWEVER I CANT GET IN IT AND I WOULD LIKE TO BE ABLE TO BUT I DON'T
> KNOW HOW
> 
> 
> I'M HOPING SOMEBODY CAN HELP ME WITH THIS AND TELL WHAT IT IS I NEED
> TO DO
> 
> AGAIN I AM VERY NEW TO THIS KIND OF THING AND I DON'T HAVE A STRONG
> COMPUTER VOCABULARY
> 
> I HOPE YOU CAN TELL ME SIMPLLY WHAT IT IS I HAVE TO DO
> 
> THANK YOU
> 
> 
> > 


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



Re: WHAT IS DJANGO?

2007-03-14 Thread Nathan R. Yergler

I think you've found the wrong Django.  This Django is a Python web
framework for building web applications.

On 3/14/07, DICK <[EMAIL PROTECTED]> wrote:
>
> I AM NEW TO THIS SITE AND THE REASON I AM POSTING THIS IS BECAUSE I
> WANTED TO DOWLOAD SOME SHEET MUSIC AND TABLATURE AT THIS LINK:
>
> cbsr26.ucr.edu/wlkfiles/Publications/JohnDowland/JohnDowland.html
>
> HOWEVER I CANT GET IN IT AND I WOULD LIKE TO BE ABLE TO BUT I DON'T
> KNOW HOW
>
>
> I'M HOPING SOMEBODY CAN HELP ME WITH THIS AND TELL WHAT IT IS I NEED
> TO DO
>
> AGAIN I AM VERY NEW TO THIS KIND OF THING AND I DON'T HAVE A STRONG
> COMPUTER VOCABULARY
>
> I HOPE YOU CAN TELL ME SIMPLLY WHAT IT IS I HAVE TO DO
>
> THANK YOU
>
>
> >
>

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



Re: Starting a new, external process

2007-03-14 Thread Daniel Hepper

Hi!

I had exactly the same problem. I solved it by having Django write the
Video file to a directory. In the background, a process checks every
couple of seconds if there is a new FLV to convert. This process is
completely independent of Django. You might want to start it with an
init.d script or something.

This process could be something simple like this bash script:

#!/bin/bash

while true
do
for i in *.avi
do
MAGIC_MENCODER_COMMAND_GOES_HERE $i $i.flv
rm $i # remove the original file, or move it
done
sleep 5  # wait a few seconds
done

(I have not tested this, just to give you an idea)  
Your code could of course be way more sophisticated, like spawning a new
process upon a signal or whatever.
I hope you find this useful.

Regards,
Daniel

Am Mittwoch, den 14.03.2007, 19:08 + schrieb Henrik Lied:
> Hi there!
> 
> I have a model which allows people to upload videos.
> In the save-method I run os.system("mencoder *variables"), which
> converts the uploaded video to a flash file.
> 
> I don't want the user to have to wait until the conversion is done
> before he can go on with his business. I've tried the Thread-module,
> but the current job still waits for the background process to finish..
> 
> Does anyone have a good idea (with a full example) on how I should go
> on? :-)
> 
> 
> > 


--~--~-~--~~~---~--~~
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: Starting a new, external process

2007-03-14 Thread Atilla

I don't have a full example, but the thread module won't do what you
need. You need to spawn an external process to do your job. For this
take a look at python's documentation. It's a faily simple thing to
do, if you just want to run mencoder on the file,

On 14/03/07, Henrik Lied <[EMAIL PROTECTED]> wrote:
>
> Hi there!
>
> I have a model which allows people to upload videos.
> In the save-method I run os.system("mencoder *variables"), which
> converts the uploaded video to a flash file.
>
> I don't want the user to have to wait until the conversion is done
> before he can go on with his business. I've tried the Thread-module,
> but the current job still waits for the background process to finish..
>
> Does anyone have a good idea (with a full example) on how I should go
> on? :-)
>
>
> >
>

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



WHAT IS DJANGO?

2007-03-14 Thread DICK

I AM NEW TO THIS SITE AND THE REASON I AM POSTING THIS IS BECAUSE I
WANTED TO DOWLOAD SOME SHEET MUSIC AND TABLATURE AT THIS LINK:

cbsr26.ucr.edu/wlkfiles/Publications/JohnDowland/JohnDowland.html

HOWEVER I CANT GET IN IT AND I WOULD LIKE TO BE ABLE TO BUT I DON'T
KNOW HOW


I'M HOPING SOMEBODY CAN HELP ME WITH THIS AND TELL WHAT IT IS I NEED
TO DO

AGAIN I AM VERY NEW TO THIS KIND OF THING AND I DON'T HAVE A STRONG
COMPUTER VOCABULARY

I HOPE YOU CAN TELL ME SIMPLLY WHAT IT IS I HAVE TO DO

THANK YOU


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



Re: newforms and templating

2007-03-14 Thread dballanc

You might take a look at BaseForm._html_output().  It's the function
that does most of the work for .as_p() and so on.  Using it as a guide
you should be able to make your own render function to add to your
form class.


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



Django models, detect whether value comes from db, or has explicitly been supplied.

2007-03-14 Thread Norjee

Imagine the following model:

class Article(models.Model):
title = models.IntegerField()

Then when you do case 1):
art = Article.objects.get(pk=1)
art.title = "New title"
art.save()

or case 2):
art = Article.objects.get(pk=1)
art.save()

Is there a way that the model, before saving, knows whether the title
(or any other field) has been reassigned? I need to know because for a
datefield I want to use now if no explicit date is given, otherwise
the given date.


--~--~-~--~~~---~--~~
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: models.ForeignKey problem

2007-03-14 Thread Roland Hedberg

Hi Rubic,

Rubic wrote:
> Roland,
> 
> The error message isn't the most helpful.  ;-)

I'll second that !

> I had a similar problem back in January and tracked it
> down to ticket #2536.  My workaround was changing
> the name of the ForeignKey attribute -- in your case
> 'project' -- to another name.

Lo and behold it actually worked !

Seems like magic :-)

Thanks !

-- Roland

--~--~-~--~~~---~--~~
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: DATE FORMAT ISSUE AGAIN.

2007-03-14 Thread James Bennett

On 3/14/07, mralokkp <[EMAIL PROTECTED]> wrote:
> Could not parse the remainder: | date: "F j Y"

No spaces before or after the bar, no spaces before or after the colon:

{{ somvar|date:"F j y" }}

-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Starting a new, external process

2007-03-14 Thread Henrik Lied

Hi there!

I have a model which allows people to upload videos.
In the save-method I run os.system("mencoder *variables"), which
converts the uploaded video to a flash file.

I don't want the user to have to wait until the conversion is done
before he can go on with his business. I've tried the Thread-module,
but the current job still waits for the background process to finish..

Does anyone have a good idea (with a full example) on how I should go
on? :-)


--~--~-~--~~~---~--~~
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: newb: Django & CountingDown

2007-03-14 Thread Atilla

On 14/03/07, johnny <[EMAIL PROTECTED]> wrote:
>
> I have an app that is for online test taking. Most online test are 30
> mins to 2hrs. I need to create count down clock from when the test is
> stared. If 30 mins test, then count down will start from 30 mins : 00
> Secs, 29 min: 59 secs and so on. How do I do this?

One simple way will be to add a simple JavaScript clock countdown in
your application. You can find many examples online, or even ready
scripts.  You have to make sure on the track the time used on the
server side though - you should register the time at which user got
the test and the time at which he submitted the answers, at the very
least. If you have multiple pages/forms, make sure you register the
time at which the user requested each page and adjust the countdown
accordingly. Do not implement this with some random script entirely on
the client side, as then it'll be very easy to cheat.

--~--~-~--~~~---~--~~
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: Checking whether an app is installed?

2007-03-14 Thread Aidas Bendoraitis

Actually, the order of the apps in my template is also customized, so
it seems, that I'll have to create an template tag, taking an app
name, comparing it to settings.INSTALLED_APPS and returning a boolean
variable, i.e.
{% check "auth" as is_installed %}
{% if is_installed %}
... show links to administration lists ...
{% endif %}

But thanks, anyway.

Regards,
Aidas Bendoraitis [aka Archatas]


On 3/14/07, James Bennett <[EMAIL PROTECTED]> wrote:
>
> On 3/14/07, Aidas Bendoraitis <[EMAIL PROTECTED]> wrote:
> > Is there a function for checking whether an app was installed in the
> > current project?
>
> Currently, the list of apps on the default admin index page is
> generated by the 'get_admin_app_list' template tag, which just returns
> a list of apps. If all you need to do is show some content along with
> that app's stuff on the index you can do something like
>
> {% load adminapplist %}
> {% get_admin_app_list as app_list %}
> {% for app in app_list %}
> {% ifequal app.name 'myapp' %}
> ...do your special stuff here...
> {% else %}
> ...do the normal stuff showing links to add/change model instances...
> {% endifequal %}
> {% endfor %}
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
>
> >
>

--~--~-~--~~~---~--~~
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: Per-app permissions ?

2007-03-14 Thread David Cramer

Because this has everything to do with the web 2.0 expo

On Mar 14, 9:33 am, "Chris Brand" <[EMAIL PROTECTED]> wrote:
> What's the best way to restrict access on a per-app basis ?
> I want to have two apps, with some users allowed access to one, others
> allowed access to the other, and some allowed access to both.
>
> Any advice would be very much appreciated.
>
> Thanks,
>
> Chris


--~--~-~--~~~---~--~~
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: Search Swish

2007-03-14 Thread Mary

If jacobe or Adrain can help in answering me i will really appreciate

Thank you in advance ;
Mary Adel

On Mar 11, 9:45 pm, "Mary" <[EMAIL PROTECTED]> wrote:
> I read on one of the posts here
>
> > At World Online, thesearchengine (lawrence.com/search,
> > ljworld.com/search) uses swish-e (http://swish-e.org/) to index files.
>
> [snip]
>
> > Hope that helps! It would be pretty cool to open-source this mini
> >searchframework and pop it in django/contrib, but that would be up to
> > Jacob to decide.
>
> I'd love to open it up; I don't see any reason that we'd need to
> keep
> it hidden.  I'll put it on my todo list :)
>
> Jacob
>
> So i would like to know if i can see the code if it already published
> cause i need to implement asearchcriteria in my site and this will
> really helps


--~--~-~--~~~---~--~~
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: models.ForeignKey problem

2007-03-14 Thread Rubic

Roland,

The error message isn't the most helpful.  ;-)

I had a similar problem back in January and tracked it
down to ticket #2536.  My workaround was changing
the name of the ForeignKey attribute -- in your case
'project' -- to another name.

--
Jeff Bauer
Rubicon, Inc.


--~--~-~--~~~---~--~~
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: DATE FORMAT ISSUE AGAIN.

2007-03-14 Thread Tim Chase

> Thanks for that TIM A LOT

glad to help

> But stuck again
> 
> AttributeError at /registration/
> 'FormFieldWrapper' object has no attribute 'month'

Well, somewhere in your code, you're asking for the "month" 
attribute of an object.  And that object doesn't have a "month" 
property, so it raises the AttributeError exception.

This might stem from assigning a non-date value to a DateField 
value, and then trying to read it back.  Or it might stem from 
assigning None to such an attribute (though IIRC, that raises 
something like "'NoneType' object has no attribute 'month'".  Or 
you might be passing something that's a non-date to a "date" filter.

-tkc



--~--~-~--~~~---~--~~
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 Book

2007-03-14 Thread [EMAIL PROTECTED]

I wouldn't expect that date at all.

On Mar 14, 12:52 pm, "Derek Lee-Wo" <[EMAIL PROTECTED]> wrote:
> Amazon shows that the book on Django will be published on March 26th
> which is 1 1/2 weeks away.  Does anyone know if that date is still
> valid?
>
> I'm anxiously waiting to order it.
>
> Derek


--~--~-~--~~~---~--~~
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: DATE FORMAT ISSUE AGAIN.

2007-03-14 Thread [EMAIL PROTECTED]

I don't know what you're trying to format, but is it actually a
datetime field?

On Mar 14, 1:05 pm, "mralokkp" <[EMAIL PROTECTED]> wrote:
> HELP PLZZ
>
> On Mar 14, 7:54 pm, "mralokkp" <[EMAIL PROTECTED]> wrote:
>
> > Thanks for that TIM A LOT
> > But stuck again
>
> > AttributeError at /registration/
> > 'FormFieldWrapper' object has no attribute 'month'
> > Request Method: GET
> > Request URL:http://127.0.0.1:8000/registration/
> > Exception Type: AttributeError
> > Exception Value: 'FormFieldWrapper' object has no attribute 'month'
> > Exception Location: c:\Python24\Lib\site-packages\django\utils
> > \dateformat.py in F, line 123
>
> > On Mar 14, 7:49 pm, Tim Chase <[EMAIL PROTECTED]> wrote:
>
> > > > Case is this
> > > > XXX | date "F J Y"
>
> > > > It should read in the format that i choosen but instead of this gives
> > > > this error
> > > > TemplateSyntaxError at /mypage/
> > > > Could not parse the remainder: | date "F J Y"
>
> > > I've been bitten by this one several times.  I haven't seen any
> > > notes to the effect, but for some reason, the template parser
> > > doesn't seem like extra whitespace.  You'll also want to separate
> > > your "date" from its argument with the colon:
>
> > > fails:   | date "F J Y"
> > > works:  |date:"F J Y"
>
> > > I'll agree that whitespace makes it more readable, and that it
> > > would be nice if the template engine was a little more forgiving.
>
> > > But fortunately, it's an easy fix to just remove the whitespace.
>
> > > Perhaps a little caveat about whitespace at
>
> > >http://www.djangoproject.com/documentation/templates/#filters
>
> > > would help reduce confusion?
>
> > > -tkc


--~--~-~--~~~---~--~~
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: Newforms - Dynamic Fields from a queryset

2007-03-14 Thread Rubic

Tipan,

I've posted a code snippet that I think addresses your
issue: http://www.djangosnippets.org/snippets/82/

--
Jeff Bauer
Rubicon, Inc.


--~--~-~--~~~---~--~~
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: DATE FORMAT ISSUE AGAIN.

2007-03-14 Thread mralokkp

HELP PLZZ

On Mar 14, 7:54 pm, "mralokkp" <[EMAIL PROTECTED]> wrote:
> Thanks for that TIM A LOT
> But stuck again
>
> AttributeError at /registration/
> 'FormFieldWrapper' object has no attribute 'month'
> Request Method: GET
> Request URL:http://127.0.0.1:8000/registration/
> Exception Type: AttributeError
> Exception Value: 'FormFieldWrapper' object has no attribute 'month'
> Exception Location: c:\Python24\Lib\site-packages\django\utils
> \dateformat.py in F, line 123
>
> On Mar 14, 7:49 pm, Tim Chase <[EMAIL PROTECTED]> wrote:
>
> > > Case is this
> > > XXX | date "F J Y"
>
> > > It should read in the format that i choosen but instead of this gives
> > > this error
> > > TemplateSyntaxError at /mypage/
> > > Could not parse the remainder: | date "F J Y"
>
> > I've been bitten by this one several times.  I haven't seen any
> > notes to the effect, but for some reason, the template parser
> > doesn't seem like extra whitespace.  You'll also want to separate
> > your "date" from its argument with the colon:
>
> > fails:   | date "F J Y"
> > works:  |date:"F J Y"
>
> > I'll agree that whitespace makes it more readable, and that it
> > would be nice if the template engine was a little more forgiving.
>
> > But fortunately, it's an easy fix to just remove the whitespace.
>
> > Perhaps a little caveat about whitespace at
>
> >http://www.djangoproject.com/documentation/templates/#filters
>
> > would help reduce confusion?
>
> > -tkc


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



Django Book

2007-03-14 Thread Derek Lee-Wo

Amazon shows that the book on Django will be published on March 26th
which is 1 1/2 weeks away.  Does anyone know if that date is still
valid?

I'm anxiously waiting to order it.

Derek

--~--~-~--~~~---~--~~
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 install on mac osx 10.4.8

2007-03-14 Thread [EMAIL PROTECTED]

Hi everybody,

hope you're all good out there.

I did a few progress with my install.
i installed python 2.4.

with this install instead of the latest one i could install django
with the sudo python setup.py install command.

but now i can't seem to start a project.
when i do the import django line in the terminal i do not have any
error message again
but when i try the

 django-admin.py start-project testsite

i get a syntax error message

  File "", line 1
django-admin.py start-project testsite
^
SyntaxError: invalid syntax

it says on the documentation page that djang should be installed in a
sit-package folder and that the installer should have linked to it.
when i check in my library folder, django is installed inside the bin
folder of the current pythin version.

would it be the reason why it can't connect to the django admin file?

and how can i reset this link?


cheers

On Mar 12, 4:40 pm, "Jay Parlar" <[EMAIL PROTECTED]> wrote:
> On 3/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
> > nope i do it from home, never had any problem before, not like i would
> > really have known anyway got problem all the time :),
> > problem isntalling this and that, problem installing rails and so on.
> > shame i really want to give a try atdjangoreviews looks good, better
> > than rail for a designer like me.
>
> I recommend staying away from DarwinPorts. It sometimes works very
> nicely, other times, not so much.
>
> I would insteadinstallPython2.4 and sqlite2 
> fromhttp://pythonmac.org/packages/py24-fat/index.html
>
> (As you're running Tiger, sqlite itself is already installed, you just
> need the Python wrappers).
>
> Theninstallsubversion 
> fromhttp://www.codingmonkeys.de/mbo/Subversion-1.4.3.pkg.zip
>
> TheninstallDjangovia svn (theinstalldocument says how to do that).
>
> Jay P.


--~--~-~--~~~---~--~~
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: Deployment with Subversion

2007-03-14 Thread Bob T.

Hi Vincent,

Check out http://code.djangoproject.com/wiki/DosAndDontsForApplicationWriters.

Bob


--~--~-~--~~~---~--~~
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: Deployment with Subversion

2007-03-14 Thread Bob T.

This one is a bit more direct: http://code.djangoproject.com/wiki/SplitSettings

Bob


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



Deployment with Subversion

2007-03-14 Thread [EMAIL PROTECTED]

Hello,

how do people deploy Django projects with subversion?  We did a simple
checkout at a client's and when we need to do updates, we copy his
settings.py file somewhere outside the directory, do the svn update,
we copy the settings.py file back in and do a graceful restart of
Apache.

Does anyone have tricks to make this process a bit more efficient and
not catastrophic in case we forget to copy the settings.py file?

Vincent.


--~--~-~--~~~---~--~~
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: Deployment with Subversion

2007-03-14 Thread Bob T.

This one is a bit more direct: http://code.djangoproject.com/wiki/SplitSettings

Bob


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



Newforms - Dynamic Fields from a queryset

2007-03-14 Thread Tipan

I wonder if anyone can give me some pointers. I've been working with
new forms with reasonable results, but I've come across a problem when
creating a form with dynamic fields and rendering to an HTML template.

I want to create a form using data from a queryset which extracts data
for a specific user. Alongside each row, I want to place a checkbox
which the user can tick to indicate their preference.

The output table would look something like this:


 Points Type Points Select
 Points Type 1Points Select
 Points Type 2Points Select

 Points Type nPoints Select

The intention here being that the user can select one or more rows and
use them in further processing.

I've defined the form class as:

class MyForm(forms.Form):
def __init__(self, *args, **kwargs):
super(MyForm, self).__init__(*args, **kwargs)
qs=UserPoints.objects.all()
for i in qs:
self.fields['type_%s' % i.type_id] = forms.CharField()
self.fields['points_%s' % i.points] = forms.CharField()
self.fields['select_%s % i]=forms.BooleanField()

In my view I call the form and return the response to the template.

myuser=request.user
if request.method == "POST":
form=MyForm(request.POST)
if form.is_valid():
etc
else:
form=MyForm()
context = Context({'form':form)
return render_to_response('mytemplate.html', context)

My issue is that I want to be able to filter the form queryset so that
it only shows the specific user's records - can anyone suggest a way
to do this.

I also want to output the various fields on the form in the HTML
template, but I can't work out the correct syntax.

I'm probably doing something daft through lack of experience. However,
any insight gretaly received.


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



Per-app permissions ?

2007-03-14 Thread Chris Brand

What's the best way to restrict access on a per-app basis ?
I want to have two apps, with some users allowed access to one, others
allowed access to the other, and some allowed access to both.

Any advice would be very much appreciated.

Thanks,

Chris



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



Web 2.0 Expo

2007-03-14 Thread David Cramer

Any other Django users going to be in the area? I see there's a Django
talk at the conference by Adrian and there's a lot of other great
stuff going to be there as well.


--~--~-~--~~~---~--~~
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: postgesql commit problem?

2007-03-14 Thread omat * gezgin.com

By the way, when I try to commit using transaction.commit(), I get a
TransactionManagementError saying "This code isn't under transaction
management", which makes sense, as the cursor is not in a transaction
context.




On 14 Mart, 17:36, "omat * gezgin.com" <[EMAIL PROTECTED]> wrote:
> I am trying to run a custom insert sql on postgres db, but the command
> does not seem to commit. I searched through this list and saw that
> there are unresolved discussions 
> like:http://groups.google.com/group/django-users/browse_thread/thread/65ad...
>
> Following the examples in the documentation, I build my code like:
>
> from django.db import connection
> cursor = connection.cursor()
> cursor.execute(insert_query)
>
> but this does not do anything.
>
> Any ideas?
>
> Thanks,
> oMat


--~--~-~--~~~---~--~~
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: Checking whether an app is installed?

2007-03-14 Thread James Bennett

On 3/14/07, Aidas Bendoraitis <[EMAIL PROTECTED]> wrote:
> Is there a function for checking whether an app was installed in the
> current project?

Currently, the list of apps on the default admin index page is
generated by the 'get_admin_app_list' template tag, which just returns
a list of apps. If all you need to do is show some content along with
that app's stuff on the index you can do something like

{% load adminapplist %}
{% get_admin_app_list as app_list %}
{% for app in app_list %}
{% ifequal app.name 'myapp' %}
...do your special stuff here...
{% else %}
...do the normal stuff showing links to add/change model instances...
{% endifequal %}
{% endfor %}

-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~-~--~~~---~--~~
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: newforms dateField

2007-03-14 Thread Joseph Kocherhans

On 3/14/07, Grupo Django <[EMAIL PROTECTED]> wrote:
>
> Hello, I have noticed that the field DateField in the newforms library
> doesn't validate all right when introducing data.
> I have this code:
>
> FormClass = forms.models.form_for_model(Model)
> form = FormClass(data)
> data = request.POST.copy()
> data['author'] = request.user
> formulario = FormClass(data)
>
> if form.is_valid():
>   form.save()
>
> And I get a validation error, meanwhile, when I validate using the
> shell with the following code, it's ok:
> >>> f2 = forms.DateField(input_formats=['%d/%m/%Y'])
> >>> f2.clean('25/10/2006')
> datetime.date(2006, 10, 25)
>
> What's wrong in the first case?

When you use form_for_model, the deafult import_formats argument that
gets used does not include '%d/%m/%Y'. It is expecting '%m/%d/%Y'
among other things.

The most straightforward solution would be to create a custom form
class instead of using form_for_model. There are a couple of other
options, but they're a little tricky if you aren't familiar with
Django's internals. Look at the docsting and code for form_for_model
for clues on the other 2 options and feel free to ask questions if it
doesn't make sense.

Joseph

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



Checking whether an app is installed?

2007-03-14 Thread Aidas Bendoraitis

Hello, Djangoers!

Is there a function for checking whether an app was installed in the
current project?

I have a custom index.html template for contributed administration and
I need to check whether to show some links or not.

Regards,
Aidas Bendoraitis [aka Archatas]

--~--~-~--~~~---~--~~
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: Starting other processes in a view gives me some weird results.

2007-03-14 Thread Ino Pua



On Mar 14, 9:28 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2007-03-13 at 08:10 -0700, Ino Pua wrote:
> > Using just 'ls' or something similar does not trigger the bug. You
> > have to start a daemon from django in order to trigger it. The
> > attached views assume cmd to be a command that takes 'start' as a
> > parameter in order to daemonize it, so for freebsd you might have to
> > customize the "p = subprocess.Popen([cmdname, 'start'],
> > stdout=subprocess.PIPE) " line in order to start your daemon.
>
> I suspect this really a Django problem. It sounds like, despite the
> attempt to daemonize the process, the init script isn't properly
> shutting down or something and so the process that is executing
> mod_python and that particular view hasn't finished yet (it still has a
> child process).

Writing the same service using twisted works just fine, so at the
moment Im using
a really dirty workaround by making an xmlrpc-call to the twisted
server telling it
to execute my command instead. Shutting down/restarting the twisted
server works
without a problem even while starting any amount of services (be it
any in /etc/init.d
or my custom services).

> One way to check this out would be to check out the state
> of /proc//fd and the like (it sounds like you're on a Linux system)
> to see if there are file handles to your subprocess command still open.
> Basically, you need to investigate at the sytsem level and work out why
> the python function does think its work is done yet. There is nothing
> really Django specific going on here that I can see, but deeper
> investigation may prove otherwise.

Judging from /proc/pid/fd everything is as I would assume it was: just
a config file,
a log file and three sockets open (in my case, the program listens on
three ports), And
three references (Im assuming stdin, stdout, stderr) to /dev/null.
Same with any other
daemon I've looked at. Since it works ok from the command line or from
a twisted
service, I can only assume its not where the problem lies.


UPDATE:

Ive tried getting it to work with mod_python, but all kinds of
permission issues and
environment issues came biting me when I did, so Ive decided to stick
with the
xmlrpc-server solution for the time being.


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



postgesql commit problem?

2007-03-14 Thread omat * gezgin.com

I am trying to run a custom insert sql on postgres db, but the command
does not seem to commit. I searched through this list and saw that
there are unresolved discussions like:
http://groups.google.com/group/django-users/browse_thread/thread/65adbdfa9bc92a7b/

Following the examples in the documentation, I build my code like:

from django.db import connection
cursor = connection.cursor()
cursor.execute(insert_query)

but this does not do anything.

Any ideas?


Thanks,
oMat


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



models.ForeignKey problem

2007-03-14 Thread Roland Hedberg

Hi again,

I'm trying to model a software project

So I have the following models (slightly abreviated):

class Project(models.Model):
name = models.CharField(maxlength=80)

class Software(models.Model):
name = models.CharField(maxlength=80)
version = models.CommaSeparatedIntegerField(maxlength=5)
project = models.ForeignKey(Project,blank=True,null=True)
software =
models.ForeignKey("self",blank=True,null=True,related_name="extra")

The thought behind this is that a software project might contain some
basic software and then additional software pieces (e.g. extentions).
So a specific software piece can either be part of the project or be an
extension made by someone else for whatever reason and would therefor
not be counted as part of our project but would definitely be connected
to the base implementation.

Anyway, that's a side issue.

The problem I have with this is that when I try to add a software using
the admin interface, I get the following error:

Exception Type: AttributeError
Exception Value:'bool' object has no attribute 'get'
Exception Location:
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/db/models/related.py
in get_manipulator_fields, line 119

I've verified that the problem is with the software->software connection
(I think) since if I remove that attribute from the class everything
works as planned.

So, what have I missed ?

- Roland

--~--~-~--~~~---~--~~
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: DATE FORMAT ISSUE AGAIN.

2007-03-14 Thread mralokkp

Thanks for that TIM A LOT
But stuck again

AttributeError at /registration/
'FormFieldWrapper' object has no attribute 'month'
Request Method: GET
Request URL: http://127.0.0.1:8000/registration/
Exception Type: AttributeError
Exception Value: 'FormFieldWrapper' object has no attribute 'month'
Exception Location: c:\Python24\Lib\site-packages\django\utils
\dateformat.py in F, line 123





On Mar 14, 7:49 pm, Tim Chase <[EMAIL PROTECTED]> wrote:
> > Case is this
> > XXX | date "F J Y"
>
> > It should read in the format that i choosen but instead of this gives
> > this error
> > TemplateSyntaxError at /mypage/
> > Could not parse the remainder: | date "F J Y"
>
> I've been bitten by this one several times.  I haven't seen any
> notes to the effect, but for some reason, the template parser
> doesn't seem like extra whitespace.  You'll also want to separate
> your "date" from its argument with the colon:
>
> fails:   | date "F J Y"
> works:  |date:"F J Y"
>
> I'll agree that whitespace makes it more readable, and that it
> would be nice if the template engine was a little more forgiving.
>
> But fortunately, it's an easy fix to just remove the whitespace.
>
> Perhaps a little caveat about whitespace at
>
> http://www.djangoproject.com/documentation/templates/#filters
>
> would help reduce confusion?
>
> -tkc


--~--~-~--~~~---~--~~
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: DATE FORMAT ISSUE AGAIN.

2007-03-14 Thread mralokkp

Thanks for the quickest reply
But the problem remains the same
TemplateSyntaxError at /registration/
Could not parse the remainder: | date: "F j Y"
Request Method: GET
Request URL: http://127.0.0.1:8000/registration/
Exception Type: TemplateSyntaxError
Exception Value: Could not parse the remainder: | date: "F j Y"
Exception Location: c:\Python24\Lib\site-packages\django\template
\__init__.py in __init__, line 556


On Mar 14, 7:34 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Just like it told you: Syntax error.
>
> You want
> {{  | date:"F J Y" }}
> You missed the colon.
>
> On Mar 14, 9:21 am, "mralokkp" <[EMAIL PROTECTED]> wrote:
>
> > Hi All
> > Why Django Can't understand the supplied arguments.Why the code is too
> > rigid !
>
> > Case is this
> > XXX | date "F J Y"
>
> > It should read in the format that i choosen but instead of this gives
> > this error
> > TemplateSyntaxError at /mypage/
> > Could not parse the remainder: | date "F J Y"
> > Request Method: GET
> > Request URL:http://127.0.0.1:8000/mypage/
> > Exception Type: TemplateSyntaxError
> > Exception Value: Could not parse the remainder: | date "F J Y"
>
> > Even I followed the from this post itself. But Unable to do. could any
> > body tell what the problem exactly.
>
> > Even I tryed to import the file name dateformat.py from utils
> > but still stuck at the same point.
>
> > Help
> > Regards
> > Alok Tiwari


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



Nested edit_inline?

2007-03-14 Thread Daniel Ellison

Hi all,

Is there a way to have nested inline editing? For example, I have a Poll 
model which can have multiple Questions - which, of course, can have 
multiple Answers. I tried adding edit_inline=models.TABULAR to both the 
Question and Answer models, but of course, it didn't work.

I can edit a question and see all of the answers inline, and I can edit 
a poll and see all of the questions inline. But what I want is to edit a 
poll and see all its questions, each with its associated answers.

Is this possible?

--~--~-~--~~~---~--~~
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: DATE FORMAT ISSUE AGAIN.

2007-03-14 Thread [EMAIL PROTECTED]

Just like it told you: Syntax error.

You want
{{  | date:"F J Y" }}
You missed the colon.


On Mar 14, 9:21 am, "mralokkp" <[EMAIL PROTECTED]> wrote:
> Hi All
> Why Django Can't understand the supplied arguments.Why the code is too
> rigid !
>
> Case is this
> XXX | date "F J Y"
>
> It should read in the format that i choosen but instead of this gives
> this error
> TemplateSyntaxError at /mypage/
> Could not parse the remainder: | date "F J Y"
> Request Method: GET
> Request URL:http://127.0.0.1:8000/mypage/
> Exception Type: TemplateSyntaxError
> Exception Value: Could not parse the remainder: | date "F J Y"
>
> Even I followed the from this post itself. But Unable to do. could any
> body tell what the problem exactly.
>
> Even I tryed to import the file name dateformat.py from utils
> but still stuck at the same point.
>
> Help
> Regards
> Alok Tiwari


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



newforms dateField

2007-03-14 Thread Grupo Django

Hello, I have noticed that the field DateField in the newforms library
doesn't validate all right when introducing data.
I have this code:

FormClass = forms.models.form_for_model(Model)
form = FormClass(data)
data = request.POST.copy()
data['author'] = request.user
formulario = FormClass(data)

if form.is_valid():
  form.save()

And I get a validation error, meanwhile, when I validate using the
shell with the following code, it's ok:
>>> f2 = forms.DateField(input_formats=['%d/%m/%Y'])
>>> f2.clean('25/10/2006')
datetime.date(2006, 10, 25)

What's wrong in the first case?

Thank you.


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



DATE FORMAT ISSUE AGAIN.

2007-03-14 Thread mralokkp

Hi All
Why Django Can't understand the supplied arguments.Why the code is too
rigid !

Case is this
XXX | date "F J Y"

It should read in the format that i choosen but instead of this gives
this error
TemplateSyntaxError at /mypage/
Could not parse the remainder: | date "F J Y"
Request Method: GET
Request URL: http://127.0.0.1:8000/mypage/
Exception Type: TemplateSyntaxError
Exception Value: Could not parse the remainder: | date "F J Y"

Even I followed the from this post itself. But Unable to do. could any
body tell what the problem exactly.

Even I tryed to import the file name dateformat.py from utils
but still stuck at the same point.

Help
Regards
Alok Tiwari


--~--~-~--~~~---~--~~
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: newb: Django & CountingDown

2007-03-14 Thread Tim Chase

> I have an app that is for online test taking. Most online test
> are 30 mins to 2hrs. I need to create count down clock from
> when the test is stared. If 30 mins test, then count down will
> start from 30 mins : 00 Secs, 29 min: 59 secs and so on. How
> do I do this?


In a word:  unreliably.

Common attempts make use of JavaScript and Meta-refresh hacks. 
However, unless you control the browser environment (such as a 
testing lab), these can be readily disabled.  I run FireFox with 
the NoScript and RefreshBlocker plugins, both of which prevent 
unsolicited "push" activity.  Anybody who puts a meta-refresh on 
a page containing form-input should be smacked.  As for scripts, 
nothing prevents a test-taker from using a JS debugger to 
increase the allowed time.

The only way to come close to doing something of the like is to 
track all time on the server side, from the initial page 
delivery.  Once the time on the server surpasses (initial_time + 
time_delta) the server reacts accordingly to submissions.  This 
would be the only Django-related issue for the most part.  In 
this case, clicking on the "begin the test" form button would 
post back to the server, allowing you to create a "test" entry 
containing the current time, and then redirect the resulting page 
to change the POST to GET so that reloads to re-post back the 
test request.

Disadvantages:

* a person can start the test, have a personal issue (such as a 
restroom break, medical issue, or what have you) and step away 
from the computer without realizing that the timer is still 
ticking.  Or network difficulties (dropped aircard connection, 
back-hoe interruptus, ISP difficulties, FAA requirements for 
turning off wireless devices before takeoff, etc)

* if all your questions are on one page, and they submit the 
whole thing a fraction of a second after the time expires, and 
they get no credit for any of their answers

* if you have a page for each question (preventing the previous 
problem) you then have to take into consideration page-load times 
if, for example, the person is on a slow dialup or aircard 
connection.  If your test is 30 minutes and 5 of those are spent 
transferring pages over a slow connection, is the test-taker 
penalized?

One's not precluded from using a combination of the above in 
concert, so you can use the server-side stuff, with client-side 
JS that will update a count-down timer in a  somewhere, or 
to submit the form when time's up.  Just don't rely on 
functionality that may not be there.

Just a few thoughts for your consideration.

-tkc





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



Re: Template Problem

2007-03-14 Thread samira

Thanks a lot. My problem solved.
On Mar 14, 2:09 pm, "ScottB" <[EMAIL PROTECTED]> wrote:
> Hi Samira.
>
> On Mar 11, 11:56 am, "samira" <[EMAIL PROTECTED]> wrote:
>
> > Hi every Body, can any body help me? I want to have two folders for my
> > templates. One it for general template and other for template related
> > to member for example. How I can extend from general folder in
> > member ?
>
> Not sure if this is what you mean, but you can extend files in
> different directories.
>
> e.g.
> {% extends 'base.html' %} -- base.html in same directory
> {% extends 'subdir/base.html' %} -- base.html in a subdirectory
> {% extends '../base.html' %} -- base.html in parent directory
> {% extends '../sibling/base.html' %} -- base.html in another directory
> at the same level
>
> You could also have multiple template directories in your settings.py:
>
> TEMPLATE_DIRS = (
> '/path/to/templates',
> '/path/to/templates/member',
> )
>
> Then when you use extends, I believe Django will look in the different
> template directories to find the base.  You would probably use
> different filenames e.g. base.html and member_base.html.
>
> Scott


--~--~-~--~~~---~--~~
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: Weird session

2007-03-14 Thread Seth Buntin

Well this didn't work:

request.session["order_items"] = request.session["order_items"] +
[order_item.id]

Any other ideas?  Is it how Django is implementing sessions or how
mod_python and Apache have their child processes?

Thanks.

Seth


--~--~-~--~~~---~--~~
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: referncing a model within a model

2007-03-14 Thread DuncanM

It's the traversing the multiple relations in my template I'm having
trouble with, my models are something similar too:

Team(id, name, squad, manager,,)
Fixture(id, team_id, date, opposition, location)
Result(id, fixture_id, home_score, away_score)



In my Team_Details.html template
I'm showing things like

Team Name:  Man Utd
Manager: Alex Fergusson
.

Upcoming Fixtures:
Date: 12/03/07
Location: Home
Opposition: Chelsea

And I want to have (but I Don't know how)
Recent Fixtures:
Date: 09/02/07   (date from Fixture model)
Location: Home
Opposition: West Ham
away_score: 1
home_score: 4



This is my template:

<< Team list
{{ object }}


Squad
{{ object.squad }}
Ground
{{ object.ground }}
Manager
{{ object.manager }}
...
Home Ground
{{ object.ground }}
Sponsor


Fixtures

{% for fixture in object.fixture_set.all %}
{{ fixture }}
{% endfor %}



Results

{% for result in team.result_set.all %}
{{ result }}
{% endfor %}




Results Test
{% for fixture in object.fixture_set.all %}
  {% for result in object.result_set.all %}
  {{ fixture.date}}
  {{ result.howdenscore }}
  {{ result.opponentscore }}
  {{ fixture.opponent }}
  {% endfor %}
{% endfor %}


However neither attempt at showing a result work, any help is much
appreciated.
Duncan

On Mar 14, 11:27 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Wed, 2007-03-14 at 04:20 -0700, DuncanM wrote:
> > Thank you for the pointer Malcom,
> > however you are only using 2 tables/classes (Player which is directly
> > related to Match)
> > The problem I am having is because I am using 3 tables/classes (Team
> > is related to fixture, Fixture is related to Result) so I do not know
> > how to get around that without having to duplicate data in my result
> > table (e.g. repeating the information such as home team, away team,
> > date, venue) etc.  Which I am trying to avoid as much as possible
> > because the data wouldn't be normalised.
>
> Grabbing information from three models is no harder than from two. Just
> create the models exactly as you describe. Probably a couple of foreign
> keys from Fixture to Team (one for each team) and another ForeignKey
> from Fixture to Result (or vice-versa). QuerySets in Django allow you to
> traverse multiple relations in one key. So just try it and see.
>
> If you are still having problems, it will be a lot easier to help you if
> you have attempted to create some models so that we can point to
> specific lines of code. At the moment, it is a bit too up in the air to
> see exactly where you are having problems.
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Weird session

2007-03-14 Thread Seth Buntin

Well this didn't work:

request.session["order_items"] = request.session["order_items"] +
[order_item.id]

Any other ideas?  Is it how Django is implementing sessions or how
mod_python and Apache have their child processes?

Thanks.

Seth


--~--~-~--~~~---~--~~
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 do I make a TextArea box in a form bigger?

2007-03-14 Thread [EMAIL PROTECTED]

Or give it an id or class and just set it in the CSS.

On Mar 14, 1:58 am, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 14-Mar-07, at 12:02 PM, Michael Lake wrote:
>
> > The textarea is about two lines high only. I want the text entry
> > box to be much
> > bigger as it will be holding a full page of text including HTML tags.
>
> widgets.TextArea(attrs={'rows':10,'cols':60}) for example
>
> --
>
> regards
> kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/web/


--~--~-~--~~~---~--~~
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: low performance of FastCGI deployment

2007-03-14 Thread Alexander Boldakov

The web pages served in my django applications are not static media
files, but dynamically generated content (the result of applying XSLT
transformation to the XML data retrieved from XML database). I
consider the architecture of public site with static version of data
and private dynamic site, but the problem of synchronization of the
two systems is not trivial in my case. Though i agree that serving big
dynamic content will fail with increasing the number of users.

P.S. Your writeup is very exciting and interesting!


On 14 мар, 13:46, Ivan Sagalaev <[EMAIL PROTECTED]> wrote:
> Alexander Boldakov wrote:
> > Django deployment documentation claims the need of flup as the FastCGI
> > library. Are there any flup features that Django relies on?
>
> Nothing specific. Flup is recommended because it's pure Python and
> easier to install.
>
> Also documentation *strongly* recommends not to serve media files from
> Django but to use a separate server instead. This is because serving
> media from a framework will always be slower and should be avoided. I
> suspect that even your fix with using more faster FastCGI should still
> fail you when you get more users. The thing is that you will need a
> separate process for each download and Django process tends to take
> about 15-20 MB in memory. Multiply this by user count and you get pretty
> much memory exhausted for just copying bytes into socket.
>
> P.S. I was struggling with similar problem last year and made a 2-part
> writeup that I think you'll be able to read in 
> Russian:http://softwaremaniacs.org/blog/2006/04/18/controlled-download/http://softwaremaniacs.org/blog/2006/04/18/controlled-download-2/


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



newb: Django & CountingDown

2007-03-14 Thread johnny

I have an app that is for online test taking. Most online test are 30
mins to 2hrs. I need to create count down clock from when the test is
stared. If 30 mins test, then count down will start from 30 mins : 00
Secs, 29 min: 59 secs and so on. How do I do this?


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



cool!!!

2007-03-14 Thread aviel571

http://www.fav.co.il/main.php?parent=587=2011 cool!!!


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



cool!!

2007-03-14 Thread aviel571

http://www.fav.co.il/main.php?parent=587=2011 cool!!!


--~--~-~--~~~---~--~~
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: Model question

2007-03-14 Thread Gustav

Thanks guys, I guess I'm in the right path then!

Duncan, it's a good idea but I'm not sure I want to mess with parsing
logs in my main app; I'd prefer to centralize everything on the db.
Thus, I'd rather go the route suggested by Rubic and Carole. I'll try
to implemente it with a "date_now" field on a new table and I'll let
you guys know how it goes.

BTW, I really meant "id" when I wrote "employee_id" and "dpt_id" on
the original post (EMPLOYEE and DEPARTMENT tables).

Best,

Gustav


On Mar 14, 12:44 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> I would create an employee_history table
>
> Then have an employee_id, date_change, old_dept, new_dept.
>
> Or if you wanted to track multiple types of changes...just have
> employee_id, date_change, change description, something like that.
>
> On Mar 13, 7:07 pm, "DuncanM" <[EMAIL PROTECTED]> wrote:
>
> > I'm not sure exactly how you could do this,
> > but for an employee to change department, you will edit it.  This edit
> > is saved in django's admin log (or whatever its called) so maybe you
> > look at something similar to that where it only saves the changes for
> > an employee where the department id has changed?
>
> > Sorry I can't give any more specific examples, I'm too new to django/
> > python for that.
>
> > Duncan
>
> > On Mar 14, 12:01 am, "Gustav" <[EMAIL PROTECTED]> wrote:
>
> > > Hi guys!
>
> > > Sorry for the newbie question here, but I've looked around and
> > > couldn't find the answer... So, here's the problem: say I've got two
> > > models and a database that look like this:
>
> > > EMPLOYEE DEPARTMENT
> > > ==   
> > > employee_id dpt_id
> > > first_namedpt_name
> > > last_name
> > > department_id
>
> > > So, the employee table references the department table many-to-one.
> > > Thus, say an employee changes deparment and I want to keep track
> > > historically of all the changes, how would I design it? I've tried
> > > creating a many-to-many table , but it didn't work. Again, sorry if
> > > it's too basic and I realize that this is more of db design experience
> > > than a django per se, but I'm stuck
>
> > > Thanks and best,
>
> > >Gustav


--~--~-~--~~~---~--~~
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 does django display th/td:hover style incorrectly ?

2007-03-14 Thread Steven Armstrong

Aidas Bendoraitis wrote:
> I'm not sure about IE7, but all the previous versions of IE certainly
> didn't support hover for other html tags than . So it is
> not Django issue at all. 
[...]
 > If you need some browser specific special
> effects, use javascript for IE.
> 
[...]

This might help
http://www.htmldog.com/articles/suckerfish/



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



Jobs Vs Opportunity - The Movie

2007-03-14 Thread mike

Jobs Vs Opportunity - The Movie

www.thewealththeory.com/beyond-freedom

This is excellent!
If you haven't already watched it, check it out now.


--~--~-~--~~~---~--~~
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: referncing a model within a model

2007-03-14 Thread DuncanM

Thank you for the pointer Malcom,
however you are only using 2 tables/classes (Player which is directly
related to Match)
The problem I am having is because I am using 3 tables/classes (Team
is related to fixture, Fixture is related to Result) so I do not know
how to get around that without having to duplicate data in my result
table (e.g. repeating the information such as home team, away team,
date, venue) etc.  Which I am trying to avoid as much as possible
because the data wouldn't be normalised.

Do you know a way of achieving this?

Regards,
Duncan

On Mar 14, 9:10 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Wed, 2007-03-14 at 00:13 +, DuncanM wrote:
> > I have a schema as follows:
> [...]
> > How would I get it so I had a template that showed:
> > Result
> > Team A 0 - 3 Team B 22/03/07
>
> > e.g. the homeTeam and awayTeam are pulled from Fixture, which pulls
> > from Team, and Date is pulled from Fixture (according to the
> > fixture_id) in Result, along with the homeScore and awayScore values
> > of result??
>
> I talked about a somewhat simplified version of this problem in a
> tutorial I gave recently. You may get some help from the slides and/or
> the code athttp://www.pointy-stick.com/lca2007/.
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: referncing a model within a model

2007-03-14 Thread Malcolm Tredinnick

On Wed, 2007-03-14 at 04:20 -0700, DuncanM wrote:
> Thank you for the pointer Malcom,
> however you are only using 2 tables/classes (Player which is directly
> related to Match)
> The problem I am having is because I am using 3 tables/classes (Team
> is related to fixture, Fixture is related to Result) so I do not know
> how to get around that without having to duplicate data in my result
> table (e.g. repeating the information such as home team, away team,
> date, venue) etc.  Which I am trying to avoid as much as possible
> because the data wouldn't be normalised.

Grabbing information from three models is no harder than from two. Just
create the models exactly as you describe. Probably a couple of foreign
keys from Fixture to Team (one for each team) and another ForeignKey
from Fixture to Result (or vice-versa). QuerySets in Django allow you to
traverse multiple relations in one key. So just try it and see.

If you are still having problems, it will be a lot easier to help you if
you have attempted to create some models so that we can point to
specific lines of code. At the moment, it is a bit too up in the air to
see exactly where you are having problems.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: referncing a model within a model

2007-03-14 Thread DuncanM

Thats the problem, I have no idea where to start with it, so do not
have any current code for it, or any errors.

Duncan

On Mar 14, 3:42 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Can you post your current code...and the error you are receiving?
>
> On Mar 13, 7:13 pm, "DuncanM" <[EMAIL PROTECTED]> wrote:
>
> > I have a schema as follows:
>
> > Team
> > Fixture
> > Result
> > =
> > ====
> > id
> > id
> > id
> > name
> > homeTeam fixture_id
> > .
> > awayTeam  homeScore
>
> > date
> > awayScore
>
> > How would I get it so I had a template that showed:
> > Result
> > Team A 0 - 3 Team B 22/03/07
>
> > e.g. the homeTeam and awayTeam are pulled from Fixture, which pulls
> > from Team, and Date is pulled from Fixture (according to the
> > fixture_id) in Result, along with the homeScore and awayScore values
> > of result??
>
> > I have had many many problems with attempting this and have no
> > success.  I am pretty certain my modelling is correct, as anyother way
> > I think off isn't normalised.
>
> > Thanks,
> > Duncan


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



Re: Template Problem

2007-03-14 Thread ScottB

Hi Samira.

On Mar 11, 11:56 am, "samira" <[EMAIL PROTECTED]> wrote:
> Hi every Body, can any body help me? I want to have two folders for my
> templates. One it for general template and other for template related
> to member for example. How I can extend from general folder in
> member ?

Not sure if this is what you mean, but you can extend files in
different directories.

e.g.
{% extends 'base.html' %} -- base.html in same directory
{% extends 'subdir/base.html' %} -- base.html in a subdirectory
{% extends '../base.html' %} -- base.html in parent directory
{% extends '../sibling/base.html' %} -- base.html in another directory
at the same level

You could also have multiple template directories in your settings.py:

TEMPLATE_DIRS = (
'/path/to/templates',
'/path/to/templates/member',
)

Then when you use extends, I believe Django will look in the different
template directories to find the base.  You would probably use
different filenames e.g. base.html and member_base.html.

Scott


--~--~-~--~~~---~--~~
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: Bit torrent class

2007-03-14 Thread ScottB

Hi Hubi.

On Mar 10, 12:07 pm, "Hubi" <[EMAIL PROTECTED]> wrote:
> i'm looking for bit torrent class for Django which can scrape
> information (seed, peer) about the torrent file from trackers.

I'm not sure if there is a Python module/library that does this, but
if not it should be pretty easy to get what you need from one of the
BitTorrent clients.  BitTorrent is mostly written in Python, so you'll
just need to figure out which parts are getting information from the
trackers and use that code in your project.

http://dessent.net/btfaq/#linux
http://wiki.theory.org/BitTorrentTrackerProtocol

Scott


--~--~-~--~~~---~--~~
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: low performance of FastCGI deployment

2007-03-14 Thread Ivan Sagalaev

Alexander Boldakov wrote:
> Django deployment documentation claims the need of flup as the FastCGI
> library. Are there any flup features that Django relies on?

Nothing specific. Flup is recommended because it's pure Python and 
easier to install.

Also documentation *strongly* recommends not to serve media files from 
Django but to use a separate server instead. This is because serving 
media from a framework will always be slower and should be avoided. I 
suspect that even your fix with using more faster FastCGI should still 
fail you when you get more users. The thing is that you will need a 
separate process for each download and Django process tends to take 
about 15-20 MB in memory. Multiply this by user count and you get pretty 
much memory exhausted for just copying bytes into socket.

P.S. I was struggling with similar problem last year and made a 2-part 
writeup that I think you'll be able to read in Russian:
http://softwaremaniacs.org/blog/2006/04/18/controlled-download/
http://softwaremaniacs.org/blog/2006/04/18/controlled-download-2/

--~--~-~--~~~---~--~~
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 does django display th/td:hover style incorrectly ?

2007-03-14 Thread Aidas Bendoraitis

I'm not sure about IE7, but all the previous versions of IE certainly
didn't support hover for other html tags than . So it is
not Django issue at all. If you need some browser specific special
effects, use javascript for IE.

Regards,
Aidas Bendoraitis [aka Archatas]


On 3/14/07, OudS <[EMAIL PROTECTED]> wrote:
>
> thank you for ur reply, Malcolm :)
>
> I define style th/td:hover as a:hover, but a:hover is right, th/
> td:hover is none.
>
> first I define all style in a single css file, but there has not my
> anticipant style effect.
>
>
> then, I write a style block in html file:
>
>
> th:hover {
> background-color: white;
>
>
>
> }
>
>
> It is not correct effect that should display.
>
> at last, I saved current page which is being generated by django as a
> html file on my desktop by ie->file->save as.
>
>
> then I run the html file, all are right.why ?
>
>
>
>
> >
>

--~--~-~--~~~---~--~~
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 does django display th/td:hover style incorrectly ?

2007-03-14 Thread OudS

thank you for ur reply, Malcolm :)

I define style th/td:hover as a:hover, but a:hover is right, th/
td:hover is none.

first I define all style in a single css file, but there has not my
anticipant style effect.


then, I write a style block in html file:


th:hover {
background-color: white;



}


It is not correct effect that should display.

at last, I saved current page which is being generated by django as a
html file on my desktop by ie->file->save as.


then I run the html file, all are right.why ?




--~--~-~--~~~---~--~~
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 does django display th/td:hover style incorrectly ?

2007-03-14 Thread OudS

thank you for ur reply, Malcolm :)

first I write a single css file, but there has not my anticipant
style.

then, I write a style block in html file:

th:hover {
background-color: white;
}

It is not correct effect that should display.

at last, I saved current page which is being generated by django as a
html file on my desktop by ie->file->save as.

then I run the html file, all are right.why ?


--~--~-~--~~~---~--~~
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 does django display th/td:hover style incorrectly ?

2007-03-14 Thread Malcolm Tredinnick

On Wed, 2007-03-14 at 02:56 -0700, OudS wrote:
> why does django display "th/td:hover" style incorrectly ?
> 
> but "a:hover" is no problem...

Please put some effort into supplying enough information that we might
be able to understand what problem you are seeing. In this case it might
be relevant to know:

(a) How you are generating the HTML in question (since you are implying
it's a Django-specific thing, so you need to work out which role Django
is playing in producing the output).

(b) What HTML is being generated.

(c) What you are seeing and what you expect to see.

(d) What browser/OS combination(s) you are using, since display is a
very browser-sensitive issue. Does the problem appear on multiple
browsers?

At a minimum, start trying to work out (and demonstrate) what Django is
rendering, versus what should be rendered. If it's a display bug, it
means the generated HTML is somehow wrong, so find a (short!) fragment
of the HTML that is incorrectly generated so that we can see it.

Thanks,
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



why does django display th/td:hover style incorrectly ?

2007-03-14 Thread OudS

why does django display "th/td:hover" style incorrectly ?

but "a:hover" is no problem...


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



Re: referncing a model within a model

2007-03-14 Thread Malcolm Tredinnick

On Wed, 2007-03-14 at 00:13 +, DuncanM wrote:
> I have a schema as follows:
[...]
> How would I get it so I had a template that showed:
> Result
> Team A 0 - 3 Team B 22/03/07
> 
> 
> e.g. the homeTeam and awayTeam are pulled from Fixture, which pulls
> from Team, and Date is pulled from Fixture (according to the
> fixture_id) in Result, along with the homeScore and awayScore values
> of result??

I talked about a somewhat simplified version of this problem in a
tutorial I gave recently. You may get some help from the slides and/or
the code at http://www.pointy-stick.com/lca2007/ .

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: {% url %} problem

2007-03-14 Thread Malcolm Tredinnick

On Tue, 2007-03-13 at 18:19 +0300, Ivan Sagalaev wrote:
> akonsu wrote:
> > i think the reason is two entries in the urlpatterns with the same
> > view. is this a bug?
> 
> Well, not exactly a bug but a limitation of "reverse" function that {% 
> url %} uses to do actual resolving. Incidentally there is a thread in 
> django-developers[1] about solving a similar issue.

This is different from the problem you are trying to solve on
django-dev. This one is actually a bug: we bail out at the first
attempted match, rather than continuing on if we fail. It's ticket
#3525.

If we have clearly different parameter sets to match, there's no
ambiguity about which one to select.

This will be fixed shortly.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Related foreign fields in admin application

2007-03-14 Thread Atilla
On 14/03/07, Krassimir Grozdanov <[EMAIL PROTECTED]> wrote:
> I am a python and Django novice so please excuse me if my question is
> too stupid.
>
> I have 3 models: Regions, Municipalities  and Persons.
> In the admin interface, when editing the Person object, I want to
> limit the choices for the Municipalities based on the Region choice
> (e.g. I want to limit the list only to Municipalities that are in the
> chosen region). Please advice me which is the best way to do that.
>
> Here follow my models:
>
> class Region(models.Model):
> region = models.CharField(maxlength=128)
>
> def __str__(self):
> return self.region
> class Meta:
> verbose_name = 'Област'
> verbose_name_plural = 'Области'
> class Admin:
> pass
>
> class Municipality(models.Model):
> region = models.ForeignKey(Region)
> municipality = models.CharField(maxlength=128)
>
> def __str__(self):
> return self.municipality
> class Meta:
> verbose_name = 'Община'
> verbose_name_plural = 'Общини'
> class Admin:
> pass
>
> class Person(models.Model):
> PERSON_TYPES = (
> ('Да', 'Юридическо лице'),
> ('Не', 'Физическо лице')
> )
> region = models.ForeignKey(Region, null = True)
> municipality = models.ForeignKey(Municipality, null = True)
> name = models.CharField(maxlength=384)
> type = models.CharField("Юридическо лице", maxlength=8, choices =
> PERSON_TYPES, default = 'Да', radio_admin = True)
> dnomer = models.CharField(maxlength=16, blank = True)
> bulstat = models.CharField('БУЛСТАТ', maxlength=16, blank = True)
> egn = models.CharField('ЕГН', maxlength=10, blank = True)
> city = models.CharField(maxlength=64)
> postcode_p = models.CharField(maxlength=16, blank = True)
> address_p = models.CharField(maxlength=128, blank = True)
> phone_p = models.CharField(maxlength=64, blank = True)
>
> def __str__(self):
> return self.name
> class Meta:
> verbose_name = 'Юридическо лице'
> verbose_name_plural = 'Юридически лица'
> class Admin:
> pass

I am afraid that currently, there isn't a out-of-the-box
implementation of that type of filters in the admin panel. It's more
of a true interface for administrators, rather than a proper content
management insterface.

You'll probably have to extend some control and modify the necessary
view from the admin panel, if you want it to go there. If you're using
the newforms admin - it might be easier to write that there.

--~--~-~--~~~---~--~~
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: Integrating web services with django

2007-03-14 Thread Malcolm Tredinnick

On Tue, 2007-03-13 at 13:36 +, Nathan Harmston wrote:
> Hi, 
>  
> I was wondering if anyone had added a web services client to django.
> Ie when a user makes a request,

"Web service" is an extremely generic term, so you aren't really asking
a specific question here.

>  it is processed by django and then a web service is invoked and the
> results send back. Has anyone developed any frameworks or apps which
> do this?

Nothing special is really required. You can do whatever you want inside
a view function and there is a view for every single URL the application
can handle. So you would only need to write a view that does whatever
processing you want to.

It's difficult to be more specific than that because, as I said "web
services" can mean anything. For each particular case, the design work
comes down to working out which URLs correspond to which views.

There are some pages in the wiki giving examples of how people have
thought about hooking up xml-rpc calls through Django. Implementing REST
URL schemes is almost trivial (at the URL mapping level), since it's
just pattern matching and view dispatching. All the hard work lies in
writing the view function to do the real heavy lifting and that varies
on a case-by-case basis.

>  How can I deal with invocations/jobs which take a long time i.e
> several hours, and still enable the user to come back later and view
> the result of the job from the web service. Would I have to create
> some kind of job manager within my models to allow this and spawn a
> thread to deal with the web service stuff. 

This has been discussed in a lot of other threads on this list (search
for "long running processes" might be one place to look). Basically,
anything that prevents the view from returning as fast as possible is a
bad idea, because the client is waiting. So if it really is going to
take a long time, the view should just shove the request in a queue and
some other (external) process will come along and run items from the
queue periodically.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: year archive

2007-03-14 Thread Malcolm Tredinnick

On Tue, 2007-03-13 at 13:30 +, Michel Thadeu Sabchuk wrote:
> Hi guys!
> 
> I want to use generic views to show all events on a year. I made use
> of year_archive view to accomplish my task. I want to show up the
> events on the year page categorized by its month, there won't be a
> month page, but the object_list gives the events uncategorized.
> 
> I think on a filter, maybe "regroup" is what I'm looking for, but I
> don't realize how to use it with date fields. Does someone know how
> can I make this happen? Can the year_archive view hit my needs or
> should I write a custom view?

Have a look at the "ifchanged" template tag (it's a standard one in
Django). This allows you to control the displaying of a line based on
whether some value has changed since the last time you checked it.

In my blog software, for example, I have a section that says

{% ifchanged %}
{{ entry.creation|date:"D, j M Y" 
}}
{% endifchanged %}

inside the loop that displays the articles on a page.

This will only display the day and date header if it has changed from
the previous article (the previous time around the loop).

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using different template for different instances of an object.

2007-03-14 Thread Malcolm Tredinnick

On Tue, 2007-03-13 at 12:52 +0100, Alessandro Ronchi wrote:
> I need to make 2 or 3 different templates to be used to show an object. In 
> the 
> admin I would like to have a check list to choice wich template I will use to 
> show it.
> 
> It's possible?

Have a field in your model that allows you to select which template to
use as the "default display", so you store it with the model.

Note that you won't be able to use standard generic views to do the
displaying in this case, since the generic views requires the template
to be used to be passed in as part of the function call. However, you
could easily write a short wrapper around the generic view that extracts
the template name from the object and then calls the real generic view
with the right parameters. Or just not use generic views at all (I'm
only guessing that you are using them in the first place; maybe you
aren't).


--~--~-~--~~~---~--~~
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 Signal multiple machine safe?

2007-03-14 Thread Malcolm Tredinnick

On Tue, 2007-03-13 at 04:53 +, Alex Dong wrote:
> Hi all,
> I'm using post_save signal to send a "Your Account is Created" type of
> email.  Since I have four machines, two django front end server
> pointing to two MySQL cluster, I'm wondering is the post_save signal
> multiple machine safe?
> 
> That is, if my signal is processed, is it possible that the "instance"
> it receives is invalid because the model object was updated on another
> machine?   Or, maybe django has already handled this so that as long
> as the two front end django application server shares the same
> database, it should be fine?

Short answer: "yes".

Longer answer: The signal module is a purely intra-process software
implementation of signals -- it operates entirely using Python function
calls. So the effects will not even be visible outside of the process
that calls signal.dispatch, let alone the machine.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Starting other processes in a view gives me some weird results.

2007-03-14 Thread Malcolm Tredinnick

On Tue, 2007-03-13 at 08:10 -0700, Ino Pua wrote:
> Using just 'ls' or something similar does not trigger the bug. You
> have to start a daemon from django in order to trigger it. The
> attached views assume cmd to be a command that takes 'start' as a
> parameter in order to daemonize it, so for freebsd you might have to
> customize the "p = subprocess.Popen([cmdname, 'start'],
> stdout=subprocess.PIPE) " line in order to start your daemon.

I suspect this really a Django problem. It sounds like, despite the
attempt to daemonize the process, the init script isn't properly
shutting down or something and so the process that is executing
mod_python and that particular view hasn't finished yet (it still has a
child process).

One way to check this out would be to check out the state
of /proc//fd and the like (it sounds like you're on a Linux system)
to see if there are file handles to your subprocess command still open.
Basically, you need to investigate at the sytsem level and work out why
the python function does think its work is done yet. There is nothing
really Django specific going on here that I can see, but deeper
investigation may prove otherwise.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Allowing no value for a DateField

2007-03-14 Thread Malcolm Tredinnick

On Tue, 2007-03-13 at 08:48 +0100, Roland Hedberg wrote:
> Malcolm Tredinnick wrote:
> > On Mon, 2007-03-12 at 12:14 +0100, Roland Hedberg wrote:
> >> Hi!
> >>
> >> I have designed a model which contains among other things a couple of
> >> DateFields.
> >>
> >> Some, actually one, of these must have a value but the other may not.
> >>
> >> So, I tried to use the construct:
> >>
> >> done_planned = models.DateField(blank=True)
> >>
> >> But that doesn't work, because I get a exception with the error:
> >>
> >> "act_activity.done_planned may not be NULL"
> > 
> > You will also need null=True on that field, so that the database can
> > store a NULL (no value) in that column. Note that if you just add
> > null=True to your model, it will not change the database. You will also
> > need to either change the database column by hand or recreate the
> > database table.
> 
> Both you and [EMAIL PROTECTED] talks about recreating the
> database. For me who know close to nothing about SQL and sqlite3 (which
> is what I'm using in this case) it would be interesting if you could
> expand on this or, equally good, point me to something that I can read
> myself.

Look up the "ALTER TABLE" statement in your favourite SQLite reference.
That is the command for changing the types of columns, adding
constraints (which is what you want to do here, by adding "NOT NULL" to
the column), or adding or removing columns from the table.

> I guess this must be a reoccurring topic when you are modeling a new
> site since you never get it right the first time around.

Quite often when you're initially developing models, you don't have any
valuable data in your database, so you can quite happily use the
"sqlreset", "sql" and related commands to manage.py to drop and recreate
the database tables. Once you have data that you don't want to lose, or
are migrating an existing production version to new models, you use
"manage.py sql ..." to dump what the SQL should look like, work out the
changes from your existing tables and then use things like "ALTER
TABLE..." to bring the database into line.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Related foreign fields in admin application

2007-03-14 Thread Krassimir Grozdanov
I am a python and Django novice so please excuse me if my question is
too stupid.

I have 3 models: Regions, Municipalities  and Persons.
In the admin interface, when editing the Person object, I want to
limit the choices for the Municipalities based on the Region choice
(e.g. I want to limit the list only to Municipalities that are in the
chosen region). Please advice me which is the best way to do that.

Here follow my models:

class Region(models.Model):
region = models.CharField(maxlength=128)

def __str__(self):
return self.region
class Meta:
verbose_name = 'Област'
verbose_name_plural = 'Области'
class Admin:
pass

class Municipality(models.Model):
region = models.ForeignKey(Region)
municipality = models.CharField(maxlength=128)

def __str__(self):
return self.municipality
class Meta:
verbose_name = 'Община'
verbose_name_plural = 'Общини'
class Admin:
pass

class Person(models.Model):
PERSON_TYPES = (
('Да', 'Юридическо лице'),
('Не', 'Физическо лице')
)
region = models.ForeignKey(Region, null = True)
municipality = models.ForeignKey(Municipality, null = True)
name = models.CharField(maxlength=384)
type = models.CharField("Юридическо лице", maxlength=8, choices =
PERSON_TYPES, default = 'Да', radio_admin = True)
dnomer = models.CharField(maxlength=16, blank = True)
bulstat = models.CharField('БУЛСТАТ', maxlength=16, blank = True)
egn = models.CharField('ЕГН', maxlength=10, blank = True)
city = models.CharField(maxlength=64)
postcode_p = models.CharField(maxlength=16, blank = True)
address_p = models.CharField(maxlength=128, blank = True)
phone_p = models.CharField(maxlength=64, blank = True)

def __str__(self):
return self.name
class Meta:
verbose_name = 'Юридическо лице'
verbose_name_plural = 'Юридически лица'
class Admin:
pass

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



Sort by output of arbitrary method

2007-03-14 Thread Mark Engelberg

According to the tutorial:
"You can click on the column headers to sort by those values -- except
in the case of the was_published_today header, because sorting by the
output of an arbitrary method is not supported. "

Well, I understand that it would not be as efficient to sort on an
attribute that isn't a field of the database, but is there an easy way
to make the admin do this anyway?

Barring that, since most databases support min max and average, is
there a way to sort on those aspects of a field?

Thanks,

Mark

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



  1   2   >