Re: Mutually exclusive fields in model validation

2009-09-15 Thread Daniel Roseman

On Sep 15, 11:19 pm, Sonal Breed  wrote:
> Thanks a lot Cliff, I implemented it in a similar manner, just wanted
> to know if we
> have anything like validation rules a la Access.
>
> Thanks again,
> Sincerely,
> Sonal.

Not yet. Honza Kral's Google Summer of Code project for model
validation is due to be merged reasonably soon though, so this will be
in version 1.2 - or in trunk at some earlier point if you don't want
to wait that long.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Separate a project into 2 - both need to access the same models

2009-09-15 Thread Daniel Roseman

On Sep 16, 6:45 am, Merrick  wrote:
> I have a project that I am thinking of breaking up into 2 sites/
> projects. The goal is to be able to make changes to one site/project
> without affecting the other one. Here is an example of what each would
> do:
>
> mydomain.com
> -
> - displays the brochure website (sales copy on the homepage, about,
> privacy etc...) (Page Model)
> - tracks visitors as they move around from one Page to another (Access
> Model)
>
> dashboard.mydomain.com
> 
> - users can login
> - user can click on a Page and see how many times it was Accessed
> (Page and Access model)
>
> So I am operating under the assumption that I will have a total of 2
> settings files, one for each site/project. I am guessing that I need
> to define the models Page and Access model on each project. Is this
> correct? Is there an optimal way of splitting things up to keep up
> time up, but avoiding repeating model definitions?
>
> Thanks.

'Project' is a bit of an artificial concept. The only thing a Django
site really needs is a settings.py. So you can have two of these, with
separate Apache vhosts or whatever, but with both referring to the
same models files - as long as those models are on the Python path.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: views help with category_list for a blgo

2009-09-15 Thread Daniel Roseman

On Sep 16, 4:35 am, ChrisR  wrote:
> I appreciate the help you gave DR, however, I am still a bit lost.
> Any more suggestions or guidance with custom tags?
>
> I've been looking at the custom tags documentation...

Well, currently you're relying on the extra_context parameter to your
generic views to pass in the category list. However, as you've noted,
this doesn't work for pages like search which aren't generated by
generic views.

So take the category_list stuff out of urls.py completely. Instead,
use an inclusion tag. This could be as simple as:

@register.inclusion_tag('_category_list.html')
def category_list():
return {'category_list':Category.objects.all()}

Now, take the template code that displays the list out of your base
template, and put it into a new file called _category_list.html. Back
in the base template, put:
 {% load mytemplatetags %}{% category_list %}

(replace 'mytemplatetags' with whatever you've called the template tag
file you created). All done.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Separate a project into 2 - both need to access the same models

2009-09-15 Thread Merrick

I have a project that I am thinking of breaking up into 2 sites/
projects. The goal is to be able to make changes to one site/project
without affecting the other one. Here is an example of what each would
do:

mydomain.com
-
- displays the brochure website (sales copy on the homepage, about,
privacy etc...) (Page Model)
- tracks visitors as they move around from one Page to another (Access
Model)

dashboard.mydomain.com

- users can login
- user can click on a Page and see how many times it was Accessed
(Page and Access model)

So I am operating under the assumption that I will have a total of 2
settings files, one for each site/project. I am guessing that I need
to define the models Page and Access model on each project. Is this
correct? Is there an optimal way of splitting things up to keep up
time up, but avoiding repeating model definitions?

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



Re: How to get cms like features in Django

2009-09-15 Thread Tiago Serafim
If it's simple enough, check FlatPages. Comes bundled with django, so you
have it running within minutes.

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



How to get cms like features in Django

2009-09-15 Thread ristretto.rb

Hello All,

I have pages like home, contact us, about us, that are on nearly every
webapp that I create.  The other parts of the webapps are specific to
some business requirement, but the *us type pages are not.  Unlike the
application pages proper, this supporting pages need to be updated
occasionally when the system is Live, and by non-programmers.

I could use a CMS, and then have links to my app on the pages.  But, I
don't want to run a full blown CMS and Python/Django.  And getting the
templates working in both seem like extra work.

I have searched a bit, and haven't found support for this.  So I
thought I would roll my own (see below.)  Does anyone else have this
need?  How do you solve it?

class CMSPage
page_data = 
page = 

urls.py
   (r'^about/$', 'about'),

views.py
   def about(request):
 page = CMSPages.objects.get(page='about')

 return render_to_response('cms_page.html', {'page':page},
context_instance=RequestContext(request) )


cms_page.html
:
{{page.page_data}}


Then I can let the user edit the CMSPage via the admin.  And, perhaps
I could even get TinyMCE or DOJO Editor going for them them.

I just want to check there isn't support for this sort of thing,
before I run of doing something custom.

thanks
Gene


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



Formwizard dropdown lists

2009-09-15 Thread dingue fever

Hi,

I have modelform that I use in a formwizard and I populate a few of
the dropdown selects by accessing the database and creating a list for
the choice. However when I add an item to a table via the admin site
and then goto my formwizard page the new item does not show up in the
list until I recycle the server (djangos or apache).

I know that the database is being hit when the form is accessed
because I print the list to the log file when the form is called and
the new item is listed. The new item is also listed in standard
modelform, not using the formwizard.

Has anyone seen this type of thing before.

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



Re: views help with category_list for a blgo

2009-09-15 Thread ChrisR

I appreciate the help you gave DR, however, I am still a bit lost.
Any more suggestions or guidance with custom tags?

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



Re: F() expression order of operations

2009-09-15 Thread Stefan Petrea

What are F() expressions and where are they documented ? (just didn't
hear the term until now)

About your win_percentage column , wouldn't you rather have it as a
method which is being
calculated from the columns wins and losses instead of a column stored
inside the table ?

On Sep 15, 8:36 pm, Brent Hagany  wrote:
> I'm having some trouble getting F() expressions to obey my parentheses
> when I don't want the default order of operations.  For example, given
> the model:
>
> class MyModel(models.Model):
>     wins = models.DecimalField(max_digits=1, decimal_places=0)
>     losses = models.DecimalField(max_digits=1, decimal_places=0)
>     win_percentage = models.DecimalField(max_digits=4,
> decimal_places=3, default=Decimal('0.000'))
>
> I get the following results when trying to calculate the
> win_percentage:
>
> In [1]: MyModel.objects.create(wins=2, losses=4)
> Out[1]: 
>
> In [2]: MyModel.objects.all().update(win_percentage=F('wins') / (F
> ('wins') + F('losses')))
> Out[2]: 1
>
> # I expect this to return Decimal("0.333")
> In [3]: MyModel.objects.get(pk=1).win_percentage
> Out[3]: Decimal("5.000")
>
> It appears to be ignoring the parentheses around F('wins') + F
> ('losses'), and so instead of 2 / (2 + 4) = .333, I'm getting 2 / 2 +
> 4 = 5.  Am I doing this wrong, or is this by design, or is it a bug?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



F() expression order of operations

2009-09-15 Thread Brent Hagany

I'm having some trouble getting F() expressions to obey my parentheses
when I don't want the default order of operations.  For example, given
the model:

class MyModel(models.Model):
wins = models.DecimalField(max_digits=1, decimal_places=0)
losses = models.DecimalField(max_digits=1, decimal_places=0)
win_percentage = models.DecimalField(max_digits=4,
decimal_places=3, default=Decimal('0.000'))

I get the following results when trying to calculate the
win_percentage:

In [1]: MyModel.objects.create(wins=2, losses=4)
Out[1]: 

In [2]: MyModel.objects.all().update(win_percentage=F('wins') / (F
('wins') + F('losses')))
Out[2]: 1

# I expect this to return Decimal("0.333")
In [3]: MyModel.objects.get(pk=1).win_percentage
Out[3]: Decimal("5.000")

It appears to be ignoring the parentheses around F('wins') + F
('losses'), and so instead of 2 / (2 + 4) = .333, I'm getting 2 / 2 +
4 = 5.  Am I doing this wrong, or is this by design, or is it a bug?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Getting fields in a user profile

2009-09-15 Thread PlanetUnknown

Thanks Tiago 
You are Correct, that worked !

I now notice that the exception says "Queryset", and was reading
"http://docs.djangoproject.com/en/dev/ref/models/querysets/"; When I
saw you reply.
I'm new to python, but I should've noticed that.
Thanks again.

Also, just in case someone this helps someone -
>>> g1 = GenericUserProfile.objects.get(user=c1)
>>> g1

>>> g1.create_dt
datetime.datetime(2009, 9, 15, 17, 41, 24)
>>> g1.farms.add(f1)





On Sep 15, 7:27 pm, Tiago Serafim  wrote:
> Notice that the return is within []. Which means that it has returned a
> list.
>
> Try this:
>
> >>> g1[0].get_modify_dt
>
> On Tue, Sep 15, 2009 at 8:23 PM, PlanetUnknown 
> wrote:
>
>
>
>
>
> > I could get the user profile object like below, but when I try to view
> > any of its properties I just get "has no attribute xxx" -
> > I can see that the genericUserProfile has data in it.
>
> > # Continued from earlier entries in django python shell
> > >>> g1 = GenericUserProfile.objects.filter(user=c1)
> > >>> g1
> > []
> > >>> g1.modify_dt
> > Traceback (most recent call last):
> >  File "", line 1, in 
> > AttributeError: 'QuerySet' object has no attribute 'modify_dt'
>
> --
> Tiago Serafim
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Authentication with two or more sites under mod_python

2009-09-15 Thread Graham Dumpleton

Are you bothering to set SESSION_COOKIE_NAME or SESSION_COOKIE_PATH
differently for each site instance so they don't try and use the same
values?

Graham

On Sep 16, 3:40 am, Lester  wrote:
> Hello - I have a fedora 11, django 1.02, Apache 2.2, mod_python set
> up.  I am using the standard Django modules and authentication system.
>
> I am running two django sites on the same server - my main site and a
> 'beta'.
>
> For some reason I can authenticate onto my main site fine, however
> when I try to log onto the beta site I get redirected to the main
> site, and am not logged in.  However I do not get any python errors.
> I also have no problems if I switch the sites over (they are
> essentially identical) or run the beta site from the command line.
>
> Is there something I could have in mod_python/apache set up that could
> be interfering with my authentication?  My python.conf is shown below:
>
> LoadModule python_module modules/mod_python.so
>
> 
>     SetHandler python-program
>     PythonHandler myvirtualdjango
>     SetEnv DJANGO_SETTINGS_MODULE technology.settings
>     SetEnv PYTHON_EGG_CACHE /var/www/django/technology/egg_temp
>     PythonDebug Off
>     PythonInterpreter portal
>     PythonPath "['/var/www/django/'] + sys.path"
>     #PythonOption django.root "/portal"
> 
>
> 
>     SetHandler python-program
>     PythonHandler myvirtualdjango
>     SetEnv DJANGO_SETTINGS_MODULE technology.settings
>     SetEnv PYTHON_EGG_CACHE /var/www/django-dev/technology/egg_temp
>     PythonInterpreter beta
>     PythonDebug On
>     PythonPath "['/var/www/django-dev/'] + sys.path"
>     PythonOption django.root /beta
> 
>
> 
>     SetHandler None
> 
>
> Does anyone have two or more authentic'able django apps running under
> mod_python on the same server, so I at least know that the problem is
> buried in my code somewhere?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Getting fields in a user profile

2009-09-15 Thread Tiago Serafim
Notice that the return is within []. Which means that it has returned a
list.

Try this:

>>> g1[0].get_modify_dt

On Tue, Sep 15, 2009 at 8:23 PM, PlanetUnknown wrote:

>
> I could get the user profile object like below, but when I try to view
> any of its properties I just get "has no attribute xxx" -
> I can see that the genericUserProfile has data in it.
>
> # Continued from earlier entries in django python shell
> >>> g1 = GenericUserProfile.objects.filter(user=c1)
> >>> g1
> []
> >>> g1.modify_dt
> Traceback (most recent call last):
>  File "", line 1, in 
> AttributeError: 'QuerySet' object has no attribute 'modify_dt'
>
>
>


-- 
Tiago Serafim

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



Re: Getting fields in a user profile

2009-09-15 Thread Tiago Serafim
Hi,

filter returns a list, with zero or more elements. To fix what you showed,
you should call "get" instead of "filter". "get" either return a object or
throws an Exception. Check the docs for more info.

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



Re: Getting fields in a user profile

2009-09-15 Thread PlanetUnknown

I could get the user profile object like below, but when I try to view
any of its properties I just get "has no attribute xxx" -
I can see that the genericUserProfile has data in it.

# Continued from earlier entries in django python shell
>>> g1 = GenericUserProfile.objects.filter(user=c1)
>>> g1
[]
>>> g1.modify_dt
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'QuerySet' object has no attribute 'modify_dt'




