django filters

2010-05-19 Thread rahul jain
Hi,

In my model, I have set up one filter which helps in filtering out the
results on admin Panel. The way its works now
that its displays the old objects first and then the most recent ones. Is it
possible to make it other way around ?.

Let me know.

--RJ

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



Re: Uploaded File Security

2010-05-19 Thread Lee Hinde
On Wed, May 19, 2010 at 7:19 PM, Mike Dewhirst wrote:

> On 20/05/2010 11:00am, Lee Hinde wrote:
>
>> I'm working on an intranet app for a client that will have file uploads.
>> I'm early in the process, but have the uploading working just fine via
>> admin.
>>
>> Once we get to deployment, I'm unclear on how to coordinate the security
>> that django will know about (group X has access to X's files, but not
>> group Y's),
>>
>> When I poke around for discussions on protecting uploaded files, the
>> most recent and seemingly on point discussion is here:
>>
>>
>> http://stackoverflow.com/questions/2780893/django-authentication-htaccess-static
>>
>> Which is basically suggesting that one hash the name and hope that
>> no-one guesses the resulting path.
>>
>> What's best practice here?
>>
>
> If it has to be secure rather than just wishful thinking the webserver must
> demand credentials. If you are using Apache, that means .htaccess files
> which point to a list of credentials for each group.
>
> Maybe you could obtain a django authentication backend which Apache can use
> as well? On an Intranet you should be able to access LDAP connectivity
> somewhere - Microsoft AD, Novell eDirectory or Linux LDAP.
>
> I'm very interested in your progress here because I have to travel this
> road in the medium term future.
>
> I have done a test implementation of Peter Herndon's django-ldap-groups
> with eDir and one of the next steps for me is to look at the Apache LDAP
> docs.
>
> http://code.google.com/p/django-ldap-groups/
>
> Good luck
>
> Mike
>
>
>> Thanks.
>>
>>   - Lee
>>
>> --
>>
>>
This is going to be a hosted solution and if I add LDAP maintenance to the
new things they have to do, I think they'll go back to shuffling Excel files
back and forth via email.

One Apache log-in and then one Django log-in? Blech.

Let's see what anyone else has to say...

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



Re: How to insert a search form inside Django?

2010-05-19 Thread ravi krishna
Thanks really..that was helpful :)

On Wed, May 19, 2010 at 6:43 PM, bx2  wrote:

> I'm suggesting to use one of signal-based approches as explained at
> DjangoCon presentation by co-author of Satchmo.
> Here is the link with examples of source code:
> http://www.slideshare.net/ecomsmith/custom-signals-for-uncoupled-design.
>
> Furthermore you can look at DjangoBook here:
> http://www.djangobook.com/en/2.0/chapter07/
>
> Have fun!
> bx2
>
>
> On 19 Maj, 08:47, ravi krishna  wrote:
> > Hi,
> > I want to include a search button inside my Django, which retrieves data
> > from some google API or Wikimapia API, But i am stuck with adding a
> search
> > option inside Django. i am a beginner with Django and Python programming.
> > Can somebody please help me with this.
> >
> > --
> > Regards,
> > Rav!
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> > For more options, visit this group athttp://
> groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Regards,
Rav!

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



Problems with url encoding

2010-05-19 Thread Caumons
Hi everybody.

I am having problems with the urlencoding. I explain. In a template I
have the following code:

Return to list

In the view I pass the variables slug_platform and num_pag to the
template, but the problem is that when I click the link it brings me
to the following page (copy/paste from the developing server):

/plataforms/wii%26pag%3D1/HTTP/1.1" 404 1738

As you can see there are these % symbols and I do not know if Django
does an automatic urlencoding, but then the URL does not match with
any pattern because of these symbols! But if I test the code with an
html validator it gives me errors because it says that this line is
not urlencoded.

I have also tried doing this:
Return to list
but this raises a syntax error in the template

I do not know what to do and I also do not know if when we do
something like request.get["something"] you have to unquote it or it
is not needed.

Thank you so much.

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



Re: Uploaded File Security

2010-05-19 Thread Mike Dewhirst

On 20/05/2010 11:00am, Lee Hinde wrote:

I'm working on an intranet app for a client that will have file uploads.
I'm early in the process, but have the uploading working just fine via
admin.

