Using shell to add images

2009-09-22 Thread Timboy

Having issues saving model from within the shell.

Using File from from django.core.files import File

http://pastebin.com/f3030ca1e

Tried this several different ways...

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



Re: django twisted model

2009-05-21 Thread Timboy

Anyone familiar with using twisted and hooking it to a model?

On May 16, 8:55 pm, Timboy <corn13r...@gmail.com> wrote:
> I am looking to make a webmail client proof of concept in django. I
> ran across twisted mail and this 
> post:http://clemesha.org/blog/2009/apr/23/Django-on-Twisted-using-latest-t...
> showing how to use django on twisted.
>
> Can anyone point me in the right direction for actually getting data
> out of a twisted app into a django mail model?
>
> TIA
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Separate User namespace

2009-05-20 Thread Timboy

I have thought about this and will probably do so. I was just hoping
it would be easy to just add an additional namespace. Seems cleaner to
me.

On May 20, 11:46 am, Andy Mikhailenko <neith...@gmail.com> wrote:
> What about using emails or openIDs for authentication? These include
> namespaces per se ;)
>
> On May 20, 1:09 am, Timboy <corn13r...@gmail.com> wrote:
>
> > Initially we will have in the ballpark of 10,000 Private users. Anyone
> > have an idea on an additional user namespace?
>
> > On May 19, 8:42 am, Aneesh <aneeshvkulka...@gmail.com> wrote:
>
> > > How many private users do you have?  If it's just a small number,
> > > consider using the same model for all Users, and making some profiles
> > > public/private.  A couple usernames will be taken, but that shouldn't
> > > be a big deal.
>
> > > If you actually want a second namespace, I'm not sure of the best way
> > > to proceed.
>
> > > On May 18, 9:28 pm, Timboy <corn13r...@gmail.com> wrote:
>
> > > > I have a normal User model for our private users of our project we
> > > > also have a UserProfile for those users.
>
> > > > We need to have a public portion of our site as well with a separate
> > > > user namespace.
>
> > > > Please advise the best way to achieve our goal.
>
> > > > TIA
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Separate User namespace

2009-05-19 Thread Timboy

Initially we will have in the ballpark of 10,000 Private users. Anyone
have an idea on an additional user namespace?



On May 19, 8:42 am, Aneesh <aneeshvkulka...@gmail.com> wrote:
> How many private users do you have?  If it's just a small number,
> consider using the same model for all Users, and making some profiles
> public/private.  A couple usernames will be taken, but that shouldn't
> be a big deal.
>
> If you actually want a second namespace, I'm not sure of the best way
> to proceed.
>
> On May 18, 9:28 pm, Timboy <corn13r...@gmail.com> wrote:
>
> > I have a normal User model for our private users of our project we
> > also have a UserProfile for those users.
>
> > We need to have a public portion of our site as well with a separate
> > user namespace.
>
> > Please advise the best way to achieve our goal.
>
> > TIA
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Separate User namespace

2009-05-18 Thread Timboy

I have a normal User model for our private users of our project we
also have a UserProfile for those users.

We need to have a public portion of our site as well with a separate
user namespace.

Please advise the best way to achieve our goal.

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



django twisted model

2009-05-16 Thread Timboy

I am looking to make a webmail client proof of concept in django. I
ran across twisted mail and this post:
http://clemesha.org/blog/2009/apr/23/Django-on-Twisted-using-latest-twisted-web-wsgi/
showing how to use django on twisted.

Can anyone point me in the right direction for actually getting data
out of a twisted app into a django mail model?

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



Re: Custom primary key

2009-04-29 Thread Timboy

Thank you for your time and response Malcom, I appreciate it very
much.