On Sep 15, 6:49 pm, PlanetUnknown  wrote:
> Hello All,
>         I recently extended my User, with a User profile called
> GenericUserProfile, and it has a many-to-many field called farms (code
> below). Now all I want to do was add a "farm" to this farms field in
> the GenericUserProfile.
>
> But when I try doing that using the django python shell I get error -
> "AttributeError: 'QuerySet' object has no attribute 'get_profile'".
>
>        I'd really appreciate if someone could point out what I'm doing
> incorrectly and what is the correct approach. The documentation says
> that get_profile() is created when the profile is present and I
> checked the database and it shows an entry in "genericuserprofile"
> table corresponding to the "user" who is registered.
>
> Code -
>
> # The User profile which extends fields for User
> class GenericUserProfile(models.Model):
>     user = models.ForeignKey(User)
>     #other fields here
>     farms = models.ManyToManyField(Farm)
>     confirmation_code = models.CharField(max_length=200, unique=True)
>     is_active = models.BooleanField()
>     create_dt = models.DateTimeField(auto_now_add=True)
>     modify_dt = models.DateTimeField(auto_now_add=True)
>
>     def __str__(self):
>         return "%s's profile" % self.user
>
>     def create_user_profile(sender, instance, created, **kwargs):
>         if created:
>             profile,created = GenericUserProfile.objects.get_or_create
> (user=instance)
>
>     post_save.connect(create_user_profile, sender=User)
>
> # The Farm model, A user can have many farms, and farms can have many
> owners, hence many-to-many
> class Farm(models.Model):
>     farm_id = models.AutoField(primary_key=True)
>     is_owner = models.BooleanField()
>
>  I try this in the django python shell, I want to add the farm to
> the "farms" field in GenericUserProfile. Hence trying to get the
> profile first.>>> f1 = Farm(farm_id=None, is_owner=True)
> >>> f1.save()
> >>> c1 = User.objects.filter(email__iexact="x...@xyz.com")
> >>> c1.get_profile
>
> Traceback (most recent call last):
>   File "", line 1, in 
> AttributeError: 'QuerySet' object has no attribute 'get_profile'
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Getting fields in a user profile

2009-09-15 Thread PlanetUnknown

Hello All,
I recently extended my User, with a User profile called
GenericUserProfile, and it has a many-to-many field called farms (code
below). Now all I want to do was add a "farm" to this farms field in
the GenericUserProfile.

But when I try doing that using the django python shell I get error -
"AttributeError: 'QuerySet' object has no attribute 'get_profile'".

   I'd really appreciate if someone could point out what I'm doing
incorrectly and what is the correct approach. The documentation says
that get_profile() is created when the profile is present and I
checked the database and it shows an entry in "genericuserprofile"
table corresponding to the "user" who is registered.

Code -

# The User profile which extends fields for User
class GenericUserProfile(models.Model):
user = models.ForeignKey(User)
#other fields here
farms = models.ManyToManyField(Farm)
confirmation_code = models.CharField(max_length=200, unique=True)
is_active = models.BooleanField()
create_dt = models.DateTimeField(auto_now_add=True)
modify_dt = models.DateTimeField(auto_now_add=True)

def __str__(self):
return "%s's profile" % self.user

def create_user_profile(sender, instance, created, **kwargs):
if created:
profile,created = GenericUserProfile.objects.get_or_create
(user=instance)

post_save.connect(create_user_profile, sender=User)


# The Farm model, A user can have many farms, and farms can have many
owners, hence many-to-many
class Farm(models.Model):
farm_id = models.AutoField(primary_key=True)
is_owner = models.BooleanField()

 I try this in the django python shell, I want to add the farm to
the "farms" field in GenericUserProfile. Hence trying to get the
profile first.
>>> f1 = Farm(farm_id=None, is_owner=True)
>>> f1.save()
>>> c1 = User.objects.filter(email__iexact="x...@xyz.com")
>>> c1.get_profile
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'QuerySet' object has no attribute 'get_profile'
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: HELP ME

2009-09-15 Thread alivad

hi,

my validation is:

if the user chooses as the type of visa 'BUSINESS', then this
obligation to enter the name of the company,

rethinking my question

as I do to see if the user has selected the type of visa 'BUSINESS'?

THANKs

On 15 sep, 16:44, Masklinn  wrote:
> On 15 sept. 2009, at 23:13, alivad  wrote:> Hi DR
>
> > The following code does not work:
>
> > if tipo_de_visa and tipo_de_visa == 'NEGOCIO':
>
> > Thanks
>
> You still haven't explained how it doesn't work: what did you expect  
> to happen, what was observed to happen, the steps you (unsuccessfully)  
> took to understand and solve the issue, …
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Mutually exclusive fields in model validation

2009-09-15 Thread Sonal Breed

Thanks a lot Cliff, I implemented it in a similar manner, just wanted
to know if we
have anything like validation rules a la Access.

Thanks again,
Sincerely,
Sonal.

On Sep 15, 3:08 pm, "J. Cliff Dyer"  wrote:
> Override the save method on your model, something like:
>
> class MyModel(models.Model):
>     field1 = models.TextField(blank=True)
>     field2 = models.TextField(blank=True)
>
>     def save(self):
>         if (self.field1 and self.field2):
>             raise ModelValidationError, "only one can live"
>         elif (not self.field1 and not self.field2):
>             raise ModelValidationError, "one must live"
>         else:
>             super(MyModel, self).save()
>
> Untested code.  I don't remember if ModelValidationError exists, and I
> don't know if you need to tweak the signature on your save method, but
> that should get you pointed in the right direction.
>
> Cheers,
> Cliff
>
> On Tue, 2009-09-15 at 14:33 -0700, Sonal Breed wrote:
> > Hi all,
>
> > I have a model wherein I want to put a validation as
> > You must enter Field1 or Field2, but not both.
>
> > This model is at the back end and not visible through forms.
> > How do I accomplish it?
>
> > Thanks,
>
> > Sincerely,
> > Sonal
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Test tables not all created

2009-09-15 Thread peppergrower

By "normal database" I meant the one that gets used normally by
Django, e.g., while running the development server (manage.py
runserver)--in contrast to the test database.

Thanks for the pointer.  I checked my INSTALLED_APPS, and somehow I'd
missed a module.  I'm not sure how that happened, since the
appropriate tables did exist in my normal database, and I don't have
any idea why I would have removed the appropriate line after I already
had it set up properly.

Adding back in the missing module, the test worked as expected (and
all necessary tables are created).  Thanks for the help!


On Sep 15, 9:52 am, Karen Tracey  wrote:
> I don't know what you mean by "normal database".  The test runner
> essentially does a syncdb on the test database -- thus, it will create all
> the tables for all the models for all the apps listed in INSTALLED_APPS.  If
> you are seeing behavior different from this we'll need more specifics about
> what exactly you are doing and what tables, specifically, are missing in
> order to help figure out what is going on.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Mutually exclusive fields in model validation

2009-09-15 Thread J. Cliff Dyer

Override the save method on your model, something like:

class MyModel(models.Model):
field1 = models.TextField(blank=True)
field2 = models.TextField(blank=True)

def save(self):
if (self.field1 and self.field2):
raise ModelValidationError, "only one can live"
elif (not self.field1 and not self.field2):
raise ModelValidationError, "one must live"
else:
super(MyModel, self).save()

Untested code.  I don't remember if ModelValidationError exists, and I
don't know if you need to tweak the signature on your save method, but
that should get you pointed in the right direction.

Cheers,
Cliff


On Tue, 2009-09-15 at 14:33 -0700, Sonal Breed wrote:
> Hi all,
> 
> I have a model wherein I want to put a validation as
> You must enter Field1 or Field2, but not both.
> 
> This model is at the back end and not visible through forms.
> How do I accomplish it?
> 
> Thanks,
> 
> Sincerely,
> Sonal
> > 


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



Re: HELP ME

2009-09-15 Thread Masklinn

On 15 sept. 2009, at 23:13, alivad  wrote:
> Hi DR
>
> The following code does not work:
>
> if tipo_de_visa and tipo_de_visa == 'NEGOCIO':
>
> Thanks
>
You still haven't explained how it doesn't work: what did you expect  
to happen, what was observed to happen, the steps you (unsuccessfully)  
took to understand and solve the issue, … 
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: HELP ME

2009-09-15 Thread alivad

Hi DR

The following code does not work:

if tipo_de_visa and tipo_de_visa == 'NEGOCIO':

Thanks

On 15 sep, 16:03, Daniel Roseman  wrote:
> On Sep 15, 9:48 pm, alivad  wrote:
>
>
>
> > hi all:
>
> > I have the following code:
>
> >     .
> >     formamig = forms.ModelChoiceField(label = "Tipo de visa",
> > queryset=Formamig.objects.all())
> >     empresa = forms.CharField(max_length=60, required=False)
>
> >     def clean(self):
> >         cleaned_data = self.cleaned_data
> >         tipo_de_visa = cleaned_data.get("formamig")
> >         empresa = cleaned_data.get("empresa")
>
> >         #if tipo_de_visa and "NEGOCIO" in tipo_de_visa:
> >         if tipo_de_visa and tipo_de_visa == 'NEGOCIO':
> >             #raise forms.ValidationError("Debe ingresar el nombre de
> > la empresa.")
> >             msg = u"Debe ingresar el nombre de la empresa."
> >             self._errors["tipo_de_visa"] = ErrorList([msg])
> >             self._errors["empresa"] = ErrorList([msg])
>
> >             # These fields are no longer valid. Remove them from the
> >             # cleaned data.
> >             del cleaned_data["tipo_de_visa"]
> >             del cleaned_data["empresa"]
>
> >         return cleaned_data
>
> > with the above code I am trying to validate if the user selects
> > business then you must place the name of the company.
>
> > It does not work, someone can help me.
>
> > Thanks
>
> What does not work? What happens?
> --
> DR.

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



Mutually exclusive fields in model validation

2009-09-15 Thread Sonal Breed

Hi all,

I have a model wherein I want to put a validation as
You must enter Field1 or Field2, but not both.

This model is at the back end and not visible through forms.
How do I accomplish it?

Thanks,

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



Re: HELP ME

2009-09-15 Thread alivad

Hi,

The following code does not work:


tipo_de_visa = cleaned_data.get("formamig")
.
if tipo_de_visa and tipo_de_visa == 'NEGOCIO':


thanks.





On 15 sep, 16:03, Daniel Roseman  wrote:
> On Sep 15, 9:48 pm, alivad  wrote:
>
>
>
> > hi all:
>
> > I have the following code:
>
> >     .
> >     formamig = forms.ModelChoiceField(label = "Tipo de visa",
> > queryset=Formamig.objects.all())
> >     empresa = forms.CharField(max_length=60, required=False)
>
> >     def clean(self):
> >         cleaned_data = self.cleaned_data
> >         tipo_de_visa = cleaned_data.get("formamig")
> >         empresa = cleaned_data.get("empresa")
>
> >         #if tipo_de_visa and "NEGOCIO" in tipo_de_visa:
> >         if tipo_de_visa and tipo_de_visa == 'NEGOCIO':
> >             #raise forms.ValidationError("Debe ingresar el nombre de
> > la empresa.")
> >             msg = u"Debe ingresar el nombre de la empresa."
> >             self._errors["tipo_de_visa"] = ErrorList([msg])
> >             self._errors["empresa"] = ErrorList([msg])
>
> >             # These fields are no longer valid. Remove them from the
> >             # cleaned data.
> >             del cleaned_data["tipo_de_visa"]
> >             del cleaned_data["empresa"]
>
> >         return cleaned_data
>
> > with the above code I am trying to validate if the user selects
> > business then you must place the name of the company.
>
> > It does not work, someone can help me.
>
> > Thanks
>
> What does not work? What happens?
> --
> DR.

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



Re: Query with left join?

2009-09-15 Thread Daniel Roseman

On Sep 15, 6:22 am, tom  wrote:
> Hi Daniel,
>
> i don't want to presentate the data. i want to produce graphs with
> this data. so it's not a presentation problem. i know that i can use
> python to get the data in correct order and style, but it's a huge
> amount of data and python would be very slow for that. so it's better
> when the database does the work.

Fair enough. I suspect this is one of those times when you've gone
beyond what the ORM can do for you, and you need to drop back to SQL.
Luckily this is easy to do:

from django.db import connection
cursor = connection.cursor()
cursor.execute("""SELECT S.value, D.value from data as S left join
data as D on
S.entry_id=D.entry_id;""")
for row in cursor.fetchall():
   # do something with row

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



Re: HELP ME

2009-09-15 Thread Daniel Roseman