Once we get to deployment, I'm unclear on how to coordinate the security
that django will know about (group X has access to X's files, but not
group Y's),

When I poke around for discussions on protecting uploaded files, the
most recent and seemingly on point discussion is here:

http://stackoverflow.com/questions/2780893/django-authentication-htaccess-static

Which is basically suggesting that one hash the name and hope that
no-one guesses the resulting path.

What's best practice here?


If it has to be secure rather than just wishful thinking the webserver 
must demand credentials. If you are using Apache, that means .htaccess 
files which point to a list of credentials for each group.


Maybe you could obtain a django authentication backend which Apache can 
use as well? On an Intranet you should be able to access LDAP 
connectivity somewhere - Microsoft AD, Novell eDirectory or Linux LDAP.


I'm very interested in your progress here because I have to travel this 
road in the medium term future.


I have done a test implementation of Peter Herndon's django-ldap-groups 
with eDir and one of the next steps for me is to look at the Apache LDAP 
docs.


http://code.google.com/p/django-ldap-groups/

Good luck

Mike



Thanks.

   - Lee

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


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



Uploaded File Security

2010-05-19 Thread Lee Hinde
I'm working on an intranet app for a client that will have file uploads. I'm
early in the process, but have the uploading working just fine via admin.

Once we get to deployment, I'm unclear on how to coordinate the security
that django will know about (group X has access to X's files, but not group
Y's),

When I poke around for discussions on protecting uploaded files, the most
recent and seemingly on point discussion is here:

http://stackoverflow.com/questions/2780893/django-authentication-htaccess-static

Which is basically suggesting that one hash the name and hope that no-one
guesses the resulting path.

What's best practice here?

Thanks.

  - Lee

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



Re: If is first time logging in

2010-05-19 Thread Nick
 I am, but I'm not opposed to custmizing one. This part of the project
will undoubtedly get bundled as a reusable registratioon and login app
for other projects so it doing what I'd like it to do is more
important than convenience.

On May 19, 5:23 pm, Dejan Noveski  wrote:
> Do you use the generic login view?
>
>
>
>
>
> On Thu, May 20, 2010 at 12:16 AM, Nick  wrote:
> > I have an expanded user form right now. Here is the sign up process.
>
> > user registers using username, email, password
>
> > It sends and activation link to that email.
>
> > User clicks on the link and they are activated
>
> > User logs in
>
> > Here is where I would like the extended profile to pop up the first
> > time. When they pass through the login screen to their home page (each
> > user has a home page with a selection of different actions).
>
> > I can kind of see where you are going with what you have, I'm adding a
> > field to check to make sure the forms are finished?
>
> > I'm not too worried about users not filling out the profile, this is a
> > site built for submitted obituaries and the users will be funeral
> > homes so filling out the form is a necessary part of their job. I just
> > want to know how to make it really obvious to them the first time they
> > login.
>
> > On May 19, 4:36 pm, Dejan Noveski  wrote:
> > > Best will be if you make Useraccount model that will inherit from User,
> > add
> > > field formsets_passed = BooleanField(initial = False)
>
> > > The reason why i think this is better idea is, user might leave the page
> > > before finishing the aditional forms. That way, next time it will be
> > second
> > > login and you will be able to show them again.
>
> > > On Wed, May 19, 2010 at 11:05 PM, Nick  wrote:
> > > > I'm trying to figure out a way to see if it is a users first time
> > > > logging in after registering on the site. If it is then I will pass
> > > > them through some formsets, otherwise I let them go to their profile
> > > > page.
>
> > > > I tried using date_joined == last_login but that doesn't work, as the
> > > > last login date changes the second you log in.
>
> > > > Anyone ever done anything like this?
>
> > > > Any thoughts?
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Django users" group.
> > > > To post to this group, send email to django-us...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > django-users+unsubscr...@googlegroups.com > > >  groups.com>
> > 
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/django-users?hl=en.
>
> > > --
> > > --
> > > Dejan Noveski
> > > Web Developer
> > > dr.m...@gmail.com
> > > Twitter:http://twitter.com/dekomote|LinkedIn:
> >http://mk.linkedin.com/in/dejannoveski
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > > To post to this group, send email to django-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com > groups.com>
> > .
> > > For more options, visit this group athttp://
> > groups.google.com/group/django-users?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com > groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> --
> Dejan Noveski
> Web Developer
> dr.m...@gmail.com
> Twitter:http://twitter.com/dekomote| 
> LinkedIn:http://mk.linkedin.com/in/dejannoveski
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Output data across models in XML

2010-05-19 Thread Andrew
I'm trying to make a webservice that outputs XML representation of
data from a model. The model itself looks roughly like this:

-
class Product(models.Model):
short_description=models.CharField(max_length=300)
long_description=models.CharField(max_length=2000)
price=models.DecimalField(decimal_places=2, max_digits=6)
store=models.ForeignKey(Merchant)
def __unicode__(self):
return self.short_description

class Merchant(models.Models):
name=models.CharField(max_length=20)
zip=models.CharField(max_length=6)
category=models.CharField(max_length=10)

   def __unicode__(self):
return self.name
--

What I've done so far is this:

--
zip='12345'
category='food'
products_list=Product.objects.filter(store__zip=zip,
store__category=category)
xml=serializers.serialize("xml",products_list,field=('short_description','price','store'))



It works, and I get XML back, but the 'store' data is just the id for
the Merchant table. What I want instead is the name of the store. I've
tried replacing 'store' with 'store.name' and 'store__name' to no
avail -- how can I get the XML serializer to return a data member of
the 'store' object instead of just a pointer to that object?

If it's not possible with serializer, what's the best way to do it?

Thanks
Andrew


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



Django for desktop application

2010-05-19 Thread Ahmed Salem

Hi all

I'm search for python tool help my in Quran search program for NLP &
python
now i found dijango but i ask about can it conected with jython and
perform desktop app

Please advice or send me link if it can do that

Thanks a lot

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



custom css class on all form fields

2010-05-19 Thread andreas schmid
hi,

is it possible to programmatically add a custom css class to each label and 
field in a djangoform?
i know i can add a class to a specific widget with attrs={} but i need such a 
class on all labels and fields for many forms.

im using django newforms on appengine with its default version ... so 0.89??!!

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



group password

2010-05-19 Thread Junkie Dolphin
Hello everybody,
I am coding a django app for performing an online, anonymous
experiment system. The idea is that we give a login code to a group of
participants (e.g. students at our university) and tell them a
specific time window (usually a couple of hours) during which they can
login to the website using that code we gave them (hence no
registration required). Once they login the website randomly matches
pairs of participants for a game (the actual experiment).

The key factor here is anonymity. We don't want participants to give
us any personal information, but still we need to identify each
anonymous user in order to do the random matching.

What would be the best solution? I was thinking to use the builtin
authentication system but I don't know if it would be better to extend
django.contrib.auth.User or just use a plain form.

-Giovanni

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



Re: template_context_processors

2010-05-19 Thread stefan
Hi,

I have this issue too :)

On May 17, 1:00 pm, stefan  wrote:
> Hello,
>
> I have this issue, I am using the development Django version (checked
> out from svn). I use a template_context_processor and sometimes the
> context_processor is processedtwice,
> one for the current request and one for the referring/previous
> request. I know this because I am using logging inside the
> context_processor function, and I log request.META['REQUEST_URI']
> Do you have any idea how to solve this ?
>
> Thanks,
> 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: If is first time logging in

2010-05-19 Thread Dejan Noveski
Do you use the generic login view?

On Thu, May 20, 2010 at 12:16 AM, Nick  wrote:

> I have an expanded user form right now. Here is the sign up process.
>
> user registers using username, email, password
>
> It sends and activation link to that email.
>
> User clicks on the link and they are activated
>
> User logs in
>
> Here is where I would like the extended profile to pop up the first
> time. When they pass through the login screen to their home page (each
> user has a home page with a selection of different actions).
>
> I can kind of see where you are going with what you have, I'm adding a
> field to check to make sure the forms are finished?
>
> I'm not too worried about users not filling out the profile, this is a
> site built for submitted obituaries and the users will be funeral
> homes so filling out the form is a necessary part of their job. I just
> want to know how to make it really obvious to them the first time they
> login.
>
>
>
> On May 19, 4:36 pm, Dejan Noveski  wrote:
> > Best will be if you make Useraccount model that will inherit from User,
> add
> > field formsets_passed = BooleanField(initial = False)
> >
> > The reason why i think this is better idea is, user might leave the page
> > before finishing the aditional forms. That way, next time it will be
> second
> > login and you will be able to show them again.
> >
> >
> >
> >
> >
> > On Wed, May 19, 2010 at 11:05 PM, Nick  wrote:
> > > I'm trying to figure out a way to see if it is a users first time
> > > logging in after registering on the site. If it is then I will pass
> > > them through some formsets, otherwise I let them go to their profile
> > > page.
> >
> > > I tried using date_joined == last_login but that doesn't work, as the
> > > last login date changes the second you log in.
> >
> > > Anyone ever done anything like this?
> >
> > > Any thoughts?
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Django users" group.
> > > To post to this group, send email to django-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com
> 
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
> >
> > --
> > --
> > Dejan Noveski
> > Web Developer
> > dr.m...@gmail.com
> > Twitter:http://twitter.com/dekomote| LinkedIn:
> http://mk.linkedin.com/in/dejannoveski
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> > For more options, visit this group athttp://
> groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
--
Dejan Noveski
Web Developer
dr.m...@gmail.com
Twitter: http://twitter.com/dekomote | LinkedIn:
http://mk.linkedin.com/in/dejannoveski

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



Re: If is first time logging in

2010-05-19 Thread Nick
I have an expanded user form right now. Here is the sign up process.

user registers using username, email, password

It sends and activation link to that email.

User clicks on the link and they are activated

User logs in

Here is where I would like the extended profile to pop up the first
time. When they pass through the login screen to their home page (each
user has a home page with a selection of different actions).

I can kind of see where you are going with what you have, I'm adding a
field to check to make sure the forms are finished?

I'm not too worried about users not filling out the profile, this is a
site built for submitted obituaries and the users will be funeral
homes so filling out the form is a necessary part of their job. I just
want to know how to make it really obvious to them the first time they
login.



On May 19, 4:36 pm, Dejan Noveski  wrote:
> Best will be if you make Useraccount model that will inherit from User, add
> field formsets_passed = BooleanField(initial = False)
>
> The reason why i think this is better idea is, user might leave the page
> before finishing the aditional forms. That way, next time it will be second
> login and you will be able to show them again.
>
>
>
>
>
> On Wed, May 19, 2010 at 11:05 PM, Nick  wrote:
> > I'm trying to figure out a way to see if it is a users first time
> > logging in after registering on the site. If it is then I will pass
> > them through some formsets, otherwise I let them go to their profile
> > page.
>
> > I tried using date_joined == last_login but that doesn't work, as the
> > last login date changes the second you log in.
>
> > Anyone ever done anything like this?
>
> > Any thoughts?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com > groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> --
> Dejan Noveski
> Web Developer
> dr.m...@gmail.com
> Twitter:http://twitter.com/dekomote| 
> LinkedIn:http://mk.linkedin.com/in/dejannoveski
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: If is first time logging in

2010-05-19 Thread Dejan Noveski
Best will be if you make Useraccount model that will inherit from User, add
field formsets_passed = BooleanField(initial = False)

The reason why i think this is better idea is, user might leave the page
before finishing the aditional forms. That way, next time it will be second
login and you will be able to show them again.

On Wed, May 19, 2010 at 11:05 PM, Nick  wrote:

> I'm trying to figure out a way to see if it is a users first time
> logging in after registering on the site. If it is then I will pass
> them through some formsets, otherwise I let them go to their profile
> page.
>
> I tried using date_joined == last_login but that doesn't work, as the
> last login date changes the second you log in.
>
> Anyone ever done anything like this?
>
> Any thoughts?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
--
Dejan Noveski
Web Developer
dr.m...@gmail.com
Twitter: http://twitter.com/dekomote | LinkedIn:
http://mk.linkedin.com/in/dejannoveski

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



Re: trying not to do any operations in template, but not sure i can avoid it.

2010-05-19 Thread Bill Freeman
You could put a method on your basket object which calculates the shipping.
Then if the basket object is included in the context, you can trivially call it.

Or perhaps better, fix up you all_purchases iterable to append it.
Something like:

   def add_shipping(purchaces_iterable):
  for i, p in enumerate(purchases_iterable):
 yield p
  yield Purchase(name="Shipping",
amount=Decimal(PER_ITEM_SHIPPING)*(i+1)...)


On Wed, May 19, 2010 at 4:44 PM, shofty  wrote:
> apologies, i tab spaced before id finished.
>
> the if forloop.last is waiting til its written out all fo the html for
> the items then i was going to add a final item which was shipping to
> the basket. but cant really do that without doing math in the
> template.
>
> would like to know if anyone knows of a better way to do it. have i
> missed the really obvious?
> am i trying to hard to stick to not putting logic into the template?
>
> Matt
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



If is first time logging in

2010-05-19 Thread Nick
I'm trying to figure out a way to see if it is a users first time
logging in after registering on the site. If it is then I will pass
them through some formsets, otherwise I let them go to their profile
page.

I tried using date_joined == last_login but that doesn't work, as the
last login date changes the second you log in.

Anyone ever done anything like this?

Any thoughts?

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



Re: trying not to do any operations in template, but not sure i can avoid it.

2010-05-19 Thread shofty
apologies, i tab spaced before id finished.

the if forloop.last is waiting til its written out all fo the html for
the items then i was going to add a final item which was shipping to
the basket. but cant really do that without doing math in the
template.

would like to know if anyone knows of a better way to do it. have i
missed the really obvious?
am i trying to hard to stick to not putting logic into the template?

Matt

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



trying not to do any operations in template, but not sure i can avoid it.

2010-05-19 Thread shofty
not sure if i've totally missed the point of the correct way to do
this.

because i couldn't get the django-cart project to do what i wanted
(and more because there is a note on the page explaining its got bugs
and that i should have been able to fix them but not detailing said
bugs) i decided to write my own cart. and called it basket ;)

the basket works and is super simple. its built to create html for
submission to google checkout. which works.
the code that generates the html follows.

{% for purchase in all_purchases %}






{% if forloop.last %}
end of loopsss
{% endif %}
{% endfor %}

consider this situation though. the shipping option is a fixed cost
per item, which google doesnt allow you to configure in their options
exactly as the client wants it.

so you think it'd be easy to just wait for the last item in the
basket, then sum the number of items (forloop.counter) and multiply it
by the flat rate. but i dont think im supposed to do maths in the
template am i?

so my alternative is to do the maths based on the number of items in
the basket at creation of the dict in the view.

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



Re: manager.raw returning Capitalized field names

2010-05-19 Thread geraldcor
Russ,

>As for templates - they don't ever use the CamelCase name. They
>exclusively use the model names, and there's no 'raw query' equivalent
>for templates.

This is the problem that is presenting the possible bug. I have to use
{{ m.SomeField }} in my template rather than {{ m.somefield }} as you
suggest should always be the case.

I am using a raw query because I couldn't for the life of me get the
related object query for Checkin.objects.filter(...) to work.
Sometimes I actually find the ORM more confusing than raw sql ;)

Greg

On May 15, 5:19 am, Russell Keith-Magee 
wrote:
> On Fri, May 14, 2010 at 5:29 AM, geraldcor  wrote:
> > Hello,
>
> > Some background first. I am working with a legacy database that is not
> > only legacy, it is legacy Microsoft access so there is some hacking
> > going on. I am accessing a MySQL backend and my models are set up to
> > use the existing tables/field names. When I use regular old ORM
> > queries, Everything works as normal and I can access fields using a
> > for loop and iterator.fieldname.
>
> > In order to access the joined fields between two tables, I had to
> > resort to themanager.rawsyntax. Here is my syntax
>
> > confirm_data = Checkin.objects.raw('SELECT * FROM Checkin JOIN
> > CheckinTests ON Checkin.SampleID = CheckinTests.SampleID WHERE
> > Checkin.DateArrived = %s AND Checkin.Company = %s', [date_arrived,
> > company_name])
>
> > 1. I have to use the legacy db table names and field names i.e.
> > CamelCase names
> > 2. Once the query is executed and either in the shell or a template,
> > when I iterate over the queryset for the main table I can use
> > c.fieldname but for the joined table I have to use c.FieldName. It's
> > as if the joined table isn't returning the model names but the table
> > names from MySQL. Is this a bug? It's kindof annoying to have to use
> > two different syntaxes in my templates.
>
> It's hard to tell if this is a bug, but my initial reaction is
> probably not -- although that is moderated by the fact that I'm a
> little hazy on what you are describing. This is mostly because I'm
> getting confused over which bits are MySQL, which bits are Access,
> which bits are template code, and why joining matters at all.
>
> There are two completely independent naming domains in use here
>  1) The attributes on a Django model
>  2) The field names on the SQL database.
>
> By way of example, if you have the following model:
>
> class MyModel(Model):
>     fieldname = CharField(max_length=100, db_colum='FieldName')
>
> This defines a Django model with a field called 'fieldname', backed by
> a database column named 'FieldName'. You can create instances and
> assign values using the lowercased name:
>
> >>> m = MyModel()
> >>> m.fieldname = 'ham'
> >>> m.save()
>
> and the underlying SQL that is executed will use the db_column:
>
> SELECT FieldName ... FROM myapp_mymodel WHERE ...
>
> If you're issuing raw queries, then yes - you will need to deal with
> the CamelCase names, but that's because you're manually issuing SQL.
> However, if your queries are as simple as the example you provide, you
> shouldn't even need to use raw queries - you should be able to do a
> simple MyModel.objects.filter(...) call, and not worry about the
> column names at all.
>
> As for templates - they don't ever use the CamelCase name. They
> exclusively use the model names, and there's no 'raw query' equivalent
> for templates.
>
> Yours,
> Russ Magee %-)
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: List of Users online