On Apr 29, 3:42 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:
> On Wed, 2009-04-29 at 15:37 -0700, Timboy wrote:
> > I am trying to make a pk for an object that starts with the year
> > followed by seven additional digits. YYXXX I want the digits to
> > automatically increase like normal.
>
> > I'm guessing I need to pass force_insert=True to my save if not
> > self.pk. I'd appreciate some advice.
>
> If you're not using Django's AutoField for primary key values (which you
> aren't), then you need to always supply the primary key value before
> calling save(). Django cannot guess what value you want to put in there.
>
> Now, you could "provide" the value by specifying a (Python) function for
> the "default" attribute on, say, an integer field and use that to create
> the value, although there's then no way to enforce the sequential
> increase if multiple new models are created more or less imsultaneously
> in separate threads.
>
> I would encourage stepping back a bit to consider your problem in a
> different way, which might be much simpler. Use a normal
> auto-incrementing sequence for the primary key in the table (i.e. use
> Django's default) and have another field that specifies the year of
> creation. Then have a property or method on the model which combines the
> year-of-creation field with the pk value to get the combined value
> you're after for display or reference purposes. Modifications on this
> are possible if you're also doing lookups, etc.
>
> Or you could, at the database level, set the sequence value to a
> particular value before doing the first insert for a year. How this is
> done is database dependent and is done with direct database
> modification, not via Django directly (you could do it with
> cursor.execute(), but it's something you only want to do once a year, in
> any case).
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Custom primary key

2009-04-29 Thread Timboy

I am trying to make a pk for an object that starts with the year
followed by seven additional digits. YYXXX I want the digits to
automatically increase like normal.

I'm guessing I need to pass force_insert=True to my save if not
self.pk. I'd appreciate some advice.

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



Re: automatic updates for a set of model objects via email

2009-04-27 Thread Timboy

Reading back through I might still not have explained simply enough.

I have a VehicleSearch Model with a m2m to Vehicle and a FK to User. I
want to be able to notify the user that has the VehicleSearch object
when a vehicle inside of the m2m has been added or updated.

I'm looking for the best way to cross reference the new ones and the
best way to handle the notifications that the specific VehicleSearch
was updated with N new vehicles and there were changes to N vehicles.

TIA

On Apr 23, 10:42 pm, Timboy <corn13r...@gmail.com> wrote:
> Let me be more specific to my needs:
>
> Here is my example AutoSearch model:
> name = charfield
> uuid = uuid
> query = charfield
> autos = m2m
> updated = boolean
> emailed_on_update = boolean
> emailed_on_new = boolean
>
> Here are my needs:
>  * updates to this search send the user an email
>  * the user needs to know which autos were updated
>  * new autos email the user
>  * the user needs to know which autos are new
>
> Questions assuming 1000 users.
>
>  * Should this be a cron?
>  * should I add two more m2m's to autos 1 for new autos and 1 for
> updated autos? or is there a better way to keep track for the user?
>
> Thanks.
>
> On Apr 23, 10:20 pm, Alex Gaynor <alex.gay...@gmail.com> wrote:
>
> > On Fri, Apr 24, 2009 at 1:15 AM, Timboy <corn13r...@gmail.com> wrote:
>
> > > I want my users to be able to be updated for changes to specific
> > > models objects.
>
> > > Let's say a user does a search of vehicle listings and the search
> > > returns 3 cars. I want them to be able to be alerted when any of those
> > > three car listings get updated. What's the best way to accomplish
> > > this?
>
> > > TIA
>
> > The first thing to figure out is will this feature be for any model or for a
> > specific one?  The next step is to set up a DB table, it's probably going to
> > just be a few columns, a foreign key to user(or maybe just an email field if
> > you want unauthenticated users to be able to sign up for updates), and a
> > foreign key to the model(or a generic foriegn key).  Then you'd write a
> > signal handler, probably a post_save one, that sends out an email to the
> > appropriate people if it determines that the object has been changed, and it
> > would just send emails to everyone who's email is in the table.
>
> > Alex
>
> > --
> > "I disapprove of what you say, but I will defend to the death your right to
> > say it." --Voltaire
> > "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to handle database down time gracefully?

2009-04-24 Thread Timboy

I'm interested as well. You'd want to have a 500 with a nice
unexpected maintanence message.

On Apr 24, 4:51 am, realfun  wrote:
> Hi,
>
> I build a website(fayaa.com) on Bluehost using Django, but this month
> database down 3 times, during that period, user can only see an
> "Unexpected Exception" message, is there a way to redirect to a 404
> page instead?
>
> Regards,
> -realfun
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: automatic updates for a set of model objects via email

2009-04-23 Thread Timboy

Let me be more specific to my needs:

Here is my example AutoSearch model:
name = charfield
uuid = uuid
query = charfield
autos = m2m
updated = boolean
emailed_on_update = boolean
emailed_on_new = boolean

Here are my needs:
 * updates to this search send the user an email
 * the user needs to know which autos were updated
 * new autos email the user
 * the user needs to know which autos are new

Questions assuming 1000 users.

 * Should this be a cron?
 * should I add two more m2m's to autos 1 for new autos and 1 for
updated autos? or is there a better way to keep track for the user?

Thanks.

On Apr 23, 10:20 pm, Alex Gaynor <alex.gay...@gmail.com> wrote:
> On Fri, Apr 24, 2009 at 1:15 AM, Timboy <corn13r...@gmail.com> wrote:
>
> > I want my users to be able to be updated for changes to specific
> > models objects.
>
> > Let's say a user does a search of vehicle listings and the search
> > returns 3 cars. I want them to be able to be alerted when any of those
> > three car listings get updated. What's the best way to accomplish
> > this?
>
> > TIA
>
> The first thing to figure out is will this feature be for any model or for a
> specific one?  The next step is to set up a DB table, it's probably going to
> just be a few columns, a foreign key to user(or maybe just an email field if
> you want unauthenticated users to be able to sign up for updates), and a
> foreign key to the model(or a generic foriegn key).  Then you'd write a
> signal handler, probably a post_save one, that sends out an email to the
> appropriate people if it determines that the object has been changed, and it
> would just send emails to everyone who's email is in the table.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



automatic updates for a set of model objects via email

2009-04-23 Thread Timboy

I want my users to be able to be updated for changes to specific
models objects.

Let's say a user does a search of vehicle listings and the search
returns 3 cars. I want them to be able to be alerted when any of those
three car listings get updated. What's the best way to accomplish
this?

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



Re: Multi Page Form With Database Persistence

2009-04-23 Thread Timboy

Well I really want the data to post to the database at the same time
as well. Thanks n e way but I'll just re-write the form wizard to do
what I want.



On Apr 23, 9:51 pm, Timboy <corn13r...@gmail.com> wrote:
> I basically want to be able to skip to a specific step in the form
> wizard process.
>
> On Apr 20, 5:56 pm, Timboy <corn13r...@gmail.com> wrote:
>
> > I need to create a multiple page form that upon submit the information
> > is saved to the database so the user can finish it later.
>
> > I want to be able to check the data filled out on the form and
> > depending on the values entered present different pages to the user.
>
> > I know this is possible, I just don't know how and the best way to
> > accomplish this. I have looked into the FormWizard but it looks like
> > it is more meant for forms that go in a straight line.
>
> > Formwizard
> > Page1 --> Page2 --> Page3 --> Page4 --> Page5 --> Page6 --> Page7 -->
> > Page8
>
> > I want my form to be able to skip a page or insert one, depending on
> > the input given on those pages.
> > Page1 --> Page3 --> Page5 --> Page7 --> Page8
> > or
> > Page1 --> Page2 --> Page4 --> Page5 --> Page8
>
> > Example of my model:
>
> > #models.py
> > from django.db import models
>
> > class Poll(models.Model):
> >     question1 = models.CharField(max_length=200)
> >     pub_date1 = models.DateTimeField('date published')
> >     question2_state = USStateField()
> >     question3 = models.CharField(max_length=200)
> >     question4 = models.CharField(max_length=200)
> >     question5 = models.CharField(max_length=200)
> >     question6...
> >     agree = models.BooleanField(help_text='I agree that this is
> > correct')
>
> > #forms.py
> > from django import forms
>
> >  class PollForm1(forms.Form):
> >      question1 = forms.CharField(max_length=200)
> >      question2 = forms.ChoiceField(max_length=200)
>
> >  class PollForm2(forms.Form):
> >      question3 = forms.CharField(max_length=200)
>
> >  class PollForm3(forms.Form):
> >      question4 = forms.CharField(max_length=200)
>
> >  class PollForm4(forms.Form):
> >      question5 = forms.CharField(max_length=200)
> >      question6 = forms.CharField(max_length=200)
>
> >  class PollForm5...
> >  class PollFormN...
> >      agree = forms.BooleanField()
>
> > Thanks in advance for the help!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multi Page Form With Database Persistence

2009-04-23 Thread Timboy

I basically want to be able to skip to a specific step in the form
wizard process.

On Apr 20, 5:56 pm, Timboy <corn13r...@gmail.com> wrote:
> I need to create a multiple page form that upon submit the information
> is saved to the database so the user can finish it later.
>
> I want to be able to check the data filled out on the form and
> depending on the values entered present different pages to the user.
>
> I know this is possible, I just don't know how and the best way to
> accomplish this. I have looked into the FormWizard but it looks like
> it is more meant for forms that go in a straight line.
>
> Formwizard
> Page1 --> Page2 --> Page3 --> Page4 --> Page5 --> Page6 --> Page7 -->
> Page8
>
> I want my form to be able to skip a page or insert one, depending on
> the input given on those pages.
> Page1 --> Page3 --> Page5 --> Page7 --> Page8
> or
> Page1 --> Page2 --> Page4 --> Page5 --> Page8
>
> Example of my model:
>
> #models.py
> from django.db import models
>
> class Poll(models.Model):
>     question1 = models.CharField(max_length=200)
>     pub_date1 = models.DateTimeField('date published')
>     question2_state = USStateField()
>     question3 = models.CharField(max_length=200)
>     question4 = models.CharField(max_length=200)
>     question5 = models.CharField(max_length=200)
>     question6...
>     agree = models.BooleanField(help_text='I agree that this is
> correct')
>
> #forms.py
> from django import forms
>
>  class PollForm1(forms.Form):
>      question1 = forms.CharField(max_length=200)
>      question2 = forms.ChoiceField(max_length=200)
>
>  class PollForm2(forms.Form):
>      question3 = forms.CharField(max_length=200)
>
>  class PollForm3(forms.Form):
>      question4 = forms.CharField(max_length=200)
>
>  class PollForm4(forms.Form):
>      question5 = forms.CharField(max_length=200)
>      question6 = forms.CharField(max_length=200)
>
>  class PollForm5...
>  class PollFormN...
>      agree = forms.BooleanField()
>
> Thanks in advance for the help!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django forms validation with choice and m2m fields

2009-04-23 Thread Timboy

Thank you very much Alex!

On Apr 23, 9:28 pm, Alex Gaynor <alex.gay...@gmail.com> wrote:
> On Fri, Apr 24, 2009 at 12:25 AM, Timboy <corn13r...@gmail.com> wrote:
>
> > Does this data get checked to make sure that it is what was on the
> > form?
>
> > If I have a list of choices 1,2,3 and someone modifies the form to add
> > a # 4 and chooses that will django forms catch it or do I need to make
> > sure on every one of my fields that the entered value is what was in
> > the list?
>
> > TIA
>
> Yes, if someone submits data that isn't a valid choice Django forms will
> validate and reject it.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



django forms validation with choice and m2m fields

2009-04-23 Thread Timboy

Does this data get checked to make sure that it is what was on the
form?

If I have a list of choices 1,2,3 and someone modifies the form to add
a # 4 and chooses that will django forms catch it or do I need to make
sure on every one of my fields that the entered value is what was in
the list?

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



Multi Page Form With Database Persistence

2009-04-20 Thread Timboy

I need to create a multiple page form that upon submit the information
is saved to the database so the user can finish it later.

I want to be able to check the data filled out on the form and
depending on the values entered present different pages to the user.

I know this is possible, I just don't know how and the best way to
accomplish this. I have looked into the FormWizard but it looks like
it is more meant for forms that go in a straight line.

Formwizard
Page1 --> Page2 --> Page3 --> Page4 --> Page5 --> Page6 --> Page7 -->
Page8

I want my form to be able to skip a page or insert one, depending on
the input given on those pages.
Page1 --> Page3 --> Page5 --> Page7 --> Page8
or
Page1 --> Page2 --> Page4 --> Page5 --> Page8


Example of my model:

#models.py
from django.db import models

class Poll(models.Model):
question1 = models.CharField(max_length=200)
pub_date1 = models.DateTimeField('date published')
question2_state = USStateField()
question3 = models.CharField(max_length=200)
question4 = models.CharField(max_length=200)
question5 = models.CharField(max_length=200)
question6...
agree = models.BooleanField(help_text='I agree that this is
correct')

#forms.py
from django import forms

 class PollForm1(forms.Form):
 question1 = forms.CharField(max_length=200)
 question2 = forms.ChoiceField(max_length=200)

 class PollForm2(forms.Form):
 question3 = forms.CharField(max_length=200)

 class PollForm3(forms.Form):
 question4 = forms.CharField(max_length=200)

 class PollForm4(forms.Form):
 question5 = forms.CharField(max_length=200)
 question6 = forms.CharField(max_length=200)

 class PollForm5...
 class PollFormN...
 agree = forms.BooleanField()

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



Re: how to use email instead of username for user authentication?

2009-04-02 Thread Timboy

What's the best way to add users with an auto generating username? ie:
Taub.John, Smith.Tim, Smith.Tim2


On Apr 1, 3:37 am, johan.u...@student.hpi.uni-potsdam.de wrote:
> Best way is to write your own authentication backend I think.
>
> Check the 
> docs:http://docs.djangoproject.com/en/dev/topics/auth/?from=olddocs#writin...
>
> This article might also give you a good 
> idea:http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-mod...
>
> The actual authenticate function might look something like this:
>
> def authenticate(self, username=None, password=None):
>         # authenticate with email
>         try:
>                 user = self.user_class.objects.get(email=username)
>                 if user.check_password(password):
>                         return user
>         except self.user_class.DoesNotExist:
>                 # authentication with username
>                 try:
>                         user = self.user_class.objects.get(username=username)
>                         if user.check_password(password):
>                                 return user
>                 except self.user_class.DoesNotExist:
>                         # neither nor succesfull, so no user exists
>                         return None
>
> Beware: During registration I have forbidden usernames that might look
> like mail adresses (just unallow character @). Other than that there
> might be the rare possibility that people can not login with their
> username/password credentials if it username is the e-mail-adress used
> by another account.
>
> On Mar 31, 10:03 am, Rama Vadakattu  wrote:
>
> > The authentication model provided along with django is based on
> > username.
>
> > What to do to change the authentication based on email instead of
> > username?
>
> > To be more specific
> > ~~~
> >      With username authentication , to login user  we do the following
>
> >      user = authenticate(name,password)
> >      ...
> >      login(request,user)
>
> >      what to write for the above statements if we are authenticating
> > using email?
>
> >  For form
> >  ~
> > iam planning to write my own form which shows the fields
> > email,password and the validation.
> > Is this the correct approach?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to create ability to send email from the admin with django?

2009-04-02 Thread Timboy

In two lines:

from django.core.mail import send_mail

send_mail('Subject here', 'Here is the message.', 'f...@example.com',
['t...@example.com'], fail_silently=False)

Mail is sent using the SMTP host and port specified in the EMAIL_HOST
and EMAIL_PORT settings. The EMAIL_HOST_USER and EMAIL_HOST_PASSWORD
settings, if set, are used to authenticate to the SMTP server, and the
EMAIL_USE_TLS setting controls whether a secure connection is used.

On Apr 2, 8:42 am, ChrisR  wrote:
> I've been searching and trying to figure this out, but I haven't quite
> found the source that makes it snap in my mind.
>
> I'd like to be able to send an email or emails out from my site
> through the admin.  I have the email settings added to settings.py,
> but not sure where to go next.
>
> I've read the documentation about sending email on the django 
> site:http://docs.djangoproject.com/en/1.0/topics/email/
>
> The "Quick" example that allows you to send email in 2 lines doesn't
> make sense to me:
> "from django.core.mail import send_mail
>
> send_mail('Subject here', 'Here is the message.', 'f...@example.com',
>     ['@example.com'], fail_silently=False)"
>
> Where is that code supposed to live?  How do you actually send it?
> I've seen a few things that imply you did it from the Python API?
>
> Can someone point me in the right direction on how to make this happen
> through the admin?  Do I need to make a model for it?  What triggers
> the actual send then?
>
> Thanks for any help!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: persistent get url question

2009-03-26 Thread Timboy

I figured it out. I passed the requested calendars to my template and
used a forloop to pass them as a get request to the URL.

On Mar 26, 4:23 pm, Timboy <corn13r...@gmail.com> wrote:
> I've created a calendar view and users can select multiple calendars
> with checkboxes. It passes this: ?
> calendars=CALNAME=CALNAME2=CALNAME2 to the url and
> returns the proper events but when I change months it goes back to the
> default calendar...
>
> how can I make the selected calendars persistent?
>
> I was searching for some sort of solution and ran across the following
> link for 0.96. I'm hoping there is some sort of built in way. I would
> think that this would be somewhat of a common need for 
> sites.http://www.djangosnippets.org/snippets/1175/
>
> TIA
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



persistent get url question

2009-03-26 Thread Timboy

I've created a calendar view and users can select multiple calendars
with checkboxes. It passes this: ?
calendars=CALNAME=CALNAME2=CALNAME2 to the url and
returns the proper events but when I change months it goes back to the
default calendar...

how can I make the selected calendars persistent?

I was searching for some sort of solution and ran across the following
link for 0.96. I'm hoping there is some sort of built in way. I would
think that this would be somewhat of a common need for sites.
http://www.djangosnippets.org/snippets/1175/

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



Re: wondering how to do something similar to save_model for inline.

2009-01-07 Thread Timboy

Good call on the ModelAdmin spot. (user contacted me by email to see
if I had a solution yet.)

I got the formset.save() from here:
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-save-method
saying: "If your formset contains a ManyToManyField, you'll also need
to call formset.save_m2m() to ensure the many-to-many relationships
are saved properly."

Works now just had it in the wrong spot. thx!

On Jan 6, 9:23 pm, "Karen Tracey" <kmtra...@gmail.com> wrote:
> On Tue, Jan 6, 2009 at 10:10 PM, Timboy <corn13r...@gmail.com> wrote:
>
> > Still no solution to this. It has been confirmed by another user. Is
> > it a bug?
>
> (Where was it confirmed by another user?  I don't see that.)
>
> The doc list "save_formset" under "ModelAdmin methods" yet you seem to have
> added it to your inline admin class.  I also don't see any indication in the
> traceback you posted that your custom method is being called, which leads me
> to think where you have put it is not where it needs to be in order for it
> to be called.
>
> (Also you changed formset.save_m2m() from the example in the docs to
> formset.save().  I doubt that this change is correct.)
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: wondering how to do something similar to save_model for inline.

2009-01-06 Thread Timboy

Still no solution to this. It has been confirmed by another user. Is
it a bug?

On Dec 29 2008, 2:33 pm, Timboy <corn13r...@gmail.com> wrote:
> DB is sqlite3. Deleted DB file syncd and still same traceback.
> here is proper traceback paste:http://dpaste.com/103517/
>
> On Dec 28, 9:10 pm, Praveen <praveen.python.pl...@gmail.com> wrote:
>
> > This is your database error..
>
> > On Dec 28, 8:32 am, Timboy <corn13r...@gmail.com> wrote:
>
> > > Great link. I was really excited to try it.
>
> > > Here is my new inline:
> > > class rentalInline(admin.TabularInline):
> > >     model= Rent
> > >     extra = 3
> > >     raw_id_fields = ('movie',)
> > >     exclude = ['rented_by']
>
> > >     def save_formset(self, request, form, formset, change):
> > >         instances = formset.save(commit=False)
> > >         for instance in instances:
> > >             instance.rented_by = request.user
> > >             instance.save()
> > >         formset.save()
>
> > > I am still getting the same issue:
> > > Traceback:
> > > File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py"
> > > in get_response
> > >   86.                 response = callback(request, *callback_args,
> > > **callback_kwargs)
> > > File "/usr/lib/python2.5/site-packages/django/contrib/admin/sites.py"
> > > in root
> > >   157.                 return self.model_page(request, *url.split('/',
> > > 2))
> > > File "/usr/lib/python2.5/site-packages/django/views/decorators/
> > > cache.py" in _wrapped_view_func
> > >   44.         response = view_func(request, *args, **kwargs)
> > > File "/usr/lib/python2.5/site-packages/django/contrib/admin/sites.py"
> > > in model_page
> > >   176.         return admin_obj(request, rest_of_url)
> > > File "/usr/lib/python2.5/site-packages/django/contrib/admin/
> > > options.py" in __call__
> > >   197.             return self.change_view(request, unquote(url))
> > > File "/usr/lib/python2.5/site-packages/django/db/transaction.py" in
> > > _commit_on_success
> > >   238.                 res = func(*args, **kw)
> > > File "/usr/lib/python2.5/site-packages/django/contrib/admin/
> > > options.py" in change_view
> > >   583.                     self.save_formset(request, form, formset,
> > > change=True)
> > > File "/usr/lib/python2.5/site-packages/django/contrib/admin/
> > > options.py" in save_formset
> > >   382.         formset.save()
> > > File "/usr/lib/python2.5/site-packages/django/forms/models.py" in save
> > >   372.         return self.save_existing_objects(commit) +
> > > self.save_new_objects(commit)
> > > File "/usr/lib/python2.5/site-packages/django/forms/models.py" in
> > > save_new_objects
> > >   407.             self.new_objects.append(self.save_new(form,
> > > commit=commit))
> > > File "/usr/lib/python2.5/site-packages/django/forms/models.py" in
> > > save_new
> > >   473.         return save_instance(form, new_obj, exclude=
> > > [self._pk_field.name], commit=commit)
> > > File "/usr/lib/python2.5/site-packages/django/forms/models.py" in
> > > save_instance
> > >   59.         instance.save()
> > > File "/home/richard/work/svn/moviedb/../moviedb/store/models.py" in
> > > save
> > >   91.         super(Rent, self).save(**kwargs)
> > > File "/usr/lib/python2.5/site-packages/django/db/models/base.py" in
> > > save
> > >   307.         self.save_base(force_insert=force_insert,
> > > force_update=force_update)
> > > File "/usr/lib/python2.5/site-packages/django/db/models/base.py" in
> > > save_base
> > >   379.                 result = manager._insert(values,
> > > return_id=update_pk)
> > > File "/usr/lib/python2.5/site-packages/django/db/models/manager.py" in
> > > _insert
> > >   138.         return insert_query(self.model, values, **kwargs)
> > > File "/usr/lib/python2.5/site-packages/django/db/models/query.py" in
> > > insert_query
> > >   888.     return query.execute_sql(return_id)
> > > File "/usr/lib/python2.5/site-packages/django/db/models/sql/
> > > subqueries.py" in execute_sql
> > >   308.         cursor = super(InsertQuery, self).execute_sql(None)
> > > File "/usr/lib/python2.5/site-packages/django/db/models/sql/query.py"
> > > in execute_sql
> > >   1700.         cursor.execute(sql, params)
> > > File "/usr/lib/python2.5/site-packages/django/db/backends/util.py" in
> > > execute
> > >   19.             return self.cursor.execute(sql, params)
>
> > > Exception Type: IntegrityError at /admin/store/renter/4/
> > > Exception Value: null value in column "rented_by_id" violates not-null
> > > constraint
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: wondering how to do something similar to save_model for inline.

2008-12-29 Thread Timboy

DB is sqlite3. Deleted DB file syncd and still same traceback.
here is proper traceback paste: http://dpaste.com/103517/

On Dec 28, 9:10 pm, Praveen <praveen.python.pl...@gmail.com> wrote:
> This is your database error..
>
> On Dec 28, 8:32 am, Timboy <corn13r...@gmail.com> wrote:
>
> > Great link. I was really excited to try it.
>
> > Here is my new inline:
> > class rentalInline(admin.TabularInline):
> >     model= Rent
> >     extra = 3
> >     raw_id_fields = ('movie',)
> >     exclude = ['rented_by']
>
> >     def save_formset(self, request, form, formset, change):
> >         instances = formset.save(commit=False)
> >         for instance in instances:
> >             instance.rented_by = request.user
> >             instance.save()
> >         formset.save()
>
> > I am still getting the same issue:
> > Traceback:
> > File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py"
> > in get_response
> >   86.                 response = callback(request, *callback_args,
> > **callback_kwargs)
> > File "/usr/lib/python2.5/site-packages/django/contrib/admin/sites.py"
> > in root
> >   157.                 return self.model_page(request, *url.split('/',
> > 2))
> > File "/usr/lib/python2.5/site-packages/django/views/decorators/
> > cache.py" in _wrapped_view_func
> >   44.         response = view_func(request, *args, **kwargs)
> > File "/usr/lib/python2.5/site-packages/django/contrib/admin/sites.py"
> > in model_page
> >   176.         return admin_obj(request, rest_of_url)
> > File "/usr/lib/python2.5/site-packages/django/contrib/admin/
> > options.py" in __call__
> >   197.             return self.change_view(request, unquote(url))
> > File "/usr/lib/python2.5/site-packages/django/db/transaction.py" in
> > _commit_on_success
> >   238.                 res = func(*args, **kw)
> > File "/usr/lib/python2.5/site-packages/django/contrib/admin/
> > options.py" in change_view
> >   583.                     self.save_formset(request, form, formset,
> > change=True)
> > File "/usr/lib/python2.5/site-packages/django/contrib/admin/
> > options.py" in save_formset
> >   382.         formset.save()
> > File "/usr/lib/python2.5/site-packages/django/forms/models.py" in save
> >   372.         return self.save_existing_objects(commit) +
> > self.save_new_objects(commit)
> > File "/usr/lib/python2.5/site-packages/django/forms/models.py" in
> > save_new_objects
> >   407.             self.new_objects.append(self.save_new(form,
> > commit=commit))
> > File "/usr/lib/python2.5/site-packages/django/forms/models.py" in
> > save_new
> >   473.         return save_instance(form, new_obj, exclude=
> > [self._pk_field.name], commit=commit)
> > File "/usr/lib/python2.5/site-packages/django/forms/models.py" in
> > save_instance
> >   59.         instance.save()
> > File "/home/richard/work/svn/moviedb/../moviedb/store/models.py" in
> > save
> >   91.         super(Rent, self).save(**kwargs)
> > File "/usr/lib/python2.5/site-packages/django/db/models/base.py" in
> > save
> >   307.         self.save_base(force_insert=force_insert,
> > force_update=force_update)
> > File "/usr/lib/python2.5/site-packages/django/db/models/base.py" in
> > save_base
> >   379.                 result = manager._insert(values,
> > return_id=update_pk)
> > File "/usr/lib/python2.5/site-packages/django/db/models/manager.py" in
> > _insert
> >   138.         return insert_query(self.model, values, **kwargs)
> > File "/usr/lib/python2.5/site-packages/django/db/models/query.py" in
> > insert_query
> >   888.     return query.execute_sql(return_id)
> > File "/usr/lib/python2.5/site-packages/django/db/models/sql/
> > subqueries.py" in execute_sql
> >   308.         cursor = super(InsertQuery, self).execute_sql(None)
> > File "/usr/lib/python2.5/site-packages/django/db/models/sql/query.py"
> > in execute_sql
> >   1700.         cursor.execute(sql, params)
> > File "/usr/lib/python2.5/site-packages/django/db/backends/util.py" in
> > execute
> >   19.             return self.cursor.execute(sql, params)
>
> > Exception Type: IntegrityError at /admin/store/renter/4/
> > Exception Value: null value in column "rented_by_id" violates not-null
> > constraint
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: wondering how to do something similar to save_model for inline.

2008-12-27 Thread Timboy

Great link. I was really excited to try it.

Here is my new inline:
class rentalInline(admin.TabularInline):
model= Rent
extra = 3
raw_id_fields = ('movie',)
exclude = ['rented_by']

def save_formset(self, request, form, formset, change):
instances = formset.save(commit=False)
for instance in instances:
instance.rented_by = request.user
instance.save()
formset.save()

I am still getting the same issue:
Traceback:
File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py"
in get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "/usr/lib/python2.5/site-packages/django/contrib/admin/sites.py"
in root
  157. return self.model_page(request, *url.split('/',
2))
File "/usr/lib/python2.5/site-packages/django/views/decorators/
cache.py" in _wrapped_view_func
  44. response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.5/site-packages/django/contrib/admin/sites.py"
in model_page
  176. return admin_obj(request, rest_of_url)
File "/usr/lib/python2.5/site-packages/django/contrib/admin/
options.py" in __call__
  197. return self.change_view(request, unquote(url))
File "/usr/lib/python2.5/site-packages/django/db/transaction.py" in
_commit_on_success
  238. res = func(*args, **kw)
File "/usr/lib/python2.5/site-packages/django/contrib/admin/
options.py" in change_view
  583. self.save_formset(request, form, formset,
change=True)
File "/usr/lib/python2.5/site-packages/django/contrib/admin/
options.py" in save_formset
  382. formset.save()
File "/usr/lib/python2.5/site-packages/django/forms/models.py" in save
  372. return self.save_existing_objects(commit) +
self.save_new_objects(commit)
File "/usr/lib/python2.5/site-packages/django/forms/models.py" in
save_new_objects
  407. self.new_objects.append(self.save_new(form,
commit=commit))
File "/usr/lib/python2.5/site-packages/django/forms/models.py" in
save_new
  473. return save_instance(form, new_obj, exclude=
[self._pk_field.name], commit=commit)
File "/usr/lib/python2.5/site-packages/django/forms/models.py" in
save_instance
  59. instance.save()
File "/home/richard/work/svn/moviedb/../moviedb/store/models.py" in
save
  91. super(Rent, self).save(**kwargs)
File "/usr/lib/python2.5/site-packages/django/db/models/base.py" in
save
  307. self.save_base(force_insert=force_insert,
force_update=force_update)
File "/usr/lib/python2.5/site-packages/django/db/models/base.py" in
save_base
  379. result = manager._insert(values,
return_id=update_pk)
File "/usr/lib/python2.5/site-packages/django/db/models/manager.py" in
_insert
  138. return insert_query(self.model, values, **kwargs)
File "/usr/lib/python2.5/site-packages/django/db/models/query.py" in
insert_query
  888. return query.execute_sql(return_id)
File "/usr/lib/python2.5/site-packages/django/db/models/sql/
subqueries.py" in execute_sql
  308. cursor = super(InsertQuery, self).execute_sql(None)
File "/usr/lib/python2.5/site-packages/django/db/models/sql/query.py"
in execute_sql
  1700. cursor.execute(sql, params)
File "/usr/lib/python2.5/site-packages/django/db/backends/util.py" in
execute
  19. return self.cursor.execute(sql, params)

Exception Type: IntegrityError at /admin/store/renter/4/
Exception Value: null value in column "rented_by_id" violates not-null
constraint
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



wondering how to do something similar to save_model for inline.

2008-12-27 Thread Timboy

I have an admin object where I want to pass in the request.user on
save. It works fine in my normal admin class but not for the inline
version.

(works fine here):
class RentAdmin(admin.ModelAdmin):
exclude = ['rented_by']
list_display = ('renter', 'movie', 'late', 'owed', 'paid',
'due_date', 'rented_by')
sort_by = '-due_date'
raw_id_fields = ('renter', 'movie')

(but not here):
class rentalInline(admin.TabularInline):
model= Rent
extra = 3
raw_id_fields = ('movie',)
exclude = ['rented_by']

def save_model(self, request, obj, form, change):
if not change:
obj.rented_by = request.user
obj.save()

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



Re: How do wire Userprofile to UserAdmin ?

2008-12-09 Thread Timboy

The problem with this solution is that you are unable to sort and/or
filter by anything you "wire" to the User admin page. #9463 is one I
have posted a bit ago.

On Dec 9, 9:43 am, "Ronny Haryanto" <[EMAIL PROTECTED]> wrote:
> On Tue, Dec 9, 2008 at 8:58 PM, mahesh <[EMAIL PROTECTED]> wrote:
> > How do wire Userprofile to UserAdmin ?
>
> Here's one way to do it:
>
> # admin.py
> from django.contrib import admin
> from django.contrib.auth.admin import UserAdmin
> from django.contrib.auth.models import User
>
> from myproj.myapp.models import UserProfile
>
> class UserProfileAdminInline(admin.TabularInline):
>     model = UserProfile
>
> class NewUserAdmin(UserAdmin):
>     inlines = [UserProfileAdminInline]
>
> admin.site.unregister(User)
> admin.site.register(User, NewUserAdmin)
>
> Ronny
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django storage method question

2008-12-09 Thread Timboy

I'm having an issue passing a buffered StringIO to the FileField
object.

Here is my code:

##models.py
from django.db import models
from business.models import Business

class PdfFile(models.Model):
business = models.ForeignKey(Business)
pdf = models.FileField(upload_to='get_pdf_path')
created = models.DateTimeField(editable=False)

##console
from cStringIO import StringIO
from reportlab.pdfgen import canvas
from pdf.models import PdfFile
from business.models import Business
from django.core.files.base import ContentFile
from datetime import datetime

buffer = StringIO()

p = canvas.Canvas(buffer)

p.drawString(100, 100, "Hello world.")

p.showPage()
p.save()
business1 = business.objects.get(id=1)

f = ContentFile(buffer.getvalue())
PdfFile.pdf.save('blah.pdf', f)
###
I've tried this as well:
path = default_storage.save('pdf/1/1.pdf', ContentFile(buffer.getvalue
()))
test = PdfFile(listing = listing1,pdf=path, created = datetime.now())
test.save()

The issue with thtis is that the path object actually creates the file
and then when I pass it to save it actually sets the file to my media
directory/test and doesn't name the pdf or even show the proper pdf
dir.

My goal is to pass my StringIO object directly to the FileField for
upload to my upload_to dir...

TIA

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