On Sep 15, 9:48 pm, alivad  wrote:
> hi all:
>
> I have the following code:
>
>     .
>     formamig = forms.ModelChoiceField(label = "Tipo de visa",
> queryset=Formamig.objects.all())
>     empresa = forms.CharField(max_length=60, required=False)
>
>     def clean(self):
>         cleaned_data = self.cleaned_data
>         tipo_de_visa = cleaned_data.get("formamig")
>         empresa = cleaned_data.get("empresa")
>
>         #if tipo_de_visa and "NEGOCIO" in tipo_de_visa:
>         if tipo_de_visa and tipo_de_visa == 'NEGOCIO':
>             #raise forms.ValidationError("Debe ingresar el nombre de
> la empresa.")
>             msg = u"Debe ingresar el nombre de la empresa."
>             self._errors["tipo_de_visa"] = ErrorList([msg])
>             self._errors["empresa"] = ErrorList([msg])
>
>             # These fields are no longer valid. Remove them from the
>             # cleaned data.
>             del cleaned_data["tipo_de_visa"]
>             del cleaned_data["empresa"]
>
>         return cleaned_data
>
> with the above code I am trying to validate if the user selects
> business then you must place the name of the company.
>
> It does not work, someone can help me.
>
> Thanks

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



Re: How to organize django projects on a productive server?

2009-09-15 Thread Daniel Roseman

On Sep 15, 9:08 pm, orschiro  wrote:
> Hello Daniel,
>
> so the projects could be as well on the users home path?
>
> It makes more sense for me to put them on the home path than anywhere
> else.

As long as the web server process has the relevant permissions for
those files, yes.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: path depth problem

2009-09-15 Thread Tiago Serafim
Hi,

The right way(TM) to do this is using named urls:

http://docs.djangoproject.com/en/dev/topics/http/urls/#named-groups

Then you can use reverse to get the right url, avoiding duplications and
problems like the one you have now:

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

HTH,


On Tue, Sep 15, 2009 at 4:42 PM, dijxtra  wrote:

>
> Hello everybody,
>
> Django keeps surprising me with neat solutions for common web
> programming problems (I must say I haven't felt this "where has it
> been all of my life" since the time I was exploring lisp), so I hope
> django has a trick up his sleeve for this one too.
>
> So, I made a calendar "widget" (view snippet:
> http://pastebin.com/m765f778c,
> template snippet: http://pastebin.com/m16dcf115) and I have a problem
> with relative links in it. If I include this code in page with URL url/
> prefix//mm/dd (which represents one day), then my links point to
> right places, but if I'm in url/prefix//mm (which represents the
> whole month) then links point to the wrong place because they are
> relative links, and they were made to work with //mm/dd, not //
> mm.
>
> I tried to fix it with my {{calendar_data.path}} variable, but that's
> one ugly solution. I suppose this is a common problem... so, I suppose
> there is a common solution?
>
> BTW, if you give me constructive advice about my coding style, you get
> bonus points for heaven and I love you till the end of my life. :-D
>
> Thanks in advance,
> nick
>
> >
>


-- 
Tiago Serafim

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



Re: psycopyg setup error: no build_ext

2009-09-15 Thread nausikaa


Dear Matt

I hope you see this message even though it's probably too late.
To fix the permission denied error change setup.cfg as follows:


pg_config=/opt/local/lib/postgresql84/bin/


needs to be changed to


pg_config=/opt/local/lib/postgresql84/bin/pg_config


Then run sudo python setup.py build again and it'll just work fine.
Hope you didn't fiddle around with sqlplus or anything.


Gloria




On Aug 3, 12:21 am, Vasil Vangelovski  wrote:
>  From that bash interaction I can assume you are running os x.
>
> The absolutely easiest way to install postgresql and psycopg2 on os x is
> with postgresplus.
> These links may help if you decide to go down that path:
>
> http://www.enterprisedb.com/products/postgres_plus/overview.dohttp://blog.jonypawks.net/2008/06/20/installing-psycopg2-on-os-x/Matt
>  Hampel wrote:
> > Setting the pg_config path got me to the next stage of errors, which
> > is a step forward. Thanks!
>
> > Now I get a permission denied error without any more information or
> > context.
> > Any suggestions?
>
> > What I tried:
>
> > matth:psycopg2-2.0.11 matth$ python setup.py build
> > running build
> > running build_py
> > running build_ext
> > error: Permission denied
> > matth:psycopg2-2.0.11 matth$ sudo python setup.py build
> > Password:
> > running build
> > running build_py
> > running build_ext
> > error: Permission denied
>
> > On Jul 19, 12:20 am, walty  wrote:
>
> >> thx, it solves my problem (psycopg2-2.0.11 on OSX) right away :)
>
> >> just drop a few more words:
> >> if installed the postgresql 8.4 using mac binary, the line of
> >> configuration (inside setup.cfg) should be:
> >> pg_config=/Library/PostgreSQL/8.4/bin/pg_config
>
> >> On Jul 7, 6:17 am, Justin Johnson  wrote:
>
> >>> I corrected the build_ext error and successfully built/installed by
> >>> adding the full path to pg_config in setup.cfg.
>
> >>> On Jun 23, 10:19 am, Chris Haynes  wrote:
>
>  Using what I believe is the latest version of psycopyg, I get:
>
>  509 ~/Desktop/psycopg2-2.0.9$ python setup.py build
>  running build
>  running build_py
>  creating build
>  creating build/lib.macosx-10.3-fat-2.6
>  creating build/lib.macosx-10.3-fat-2.6/psycopg2
>  copying lib/__init__.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
>  copying lib/errorcodes.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
>  copying lib/extensions.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
>  copying lib/extras.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
>  copying lib/pool.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
>  copying lib/psycopg1.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
>  copying lib/tz.py -> build/lib.macosx-10.3-fat-2.6/psycopg2
>  runningbuild_ext
>  error: No such file or directory
>
>  and easy_install doesn't work either (seems like the same problem):
>
>  510 ~/Desktop/psycopg2-2.0.9$ easy_install .
>  Processing .
>  Running setup.py -q bdist_egg --dist-dir /Users/home/Desktop/
>  psycopg2-2.0.9/egg-dist-tmp-mYsMSq
>  error: Setup script exited with error: No such file or directory
>
>

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



Re: psycopyg setup error: no build_ext

2009-09-15 Thread nausikaa


Dear Matt

I assume you used mac ports to install postgresql-devel.
Now the reason for the permission denied error is that
you didn't specify the file in setup.cfg. To make it run change the
line

pg_config=/opt/local/lib/postgresql84/bin/


to

pg_config=/opt/local/lib/postgresql84/bin/pg_config

in setup.cfg.


If this does not sort out the problem try

sudo port install postgresql84

Then all should work just fine. postgresql-devel is outdated.

Hope this helps,

Nausikaa



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



path depth problem

2009-09-15 Thread dijxtra

Hello everybody,