2010-05-19 Thread Brian Neal
On May 19, 12:31 pm, EmileZola  wrote:
> I want to list the logged in users on my index page and was wondering
> what was the right way to do this.
>
> Can I do it similar to this ?
> def index(request):
>     return render_to_response('index.html', {
>         'online_users': User.objects.filter(last_login > delay)
>     })
> delay being "now - 15 minutes" or something like that...
>
> Is there a way to use is_authenticated() in that context ?
> Should I use a MiddleWare instead to acheive this ?
>

I don't think basing it off of last_login will work, because they may
login and then stay logged in for 2 weeks or whatever you have your
cookie settings set to.

I have a piece of middleware that maintains a dictionary of username,
datetime key/value pairs in the cache. If the requesting user is
authenticated I update their timestamp in the dictionary. I then
iterate over the dictionary and delete entries that are older than
some threshold.

I then have a template tag that retrieves the dictionary from the
cache and displays the names.

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



Re: File/Folder permissions for deploying Django app

2010-05-19 Thread Shawn Milochik
To some extent it doesn't matter. Just make sure your code is as secure as any 
private information you wouldn't want others to have access to.

When Django is running in a production environment, there is a Python instance 
listening on a port on your system. Your Web server (Apache, nginx, whatever) 
will direct requests to your Python instance and accept the responses. At no 
time are any of your templates or Python scripts exposed to or processed by the 
Web server the way CGI, ASP, or PHP scripts would be.

Shawn


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



List of Users online

2010-05-19 Thread EmileZola
I want to list the logged in users on my index page and was wondering
what was the right way to do this.


Can I do it similar to this ?
def index(request):
return render_to_response('index.html', {
'online_users': User.objects.filter(last_login > delay)
})
delay being "now - 15 minutes" or something like that...


Is there a way to use is_authenticated() in that context ?
Should I use a MiddleWare instead to acheive this ?

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



Re: Extremely simple question that I can't get a simple answer for in Docs

2010-05-19 Thread steve
That was it, Tom, thanks

On May 19, 9:43 am, Tom Evans  wrote:
> On Wed, May 19, 2010 at 5:37 PM, pyfreak  wrote:
> > I was on this page, but I went directly to the "1.1" link in that
> > first sentence because I am using 1.1 actually
>
> > This page is for the development version.
>
> > Thanks though.
>
> The same information is in the 1.1 manual:
>
> http://docs.djangoproject.com/en/1.1/topics/forms/#displaying-a-form-...
>
> I clicked 'docs.djangoproject.com', then 'Forms - overview' halfway
> down the page. That then has a menu item for 'Displaying a form using
> a template'.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: Extremely simple question that I can't get a simple answer for in Docs

2010-05-19 Thread Iván Raskovsky
On Wed, May 19, 2010 at 1:23 PM, pyfreak  wrote:

> I tried placing my form in the template like {{ f['subject'] }} and I
> get TemplateSyntaxError.  Of course using my own form and existing
> fields
>

Another important point is how to display the contents for a key in a
dictionary in a template (what you where trying to achieve).
Check out the meaning of the . in django templates [1].
Iván

[1]
http://docs.djangoproject.com/en/dev/ref/templates/api/#rendering-a-context

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



Re: Extremely simple question that I can't get a simple answer for in Docs

2010-05-19 Thread Daniel Roseman
On May 19, 5:37 pm, pyfreak  wrote:
> I was on this page, but I went directly to the "1.1" link in that
> first sentence because I am using 1.1 actually
>
> This page is for the development version.
>
> Thanks though.
>
I don't know why you think that makes any difference here.

In any case, your question is not about forms, but about templates.
The template docs show you exactly how to do an attribute lookup.
http://docs.djangoproject.com/en/1.1/topics/templates/
(This was also mentioned in the tutorial, part 3.)
--
DR.

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



Form Field and Form instance

2010-05-19 Thread Dejan Noveski
Hi all,

Is there any way to get the form object in a field class? Something similar
to contribute_to_class in model forms?

Thanks
-- 
--
Dejan Noveski
Web Developer
dr.m...@gmail.com
Twitter: http://twitter.com/dekomote | LinkedIn:
http://mk.linkedin.com/in/dejannoveski

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



Re: Extremely simple question that I can't get a simple answer for in Docs

2010-05-19 Thread Tom Evans
On Wed, May 19, 2010 at 5:37 PM, pyfreak  wrote:
> I was on this page, but I went directly to the "1.1" link in that
> first sentence because I am using 1.1 actually
>
> This page is for the development version.
>
> Thanks though.
>

The same information is in the 1.1 manual:

http://docs.djangoproject.com/en/1.1/topics/forms/#displaying-a-form-using-a-template

I clicked 'docs.djangoproject.com', then 'Forms - overview' halfway
down the page. That then has a menu item for 'Displaying a form using
a template'.

Cheers

Tom

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



Re: insert html in html

2010-05-19 Thread CrabbyPete
Brian,

Thanks. The safe filter worked for me. I was writing it to a file and
then doing an {% include calendar %}, but your solution worked out.

On May 18, 7:00 pm, Brian Neal  wrote:
> On May 18, 2:00 pm,CrabbyPete wrote:
>
> > I want to insert a html calendar into an existing web page. What is
> > the best way to insert html into a template that I have for the web
> > page?
>
> In what form do you have this calendar HTML? Do you compute it in a
> view? Is it already in a file? If you have it in a view, then one way
> to do it would be to pass it to a template and in the template:
>
> My Calendar
> 
> {{ my_calendar_data|safe }}
> 
>
> You could make this a template tag, or {% include %} it, or put it in
> your base template...
>
> We'd need more information to help further.
>
> Hope that helps.
> BN
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: Extremely simple question that I can't get a simple answer for in Docs

2010-05-19 Thread pyfreak
I was on this page, but I went directly to the "1.1" link in that
first sentence because I am using 1.1 actually

This page is for the development version.

Thanks though.

On May 19, 9:29 am, Nuno Maltez  wrote:
> I think you need the google search help list :-)
>
> Just type "django forms" in the search box at docs.djangoproject.com
>
> And in the first result you have a lot of examples on how to print
> everything from a form in your 
> template:http://docs.djangoproject.com/en/dev/topics/forms/
>
>
>
>
>
> On Wed, May 19, 2010 at 5:23 PM, pyfreak  wrote:
> > Frustratingly enough, docs.djangoproject.com tells you how to print
> > out the HMTL for a single field in your form, but it uses a shell to
> > demonstrate it:
>
> >  f = ContactForm()
>  print f['subject']
> >   
>  print f['message']
>
> > However, I need to know how to do this in a template
>
> > I tried placing my form in the template like {{ f['subject'] }} and I
> > get TemplateSyntaxError.  Of course using my own form and existing
> > fields
>
> > What is the syntax for this.
>
> > I tried all types of search terms to hopefully catch a thread with
> > someone doing this, but ended up at zero.
>
> > Thanks
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: Extremely simple question that I can't get a simple answer for in Docs

2010-05-19 Thread Nuno Maltez
I think you need the google search help list :-)

Just type "django forms" in the search box at docs.djangoproject.com

And in the first result you have a lot of examples on how to print
everything from a form in your template:
http://docs.djangoproject.com/en/dev/topics/forms/

On Wed, May 19, 2010 at 5:23 PM, pyfreak  wrote:
> Frustratingly enough, docs.djangoproject.com tells you how to print
> out the HMTL for a single field in your form, but it uses a shell to
> demonstrate it:
>
>  f = ContactForm()
 print f['subject']
>   >
 print f['message']
>
>
> However, I need to know how to do this in a template
>
> I tried placing my form in the template like {{ f['subject'] }} and I
> get TemplateSyntaxError.  Of course using my own form and existing
> fields
>
>
> What is the syntax for this.
>
> I tried all types of search terms to hopefully catch a thread with
> someone doing this, but ended up at zero.
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Extremely simple question that I can't get a simple answer for in Docs

2010-05-19 Thread pyfreak
Frustratingly enough, docs.djangoproject.com tells you how to print
out the HMTL for a single field in your form, but it uses a shell to
demonstrate it:

 f = ContactForm()
>>> print f['subject']
   
>>> print f['message']


However, I need to know how to do this in a template

I tried placing my form in the template like {{ f['subject'] }} and I
get TemplateSyntaxError.  Of course using my own form and existing
fields


What is the syntax for this.

I tried all types of search terms to hopefully catch a thread with
someone doing this, but ended up at zero.

Thanks

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



Template tags variables cannot be None, False, True?

2010-05-19 Thread Peter Coles
Do tags not support the literals None, False, or True? Why would
numbers and strings be supported, but not these? It is possible to
pass these as variables into the context (even in a context processor)
as {'None': None, 'True': True, 'False': False} and it's possible that
someone may be using variables named like this with completely
different values, but it seems odd to me that they're just not
supported out of the box.

If I try passing a None into a tag, I get a "VariableDoesNotExist"
error ("Failed lookup for key [None] in…")

Furthermore, it seems really simple to support by adding something
like this into the top of template.Variable.__init__ (just above the
try)

literals = {'None': None, 'False': False, 'True': True}
if var in literals:
self.literal = literals[var]
return

but that wouldn't be backwards compatible for someone who may be
passing confusing/bizarro variables into their context, such as
{'None': 0}

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



Re: Django Sphinx Foreign key search

2010-05-19 Thread yafeng wu
Hi,

I got the same problem when building my website. Have you solved it?
Please let me know.

Thanks,

On Apr 13, 4:04 am, urukay  wrote:
> Hi,
>
> I'm trying to create full text search on model, everything goes fine
> when
> searching TextFields but I have a problem with ForeignKey field.
>
> How can i do that? Can anyone point me to the right direction?
>
> Thanks
>
> Model example:
>
> class Model1(models.Model):
>
>      text_field =models.TextField(max_length=250)
>      fek_field = models.ForeignKey('Model2')
>
> class Model2(models.Model):
>      text_field = models.TextField(max_length=250)
>
> --
> View this message in 
> context:http://old.nabble.com/Django-Sphinx-Foreign-key-search-tp28219147p282...
> Sent from the django-users mailing list archive at Nabble.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: send_mail not firing

2010-05-19 Thread Nick
Welp, indentation error:

def save(self):

needed to unindent so it was called when the form was process, instead
it was waiting for an error to trigger it, which it wouldn't do
because the error halts the form from processing.  There goes 13 hours
of my life I'm never getting back.