Django keeps surprising me with neat solutions for common web
programming problems (I must say I haven't felt this "where has it
been all of my life" since the time I was exploring lisp), so I hope
django has a trick up his sleeve for this one too.

So, I made a calendar "widget" (view snippet: http://pastebin.com/m765f778c,
template snippet: http://pastebin.com/m16dcf115) and I have a problem
with relative links in it. If I include this code in page with URL url/
prefix//mm/dd (which represents one day), then my links point to
right places, but if I'm in url/prefix//mm (which represents the
whole month) then links point to the wrong place because they are
relative links, and they were made to work with //mm/dd, not //
mm.

I tried to fix it with my {{calendar_data.path}} variable, but that's
one ugly solution. I suppose this is a common problem... so, I suppose
there is a common solution?

BTW, if you give me constructive advice about my coding style, you get
bonus points for heaven and I love you till the end of my life. :-D

Thanks in advance,
nick

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



HELP ME

2009-09-15 Thread alivad

hi all:

I have the following code:


.
formamig = forms.ModelChoiceField(label = "Tipo de visa",
queryset=Formamig.objects.all())
empresa = forms.CharField(max_length=60, required=False)

def clean(self):
cleaned_data = self.cleaned_data
tipo_de_visa = cleaned_data.get("formamig")
empresa = cleaned_data.get("empresa")

#if tipo_de_visa and "NEGOCIO" in tipo_de_visa:
if tipo_de_visa and tipo_de_visa == 'NEGOCIO':
#raise forms.ValidationError("Debe ingresar el nombre de
la empresa.")
msg = u"Debe ingresar el nombre de la empresa."
self._errors["tipo_de_visa"] = ErrorList([msg])
self._errors["empresa"] = ErrorList([msg])

# These fields are no longer valid. Remove them from the
# cleaned data.
del cleaned_data["tipo_de_visa"]
del cleaned_data["empresa"]

return cleaned_data


with the above code I am trying to validate if the user selects
business then you must place the name of the company.

It does not work, someone can help me.

Thanks

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



Re: Running Django on Tornado's HTTP server

2009-09-15 Thread Brian

Thanks ... this link pointed me in the right direction.

Should I be able to serve up admin media using just Django and
Tornado?  If so, I haven't found the right combination of paths / urls
etc. in settings.py to get that working. The Tornado doc describes how
to "serve static files from Tornado by specifying the static_path
setting in your application" - so it sounds like it might eventually
work? The Tornado blog demo is one example, but I couldn't get that
approach working with my Django app.

I now have nginx serving up the Admin files, running alongside Tornado
and Django. My Admin Site formatting and layout looks fine with that
setup.

-- Brian

On Sep 15, 6:26 am, fruits  wrote:
> media files for admin is handled by the django dev server. So when you
> change the server, you have to serve admin media file yourself.
>
> http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#id3
>
> On Sep 15, 9:42 am, Brian  wrote:
>
>
>
> > I have a small Django app under development and was able to get this
> > running using the github update. My app runs and is very responsive
> > with Tornado.
>
> > Some of my admin site layout is out of whack, but it may be my
> > settings or my bug.  Formatting and CSS I created on my own looks good
> > (e.g. graphics and tables created using the Google Visualization API.)
> > My app is able to go out onto the web, get files downloaded through
> > Tornado - it feels fast ...
>
> > It's terrific to have a Python-based server that could work in both
> > development and production. (Tornado installs/runs fine on a Netbook
> > with Ubuntu!)
>
> > The real-time / asynchronous capabilities look great. Any way Django
> > apps can take advantage of that functionality?
>
> > Thanks for open sourcing this!
>
> > -- Brian
>
> > On Sep 13, 4:26 pm, Bret Taylor  wrote:
>
> > > I am one of the authors of Tornado (http://www.tornadoweb.org/), the
> > > web server/framework we built at FriendFeed that we open sourced last
> > > week (seehttp://bret.appspot.com/entry/tornado-web-server).
>
> > > The underlying non-blocking HTTP server is fairly high performance, so
> > > I have been working this weekend to get other frameworks like Django
> > > and web.py working on Tornado's server so existing projects could
> > > potentially benefit from the performance. To that end, I just checked
> > > in change to Tornado that enables you to run any WSGI-compatible
> > > framework on Tornado's HTTP server. You can find it in a class called
> > > WSGIContainer in our wsgi.py:
>
> > >http://github.com/facebook/tornado/blob/master/tornado/wsgi.py#L188
>
> > > You will have to check out Tornado from github to get the change; it
> > > is not yet included in the tarball distribution.
>
> > > Here is a template for running a Django app on Tornado's server using
> > > the module:
>
> > >     import django.core.handlers.wsgi
> > >     import os
> > >     import tornado.httpserver
> > >     import tornado.ioloop
> > >     import tornado.wsgi
>
> > >     def main():
> > >         os.environ["DJANGO_SETTINGS_MODULE"] = 'myapp.settings'
> > >         application = django.core.handlers.wsgi.WSGIHandler()
> > >         container = tornado.wsgi.WSGIContainer(application)
> > >         http_server = tornado.httpserver.HTTPServer(container)
> > >         http_server.listen()
> > >         tornado.ioloop.IOLoop.instance().start()
>
> > >     if __name__ == "__main__":
> > >         main()
>
> > > I have only done very basic tests using the new module, so if any of
> > > you are interested and start using Tornado with your Django projects,
> > > please let us know what bugs you find so we can fix them. Any and all
> > > feedback is appreciated.
>
> > > Bret
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: views help with category_list for a blgo

2009-09-15 Thread ChrisR

Thanks DR.

I do have the list on the base right now, but I don't think I have it
correctly assigned as a custom tag.  I didn't think of that, I'll
check into it.  Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to organize django projects on a productive server?

2009-09-15 Thread orschiro

Hello Andrew,

thanks for that detailed reply. :)

So the key for development and deployment is a VCS such as SVN or Git?

In short: Your developers are pushing the changes up to the branches
on the stating server where a release is going to be created. Then it
is going to be transfered to the production server. right?

One thing I still concern about. How do you manage the production
database when a application change is going to be made?

For example you changed some models. To apply that changes on the
development server you might just reset the database or alter it
manually - it's indeed only for testing purposes - but what's with a
"real" database with tons of important data?

On 15 Sep., 21:49, Andrew McGregor  wrote:
> You've asked a lot!  I'll start with this question:
>
> > And final, are you developing on your local machine with the
> > development server or immedeatly at the server via ssh?
>
> Loads of different ways, but I do this:
>
> * Production server - dedicated Debian host
>
> * Staging server - hosted Debian VM
>
> * Development boxes - each developer has one or more VMWare Debian instances
>
> > If yes, how do you deploy your project and about what points do you
> > have to concern while doing that?
>
> As a rule of thumb you only commit code changes from dev boxes to
> branches, or a tagged release if necessary. Staging should only svn
> up, and production has it's own release script.
>
> When tested these can be merged to trunk.
>
> Trunk can be released to staging for UAT.
>
> If UAT OK then press the button for the release script to send it to 
> production.
>
> This release to live can get complicated to mitigate all issues.  You
> need a way to get the latest codebase live whilst minimising downtime.
>  You could svn co to a new dir on the same filesystem, then `mv $CUR
> $OLD && mv $NEW $CUR` should be atomic, but the svn co could take time
> on large systems and eat bandwidth.  If you are using SVN you may be
> interested in file permissions. More thank likely you have schema
> changes in which case you may accept that downtime is given then you
> will need some sort of maintenance mode.
>
> Of course, extra browny points for a wrapper around svn/git/whatever
> so that on attempting a commit unit tests are run and a bunch of other
> sanity checks.  If OK then the commit works.
>
> Spend a fiver on Agile Python Development.
>
> http://www.amazon.co.uk/gp/offer-listing/1590599810/ref=dp_olp_used?i...
>
> --
> Andrew McGregor
> 07940 22 33 11
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to organize django projects on a productive server?

2009-09-15 Thread orschiro

Hello Daniel,

so the projects could be as well on the users home path?

It makes more sense for me to put them on the home path than anywhere
else.

On 15 Sep., 21:59, Daniel Roseman  wrote:
> On Sep 15, 8:49 pm, orschiro  wrote:
>
> > Hello Léon Dignòn,
>
> > you told that your projects lie beneath /var/www..
>
> > So the reason for that is that you might use Apache?
>
> > As I remember (I'm using nginx instead of Apache) this is the default
> > directory.
>
> It's a very bad idea to put your Django code under /var/www. That's
> the default root for Apache, so your code files might end up being
> served out to users - allowing them to see implementation details and
> even database passwords.
>
> Django and your project code don't need to live under the Apache root,
> it should just be somewhere on the Python path.
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: views help with category_list for a blgo

2009-09-15 Thread Daniel Roseman

On Sep 15, 5:56 pm, ChrisR  wrote:
> Hello,
>
> I am building a blog/cms for my site.  I am using django's date_based
> urls as well as object_detail for the individual posts.
>
> On my base, I have a for loop for categories in the blog.  I don't
> like the way I have made the category_list work, and feel that it is
> not the best way to do it.  I would like some help with that if
> someone is willing to make suggestions.
>
> The category list appears on all pages within my blog, but when I do a
> search in the blog, the list disappears.
>
> Here are my views:
>
> from django.shortcuts import render_to_response, get_object_or_404
> from django.db.models import Q
> from blog.models import Category, Entry
>
> def category(request, slug):
>         category_list = Category.objects.all()
>         category = get_object_or_404(Category, slug=slug)
>         entry_list = Entry.objects.filter(category=category)
>         return render_to_response("blog/entry_list.html", locals())
>
> def search(request):
>         if 'q' in request.GET:
>                 term = request.GET['q']
>                 entry_list = Entry.objects.filter(Q(title__contains=term) | Q
> (html_content__contains=term))
>                 heading = "Search results"
>         return render_to_response("blog/entry_list.html", locals())
>
> Here are my urls:
>
> from django.conf.urls.defaults import *
> from blog.models import Entry, Category
>
> info_dict = {
>         'queryset' : Entry.objects.all(),
>         'date_field': 'created',
>         'template_object_name': 'entry',
>         "extra_context" : {"category_list" : Category.objects.all()}
>
> }
>
> urlpatterns = patterns('django.views.generic.date_based',
>         url(r'^(?P\d{4})/(?P\d{1,2})/(?P\w{1,2})/(?P[-
> \w]+)/$', 'object_detail', dict(info_dict, month_format='%m',
> slug_field='slug')),
>         url(r'^(?P\d{4})/(?P\d{1,2})/(?P\w{1,2})/$',
> 'archive_day', dict(info_dict, month_format='%m')),
>         url(r'^(?P\d{4})/(?P\d{1,2})/$', 'archive_month', dict
> (info_dict, month_format='%m')),
>         url(r'^(?P\d{4})/$', 'archive_year', info_dict),
>         url(r'^$', 'archive_index', info_dict),
> )
>
> urlpatterns += patterns('blog.views',
>         url(r'^category/(?P[-\w]+)/$', 'category', name="blog-
> category"),
>         url(r'^search/$', 'search', name="blog-search"),
> )
>
> If I need to provide more information let me know.  Thanks in advance!
>
> Chris

Things like category lists on every page are exactly what custom
template tags are for. You could include your tag on every template,
or even better on the base template that other templates inherit from,
and it will then definitely appear on every page.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to organize django projects on a productive server?

2009-09-15 Thread Léon Dignòn

The reason is that I use Debian and /var/www is just Debian's default
folder (and herewith apache's). You can basically put your code
wherever you like. But you shouldn't put your code beneath apache's
document root (document_root is a setting in the apache.conf). My
docroots are configured individually at in the virtual host config: /
var/www/site1,site2,…. So /var/www/django is save!

On Sep 15, 9:49 pm, orschiro  wrote:
> Hello Léon Dignòn,
>
> you told that your projects lie beneath /var/www..
>
> So the reason for that is that you might use Apache?
>
> As I remember (I'm using nginx instead of Apache) this is the default
> directory.
>
> On 15 Sep., 21:35, Léon Dignòn  wrote:
>
>
>
> > On Sep 15, 9:28 pm, orschiro  wrote:
>
> > > Hello guys,
>
> > > first, I know it is not that important how to do this but as I'm
> > > pretty knew and callow I'd like to know how some experienced users do
> > > that.
>
> > > At the moment I have just a normal user account besides my root that
> > > stores all my django projects. Also my django trunk lives in there.
>
> > > Another point what interests me. Are you using a central directory for
> > > static files and templates etc. that are available for all your
> > > projects or does every project have its own directories in there?
>
> > My Django projects lie beneath /var/www/django/
> > Templates and media files are in /var/www/django/myproject/
> > templates,media (the comma means that there are two separate folders)
>
> > Before that I had a folder called /var/www/django/templates,media/
> > myproject
> > But because I moved them often I changed to a centralized project
> > folder like now/above.
>
> > > And final, are you developing on your local machine with the
> > > development server or immedeatly at the server via ssh?
>
> > As soon as your website is published you should use a dev server to
> > test your new code. So problems are not published to your visitors.
>
> > > If yes, how do you deploy your project and about what points do you
> > > have to concern while doing that?
>
> > > Anyway, is there any good documentation how good deployment on a
> > > server might look like?
>
> > Yes, look at the deployment docs on the django documentation website.
>
> > > I know, a bunch of questions but answers would be very helpful for
> > > me.
>
> > > Thank you guys. :)- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: passing parameters to formset

2009-09-15 Thread Daniel Roseman

On Sep 15, 6:22 pm, Michael Stevens  wrote:
> Hi.
>
> I'm creating a formset of forms using formset_factory.
>
> It's all working nicely, but I'd like to pass some values into the
> forms to use as the choices for one of the fields.
>
> Is there a way to do this? As far as I can tell the formset_factory
> takes over the creation of the form and I can't see a way to pass my
> own data in.
>
> Michael

You can use the form parameter to formset_factory to pass in a
customised Form subclass that includes your overwritten __init__
method.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to organize django projects on a productive server?

2009-09-15 Thread Daniel Roseman

On Sep 15, 8:49 pm, orschiro  wrote:
> Hello Léon Dignòn,
>
> you told that your projects lie beneath /var/www..
>
> So the reason for that is that you might use Apache?
>
> As I remember (I'm using nginx instead of Apache) this is the default
> directory.
>

It's a very bad idea to put your Django code under /var/www. That's
the default root for Apache, so your code files might end up being
served out to users - allowing them to see implementation details and
even database passwords.

Django and your project code don't need to live under the Apache root,
it should just be somewhere on the Python path.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to organize django projects on a productive server?

2009-09-15 Thread orschiro

Hello Léon Dignòn,

you told that your projects lie beneath /var/www..

So the reason for that is that you might use Apache?

As I remember (I'm using nginx instead of Apache) this is the default
directory.

On 15 Sep., 21:35, Léon Dignòn  wrote:
> On Sep 15, 9:28 pm, orschiro  wrote:
>
> > Hello guys,
>
> > first, I know it is not that important how to do this but as I'm
> > pretty knew and callow I'd like to know how some experienced users do
> > that.
>
> > At the moment I have just a normal user account besides my root that
> > stores all my django projects. Also my django trunk lives in there.
>
> > Another point what interests me. Are you using a central directory for
> > static files and templates etc. that are available for all your
> > projects or does every project have its own directories in there?
>
> My Django projects lie beneath /var/www/django/
> Templates and media files are in /var/www/django/myproject/
> templates,media (the comma means that there are two separate folders)
>
> Before that I had a folder called /var/www/django/templates,media/
> myproject
> But because I moved them often I changed to a centralized project
> folder like now/above.
>
> > And final, are you developing on your local machine with the
> > development server or immedeatly at the server via ssh?
>
> As soon as your website is published you should use a dev server to
> test your new code. So problems are not published to your visitors.
>
> > If yes, how do you deploy your project and about what points do you
> > have to concern while doing that?
>
> > Anyway, is there any good documentation how good deployment on a
> > server might look like?
>
> Yes, look at the deployment docs on the django documentation website.
>
> > I know, a bunch of questions but answers would be very helpful for
> > me.
>
> > Thank you guys. :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to organize django projects on a productive server?

2009-09-15 Thread Andrew McGregor

You've asked a lot!  I'll start with this question:

> And final, are you developing on your local machine with the
> development server or immedeatly at the server via ssh?

Loads of different ways, but I do this:

* Production server - dedicated Debian host

* Staging server - hosted Debian VM

* Development boxes - each developer has one or more VMWare Debian instances

> If yes, how do you deploy your project and about what points do you
> have to concern while doing that?

As a rule of thumb you only commit code changes from dev boxes to
branches, or a tagged release if necessary. Staging should only svn
up, and production has it's own release script.

When tested these can be merged to trunk.

Trunk can be released to staging for UAT.

If UAT OK then press the button for the release script to send it to production.

This release to live can get complicated to mitigate all issues.  You
need a way to get the latest codebase live whilst minimising downtime.
 You could svn co to a new dir on the same filesystem, then `mv $CUR
$OLD && mv $NEW $CUR` should be atomic, but the svn co could take time
on large systems and eat bandwidth.  If you are using SVN you may be
interested in file permissions. More thank likely you have schema
changes in which case you may accept that downtime is given then you
will need some sort of maintenance mode.

Of course, extra browny points for a wrapper around svn/git/whatever
so that on attempting a commit unit tests are run and a bunch of other
sanity checks.  If OK then the commit works.

Spend a fiver on Agile Python Development.

http://www.amazon.co.uk/gp/offer-listing/1590599810/ref=dp_olp_used?ie=UTF8&qid=1253043898&sr=8-1&condition=used


-- 
Andrew McGregor
07940 22 33 11

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



Re: How to organize django projects on a productive server?

2009-09-15 Thread Léon Dignòn



On Sep 15, 9:28 pm, orschiro  wrote:
> Hello guys,
>
> first, I know it is not that important how to do this but as I'm
> pretty knew and callow I'd like to know how some experienced users do
> that.
>
> At the moment I have just a normal user account besides my root that
> stores all my django projects. Also my django trunk lives in there.
>
> Another point what interests me. Are you using a central directory for
> static files and templates etc. that are available for all your
> projects or does every project have its own directories in there?

My Django projects lie beneath /var/www/django/
Templates and media files are in /var/www/django/myproject/
templates,media (the comma means that there are two separate folders)

Before that I had a folder called /var/www/django/templates,media/
myproject
But because I moved them often I changed to a centralized project
folder like now/above.

> And final, are you developing on your local machine with the
> development server or immedeatly at the server via ssh?

As soon as your website is published you should use a dev server to
test your new code. So problems are not published to your visitors.

> If yes, how do you deploy your project and about what points do you
> have to concern while doing that?
>
> Anyway, is there any good documentation how good deployment on a
> server might look like?

Yes, look at the deployment docs on the django documentation website.

> I know, a bunch of questions but answers would be very helpful for
> me.
>
> Thank you guys. :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to organize django projects on a productive server?

2009-09-15 Thread orschiro

Hello guys,

first, I know it is not that important how to do this but as I'm
pretty knew and callow I'd like to know how some experienced users do
that.

At the moment I have just a normal user account besides my root that
stores all my django projects. Also my django trunk lives in there.

Another point what interests me. Are you using a central directory for
static files and templates etc. that are available for all your
projects or does every project have its own directories in there?

And final, are you developing on your local machine with the
development server or immedeatly at the server via ssh?

If yes, how do you deploy your project and about what points do you
have to concern while doing that?

Anyway, is there any good documentation how good deployment on a
server might look like?

I know, a bunch of questions but answers would be very helpful for
me.

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



makemessages error/problem on Vista

2009-09-15 Thread Léon Dignòn

C:\Users\Leon\Documents\Django\myproject>manage.py makemessages
Error: This script should be run from the Django SVN tree or your
project or app tree. If you did indeed run it from the SVN checkout or
your project or application, maybe you are just missing the conf/
locale (in the django tree) or locale (for project and application)
directory? It is not created automatically, you have to create it by
hand if you want to enable i18n for your project or application.

C:\Users\Leon\Documents\Django\myproject\myapp>manage.py makemessages
Same as above …

C:\Users\Leon\Documents\Django\myproject>path
PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:
\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;c:\Program
Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Program Files
(x86)\ATI\ATI.ACE\Core-Static;C:\Program Files (x86)\Python;C:\Program
Files (x86)\Python\Scripts;C:\Users\Leon\Documents\Django;

I read the documentation. Maybe I did not understand it, but I don't
know what to do.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: checking for empty result in queryset

2009-09-15 Thread Carlos Leite

Just use ...
if data:


if data is empty, its not True for python...



On Tue, Sep 15, 2009 at 2:48 PM, Gonzillaaa  wrote:
>
> in the following query:
> data = Model.objects.filter(node_id=id)
>
> how do I check if data is empty before rendering or being redirected
> to a 404?
>
> G.
>
>
> >
>



-- 
Carlos Leite

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



Re: Displaying data in the admin edit form

2009-09-15 Thread justind

Marco,

See this portion of the docs: 
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-admin-templates
You can override change_form.html template and display what you need
there.


On Sep 10, 3:05 am, Marco  wrote:
> Hello,
>
> I saw in Django's tutorial that it was possible to display some data
> coming from a method of your model (for example
> 'was_published_today'). You just have to use list_display and call
> your method.
>
> But what if I want to display this in the edit form? Is there a way to
> do that?
>
> Thanks,
> Marc.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Can't get development server to run

2009-09-15 Thread ChrisR

What OS are you using?  Django may not be on your PYTHONPATH.

If you cd into your project's root directory (the one with
settings.py), type 'python' at the command line to start the python
shell.  Then try 'import django'.  You're probably going to see an
error saying it can't find that module.

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



Can't get development server to run

2009-09-15 Thread GloWyrm

I am following the tutorial, and I was able to create the mysite
directory, but I can't get the development server to work. When I run
"python manage.py runserver" from mysite I get this error...

Traceback :
  File "manage.py", line 2, in ?
from django.core.management import execute_manager
ImportError: No module named django.core.management

Thanks in advance

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



Authentication with two or more sites under mod_python

2009-09-15 Thread Lester

Hello - I have a fedora 11, django 1.02, Apache 2.2, mod_python set
up.  I am using the standard Django modules and authentication system.

I am running two django sites on the same server - my main site and a
'beta'.

For some reason I can authenticate onto my main site fine, however
when I try to log onto the beta site I get redirected to the main
site, and am not logged in.  However I do not get any python errors.
I also have no problems if I switch the sites over (they are
essentially identical) or run the beta site from the command line.

Is there something I could have in mod_python/apache set up that could
be interfering with my authentication?  My python.conf is shown below:

LoadModule python_module modules/mod_python.so


SetHandler python-program
PythonHandler myvirtualdjango
SetEnv DJANGO_SETTINGS_MODULE technology.settings
SetEnv PYTHON_EGG_CACHE /var/www/django/technology/egg_temp
PythonDebug Off
PythonInterpreter portal
PythonPath "['/var/www/django/'] + sys.path"
#PythonOption django.root "/portal"



SetHandler python-program
PythonHandler myvirtualdjango
SetEnv DJANGO_SETTINGS_MODULE technology.settings
SetEnv PYTHON_EGG_CACHE /var/www/django-dev/technology/egg_temp
PythonInterpreter beta
PythonDebug On
PythonPath "['/var/www/django-dev/'] + sys.path"
PythonOption django.root /beta




SetHandler None


Does anyone have two or more authentic'able django apps running under
mod_python on the same server, so I at least know that the problem is
buried in my code somewhere?

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



i18n not always working

2009-09-15 Thread Gabriel .

Hi,

I have some batch process that send i18n mails, I'm using a template
to render the message body.
The subject is translated but not the body.

This is a sample code:

from django.utils import translation
from django.utils.translation import ugettext as _

lang = user.get_profile().language
if lang:
language = translation.to_locale(lang)
translation.activate(language)

subject = _("A translated subject")
message = render_to_string('updater/queuestatus.mail')

Any idea why?

-- 
Kind Regards

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



checking for empty result in queryset

2009-09-15 Thread Gonzillaaa

in the following query:
data = Model.objects.filter(node_id=id)

how do I check if data is empty before rendering or being redirected
to a 404?

G.


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



Select models based on m2m relationship.

2009-09-15 Thread Léon Dignòn

Hello,

I have a m2m relationship like this:

class Actor(models.Model):
name = models.CharField(unique=True)
class Movie(models.Model):
name = models.CharField(unique=True)
actors = models.ManyToManyField(Actor)
class Comment(models.Model):
actor = models.ForeignKey(Actor)
movie = models.ForeignKey(Movie)
comment = models.CharField()

Every actor belongs to a number movies, every movie contains a number
of actors.

What I want to achieve is, that in the form I chose a movie from the
movie-dropdown list, then the actor-dropdown displays only actors
acting in that particular movie. This can happen with javascript,
ajax, or any other good stuff.

I don't know wheter to use javascript, or ajax, or whatever. I don't
know if my model is good. Please help me starting with this. It's a
little complex at the moment :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



passing parameters to formset

2009-09-15 Thread Michael Stevens

Hi.

I'm creating a formset of forms using formset_factory.

It's all working nicely, but I'd like to pass some values into the
forms to use as the choices for one of the fields.

Is there a way to do this? As far as I can tell the formset_factory
takes over the creation of the form and I can't see a way to pass my
own data in.

Michael

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



Re: how to return ajax info in one case, and redirect to a different url in another?

2009-09-15 Thread Margie

Yes, that was going to be my fallback if I couldn't get the server
validation to work.  I just find it so much more maintainable to do
the validation in python/django.  Anyway, did finally get it working,
thanks!

Margie


On Sep 15, 5:18 am, justind  wrote:
> Could you just do validation in the view, then when you get the
> response, if there are no errors, submit the form with javascript
> (form.submit()), handle it in the view and redirect?
>
> On Sep 15, 3:07 am, Margie Roginski  wrote:
>
> > I have a situation where the user fills in a form and hits submit to
> > post the form.  If my views.py code detects an error in the form, I
> > want to return some info to the client and put it into the dom via
> > jquery.  If there is no error, I want to redirect to another page.
> > Can anyone advise me on the best way to do this?  I've succesfully
> > used $.post() to grab the error info and put it in the dom.  However,
> > in the case where there is no error, I can't figure out how to do the
> > redirect.
>
> > I've tried having the views.py code pass back the url that I want to
> > redirect to, and then when my $.post() callback function is called, it
> > sets window.location to that url.   But this seems to have some issues
> > when the url contains an anchor (for some reason firefox seems to
> > cache anchored urls and not redirect to them in the normal way).
>
> > Is there any way to specify that even though $.post() started the
> > server request, that the server should just redirect to a url (ie,
> > using just the basic HttpResponseRedirect() or something like that)
> > and not return and call the $.post callback function?
>
> > Thanks for any pointers,
>
> > Margie
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to return ajax info in one case, and redirect to a different url in another?

2009-09-15 Thread Margie

Thanks for the pointers!  I finally got it to work.  I had been doing
similar to your suggestion (returning ajax response like
["redirect_to": "http://www.example.com";], but I had been having
issues with setting the location and wasn't sure if that was the right
thing to be doing.  For some reason when I had a url that had a /
before an anchor, ie http://www.example.com/#comment_32, it wasn't
redirecting correctly and that was throwing me off.  Maybe that's not
even legal and just happens to work when I type it in.  Anyway, once I
got rid of the '/' before the anchor (www.example.com#comment_32) and
used

  document.location = url

that did the trick.  Thanks very much for your comments, that was a
big help.

Margie

On Sep 15, 6:41 am, Alex Robbins 
wrote:
> Making the browser switch pages isn't too bad. Just set
> document.location to the new url using javascript. (The document
> object should be provided by the browser.)
> Maybe you should check the headers of the ajax response and if it is a
> redirect make the redirect happen using javascript? Or simply make one
> of the ajax responses be {"redirect_to": "http://www.example.com/"}
> and parse it out on the client side.
>
> Hope that helps,
> Alex
>
> On Sep 15, 2:07 am, Margie Roginski  wrote:
>
> > I have a situation where the user fills in a form and hits submit to
> > post the form.  If my views.py code detects an error in the form, I
> > want to return some info to the client and put it into the dom via
> > jquery.  If there is no error, I want to redirect to another page.
> > Can anyone advise me on the best way to do this?  I've succesfully
> > used $.post() to grab the error info and put it in the dom.  However,
> > in the case where there is no error, I can't figure out how to do the
> > redirect.
>
> > I've tried having the views.py code pass back the url that I want to
> > redirect to, and then when my $.post() callback function is called, it
> > sets window.location to that url.   But this seems to have some issues
> > when the url contains an anchor (for some reason firefox seems to
> > cache anchored urls and not redirect to them in the normal way).
>
> > Is there any way to specify that even though $.post() started the
> > server request, that the server should just redirect to a url (ie,
> > using just the basic HttpResponseRedirect() or something like that)
> > and not return and call the $.post callback function?
>
> > Thanks for any pointers,
>
> > Margie
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



views help with category_list for a blgo

2009-09-15 Thread ChrisR

Hello,

I am building a blog/cms for my site.  I am using django's date_based
urls as well as object_detail for the individual posts.

On my base, I have a for loop for categories in the blog.  I don't
like the way I have made the category_list work, and feel that it is
not the best way to do it.  I would like some help with that if
someone is willing to make suggestions.

The category list appears on all pages within my blog, but when I do a
search in the blog, the list disappears.

Here are my views:

from django.shortcuts import render_to_response, get_object_or_404
from django.db.models import Q
from blog.models import Category, Entry

def category(request, slug):
category_list = Category.objects.all()
category = get_object_or_404(Category, slug=slug)
entry_list = Entry.objects.filter(category=category)
return render_to_response("blog/entry_list.html", locals())

def search(request):
if 'q' in request.GET:
term = request.GET['q']
entry_list = Entry.objects.filter(Q(title__contains=term) | Q
(html_content__contains=term))
heading = "Search results"
return render_to_response("blog/entry_list.html", locals())


Here are my urls:

from django.conf.urls.defaults import *
from blog.models import Entry, Category

info_dict = {
'queryset' : Entry.objects.all(),
'date_field': 'created',
'template_object_name': 'entry',
"extra_context" : {"category_list" : Category.objects.all()}
}

urlpatterns = patterns('django.views.generic.date_based',
url(r'^(?P\d{4})/(?P\d{1,2})/(?P\w{1,2})/(?P[-
\w]+)/$', 'object_detail', dict(info_dict, month_format='%m',
slug_field='slug')),
url(r'^(?P\d{4})/(?P\d{1,2})/(?P\w{1,2})/$',
'archive_day', dict(info_dict, month_format='%m')),
url(r'^(?P\d{4})/(?P\d{1,2})/$', 'archive_month', dict
(info_dict, month_format='%m')),
url(r'^(?P\d{4})/$', 'archive_year', info_dict),
url(r'^$', 'archive_index', info_dict),
)

urlpatterns += patterns('blog.views',
url(r'^category/(?P[-\w]+)/$', 'category', name="blog-
category"),
url(r'^search/$', 'search', name="blog-search"),
)





If I need to provide more information let me know.  Thanks in advance!

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Seeking contributors for TODO list project written in Python/Django/jQuery ( open source )

2009-09-15 Thread Stefan Petrea

Hello,

My name is Stefan Petrea and I'm working on a project built
using Django.
Basically the idea, is that of many wishlist-type of sites out there
(of which a representative site is tadalist.com).
What you can do is make lists of items , make items , edit them ,
re-order them(using jQuery) , delete items and list.
Attach Geographic positions to items with particular labels that
show up un a Google MAP.
You also have deadlines for all the items.

The project is sitting here at the moment
http://perlhobby.googlecode.com/svn/trunk/todolist_project/
But I plan to move it to either a separate a googlecode account or
a maybe github.

I'm planning to add some more things but I'd also like your input.
I've made a presentation for this also , it's here
http://www.youtube.com/watch?v=fHBuU2jc5Lw (I wanted to make it
shorter but oh well , it shows the main ideas).

I would like to add the following:
- add caching of links that may sit inside items
- add file upload/storage on server side
- reminders for the deadlines of the items
- whatever features you may like

The project is really open to contributors.
If you
- have a patch I will merge it into the code
- want to write some docs for the project you are welcome to do so
- can optimize the existent jQuery code that is welcome also
- know of any way that I can load up the whole Google Map upon
pressing
the Location div and not inside the onload event of  you are
welcome to send a patch
- want to help by optimizing the current code that makes queries on
the
database you are welcome
- want to sponsor the project or tune it to your needs you can contact
me

As an advantage that you have with this project over other Open Source
projects is that this has a relatively small code-base that you can
easily
understand and that I'm willing to document it properly so that it
will be
easy for someone to come in and make his/her own additions.

For any information on the project please contact me at this e-mail
address.

Best regards,
Stefan

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



Re: template modules like joomla

2009-09-15 Thread Gonzalo Delgado
El Tue, 15 Sep 2009 11:38:56 -0400
Randy Barlow  escribió:

> > Do you have any example / documentation?
> 
> I don't have a very concrete example, but the high level thinking is
> pretty easy to write out.  Typically, you would store your templates in
> some kind of templates directory on the file system.  This doesn't work
> well for your problem, as you want Admin type people to be able to edit
> the templates, and you might even want some kind of revision control on
> them.
> 
> Instead, you can make a table in your DB in which to stuff the
> templates.  Maybe something like this:
> 
> class WebTemplate(models.Model):
>   template = models.TextField()
>   version = models.PositiveIntegerField(unique=True)
>   # Use this to store which page the template is for, like 'home'
>   page = models.CharField(max_length=)
> 
> When you create your template object, make it from the text in the
> template field, and look for the entry with the highest version.  When
> somebody edits the template, you just create a new instance and
> increment the version number.  Make sense?  If you don't need revision
> control, then you can simplify this, but I think it's pretty simple as is!

Or.. you could just use django-dbtemplates[0].

[0] http://bitbucket.org/jezdez/django-dbtemplates/wiki/Home

-- 
P.U. Gonzalo Delgado 
http://gonzalodelgado.com.ar/


pgphfgCNdAEvJ.pgp
Description: PGP signature


Re: Test tables not all created

2009-09-15 Thread Karen Tracey
On Mon, Sep 14, 2009 at 6:41 PM, peppergrower <
spamcomefindmeple...@gmail.com> wrote:

>
> I just started exploring Django's test framework, and it looks like
> it'll be fantastic once I get it working.  However, while trying to
> run a very simple test (just to figure out how to use the test
> features), I noticed that the test database that's being created
> doesn't contain all of the tables I would expect (i.e., not all of the
> ones in the normal database).  Since some tables are missing, the
> tests don't work.
>
>
I don't know what you mean by "normal database".  The test runner
essentially does a syncdb on the test database -- thus, it will create all
the tables for all the models for all the apps listed in INSTALLED_APPS.  If
you are seeing behavior different from this we'll need more specifics about
what exactly you are doing and what tables, specifically, are missing in
order to help figure out what is going on.

Karen

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



Re: load template

2009-09-15 Thread luca72

I have solve restarting more and more time apache, but now i have
another question.
my django application is located in http://www.mysite.net/dg
if i point directly to one page, for example http://www.mysite.net/dg/example
all work, but if i point to the admin page:
http://www.mysite.net/dg/admin i fill with user and password he
redirect me to http://www.mysite.net/admin and give me the error page
not found.
What i have to change in the configuration file to maka the redirect
correct to http://www.mysite.net/dg/my required page.
Many Thanks

Luca

On 15 Set, 17:23, luca72  wrote:
> Hello in my setting fikle i have write this:
> TEMPLATE_DIRS = ('/home/luca72/webapps/django/myproject/templates'
>     # Put strings here, like "/home/html/django_templates" or "C:/www/
> django/templates".
>     # Always use forward slashes, even on Windows.
>     # Don't forget to use absolute paths, not relative paths.
> )
>
> but i get the error :
>
> TemplateDoesNotExist at /richiedi/
>
> richiedi.html
>
> Request Method:         GET
> Request URL:    http://mysite.net/richiedi/
> Exception Type:         TemplateDoesNotExist
> Exception Value:
>
> richiedi.html
>
> Exception Location:     /home/luca72/webapps/django/lib/python2.5/django/
> template/loader.py in find_template_source, line 74
> Python Executable:      /usr/local/bin/python
> Python Version:         2.5.4
> Python Path:    ['/home/luca72/webapps/django', '/home/luca72/webapps/
> django/lib/python2.5', '/home/luca72/lib/python2.5', '/usr/local/lib/
> python2.5/site-packages/MySQL_python-1.2.2-py2.5-linux-i686.egg', '/
> usr/local/lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg', '/
> usr/local/lib/python2.5/site-packages/python_memcached-1.43-
> py2.5.egg', '/home/luca72/webapps/django/lib/python2.5', '/usr/local/
> lib/python25.zip', '/usr/local/lib/python2.5', '/usr/local/lib/
> python2.5/plat-linux2', '/usr/local/lib/python2.5/lib-tk', '/usr/local/
> lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages',
> '/usr/local/lib/python2.5/site-packages/PIL']
>
> and i see that he try to find the template here:
>
> Template-loader postmortem
>
> Django tried loading these templates, in this order:
>
>     * Using loader
> django.template.loaders.filesystem.load_template_source:
>     * Using loader
> django.template.loaders.app_directories.load_template_source:
>           o /home/luca72/webapps/django/lib/python2.5/django/contrib/
> admin/templates/richiedi.html (File does not exist)
>
> But if in the setting i have write TEMPLATE_DIRS = ('/home/luca72/
> webapps/django/myproject/templates'
> Why he try to find it in /home/luca72/webapps/django/lib/python2.5/
> django/contrib/admin/templates/richiedi.html
>
> Thanks
> Luca
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: template modules like joomla

2009-09-15 Thread Randy Barlow

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Alessandro Ronchi declared:
>> Alessandro Ronchi declared:
>>> I need to give the possibility to the administrator to manage portions
>>> of templates in pages, and let him to change that portions for every
>>> page.
>>> Joomla does this thing with modules: I need something similar. Is it 
>>> possible?

>> Store your templates in the DB!

> Do you have any example / documentation?

I don't have a very concrete example, but the high level thinking is
pretty easy to write out.  Typically, you would store your templates in
some kind of templates directory on the file system.  This doesn't work
well for your problem, as you want Admin type people to be able to edit
the templates, and you might even want some kind of revision control on
them.

Instead, you can make a table in your DB in which to stuff the
templates.  Maybe something like this:

class WebTemplate(models.Model):
template = models.TextField()
version = models.PositiveIntegerField(unique=True)
# Use this to store which page the template is for, like 'home'
page = models.CharField(max_length=)

When you create your template object, make it from the text in the
template field, and look for the entry with the highest version.  When
somebody edits the template, you just create a new instance and
increment the version number.  Make sense?  If you don't need revision
control, then you can simplify this, but I think it's pretty simple as is!

- --
Randy Barlow
Software Developer
The American Research Institute
http://americanri.com
919.228.4971
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkqvtRAACgkQw3vjPfF7QfX09ACggLQsUDZFq9WGJDTEnJmJjuu3
PMAAoIcABdyc/wH95bzASXfGYOB+vlNU
=dQnM
-END PGP SIGNATURE-

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



load template

2009-09-15 Thread luca72

Hello in my setting fikle i have write this:
TEMPLATE_DIRS = ('/home/luca72/webapps/django/myproject/templates'
# Put strings here, like "/home/html/django_templates" or "C:/www/
django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)

but i get the error :

TemplateDoesNotExist at /richiedi/

richiedi.html

Request Method: GET
Request URL:http://mysite.net/richiedi/
Exception Type: TemplateDoesNotExist
Exception Value:

richiedi.html

Exception Location: /home/luca72/webapps/django/lib/python2.5/django/
template/loader.py in find_template_source, line 74
Python Executable:  /usr/local/bin/python
Python Version: 2.5.4
Python Path:['/home/luca72/webapps/django', '/home/luca72/webapps/
django/lib/python2.5', '/home/luca72/lib/python2.5', '/usr/local/lib/
python2.5/site-packages/MySQL_python-1.2.2-py2.5-linux-i686.egg', '/
usr/local/lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg', '/
usr/local/lib/python2.5/site-packages/python_memcached-1.43-
py2.5.egg', '/home/luca72/webapps/django/lib/python2.5', '/usr/local/
lib/python25.zip', '/usr/local/lib/python2.5', '/usr/local/lib/
python2.5/plat-linux2', '/usr/local/lib/python2.5/lib-tk', '/usr/local/
lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages',
'/usr/local/lib/python2.5/site-packages/PIL']

and i see that he try to find the template here:


Template-loader postmortem

Django tried loading these templates, in this order:

* Using loader
django.template.loaders.filesystem.load_template_source:
* Using loader
django.template.loaders.app_directories.load_template_source:
  o /home/luca72/webapps/django/lib/python2.5/django/contrib/
admin/templates/richiedi.html (File does not exist)

But if in the setting i have write TEMPLATE_DIRS = ('/home/luca72/
webapps/django/myproject/templates'
Why he try to find it in /home/luca72/webapps/django/lib/python2.5/
django/contrib/admin/templates/richiedi.html

Thanks
Luca


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



Re: template modules like joomla

2009-09-15 Thread Alessandro Ronchi

2009/9/15 Randy Barlow :
>
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Alessandro Ronchi declared:
>> I need to give the possibility to the administrator to manage portions
>> of templates in pages, and let him to change that portions for every
>> page.
>> Joomla does this thing with modules: I need something similar. Is it 
>> possible?
>
> Store your templates in the DB!

Do you have any example / documentation?

-- 
Alessandro Ronchi

SOASI
Sviluppo Software e Sistemi Open Source
http://www.soasi.com

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



Re: template modules like joomla

2009-09-15 Thread Randy Barlow

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Alessandro Ronchi declared:
> I need to give the possibility to the administrator to manage portions
> of templates in pages, and let him to change that portions for every
> page.
> Joomla does this thing with modules: I need something similar. Is it possible?

Store your templates in the DB!

- --
Randy Barlow
Software Developer
The American Research Institute
http://americanri.com
919.228.4971
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkqvpxMACgkQw3vjPfF7QfXeowCfZaiZNnuu0KiBfioce5E03tu0
6xwAoIKHd7cBMviPa3jB1NdJ8OJoU4lK
=PxW7
-END PGP SIGNATURE-

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



template modules like joomla

2009-09-15 Thread Alessandro Ronchi

I need to give the possibility to the administrator to manage portions
of templates in pages, and let him to change that portions for every
page.
Joomla does this thing with modules: I need something similar. Is it possible?

-- 
Alessandro Ronchi

SOASI
Sviluppo Software e Sistemi Open Source
http://www.soasi.com

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



Re: Saving Oracle Connection across requests

2009-09-15 Thread Jani Tiainen

There exists Oracle connection pool daemon and django backend to utilize 
it. Check http://code.google.com/p/pyorapool/

Connecting to Oracle is rather slow operation and if possible you really 
like connection pooling.

Though even I'm using ajax based system to rather db intensive app that 
gets quite lot of request so far I've not seen necessity to use 
connection pooling. Normal roundtrip (django server is on different 
hardware than Oracle, connected using gigabit backplane) normal 
roundtrip is around 350ms. More speed could be obtained with Django 
caching mechanisms.

Rafael Ferreira kirjoitti:
> If you are on 11g you can try to use this:
> 
> http://www.oracle.com/technology/tech/oci/pdf/oracledrcp11g.pdf
> 
> otherwise you can look for something like mysqlproxy for oracle (if such 
> thing exist). 
> 
> The real question here tho is why do you care so much about reusing 
> connections? I can tell you that connection pooling is not all that is 
> cracked up to be. 
> 
> - raf
> 
> On Mon, Sep 14, 2009 at 6:18 AM, lfrodrigues  > wrote:
> 
> 
> Hello,
> 
> I'm not sure this is possible but I would to save a oracle connection
> across several requests (like I do with a normal object)
> 
> I would like to:
> 
> if 'object' in request.session:
>  do stuff
> else:
>  import cx_Oracle
>  conn = cx_Oracle.connect(constring)
>  request.session['object'] = conn
>  do stuff
> 
> Since this doesn't work I thought about a global variable on
> settings.py but that only works on de dev server. Apache uses multiple
> processes so the global variable has different values depending of the
> process.
> 
> Any ideas how to keep a persistent connection across requests?
> 
> Thanks
> 
> 
> 
> 
> > 


-- 
Jani Tiainen

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



Re: no such table ERROR

2009-09-15 Thread AIM


O.K.

Thanks.

I will try that.


On Sep 14, 11:36 am, Bill Freeman  wrote:
> Make DATABASE_NAME an absolute path.
>
>
>
> On Mon, Sep 14, 2009 at 12:11 AM, AIM  wrote:
>
> > HI,
>
> > When I browse to
> >http://127.0.0.1:8000/mysite/Start/
>
> > I get the following error:
>
> > OperationalError at /mysite/Start/
>
> > no such table: wiki_page
>
> > Request Method:         GET
> > Request URL:    http://127.0.0.1:8000/mysite/Start/
> > Exception Type:         OperationalError
> > Exception Value:
>
> > no such table: wiki_page (ERROR HERE)
>
> > My traceback is located at the following.
> >http://dpaste.com/93287/
>
> > I have ALREADY done the following in the EXACT order.
>
> > --mysite/urls.py
> > (r'^mysite/(?P)','mysite.wiki.views.view_page' ),
>
> > --mysite/settings.py
>
> > DATABASE_ENGINE = 'sqlite3'
> > DATABASE_NAME = 'wiki.db'
>
> > INSTALLED_APPS = (
> >    #'django.contrib.auth', DELETED
> >    'django.contrib.contenttypes',
> >    'django.contrib.sessions',
> >    'django.contrib.sites',
> >    'django_extensions',
> >    'mysite.wiki',
> > )
>
> > --created these three tables in wiki.db
> > mysite>python manage.py syncdb
>
> > Creating table django_content_type
> > Creating table django_session
> > Creating table django_site
>
> > --creates a wiki folder containing models.py and views.py
> > mysite>python manage.py startapp wiki
>
> > --mysite/wiki/models.py created a model
> > from django.db import models
>
> > class Page(models.Model):
> >        name = models.CharField(max_length="20",primary_key=True)
> >        content = models.TextField(blank=True)
>
> > mysite>python manage.py syncdb
> > Creating table wiki_page
>
> > --wiki/views.py
> > from mysite.wiki.models import Page
> > from django.shortcuts import render_to_response
>
> > def view_page(request, page_name):
> >  try:
> >    page = Page.objects.get(pk=page_name)
> >  except Page.DoesNotExist:
> >    return render_to_response("create.html",{"page_name" : page_name})
>
> > --mysite/create.html (NEVER MADE IT THIS FAR)
> > 
> >  
> >     {{page_name}} - Create
> >  
> >  
> >     {{page_name}} 
> >  
> > 
>
> > Then, I reboot my wsgi web server.
>
> > Last  I browse to
> >http://127.0.0.1:8000/mysite/Start/
>
> > And, again last I get the following error:
>
> > OperationalError at /mysite/Start/
>
> > no such table: wiki_page
>
> > Request Method:         GET
> > Request URL:    http://127.0.0.1:8000/mysite/Start/
> > Exception Type:         OperationalError
> > Exception Value:
>
> > no such table: wiki_page
>
> > My traceback is located at the following.
> >http://dpaste.com/93287/
>
> > Any ideas?
>
> > Thanks.
> >Andre- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to return ajax info in one case, and redirect to a different url in another?

2009-09-15 Thread Alex Robbins

Making the browser switch pages isn't too bad. Just set
document.location to the new url using javascript. (The document
object should be provided by the browser.)
Maybe you should check the headers of the ajax response and if it is a
redirect make the redirect happen using javascript? Or simply make one
of the ajax responses be {"redirect_to": "http://www.example.com/"}
and parse it out on the client side.

Hope that helps,
Alex

On Sep 15, 2:07 am, Margie Roginski  wrote:
> I have a situation where the user fills in a form and hits submit to
> post the form.  If my views.py code detects an error in the form, I
> want to return some info to the client and put it into the dom via
> jquery.  If there is no error, I want to redirect to another page.
> Can anyone advise me on the best way to do this?  I've succesfully
> used $.post() to grab the error info and put it in the dom.  However,
> in the case where there is no error, I can't figure out how to do the
> redirect.
>
> I've tried having the views.py code pass back the url that I want to
> redirect to, and then when my $.post() callback function is called, it
> sets window.location to that url.   But this seems to have some issues
> when the url contains an anchor (for some reason firefox seems to
> cache anchored urls and not redirect to them in the normal way).
>
> Is there any way to specify that even though $.post() started the
> server request, that the server should just redirect to a url (ie,
> using just the basic HttpResponseRedirect() or something like that)
> and not return and call the $.post callback function?
>
> Thanks for any pointers,
>
> Margie
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: email : know wether address is valid

2009-09-15 Thread arbi

Ok thx.

On 15 sep, 15:33, Tom Evans  wrote:
> On Tue, 2009-09-15 at 05:35 -0700, arbi wrote:
> > Hi there,
>
> > I'd like to know wether an email sent with Django to exam...@gmail.com
> > has arrived or not (and know if the email address is valid). How can I
> > know this ?
>
> > Thx
>
> Send them an email with a link containing a token in it. When they click
> the link, you compare the token with the DB, and confirm the email
> address.
>
> Cheers
>
> Tom
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: email : know wether address is valid

2009-09-15 Thread Tom Evans

On Tue, 2009-09-15 at 05:35 -0700, arbi wrote:
> Hi there,
> 
> I'd like to know wether an email sent with Django to exam...@gmail.com
> has arrived or not (and know if the email address is valid). How can I
> know this ?
> 
> Thx
> 

Send them an email with a link containing a token in it. When they click
the link, you compare the token with the DB, and confirm the email
address.

Cheers

Tom


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



dynamically add m2m field to model

2009-09-15 Thread Aljosa Mohorovic

i'm trying to dynamically add m2m field to model, any tips on how to
make it work?

# models.py
# after MyModel definition
if getattr(settings, 'MYMODEL_M2M', False):
app_label, model_name = settings.MYMODEL_M2M
model = models.get_model(app_label, model_name)
new_field = "%s_m2m" % model_name
setattr(MyModel, new_field, models.ManyToManyField(model))

opts = MyModel._meta
setattr(opts, new_field, new_field)

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



Re: Adding BOM to an XML response

2009-09-15 Thread Vebjorn Ljosa

On Aug 20, 11:27 pm, David Korz  wrote:
> Their
> solution is to require aBOMat the beginning of the document which I
> can't figure out how to do from Django.
>
> I tried putting aBOMin the template file and well as using a
> variable set to u"\xef\xbb\xef" but it either gets ignored (not in the
> rendered content) or gets mangled after returning (probably in the
> UTF-8 encoding the the fcgi/wsgi handler.

Putting the BOM in the template file worked for me, except that
Emacs's character code conversion (or something else below xml-mode)
ate it.  After asking for help at Stack Overflow [1], I ended up
redefining render_to_response:

def render_to_response(*args, **kwargs):
bom = kwargs.pop('bom', False)
httpresponse_kwargs = {'mimetype': kwargs.pop('mimetype', None)}
s = django.template.loader.render_to_string(*args, **kwargs)
if bom:
s = '\xef\xbb\xbf' + s.encode("utf-8")
return HttpResponse(s, **httpresponse_kwargs)

I can now do render_to_response("foo.xml", mimetype="text/xml",
bom=True) in order to prepend the BOM to a particular response.

Vebjorn

[1] 
http://stackoverflow.com/questions/1423916/prepend-bom-to-xml-response-from-django

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



email : know wether address is valid

2009-09-15 Thread arbi

Hi there,

I'd like to know wether an email sent with Django to exam...@gmail.com
has arrived or not (and know if the email address is valid). How can I
know this ?

Thx

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



Re: how to return ajax info in one case, and redirect to a different url in another?

2009-09-15 Thread justind

Could you just do validation in the view, then when you get the
response, if there are no errors, submit the form with javascript
(form.submit()), handle it in the view and redirect?

On Sep 15, 3:07 am, Margie Roginski  wrote:
> I have a situation where the user fills in a form and hits submit to
> post the form.  If my views.py code detects an error in the form, I
> want to return some info to the client and put it into the dom via
> jquery.  If there is no error, I want to redirect to another page.
> Can anyone advise me on the best way to do this?  I've succesfully
> used $.post() to grab the error info and put it in the dom.  However,
> in the case where there is no error, I can't figure out how to do the
> redirect.
>
> I've tried having the views.py code pass back the url that I want to
> redirect to, and then when my $.post() callback function is called, it
> sets window.location to that url.   But this seems to have some issues
> when the url contains an anchor (for some reason firefox seems to
> cache anchored urls and not redirect to them in the normal way).
>
> Is there any way to specify that even though $.post() started the
> server request, that the server should just redirect to a url (ie,
> using just the basic HttpResponseRedirect() or something like that)
> and not return and call the $.post callback function?
>
> Thanks for any pointers,
>
> Margie
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Syntax error

2009-09-15 Thread Maksymus007

On Tue, Sep 15, 2009 at 1:28 PM, Gonzalo Delgado
 wrote:
> El Tue, 15 Sep 2009 12:49:02 +0200
> Maksymus007  escribió:
>
>> {% if gates.forms %}
>>
>>     {% for form in gates.forms %}
>>
>>         {% if forloop.first %}
>>
>>         {% else %}
>>
>>         {% endif %}
>>
>>
>>     {% endfor $} < ?
>>
>>
>> >> {% else %}
>>
>> {% endif %}
>
>
> --
> P.U. Gonzalo Delgado 
> http://gonzalodelgado.com.ar/
>

Silly me :D Thanks!

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



Re: Syntax error

2009-09-15 Thread Gonzalo Delgado
El Tue, 15 Sep 2009 12:49:02 +0200
Maksymus007  escribió:

> {% if gates.forms %}
> 
>     {% for form in gates.forms %}
> 
>         {% if forloop.first %}
> 
>         {% else %}
> 
>         {% endif %}
> 
> 
>     {% endfor $} < ?
> 
> 
> >> {% else %}
> 
> {% endif %}


-- 
P.U. Gonzalo Delgado 
http://gonzalodelgado.com.ar/


pgpybCgIPfG82.pgp
Description: PGP signature


Re: Running Django on Tornado's HTTP server

2009-09-15 Thread fruits

media files for admin is handled by the django dev server. So when you
change the server, you have to serve admin media file yourself.

http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#id3

On Sep 15, 9:42 am, Brian  wrote:
> I have a small Django app under development and was able to get this
> running using the github update. My app runs and is very responsive
> with Tornado.
>
> Some of my admin site layout is out of whack, but it may be my
> settings or my bug.  Formatting and CSS I created on my own looks good
> (e.g. graphics and tables created using the Google Visualization API.)
> My app is able to go out onto the web, get files downloaded through
> Tornado - it feels fast ...
>
> It's terrific to have a Python-based server that could work in both
> development and production. (Tornado installs/runs fine on a Netbook
> with Ubuntu!)
>
> The real-time / asynchronous capabilities look great. Any way Django
> apps can take advantage of that functionality?
>
> Thanks for open sourcing this!
>
> -- Brian
>
> On Sep 13, 4:26 pm, Bret Taylor  wrote:
>
> > I am one of the authors of Tornado (http://www.tornadoweb.org/), the
> > web server/framework we built at FriendFeed that we open sourced last
> > week (seehttp://bret.appspot.com/entry/tornado-web-server).
>
> > The underlying non-blocking HTTP server is fairly high performance, so
> > I have been working this weekend to get other frameworks like Django
> > and web.py working on Tornado's server so existing projects could
> > potentially benefit from the performance. To that end, I just checked
> > in change to Tornado that enables you to run any WSGI-compatible
> > framework on Tornado's HTTP server. You can find it in a class called
> > WSGIContainer in our wsgi.py:
>
> >http://github.com/facebook/tornado/blob/master/tornado/wsgi.py#L188
>
> > You will have to check out Tornado from github to get the change; it
> > is not yet included in the tarball distribution.
>
> > Here is a template for running a Django app on Tornado's server using
> > the module:
>
> >     import django.core.handlers.wsgi
> >     import os
> >     import tornado.httpserver
> >     import tornado.ioloop
> >     import tornado.wsgi
>
> >     def main():
> >         os.environ["DJANGO_SETTINGS_MODULE"] = 'myapp.settings'
> >         application = django.core.handlers.wsgi.WSGIHandler()
> >         container = tornado.wsgi.WSGIContainer(application)
> >         http_server = tornado.httpserver.HTTPServer(container)
> >         http_server.listen()
> >         tornado.ioloop.IOLoop.instance().start()
>
> >     if __name__ == "__main__":
> >         main()
>
> > I have only done very basic tests using the new module, so if any of
> > you are interested and start using Tornado with your Django projects,
> > please let us know what bugs you find so we can fix them. Any and all
> > feedback is appreciated.
>
> > Bret

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



Re: File Field max size and admin interface

2009-09-15 Thread David De La Harpe Golden

Peter Bengtsson wrote:

> Sadly this means that if a user tries to upload a 11Mb file you won't
> be able to confront them with a user-friendly "error" message.
> 

It's pretty straightforward to subclass django.forms.fields.FileField to
apply a size limit in clean(), or perhaps just do the check in your
form's clean()  However, that way only checks when the upload itself has
already taken place to temporary storage. That still means you can
disallow uploaded files  above a certain size being saved to more
permanent storage though, which may well be adequate.

Something like:

from django.forms import fields

class SizedFileField(fields.FileField):
default_error_messages = {
'large_file': u"File exceeds size limit.",
}

def __init__(self, *args, **kwargs):
self.max_filesize = kwargs.pop('max_filesize', None)
super(SizedFileField, self).__init__(*args, **kwargs)

def clean(self, data, initial=None):
f = super(SizedFileField, self).clean(data, initial)
if f is None:
return None
elif not data and initial:
return initial

if self.max_filesize:
if data.size > self.max_filesize:
raise fields.ValidationError(
self.error_messages['large_file'])

return 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Syntax error

2009-09-15 Thread Maksymus007

Whats wrong with such template (entire one):? Django returns

TemplateSyntaxError at /scratchcards/

Invalid block tag: 'else'

pointing at tag marked by >>

{% if gates.forms %}

    {% for form in gates.forms %}

        {% if forloop.first %}

        {% else %}

        {% endif %}


    {% endfor $}


>> {% else %}

{% endif %}

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



Re: Getting data from user via HTML

2009-09-15 Thread koranthala



On Sep 15, 9:02 am, Nitin Boladra  wrote:
> Hi Django users,
>                 I am trying to create a simple Django application
> wherein I want to run a python function with an argument that is
> obtained from text-box whenever I click the button on my web-page. The
> problem is passing the value obtained in text-box to the python
> function. So as I am new to Django can anybody help me out to resolve
> this problem. Thanks in advance.
>
> Regards,
> Nitin

Hi,
   This might help:
http://www.djangobook.com/en/2.0/chapter07/
http://docs.djangoproject.com/en/dev/topics/forms/#topics-forms-index

  It will be good to read the djangobook (first link) once thoroughly
because all the basic scenarios are considered there. The
documentation in Django website is also very extensive. Do check it
out too.

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



Re: [solved] admin interface, nginx and fawps

2009-09-15 Thread Sven Richter
I solved the problem myself.
I had to set the SESSION_COOKIE_DOMAIN = '.domain.de' and delete the old
cookie then everything worked as it should.


Greetings
Sven

On Mon, Sep 14, 2009 at 3:33 PM, Sven Richter wrote:

> Hi all,
> i am running a django project with fapws (
> http://github.com/william-os4y/fapws3) as server managed through nginx as
> webserver (nginx just forwards to the running fapws instance).
> Fapws deploys the django project as wsgi app.
>
> Now i have a weird problem, i am using the admin interface very often and
> everytime i logout and try to relog into the interface i have to restart the
> fapws instance.
> If i dont restart it i get the following error:
> 1. 502 Bad Gateway message from nginx and
> 2. if i return to the login screen it shows me that my browser wont accept
> cookies and that i should enable them.
>
> Before i ran the project as scgi application managed by cherokee (another
> small webserver) and everything worked without problems.
>
> Any ideas?
>
>
> Greetings and thanks in advance
> Sven
>

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



Re: nested list in templates

2009-09-15 Thread Leon Harris

>From a glance at your code looks it looks like the cat reference is
not being updated to the sub category and is just endlessly looping
over the top level category

something more along these lines may help (where 'do_menu' is an
inclusion tag)
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#inclusion-tags

{% for child in children %}

{% if not child.is_leaf_node %}{% endif %}
{{ child.get_title }}
{% if child.childrens %}

{% do_menu "menu.html" child %}

{% endif %}

{% endfor %}



On Sep 14, 9:25 pm, xyz69  wrote:
> Hello,
>
> I have "Category" app. I use django-mptt to remember the structure od
> the category tree.
> I want to show this tree in nested list using generic view
> (render_to_template).
> I pass a category_list in extra_context and the problem starts when
> want to show it.
> I try something like this:
>
> # category_list.html
> 
> {% for cat in object_list %}
> {% if not cat.parent %}
> {{cat.name}}
> {% if cat.children.all %}
> {% include "category_list_helper.html" %}
> has children
> {% endif %}
> {% endif%}
> {% endfor %}
> 
>
> # category_list_helper
> 
> {% for cat in cat.children.all %}
> {{cat.name}}
>  {% if cat.children.all %}
>    {% include "category_list_helper.html"%}
>  {% endif %}
> 
> {% endfor %}
> 
>
> So... if there is only one level of recursion, everything is ok,
> but when I have subsubcategories, error happens;)
>
> "RuntimeError at /blog/categories/
> maximum recursion depth exceeded while calling a Python object"
>
> I also google for solution, and 
> this:http://www.undefinedfire.com/lab/recursion-django-templates/
> looks sensibly.
>
> What do you think?
> Have you ever had similar problem?
>
> Pawel
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Legacy db & 'serial' pk's

2009-09-15 Thread Tim Bowden

I'm new to Django, and trying to build a small app against a legacy
database.  A couple of the tables have primary keys of the form:
pk_field integer default nextval('pf_field_id_seq'::regclass)

I've used inspectdb to get a starting models.py, but how is this best
handled in django?

Thanks,
Tim Bowden

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



Re: Remote login via XML-RPC or SOAP?

2009-09-15 Thread djfis...@gmail.com

SOAP and XMLRPC have quite a few tradeoffs, but without knowing
exactly what your setup is (other than Python/Django) I'd advise you
to go with XMLRPC. However, I'll lay out why I think so and perhaps
SOAP does make more sense for you.

SOAP is the successor to XMLRPC and some people -- notably people from
the Java and .NET worlds -- think that SOAP is "better". In the Java
and .NET worlds, SOAP is pretty common but a lot of the scripting
language worlds are moving toward a third option REST which I won't
get into here since it doesn't seem to be an option for you. With
Python, XMLRPC is built into the standard library where you'll have to
go to Pypi for a SOAP library. Rolling your own SOAP library is
probably not a good idea since SOAP is complex and verbose. In
addition, there are occasionally incompatibilities with .NET SOAP
services or so I've been led to believe from others at work.

While SOAP is certainly more complex, in some cases it can make up for
it with type checking, code generation or object translation. SOAP
services usually make use of a web service description language
document (WSDL) that describes the service and can contain XML schemas
that describe in great detail the properties of the objects in the
service. Using this, a SOAP library may be able to automatically take
native objects and send them in web service calls or take web service
responses and translate them into objects. It is possible that with a
good library, you may need to write less code with SOAP. In general,
XMLRPC in Python will translate your objects into requests and
responses into objects, but XMLRPC only supports a few data types
(int, float, list, dict, datetime) compared with SOAP. Possibly
because of this lack of complexity, XMLRPC is pretty well standardized
between various clients and servers. If you just need to use a couple
services that your client is exposing and those services accept just a
couple primitive parameters, XMLRPC is your best bet.




On Sep 14, 7:07 pm, Rodrigo Cea  wrote:
> I am creating a Django website for a client who won't give me access
> to their database or server, but will allow login / account creation
> on their server via SOAP or XML-RPC from my server, where the Django-
> based website will reside.
> I would like to get an idea beforehand about which route, SOAP or XML-
> RPC, is easier, more stable, less buggy, more widely used, etc.
>
> The process will be:
> a) user inputs new account info on my server (lets call it D for
> Django).
> b) account is created on client's server (lets call it C for client)
> c) C responds with Success or Fail.
> d) next morning, user logs in via D
> e) C responds with Success or Fail, plus some user info such as name,
> age and other info gleaned during step (a).
> f) D stores this information to use during the session and logs in
> user.
>
> Any help, caveats, libraries or suggestions are much appreciated.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django generate unique sequence for each organisation in a SaaS app

2009-09-15 Thread Sid

I'm working on a django SaaS app, which hosts data for multiple
organisations. Each record in a table has a unique RecordNumber.

I could use autofield to give each record a unique incrementing Id
automatically, but that is globally unique. As in org1 might have say,
RecordNum=1 or 2 or 7 etc and org2 might have RecordNum=3,4,5,6

I want each organisation to have its own sequence, i.e. all
organisations might have RecordNum=1 or 2...etc. I can still use
autofield as primary key to identify the row. But i need the RecordNum
field as it will be visible to the end users as sequence numbers
within their org.

UUID, are too cumbersome to type in while searching for a record.

I found this - 
http://stackoverflow.com/questions/1104741/generating-sequential-numbers-in-multi-user-saas-application
But i before resorting to stored procedures, i want to make sure there
isn't any other way.

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



Re: Can all of unicode be slugified?

2009-09-15 Thread Continuation

What's the best way to implement unicode slugification?

I have an application that expects Chinese characters (with some
English mixed in) in user inputs. What's the best way to turn that
Chinese-English mix into a slugified URL that's SEO-friendly as well
as meaningful to humans?

On Sep 13, 10:01 pm, James Bennett  wrote:
> On Sun, Sep 13, 2009 at 8:25 PM, W.P. McNeill  wrote:
> > Is this expected behavior?  I can see some discussion on the web that
> > references unicode support for slugification, but I can't tell if that
> > unicode support works for any arbitrary unicode characters, or Django
> > has hand-crafted slugification for certain non-ASCII characters (e.g.
> > common European characters).
>
> When in doubt, look at the source. The 'slugify' template filter is
> implemented as, well, a template filter, and so lives with all the
> other built-in filters in django.template.defaultfilters:
>
> http://code.djangoproject.com/browser/django/trunk/django/template/de...
>
> It's easy to see from the code what's going on. A Unicode string comes
> in to the filter, and is normalized (using form NFKD) and encoded as
> ASCII, ignoring non-convertible characters. Then any character which
> is neither a space, a hyphen nor an alphanumeric character is
> stripped, as is leading and trailing whitespace. Finally, spaces are
> replaced with hyphens.
>
> The result is something which will be usable in a URL, regardless of
> the exotic characters which went into it. However, this does have the
> possibility of discarding information, in a couple of places.
>
> First, the Unicode normalization and ASCII conversion is important --
> NFKD decomposes characters, and then the ASCII encode discards
> anything that can't be converted. So, for example, if the character
> 'ñ' is in the string, the NFKD normalization decomposes it into 'n'
> and a combining diacritic, and then the ASCII conversion with the
> 'ignore' flag discards the diacritic. For a URL, this is typically
> what you want, because it means 'ñ' becomes simply 'n'.
>
> The other place where you can lose characters is in discarding
> non-alphanumeric characters, but again for a URL this is typically
> what you want.
>
> --
> "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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



how to return ajax info in one case, and redirect to a different url in another?

2009-09-15 Thread Margie Roginski

I have a situation where the user fills in a form and hits submit to
post the form.  If my views.py code detects an error in the form, I
want to return some info to the client and put it into the dom via
jquery.  If there is no error, I want to redirect to another page.
Can anyone advise me on the best way to do this?  I've succesfully
used $.post() to grab the error info and put it in the dom.  However,
in the case where there is no error, I can't figure out how to do the
redirect.

I've tried having the views.py code pass back the url that I want to
redirect to, and then when my $.post() callback function is called, it
sets window.location to that url.   But this seems to have some issues
when the url contains an anchor (for some reason firefox seems to
cache anchored urls and not redirect to them in the normal way).

Is there any way to specify that even though $.post() started the
server request, that the server should just redirect to a url (ie,
using just the basic HttpResponseRedirect() or something like that)
and not return and call the $.post callback function?

Thanks for any pointers,

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