On May 19, 10:07 am, Nick  wrote:
> It looks like the problem isn't with send_mail, its the save override
> on the form, the is_active = False isn't setting that option in the DB
> either, so it is skipping over the save options. Here they are again:
>
> forms.py:
> class RegisterForm(UserCreationForm):
>     email = forms.EmailField(label="E-Email")
>
>     class Meta:
>         model = User
>         fields = ("username", "email")
>
>     def clean_email(self):
>         email = self.cleaned_data["email"]
>
>         try:
>             User.objects.get(email=email)
>         except User.DoesNotExist:
>             return email
>
>         raise forms.ValidationError("A user with that email address
> already exists.")
>
>         def save(self):
>             user = super(RegisterForm, self).save(commit=False)
>             send_activation(user)
>             user.is_active = False
>             user.save()
>
> and the view:
>
> def register(request):
>     if request.method == 'POST':
>         form = RegisterForm(request.POST)
>         if form.is_valid():
>             new_user = form.save()
>
>             return HttpResponseRedirect("/obits/")
>     else:
>         form = RegisterForm()
>
>     return render_to_response("obits/register.html", {'form': form })
>
> So, the username and all of that are saving by the user.is_active and
> send_mail are getting skipped
>
> On May 19, 4:37 am, Nuno Maltez  wrote:
>
>
>
> > Anything it the mail server's logs? Any trace of your app trying tosendthe 
> > message? Any errors?
>
> > Nuno
>
> > On Tue, May 18, 2010 at 11:42 PM, Nick  wrote:
> > > Actually, I've fixed the problem with send_activation. If i go via the
> > > form it still doesn't trigger the email.
>
> > > On May 18, 5:19 pm, Nick  wrote:
> > >> I get the same results.
>
> > >> I dropped into the shell and tried it out
>
> > >> >>> user = User(username="nick", email="t...@test.com")
> > >> >>> send_activation(user)
>
> > >> 1
>
> > >> I think the 1 means that it passed but I don't get any emails sent
>
> > >> On May 18, 5:08 pm, "ge...@aquarianhouse.com"
>
> > >>  wrote:
> > >> > what happens if you set fail_silently to True?
>
> > >> > On May 19, 12:05 am, Nick  wrote:
>
> > >> > > I am having an issue with an authentication app I am writing. The app
> > >> > > saves the form appropriately but doesn'tsendthe confirmation email.
> > >> > > I am using the same email_host settings as with other application 
> > >> > > that
> > >> > >sendemail messages but with no results. Here is the process.
>
> > >> > > First a form processes the information:
>
> > >> > > from django.contrib.auth.forms import UserCreationForm
> > >> > > from django import forms
> > >> > > from django.contrib.auth.models import User
> > >> > > from activate import send_activation
>
> > >> > > class RegisterForm(UserCreationForm):
> > >> > >     email = forms.EmailField(label="E-Email")
>
> > >> > >     class Meta:
> > >> > >         model = User
> > >> > >         fields = ("username", "email")
>
> > >> > >     def clean_email(self):
> > >> > >         email = self.cleaned_data["email"]
>
> > >> > >         try:
> > >> > >             User.objects.get(email=email)
> > >> > >         except User.DoesNotExist:
> > >> > >             return email
>
> > >> > >         raise forms.ValidationError("A user with that email address
> > >> > > already exists.")
>
> > >> > >         def save(self):
> > >> > >             user = super(RegisterForm, self).save(commit=False)
> > >> > >             send_activation(user)
> > >> > >             user.is_active = False
> > >> > >             user.save()
>
> > >> > > the activate.py file:
>
> > >> > > from django.core.mail import send_mail
> > >> > > from hashlib import md5
> > >> > > from django.template import loader, Context
> > >> > > from Obits.settings import BASE_URL as base_url
>
> > >> > > def send_activation(user):
> > >> > >     code = md5(user.username).hexdigest()
> > >> > >     url = "%sactivate/?user=%s=%s" % (base_url, user.username,
> > >> > > code)
> > >> > >     template = loader.get_template('obits/eactivate.html')
> > >> > >     context = ({
> > >> > >          'username': user.username,
> > >> > >          'url': url,
> > >> > >      })
> > >> > >     send_mail('Activate account at super site', 'this is a test',
> > >> > > 'myem...@mydomain.com, [user.email], fail_silently=False)
>
> > >> > > The form saves to the DB, it hits all of the conditions but fails to
> > >> > >sendan email. I can't get any error messages so I'm really at a loss.
>
> > >> > > --
> > >> > > You 

Re: send_mail not firing

2010-05-19 Thread Nick
It looks like the problem isn't with send_mail, its the save override
on the form, the is_active = False isn't setting that option in the DB
either, so it is skipping over the save options. Here they are again:

forms.py:
class RegisterForm(UserCreationForm):
email = forms.EmailField(label="E-Email")

class Meta:
model = User
fields = ("username", "email")

def clean_email(self):
email = self.cleaned_data["email"]

try:
User.objects.get(email=email)
except User.DoesNotExist:
return email

raise forms.ValidationError("A user with that email address
already exists.")

def save(self):
user = super(RegisterForm, self).save(commit=False)
send_activation(user)
user.is_active = False
user.save()

and the view:

def register(request):
if request.method == 'POST':
form = RegisterForm(request.POST)
if form.is_valid():
new_user = form.save()

return HttpResponseRedirect("/obits/")
else:
form = RegisterForm()

return render_to_response("obits/register.html", {'form': form })

So, the username and all of that are saving by the user.is_active and
send_mail are getting skipped


On May 19, 4:37 am, Nuno Maltez  wrote:
> Anything it the mail server's logs? Any trace of your app trying tosendthe 
> message? Any errors?
>
> Nuno
>
>
>
> On Tue, May 18, 2010 at 11:42 PM, Nick  wrote:
> > Actually, I've fixed the problem with send_activation. If i go via the
> > form it still doesn't trigger the email.
>
> > On May 18, 5:19 pm, Nick  wrote:
> >> I get the same results.
>
> >> I dropped into the shell and tried it out
>
> >> >>> user = User(username="nick", email="t...@test.com")
> >> >>> send_activation(user)
>
> >> 1
>
> >> I think the 1 means that it passed but I don't get any emails sent
>
> >> On May 18, 5:08 pm, "ge...@aquarianhouse.com"
>
> >>  wrote:
> >> > what happens if you set fail_silently to True?
>
> >> > On May 19, 12:05 am, Nick  wrote:
>
> >> > > I am having an issue with an authentication app I am writing. The app
> >> > > saves the form appropriately but doesn'tsendthe confirmation email.
> >> > > I am using the same email_host settings as with other application that
> >> > >sendemail messages but with no results. Here is the process.
>
> >> > > First a form processes the information:
>
> >> > > from django.contrib.auth.forms import UserCreationForm
> >> > > from django import forms
> >> > > from django.contrib.auth.models import User
> >> > > from activate import send_activation
>
> >> > > class RegisterForm(UserCreationForm):
> >> > >     email = forms.EmailField(label="E-Email")
>
> >> > >     class Meta:
> >> > >         model = User
> >> > >         fields = ("username", "email")
>
> >> > >     def clean_email(self):
> >> > >         email = self.cleaned_data["email"]
>
> >> > >         try:
> >> > >             User.objects.get(email=email)
> >> > >         except User.DoesNotExist:
> >> > >             return email
>
> >> > >         raise forms.ValidationError("A user with that email address
> >> > > already exists.")
>
> >> > >         def save(self):
> >> > >             user = super(RegisterForm, self).save(commit=False)
> >> > >             send_activation(user)
> >> > >             user.is_active = False
> >> > >             user.save()
>
> >> > > the activate.py file:
>
> >> > > from django.core.mail import send_mail
> >> > > from hashlib import md5
> >> > > from django.template import loader, Context
> >> > > from Obits.settings import BASE_URL as base_url
>
> >> > > def send_activation(user):
> >> > >     code = md5(user.username).hexdigest()
> >> > >     url = "%sactivate/?user=%s=%s" % (base_url, user.username,
> >> > > code)
> >> > >     template = loader.get_template('obits/eactivate.html')
> >> > >     context = ({
> >> > >          'username': user.username,
> >> > >          'url': url,
> >> > >      })
> >> > >     send_mail('Activate account at super site', 'this is a test',
> >> > > 'myem...@mydomain.com, [user.email], fail_silently=False)
>
> >> > > The form saves to the DB, it hits all of the conditions but fails to
> >> > >sendan email. I can't get any error messages so I'm really at a loss.
>
> >> > > --
> >> > > You received this message because you are subscribed to the Google 
> >> > > Groups "Django users" group.
> >> > > To post to this group,sendemail to django-us...@googlegroups.com.
> >> > > To unsubscribe from this group,sendemail to 
> >> > > django-users+unsubscr...@googlegroups.com.
> >> > > For more options, visit this group 
> >> > > athttp://groups.google.com/group/django-users?hl=en.
>
> >> > --
> >> > You received this message because you are subscribed to the Google 
> >> > Groups "Django users" group.
> >> > To post to this group,sendemail to 

Re: Is it possible to add a table on my database with a django code ?

2010-05-19 Thread Pep
:) Thanks for your answers.

Effectively, I won't do this but I was curious on manipulate a
database like this. However it could be useful in a few project with a
limited number of users.

On 19 mai, 14:35, Dj Gilcrease  wrote:
> On Wed, May 19, 2010 at 8:18 AM, Pep  wrote:
> > Hi everybody !
>
> > I would like to know if it's possible to add automatically a table on
> > my database when, for example, a new member subscribe on my website ?
>
> > I mean, if I would like to do it manually, I'll have to change my
> > Model and then to do manage.py syncdb. And that's all. But
> > automatically ???
>
> Yes you can, as long as you have a model to create. How to do it is a
> little convoluted, and the need to do this in reality is rare, but
> here is how I would do it
>
> 1) Create a dynamic_models app that has a models.py that only has the
> required imports
> 2) During registration at the point you activate the users account you
> have a method that will append a new model to the dynamic_models
> models.py file. The model must be uniquely named
> 3) Then once the new model is in the file call 'call_command('syncdb',
> verbosity=0, interactive=False)'
>
> And poof you have a new model in the DB for each user registered.
>
> Details on programmatically calling management commands can be found
> in the django documentation.
>
> Now that I have told you how to do it I would like to hear your use
> case because there is an 80+% chance you dont need to do this to
> achieve the results you are looking for.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: Turn off SQL Collection but leave DEBUG on

2010-05-19 Thread Karen Tracey
On Wed, May 19, 2010 at 9:10 AM, Kenneth Loafman
wrote:

> The subject says it all, how do you turn off the SQL logging to memory
> but leave DEBUG on?  I need to test a daemon mode Django process in
> DEBUG mode, but the SQL collection in DEBUG makes it appear that there
> is a memory leak.
>

I would probably approach this need by periodically resetting the queries
rather than attempting to figure out how to stop the logging entirely when
DEBUG is True. django.db has a function reset_queries that it uses to reset
the query history at the beginning of each request.

Karen
-- 
http://tracey.org/kmt/

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



gourav arora wants to chat

2010-05-19 Thread gourav arora
I've been using Google Talk and thought you might like to try it out.
We can use it to call each other for free over the internet. Here's an
invitation to download Google Talk. Give it a try!

---

gourav arora wants to stay in better touch using some of Google's coolest new
products.

If you already have Gmail or Google Talk, visit:
http://mail.google.com/mail/b-26471a115f-241c40e9be-zIA7oy1lBjpmP0Bpk3zzlyg-JdY
You'll need to click this link to be able to chat with gourav arora.

To get Gmail - a free email account from Google with over 2,800 megabytes of
storage - and chat with gourav arora, visit:
http://mail.google.com/mail/a-26471a115f-241c40e9be-zIA7oy1lBjpmP0Bpk3zzlyg-JdY

Gmail offers:
- Instant messaging right inside Gmail
- Powerful spam protection
- Built-in search for finding your messages and a helpful way of organizing
  emails into "conversations"
- No pop-up ads or untargeted banners - just text ads and related information
  that are relevant to the content of your messages

All this, and its yours for free. But wait, there's more! By opening a Gmail
account, you also get access to Google Talk, Google's instant messaging
service:

http://www.google.com/talk/

Google Talk offers:
- Web-based chat that you can use anywhere, without a download
- A contact list that's synchronized with your Gmail account
- Free, high quality PC-to-PC voice calls when you download the Google Talk
  client

We're working hard to add new features and make improvements, so we might also
ask for your comments and suggestions periodically. We appreciate your help in
making our products even better!

Thanks,
The Google Team

To learn more about Gmail and Google Talk, visit:
http://mail.google.com/mail/help/about.html
http://www.google.com/talk/about.html

(If clicking the URLs in this message does not work, copy and paste them into
the address bar of your browser).

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



gourav arora wants to chat

2010-05-19 Thread gourav arora
I've been using Google Talk and thought you might like to try it out.
We can use it to call each other for free over the internet. Here's an
invitation to download Google Talk. Give it a try!

---

gourav arora wants to stay in better touch using some of Google's coolest new
products.

If you already have Gmail or Google Talk, visit:
http://mail.google.com/mail/b-26471a115f-d50801c396-Xnv70fiQpb5VsZkpr_fnmuFcG1k
You'll need to click this link to be able to chat with gourav arora.

To get Gmail - a free email account from Google with over 2,800 megabytes of
storage - and chat with gourav arora, visit:
http://mail.google.com/mail/a-26471a115f-d50801c396-Xnv70fiQpb5VsZkpr_fnmuFcG1k

Gmail offers:
- Instant messaging right inside Gmail
- Powerful spam protection
- Built-in search for finding your messages and a helpful way of organizing
  emails into "conversations"
- No pop-up ads or untargeted banners - just text ads and related information
  that are relevant to the content of your messages

All this, and its yours for free. But wait, there's more! By opening a Gmail
account, you also get access to Google Talk, Google's instant messaging
service:

http://www.google.com/talk/

Google Talk offers:
- Web-based chat that you can use anywhere, without a download
- A contact list that's synchronized with your Gmail account
- Free, high quality PC-to-PC voice calls when you download the Google Talk
  client

We're working hard to add new features and make improvements, so we might also
ask for your comments and suggestions periodically. We appreciate your help in
making our products even better!

Thanks,
The Google Team

To learn more about Gmail and Google Talk, visit:
http://mail.google.com/mail/help/about.html
http://www.google.com/talk/about.html

(If clicking the URLs in this message does not work, copy and paste them into
the address bar of your browser).

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



Re: Sync user objects with sympa mailinglist

2010-05-19 Thread Daniel Hilton
On 19 May 2010 14:51, Dexter  wrote:
> Hi thanks for your replies,
> I couldn't run the django page on a different server, because I only have
> one VPS running.
> But I understand there isn't a way to catch "events" on a database update.
> Grtz, Dexter


If you wrote a management command, you could add it to the crontab for
your VPS with it running every 30 mins or faster, that syncs any user
that isn't already in sympa.

You could have a boolean field on a profile of a user, and when a user
is successfully added to Sympa, the boolean is set to true.

That way you don't have to catch any events, just make sure your cron
job runs regularly to keep the two in sync.
Cheers,
Dan





>
> On Wed, May 19, 2010 at 3:43 PM, Daniel Hilton 
> wrote:
>>
>> On 19 May 2010 00:02, Dexter  wrote:
>> > Hi,
>> > I want to sync emailadresses in the django.contrib.auth User model, to a
>> > sympa mailinglist subscriberlist.
>> > I really don't have any experience with sympa. So I don't know how this
>> > process usually goes,
>> > but what I did found out, is that sympa documentation is lacking a bit.
>> > I find the concepts they use really vague, but I guess its powerful as
>> > well.
>> > Does anyone know how this is done?
>> > Grtz, Dexter
>>
>> You would have to write a management command that did the sync.
>>
>> Your command could then make use of the bulk load command as outlined
>> here:
>>
>> http://www.sympa.org/manual_6.1/database#importing_data_from_a_text_file
>>
>> All you would need is a management command that either wrapped around
>> that creating a stream of text which could then be piped in or that it
>> did that for you.
>>
>> Alternatively if you wanted to run the django instance on a different
>> machine (recommended++) you could make use of their SOAP server.
>>
>> I would recommend having a look at Suds, a really nice python package
>> for talking to soap services.
>>
>> HTH
>> Dan
>>
>>
>>
>>
>>
>>
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Django users" group.
>> > To post to this group, send email to django-us...@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/django-users?hl=en.
>> >
>>
>>
>>
>> --
>> Dan Hilton
>> 
>> www.twitter.com/danhilton
>> www.DanHilton.co.uk
>> 
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Dan Hilton

www.twitter.com/danhilton
www.DanHilton.co.uk


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



user registration extras

2010-05-19 Thread appel268576
hi there.

I am having some issues and don't really know where to go to with
this.

I am using the django-registration from bitbucket which is very handy,
however I would like to pass extra items upon registration such as
'first name', 'last name' etc.

any ideas?

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



Re: contrib.auth test failures persist to 1.2

2010-05-19 Thread Karen Tracey
2010/5/19 Filip Gruszczyński 

> I have just installed Django 1.2 hoping, that my test suites will
> finally work flawlessly and I won't have to watch tests from
> django.contrib.auth fail. But, here they are again. Does anyone have
> any idea, how I can get rid of those? I would really like to see no
> errors, because this way we could easily automate testing and detect
> any true errors.
>
> ==
> ERROR: test_known_user
> (django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
> --
> Traceback (most recent call last):
>  File
> "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/tests/remote_user.py",
> line 160, in test_known_user
>super(RemoteUserCustomTest, self).test_known_user()
>  File
> "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/tests/remote_user.py",
> line 67, in test_known_user
>self.assertEqual(response.context['user'].username, 'knownuser')
> TypeError: 'NoneType' object is unsubscriptable
>


If you create a new Django project & app, include admin and auth in
INSTALLED_APPS, and run the tests, they pass. I'm aware of some issues with
built-in auth and/or admin tests failing depending on specific project
settings, see for example: http://code.djangoproject.com/ticket/11077. That
ticket references discussions on django-dev covering the broader (still
open) issue of integration testing versus application testing. It's possible
that broader issue is what you are running into here.

However, so far as I can tell I have never seen a report of these auth
remote_user tests failing before. I can find no mention of such failures in
trac nor in my mail archive of django-users. So I have no idea if this is an
integration/application test issue or something else. The first things to
figure out would be what's different about your project compared to a
newly-created one that is leading to these tests failing. You have not given
any specifics about your project so I'm not really sure what might be
causing these failures.

Karen
-- 
http://tracey.org/kmt/

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



Re: Sync user objects with sympa mailinglist

2010-05-19 Thread Dexter
Hi thanks for your replies,

I couldn't run the django page on a different server, because I only have
one VPS running.

But I understand there isn't a way to catch "events" on a database update.

Grtz, Dexter

On Wed, May 19, 2010 at 3:43 PM, Daniel Hilton wrote:

> On 19 May 2010 00:02, Dexter  wrote:
> > Hi,
> > I want to sync emailadresses in the django.contrib.auth User model, to a
> > sympa mailinglist subscriberlist.
> > I really don't have any experience with sympa. So I don't know how this
> > process usually goes,
> > but what I did found out, is that sympa documentation is lacking a bit.
> > I find the concepts they use really vague, but I guess its powerful as
> well.
> > Does anyone know how this is done?
> > Grtz, Dexter
>
> You would have to write a management command that did the sync.
>
> Your command could then make use of the bulk load command as outlined here:
>
> http://www.sympa.org/manual_6.1/database#importing_data_from_a_text_file
>
> All you would need is a management command that either wrapped around
> that creating a stream of text which could then be piped in or that it
> did that for you.
>
> Alternatively if you wanted to run the django instance on a different
> machine (recommended++) you could make use of their SOAP server.
>
> I would recommend having a look at Suds, a really nice python package
> for talking to soap services.
>
> HTH
> Dan
>
>
>
>
>
>
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com
> .
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
> >
>
>
>
> --
> Dan Hilton
> 
> www.twitter.com/danhilton
> www.DanHilton.co.uk
> 
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Can you give me explanation for my

2010-05-19 Thread gourav arora
On Wed, May 19, 2010 at 6:25 AM, derek  wrote:

> On May 18, 10:38 pm, Hendra Kurniawan 
> wrote:
> > Hi all,
> > Can you give me a bright explanation for Django Framework ? how can
> > Django being configure in cloud computing? it's support? can you give
> > me some link article for this ?
> >
> > Thanks Before that..
> >
> > Sincerely
> >
> > Hendra
>
> Try:
> http://www.youtube.com/watch?v=YI_2l6rc5Kw
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: What architecture do you use for media?

2010-05-19 Thread Michel Thadeu Sabchuk
Hi Andy,

I do not use a different server for media yet but it is in project.
Maybe I could help:

> 2. Do you typically use a different hosting company for the media
> server than you do for the django server? If so, can you suggest any
> names?

There is the Amazon S3 and Rackspace Cloudfiles services. With then,
you don't buy a space demand, you pay for disk space and bandwith
usage, in my case, they will be cheaper than an another vps for media
server.

I don't know Amazon S3 very well but I know Rackspace Cloudfiles, the
problem is that I can't have a path like this:

/media/main/folder1/folder2/file.jpg

I need something like this:

http://mediax.server.com/group1/file1.jpg

If you are starting your project, it could be easier to align.

There is cases of django and Amazon S3 on google and the Rackspace
Cloudfiles has a python lib too.

> 3. (I just thought of this) Or do you just literally mean a different
> server, as in the software. Meaning use the same hardware server but
> use for example lighttpd for serving media and apache wsgi for serving
> django.

I use nginx in front of apache, if it is a media path, nginx takes
care of it without talk to apache. The apache server is used only for
django paths.

This is better than nothing but isn't the best choice. If i hit a site
with a separated media server, the page loads quickly because the page
and his media files load at the same time. There are hardware gains
too.

I hope I could help.

Best regards.

--
Michel Sabchuk
http://turbosys.com.br/

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



Re: Sync user objects with sympa mailinglist

2010-05-19 Thread Daniel Hilton
On 19 May 2010 00:02, Dexter  wrote:
> Hi,
> I want to sync emailadresses in the django.contrib.auth User model, to a
> sympa mailinglist subscriberlist.
> I really don't have any experience with sympa. So I don't know how this
> process usually goes,
> but what I did found out, is that sympa documentation is lacking a bit.
> I find the concepts they use really vague, but I guess its powerful as well.
> Does anyone know how this is done?
> Grtz, Dexter

You would have to write a management command that did the sync.

Your command could then make use of the bulk load command as outlined here:

http://www.sympa.org/manual_6.1/database#importing_data_from_a_text_file

All you would need is a management command that either wrapped around
that creating a stream of text which could then be piped in or that it
did that for you.

Alternatively if you wanted to run the django instance on a different
machine (recommended++) you could make use of their SOAP server.

I would recommend having a look at Suds, a really nice python package
for talking to soap services.

HTH
Dan






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



-- 
Dan Hilton

www.twitter.com/danhilton
www.DanHilton.co.uk


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



Re: Creating a new model field that includes two or more existing model fields (ie. xsd's complex type equivalent)

2010-05-19 Thread Marc
I have just come up myself with an easy way to implement it:
Inheriting from a model class that includes these fields.

However I don't like it at all aesthetically.

Do I really have to do it like this?

On May 19, 3:26 pm, Marc  wrote:
> Hi all,
> I would like to make my code more compact and DRY, and for that
> purpose I need to create a new field that includes two or more
> existing models fields (eg. a CharField, a DateField).
> Is there anything easier than inheriting from both classes and
> followinghttp://docs.djangoproject.com/en/1.2/howto/custom-model-fields/#howto...
> instructions?
> Can anybody share his or her experience on this?
> Thanks in advance!
> 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: Sync user objects with sympa mailinglist

2010-05-19 Thread Tom Evans
On Wed, May 19, 2010 at 12:44 PM, Dexter  wrote:
> Hi,
> I'm just trying to run a mailinglist now, but when I set alias_manager in
> sympa.conf, I get the following error:
> unknown field: alias_manager in sympa.conf
> How should I set my alias_manager?
> Grtz, Dexter

sympa has nothing to do with django, you would be better asking this
message on the sympa mailing list.

Cheers

Tom

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



Creating a new model field that includes two or more existing model fields (ie. xsd's complex type equivalent)

2010-05-19 Thread Marc
Hi all,
I would like to make my code more compact and DRY, and for that
purpose I need to create a new field that includes two or more
existing models fields (eg. a CharField, a DateField).
Is there anything easier than inheriting from both classes and
following 
http://docs.djangoproject.com/en/1.2/howto/custom-model-fields/#howto-custom-model-fields
instructions?
Can anybody share his or her experience on this?
Thanks in advance!
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Can you give me explanation for my

2010-05-19 Thread derek
On May 18, 10:38 pm, Hendra Kurniawan 
wrote:
> Hi all,
> Can you give me a bright explanation for Django Framework ? how can
> Django being configure in cloud computing? it's support? can you give
> me some link article for this ?
>
> Thanks Before that..
>
> Sincerely
>
> Hendra

Try:
http://www.youtube.com/watch?v=YI_2l6rc5Kw

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



reverse('django.contrib.auth.views.login') in auth tests returns /login/ rather then value set in LOGIN_URL

2010-05-19 Thread Filip Gruszczyński
In my settings I have set:

LOGIN_URL = '/accounts/login/'

Now if I run ./manage shell and type:

In [3]: reverse('django.contrib.auth.views.login')
Out[3]: '/accounts/login/'

which is ok. However, when I run one of the tests from django.contrib.auth:

def test_current_site_in_context_after_login(self):
response = self.client.get(reverse('django.contrib.auth.views.login'))
self.assertEquals(response.status_code, 200)
site = Site.objects.get_current()
self.assertEquals(response.context['site'], site)
self.assertEquals(response.context['site_name'], site.name)
self.assert_(isinstance(response.context['form'], AuthenticationForm),
 'Login form is not an AuthenticationForm')

reverse('django.contrib.auth.views.login') returns /login/. Why is
that? Is that a bug and I should file it in the issue tracker or maybe
I am doing something wrong?

-- 
Filip Gruszczyński

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



Re: ModelForm always calls Model's clean method

2010-05-19 Thread Karen Tracey
On Wed, May 19, 2010 at 1:12 AM, ak37  wrote:

> I just tried the new Model Validation feature in Django 1.2 and I
> found out that ModelForm always calls the Model's clean method even
> when the form validation has errors. This causes problems when the
> model has a foreign key, and the value is validated in the clean
> method. Consider this example:
>
> class Flight(models.Model):
>aircraft = models.ForeignKey(Aircraft)
>departure = models.ForeignKey(Departure)
>arrival = models.ForeignKey(Arrival)
>
>def clean(self):
># There can never be flights departing and arriving to the
> same place
>if self.departure == self.arrival:
>raise ValidationError("Departure is the same as Arrival")
>
> class FligthForm(forms.ModelForm):
>class Meta:
>model = Flight
>
> If the form is submitted with empty values, I will get a DoesNotExist
> exception when trying to access the self.departure/self.arrival
> attribute in the clean method. Is this by design? If it is then what
> is the recommended practice to implement the Model's clean method?
>


Calling the model clean() even though validation errors have already been
noted is consistent with the way form validation is done: the form-wide
clean() is called even when validation errors have been raised for
individual fields. It's up to the form-wide clean() to make sure the values
it wants to work with survived the earlier cleaning attempts; this is noted
for example here:
http://docs.djangoproject.com/en/dev/ref/forms/validation/#cleaning-and-validating-fields-that-depend-on-each-other.
Similarly a model clean() method must be aware that the values it has may
not be valid per earlier validation that has been run.

In this specific case one way to deal with the issue would be to use a
try/except block and catch the DoesNotExist. If one is raised, you may
assume that that error has already been noted by the form cleaning, and just
ignore it.

(I am a little confused by your model definition though -- you have
departure and arrival defined as ForeignKeys to different models, so I don't
see how they would ever compare as equal, unless your actual code is
checking some attribute on each rather then equality of the foreign key
values themselves?)

Karen
-- 
http://tracey.org/kmt/

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



Re: How to insert a search form inside Django?

2010-05-19 Thread bx2
I'm suggesting to use one of signal-based approches as explained at
DjangoCon presentation by co-author of Satchmo.
Here is the link with examples of source code:
http://www.slideshare.net/ecomsmith/custom-signals-for-uncoupled-design.

Furthermore you can look at DjangoBook here: 
http://www.djangobook.com/en/2.0/chapter07/

Have fun!
bx2


On 19 Maj, 08:47, ravi krishna  wrote:
> Hi,
> I want to include a search button inside my Django, which retrieves data
> from some google API or Wikimapia API, But i am stuck with adding a search
> option inside Django. i am a beginner with Django and Python programming.
> Can somebody please help me with this.
>
> --
> Regards,
> Rav!
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: Form validation

2010-05-19 Thread Dejan Noveski
>
>
>user = User.objects.get(pk=request.user.id)

   from = UpdateUserForm(user, ...initialstuff...)
>

First off, change this to form = UpdateUserForm(request.user,...)
request.user is django.contrib.auth.User object. You have to have


-- 
--
Dejan Noveski
Web Developer
dr.m...@gmail.com
Twitter: http://twitter.com/dekomote | LinkedIn:
http://mk.linkedin.com/in/dejannoveski

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



Re: Form validation

2010-05-19 Thread Dejan Noveski
On Wed, May 19, 2010 at 3:11 PM, Dejan Noveski  wrote:

>
>>user = User.objects.get(pk=request.user.id)
>
>from = UpdateUserForm(user, ...initialstuff...)
>>
>
> First off, change this to form = UpdateUserForm(request.user,...)
> request.user is django.contrib.auth.User object. You have to have
>

AuthenticationMiddleware in settings


> --
> --
> Dejan Noveski
> Web Developer
> dr.m...@gmail.com
> Twitter: http://twitter.com/dekomote | LinkedIn:
> http://mk.linkedin.com/in/dejannoveski
>



-- 
--
Dejan Noveski
Web Developer
dr.m...@gmail.com
Twitter: http://twitter.com/dekomote | LinkedIn:
http://mk.linkedin.com/in/dejannoveski

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



Turn off SQL Collection but leave DEBUG on

2010-05-19 Thread Kenneth Loafman
Hi,

The subject says it all, how do you turn off the SQL logging to memory
but leave DEBUG on?  I need to test a daemon mode Django process in
DEBUG mode, but the SQL collection in DEBUG makes it appear that there
is a memory leak.

...Thanks,
...Ken

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



Re: DKIM Email

2010-05-19 Thread Mark
On Apr 22, 4:16 am, Simon Meers  wrote:
> For anyone else who learned about DKIM recently [1], I've uploaded a
> snippet for a DKIM-signing email backend [2].

Brilliant. I'm just developing a Django app, had read the CH article
and was just about to figure out how to apply it to my project - but
you saved me the trouble. Thanks!

--
m.

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



Re: Is it possible to add a table on my database with a django code ?

2010-05-19 Thread Dj Gilcrease
On Wed, May 19, 2010 at 8:18 AM, Pep  wrote:
> Hi everybody !
>
> I would like to know if it's possible to add automatically a table on
> my database when, for example, a new member subscribe on my website ?
>
> I mean, if I would like to do it manually, I'll have to change my
> Model and then to do manage.py syncdb. And that's all. But
> automatically ???

Yes you can, as long as you have a model to create. How to do it is a
little convoluted, and the need to do this in reality is rare, but
here is how I would do it

1) Create a dynamic_models app that has a models.py that only has the
required imports
2) During registration at the point you activate the users account you
have a method that will append a new model to the dynamic_models
models.py file. The model must be uniquely named
3) Then once the new model is in the file call 'call_command('syncdb',
verbosity=0, interactive=False)'

And poof you have a new model in the DB for each user registered.

Details on programmatically calling management commands can be found
in the django documentation.

Now that I have told you how to do it I would like to hear your use
case because there is an 80+% chance you dont need to do this to
achieve the results you are looking for.

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



Re: Is it possible to add a table on my database with a django code ?

2010-05-19 Thread Daniel Roseman
On May 19, 1:18 pm, Pep  wrote:
> Hi everybody !
>
> I would like to know if it's possible to add automatically a table on
> my database when, for example, a new member subscribe on my website ?
>
> I mean, if I would like to do it manually, I'll have to change my
> Model and then to do manage.py syncdb. And that's all. But
> automatically ???
>
> Thanks for your answers
>
> PEP

You *really* don't want to do this. Why do you think you need a table
per user?
--
DR.

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



Is it possible to add a table on my database with a django code ?

2010-05-19 Thread Pep
Hi everybody !

I would like to know if it's possible to add automatically a table on
my database when, for example, a new member subscribe on my website ?

I mean, if I would like to do it manually, I'll have to change my
Model and then to do manage.py syncdb. And that's all. But
automatically ???

Thanks for your answers

PEP

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



Form validation

2010-05-19 Thread derape
Hey there,
i've got a problem with the form validation.
I have a form where I need the currently logged in user, to check some
stuff. So I did this in the form:

def __init__(self, user, *args, **kwargs):
self.user = user
super(UpdateUserForm, self).__init__(*args, **kwargs)

And I pass the user in in the view

user = User.objects.get(pk=request.user.id)
from = UpdateUserForm(user, ...initialstuff...)

Somehow now all the validation methods aren't executed anymore
(clean_), not any of them. Without my own constructor it works.
Does anyone know why?

Thanks for your help

derape

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



DjangoPluggableApp - A ReusableApp implementation

2010-05-19 Thread Gaël Pasgrimaud
Hi,

I saw some efforts to make django apps reusable[1] but nothing really
complete and documented.

I've released DjangoPluggableApp so:

- developers can easily create and distribute a setuptools ready
application with a simple command[2]

- end users can install and configure an application without having to
read a bunch of docs and editing settings parameters and urls[3]

DjangoPluggableApp is not intrusive. This mean that:

- end users can use applications that not have a DjangoPluggableApp
entry_point in their projects
- an application based on the provided template can be used by end
users without DjangoPluggableApp installed.

DjangoPluggableApp is well tested. This mean that:

- the package itself is tested
- the application template is tested.

The work still in progress but it's already stable and usable.

Hope you'll enjoy it.

Regards,

--
Gael

[1] http://code.google.com/p/django-app-plugins/ -
http://pypi.python.org/pypi/django-reusableapps/
[2] http://packages.python.org/DjangoPluggableApp/pluggableapp.html
[3] http://packages.python.org/DjangoPluggableApp/enduser.html

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



What architecture do you use for media?

2010-05-19 Thread Andy Kelley
I'm doing the first website where I need it to scale and want to host
the media on a different server than the one with the django code. I'm
going to have a lot of users uploading files ranging in 10 KB to 20 MB
in size. I estimate that the average user will upload 20 MB per week.
I have several questions about how all this works:

1. How do you get uploaded content from the django server to the media
server?
2. Do you typically use a different hosting company for the media
server than you do for the django server? If so, can you suggest any
names?
3. (I just thought of this) Or do you just literally mean a different
server, as in the software. Meaning use the same hardware server but
use for example lighttpd for serving media and apache wsgi for serving
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: css files are not loading properly for admin screens

2010-05-19 Thread Oulom Souvannavong
It is right

It is needed to have more information to help you.

Give some logs trace :

when you lunch your ./runserver.sh  :
- what are the HTTP Request logs when your browser try to find the CSS
files.
- what are your settings concerning the HTTP access at your unix directory [
HTTP server ? STATIC serving ?]



2010/5/19 Lokesh 

> Hi,
>
> CSS files are not loading when i try to access the admin screens.
>
> Here are the settings.py config file details
> MEDIA_ROOT = ''
> MEDIA_URL = 'http://127.0.0.1:8000'
> ADMIN_MEDIA_PREFIX = '/media/'
>
> Could some one please provide me help on this.
>
> Thanks a lot.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Sync user objects with sympa mailinglist

2010-05-19 Thread Dexter
Hi,

I'm just trying to run a mailinglist now, but when I set alias_manager in
sympa.conf, I get the following error:

unknown field: alias_manager in sympa.conf

How should I set my alias_manager?

Grtz, Dexter

On Wed, May 19, 2010 at 1:02 AM, Dexter  wrote:

> Hi,
>
> I want to sync emailadresses in the django.contrib.auth User model, to a
> sympa mailinglist subscriberlist.
> I really don't have any experience with sympa. So I don't know how this
> process usually goes,
> but what I did found out, is that sympa documentation is lacking a bit.
> I find the concepts they use really vague, but I guess its powerful as
> well.
>
> Does anyone know how this is done?
>
> Grtz, Dexter
>

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



Re: Proxy models and object instantiation

2010-05-19 Thread janedenone
I found the (obvious) solution:

def __init__(self, *args, **kwargs):
super(Page, self).__init__(*args, **kwargs)
subclasses = {
'blog' : BlogPage,
'log' : LogPage,
'index' : Page,
}
self.__class__ = subclasses[self.page_type.name]

Thanks,
Jan

On 18 Mai, 21:40, janedenone  wrote:
> Hi,
>
> I'd like to use proxy models to define different properties for
> different kinds of pages in my Django CMS. Which proxy model/class an
> object belongs to is based on a certain field's value. Before querying
> the database, my view cannot know which proxy model to use for
> instantiation.
>
> What is the preferred way to choose (and apply) the right proxy model
> after retrieving the object?
>
> - Jan

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



Re: How create M2M through with out PK?

2010-05-19 Thread David De La Harpe Golden

On 19/05/10 10:42, Daniel Roseman wrote:



How remove PK from table "libs_content_has_people" and don't use it?


You can't. Why would you want to?


Well, the natural primary key for a M2M table is quite typically 
composite and django's ORM just doesn't support composite primary keys 
right now.   IF you're trying to wrap an existing DB that uses composite 
primary keys with the django ORM, it's kind of a pain. Of course, you 
don't _have_ to use the django ORM if it's not fit for that purpose - 
SQLAlchemy supports composite primary keys fine IIRC, but is all a 
little more complicated than the Django ORM.


One "trick" that can help right now in some circumstances is to just lie 
and set the declared django model primary key field to just one of the 
columns in the true composite primary key. Then _reading_ data via the 
django ORM (at least 1.1.x, haven't got to trying the trick on 1.2 yet) 
will actually "happen to work" ...Just don't try to save!


I for one do believe composite keys could be added to the django orm 
without really hurting its user interface simplicity. Though not without 
complicating its implementation of course.  Say have a CompositeField 
model field that takes a list of underlying fields and translates 
to/from some dict-like CompositeValue python object wrapping the 
relevant underlying fields of the instance. ...and then "just" rework 
the ORM layer be able to handle them and constraints on them, including 
use as a primary key.


Wouldn't it be nice to be able to say

class OhAndAPonyToo(models.Model):
class Meta:
   db_table='existing_table_that_i_cannot_change'
people = models.ForeignKey(People)
content = models.ForeignKey(Content)
id = models.CompositeField(('people', 'content'), primary_key=True)
pony = models.CharField(max_length=10)

I expect CompositeForeignKey and perhaps even CompositeManyToMany and 
CompositeManyToCompositeMany fields could also be defined

(somewhat akin to GenericForeignKey implementation-wise)

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



Re: Ordering a QuerySet by a Python property ?

2010-05-19 Thread Thomas Guettler


thierry wrote:
> Hi all,
> 
> The order_by method makes possible to sort objects relatively to a
> specified field. But how can I sort a QuerySet relatively to a Python
> property ?

order_by happens in the database. If you want to sort with
python you can use sorted():

  http://wiki.python.org/moin/HowTo/Sorting/

Your QuerySet gets a list during sorting. This means all items
need to fit into the memory.

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

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



contrib.auth test failures persist to 1.2

2010-05-19 Thread Filip Gruszczyński
I have just installed Django 1.2 hoping, that my test suites will
finally work flawlessly and I won't have to watch tests from
django.contrib.auth fail. But, here they are again. Does anyone have
any idea, how I can get rid of those? I would really like to see no
errors, because this way we could easily automate testing and detect
any true errors.

==
ERROR: test_known_user
(django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
--
Traceback (most recent call last):
  File 
"/usr/local/lib/python2.6/dist-packages/django/contrib/auth/tests/remote_user.py",
line 160, in test_known_user
super(RemoteUserCustomTest, self).test_known_user()
  File 
"/usr/local/lib/python2.6/dist-packages/django/contrib/auth/tests/remote_user.py",
line 67, in test_known_user
self.assertEqual(response.context['user'].username, 'knownuser')
TypeError: 'NoneType' object is unsubscriptable

==
ERROR: test_last_login
(django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
--
Traceback (most recent call last):
  File 
"/usr/local/lib/python2.6/dist-packages/django/contrib/auth/tests/remote_user.py",
line 87, in test_last_login
self.assertNotEqual(default_login, response.context['user'].last_login)
TypeError: 'NoneType' object is unsubscriptable

==
ERROR: test_no_remote_user
(django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
--
Traceback (most recent call last):
  File 
"/usr/local/lib/python2.6/dist-packages/django/contrib/auth/tests/remote_user.py",
line 33, in test_no_remote_user
self.assert_(response.context['user'].is_anonymous())
TypeError: 'NoneType' object is unsubscriptable

==
ERROR: test_unknown_user
(django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
--
Traceback (most recent call last):
  File 
"/usr/local/lib/python2.6/dist-packages/django/contrib/auth/tests/remote_user.py",
line 168, in test_unknown_user
super(RemoteUserCustomTest, self).test_unknown_user()
  File 
"/usr/local/lib/python2.6/dist-packages/django/contrib/auth/tests/remote_user.py",
line 51, in test_unknown_user
self.assertEqual(response.context['user'].username, 'newuser')
TypeError: 'NoneType' object is unsubscriptable

==
ERROR: test_known_user
(django.contrib.auth.tests.remote_user.RemoteUserNoCreateTest)
--
Traceback (most recent call last):
  File 
"/usr/local/lib/python2.6/dist-packages/django/contrib/auth/tests/remote_user.py",
line 67, in test_known_user
self.assertEqual(response.context['user'].username, 'knownuser')
TypeError: 'NoneType' object is unsubscriptable

==
ERROR: test_last_login
(django.contrib.auth.tests.remote_user.RemoteUserNoCreateTest)
--
Traceback (most recent call last):
  File 
"/usr/local/lib/python2.6/dist-packages/django/contrib/auth/tests/remote_user.py",
line 87, in test_last_login
self.assertNotEqual(default_login, response.context['user'].last_login)
TypeError: 'NoneType' object is unsubscriptable

==
ERROR: test_no_remote_user
(django.contrib.auth.tests.remote_user.RemoteUserNoCreateTest)
--
Traceback (most recent call last):
  File 
"/usr/local/lib/python2.6/dist-packages/django/contrib/auth/tests/remote_user.py",
line 33, in test_no_remote_user
self.assert_(response.context['user'].is_anonymous())
TypeError: 'NoneType' object is unsubscriptable

==
ERROR: test_unknown_user
(django.contrib.auth.tests.remote_user.RemoteUserNoCreateTest)
--
Traceback (most recent call last):
  File 
"/usr/local/lib/python2.6/dist-packages/django/contrib/auth/tests/remote_user.py",
line 118, in test_unknown_user
self.assert_(response.context['user'].is_anonymous())
TypeError: 'NoneType' object is unsubscriptable

==
ERROR: test_known_user (django.contrib.auth.tests.remote_user.RemoteUserTest)
--
Traceback (most recent call last):
  File 

problem with admin tools 2.0 when dashboard.columns > 2

2010-05-19 Thread Massimiliano della Rovere
When I set Dashboard.columns to a value greater than 2, custom
dashboardmodules are rendered narrower than they should appear and with lots
of icons superimpressed.
I am adding 1 DashboardModule and 2 LinkListDashboardModule-s to the
CustomIndexDashboard using init_with_context.

class CustomIndexDashboard(Dashboard):
"""
Custom index dashboard for cruscotto.
"""
def __init__(self, **kwargs):
kwargs['columns'] = 4
kwargs['title'] = 'Habble'
Dashboard.__init__(self, **kwargs)

# append an app list module for "Applications"
self.children.append(AppListDashboardModule(
title=_('Applications'),
exclude_list=('django.contrib',),
))

# append an app list module for "Administration"
self.children.append(AppListDashboardModule(
title=_('Administration'),
include_list=('django.contrib',),
))

def init_with_context(self, context):
"""
Use this method if you need to access the request context.
"""
utente = context['request'].user
if utente.username in allowed_users:
#  code commented out [...]

self.children.append(DashboardModule(
title='block #1',
children=children_1
))

self.children.append(LinkListDashboardModule(
title='block 2',
children=children_2
))

self.children.append(LinkListDashboardModule(
title='block 3',
children=children_3
))

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



Re: How to insert a tuple into ManyToMany Relations

2010-05-19 Thread Daniel Roseman
On May 19, 5:03 am, Daemoneye 
wrote:
>
> class People(forms.Form):
> HoldComments=models.ManyToManyField('Comment')
> class Comment(forms.Form):
> CommentWord=models.CharField(max_length=1)
>
> I've had these two tables, I'd want the people make a comment so I new  
> p=comment(CommentWord=Comment)in the view
>
> but how can I save this tuple p of the comment to the People.HoldComment?
> I can do it in the admin.But how can I do this job by the Django sentense?
>
> thanks for helping me
>

This has nothing to do with tuples. 'p' is not a tuple, but an
instance of Comment.

h = HoldComment.objects.get(pk=mypk)
h.HoldComments.add(p)

(You may also want to take a look at PEP8 regarding the naming of your
models and fields.)
--
DR.

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



Re: How create M2M through with out PK?

2010-05-19 Thread Daniel Roseman
On May 19, 6:06 am, "poison...@gmail.com"  wrote:
> Models:
>
> from django.db import models
>
> class People(models.Model):
>         name = models.CharField(max_length=30)
>
>         class Meta:
>                 db_table = 'libs_peoples'
>
> class Content(models.Model):
>         title = models.CharField(max_length=30)
>         peoples = models.ManyToManyField(People, through='Type')
>
>         class Meta:
>                 db_table = 'libs_contents'
>
> class Type(models.Model):
>         people = models.ForeignKey(People)
>         content = models.ForeignKey(Content)
>         type = models.CharField(max_length=10)
>
>         class Meta:
>                 db_table = 'libs_content_has_people'
>
> Generated SQL:
>
> BEGIN;
> CREATE TABLE "libs_peoples" (
>     "id" integer NOT NULL PRIMARY KEY,
>     "name" varchar(30) NOT NULL
> )
> ;
> CREATE TABLE "libs_contents" (
>     "id" integer NOT NULL PRIMARY KEY,
>     "title" varchar(30) NOT NULL
> )
> ;
> CREATE TABLE "libs_content_has_people" (
>     "id" integer NOT NULL PRIMARY KEY,
>     "people_id" integer NOT NULL REFERENCES "libs_peoples" ("id"),
>     "content_id" integer NOT NULL REFERENCES "libs_contents" ("id"),
>     "type" varchar(10) NOT NULL
> )
> ;
> COMMIT;
>
> How remove PK from table "libs_content_has_people" and don't use it?

You can't. Why would you want to?
--
DR.

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



Re: send_mail not firing

2010-05-19 Thread Nuno Maltez
Anything it the mail server's logs? Any trace of your app trying to
send the message? Any errors?

Nuno

On Tue, May 18, 2010 at 11:42 PM, Nick  wrote:
> Actually, I've fixed the problem with send_activation. If i go via the
> form it still doesn't trigger the email.
>
> On May 18, 5:19 pm, Nick  wrote:
>> I get the same results.
>>
>> I dropped into the shell and tried it out
>>
>> >>> user = User(username="nick", email="t...@test.com")
>> >>> send_activation(user)
>>
>> 1
>>
>> I think the 1 means that it passed but I don't get any emails sent
>>
>> On May 18, 5:08 pm, "ge...@aquarianhouse.com"
>>
>>
>>
>>  wrote:
>> > what happens if you set fail_silently to True?
>>
>> > On May 19, 12:05 am, Nick  wrote:
>>
>> > > I am having an issue with an authentication app I am writing. The app
>> > > saves the form appropriately but doesn't send the confirmation email.
>> > > I am using the same email_host settings as with other application that
>> > > send email messages but with no results. Here is the process.
>>
>> > > First a form processes the information:
>>
>> > > from django.contrib.auth.forms import UserCreationForm
>> > > from django import forms
>> > > from django.contrib.auth.models import User
>> > > from activate import send_activation
>>
>> > > class RegisterForm(UserCreationForm):
>> > >     email = forms.EmailField(label="E-Email")
>>
>> > >     class Meta:
>> > >         model = User
>> > >         fields = ("username", "email")
>>
>> > >     def clean_email(self):
>> > >         email = self.cleaned_data["email"]
>>
>> > >         try:
>> > >             User.objects.get(email=email)
>> > >         except User.DoesNotExist:
>> > >             return email
>>
>> > >         raise forms.ValidationError("A user with that email address
>> > > already exists.")
>>
>> > >         def save(self):
>> > >             user = super(RegisterForm, self).save(commit=False)
>> > >             send_activation(user)
>> > >             user.is_active = False
>> > >             user.save()
>>
>> > > the activate.py file:
>>
>> > > from django.core.mail import send_mail
>> > > from hashlib import md5
>> > > from django.template import loader, Context
>> > > from Obits.settings import BASE_URL as base_url
>>
>> > > def send_activation(user):
>> > >     code = md5(user.username).hexdigest()
>> > >     url = "%sactivate/?user=%s=%s" % (base_url, user.username,
>> > > code)
>> > >     template = loader.get_template('obits/eactivate.html')
>> > >     context = ({
>> > >          'username': user.username,
>> > >          'url': url,
>> > >      })
>> > >     send_mail('Activate account at super site', 'this is a test',
>> > > 'myem...@mydomain.com, [user.email], fail_silently=False)
>>
>> > > The form saves to the DB, it hits all of the conditions but fails to
>> > > send an email. I can't get any error messages so I'm really at a loss.
>>
>> > > --
>> > > You received this message because you are subscribed to the Google 
>> > > Groups "Django users" group.
>> > > To post to this group, send email to django-us...@googlegroups.com.
>> > > To unsubscribe from this group, send email to 
>> > > django-users+unsubscr...@googlegroups.com.
>> > > For more options, visit this group 
>> > > athttp://groups.google.com/group/django-users?hl=en.
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups 
>> > "Django users" group.
>> > To post to this group, send email to django-us...@googlegroups.com.
>> > To unsubscribe from this group, send email to 
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group 
>> > athttp://groups.google.com/group/django-users?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group 
>> athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: css files are not loading properly for admin screens

2010-05-19 Thread Sam Lai
Your Django instance isn't set up properly to serve media. Have you
configured your web server (Apache, nginx, Cherokee etc.) to serve
media? If so, what URLs are they mapped to? You need to set that into
the MEDIA_URL variable, e.g. /media/. What you have now doesn't look
right.

MEDIA_ROOT tells Django where your media files actually reside on your
machine. This would be something like /home/your_website/media/.

Once you have done that, you need to tell Django how to access the
admin's media files. Start by symlinking your admin's media directory
into your MEDIA_ROOT. Let's say you symlink it into admin, so it can
be accessed by MEDIA_URL/admin/

ADMIN_MEDIA_PREFIX tells how to access the admin media from the web.
It is separate to MEDIA_URL. Assuming the above (i.e. your admin media
symlink is inside the MEDIA_ROOT), you would set it to /media/admin/

Once you've done all that, it should work.

Reference -
http://docs.djangoproject.com/en/dev/ref/settings/
http://docs.djangoproject.com/en/1.2/howto/deployment/modpython/#id3

There's also a doc that tells you specifically how to set this up, but
I can't find it at the moment.

On 19 May 2010 15:09, Lokesh  wrote:
> Hi,
>
> CSS files are not loading when i try to access the admin screens.
>
> Here are the settings.py config file details
> MEDIA_ROOT = ''
> MEDIA_URL = 'http://127.0.0.1:8000'
> ADMIN_MEDIA_PREFIX = '/media/'
>
> Could some one please provide me help on this.
>
> Thanks a lot.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: One to One chat like Facebook?

2010-05-19 Thread Anand Agarwal
Hi Ivan

Thanks for the details, I will try out hotdot and let you know my feedback.


Regards
Anand
Got an Idea? BootStrap it Today!!




On Mon, May 17, 2010 at 8:33 PM, Ivan Uemlianin  wrote:

> Dear Anand
>
> Frederico Caceres' app [1,2] is worth a look, but note that it uses
> old-style repeated polling of the server.
>
> Alex Clemesha has written an exciting piece on developing real-time
> web apps with Django, Orbited and Twisted [3].  His demo application,
> hotdot [4], includes a real-time chat application.
>
> His blog also mentions Speeqe [5], which is a chat application
> integrating Django and ejabberd, the erlang xmpp server.
>
> Let us know how you get on.
>
> Best wishes
>
> Ivan
>
> [1]
> http://pythonhaven.wordpress.com/2009/07/13/django-powered-ajax-chat-%E2%80%93-part-2/
> [2]
> http://llaisdy.wordpress.com/2009/10/13/adding-a-django-application-to-pinax/
> [3]
> http://www.clemesha.org/blog/2009/dec/17/realtime-web-apps-python-django-orbited-twisted/
> [4]  http://clemesha.org/projects/hotdot/
> [5]  http://code.stanziq.com/speeqe
>
>
> On May 16, 11:13 am, Anand Agarwal  wrote:
> > Hi All
> >
> > Is there any chat application in django similar to facebook chat?
> >
> > Regards
> > Anand
> > Got an Idea? BootStrap it Today!!
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> > For more options, visit this group athttp://
> groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Ordering a QuerySet by a Python property ?

2010-05-19 Thread thierry
Hi all,

The order_by method makes possible to sort objects relatively to a
specified field. But how can I sort a QuerySet relatively to a Python
property ?

Thanks,

Thierry.

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



How to insert a search form inside Django?

2010-05-19 Thread ravi krishna
Hi,
I want to include a search button inside my Django, which retrieves data
from some google API or Wikimapia API, But i am stuck with adding a search
option inside Django. i am a beginner with Django and Python programming.
Can somebody please help me with this.

-- 
Regards,
Rav!

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