Re: return json format

2010-08-20 Thread Emily Rodgers
What goes wrong?

On Aug 20, 10:34 am, Imad Elharoussi 
wrote:
> It's not the case for me  !!!
>
> 2010/8/20 Emily Rodgers 
>
> > On Aug 20, 10:01 am, Imad Elharoussi 
> > wrote:
> > > Hello
>
> > > How can we return an object in a json format?
>
> > > it is like this :
>
> > > return HttpResponse(simplejson.dumps(ihmAgentRoot),
> > >                                     mimetype='application/json')
>
> > > or do we need an other thing?
>
> > > thank you
>
> > That is what I do and it works.
>
> > --
> > 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: return json format

2010-08-20 Thread Emily Rodgers
On Aug 20, 10:01 am, Imad Elharoussi 
wrote:
> Hello
>
> How can we return an object in a json format?
>
> it is like this :
>
> return HttpResponse(simplejson.dumps(ihmAgentRoot),
>                                     mimetype='application/json')
>
> or do we need an other thing?
>
> thank you

That is what I do and it works.

-- 
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 execute some user defined codes (functions) when Django boot?

2010-08-18 Thread Emily Rodgers
Hi,

I still don't really understand what you are trying to do, but it
sounds like Mathieu does and has offered you some pretty useful
advice.

If his link below helps you fix what you are trying to do, please let
us know what you did (this is really useful for others with the same
problem), and if not, please come back and ask again.

Em

On Aug 18, 7:05 am, Tang Daogang  wrote:
> hi, Emily,
>
> Let me introduce Scala/Lift as example.
>
> Every lift project has a file named 'Boot.scala', this file will only
> be executed once when this project boots up. In this file, we can
> write some initial codes to initial project and some userdefined
> structures.
>
> Emm, that's it. I want to find one file acting like Boot.scala of Lift
> within Django, but failed. If there is one file like that, I will put
> my plugins registering codes into it, thus, when I type "python
> manage.py runserver", it can be executed automatically and only once.
> By it, my plugins can be registered when app boot up.
>
> Do you understand my meaning? Welcome suggestion.
>
> On 8月17日, 下午8时45分, Emily Rodgers  wrote:
>
> > On Aug 17, 2:26 am, Tang Daogang  wrote:
>
> > > Dear all,
>
> > > Recently, I have developed a plugin system for my app, and I want to
> > > register those plugins when my app boot up, this need to execute some
> > > user defined codes (functions) in app boot procedure, I don't know
> > > where insert my registering codes to, anyone can help?
>
> > > Thank you.
>
> > Hi,
>
> > I don't know how to help you, but I think it is because you haven't
> > explained what you want to do thoroughly enough.
>
> > What do you mean by a plugin system, and what do you mean by
> > registering them with the app on boot up? Are you talking about
> > including another python module in your code? Or perhaps including
> > another django app in your code?
>
> > Can you give us a bit more information (and maybe examples) of what
> > you are trying to do.
>
> > Cheers,
> > Em

-- 
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 execute some user defined codes (functions) when Django boot?

2010-08-17 Thread Emily Rodgers
On Aug 17, 2:26 am, Tang Daogang  wrote:
> Dear all,
>
> Recently, I have developed a plugin system for my app, and I want to
> register those plugins when my app boot up, this need to execute some
> user defined codes (functions) in app boot procedure, I don't know
> where insert my registering codes to, anyone can help?
>
> Thank you.

Hi,

I don't know how to help you, but I think it is because you haven't
explained what you want to do thoroughly enough.

What do you mean by a plugin system, and what do you mean by
registering them with the app on boot up? Are you talking about
including another python module in your code? Or perhaps including
another django app in your code?

Can you give us a bit more information (and maybe examples) of what
you are trying to do.

Cheers,
Em

-- 
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: confusing query involving time ranges

2010-08-13 Thread Emily Rodgers


On Aug 13, 11:18 am, Steven Davidson 
wrote:
> > It would have to be another datetime field rather than an is_current flag
> > because an is_current flag wouldn't help me for queries in the past (if that
> > makes sense).
>
> Ah yes, of course, I had not fully grasped that bit. A nullable foreign key
> reference to the State that supersedes it might come in useful in future,
> and avoids adding another pesky date field. But thinking about it some more
> it would probably make the ORM query a little more involved.

I actually like that idea. Like a linked list. It would mean the
django query could be simpler, and the post processing wouldn't be too
bad.

-- 
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: confusing query involving time ranges

2010-08-13 Thread Emily Rodgers


On Aug 13, 9:51 am, Steven Davidson 
wrote:
> Hmm, I can't fathom it.
>
> I would opt for a single simple query that returns a little more than you
> need and post-process it in python. This would be more maintainable than a
> hairy ORM query, I'd say; but if you have vast numbers of results that may
> not be appropriate.
>
> Alternatively, and presuming you can't add and keep up to date an
> 'is_current' (or whatever) column in the database to make the status of a
> given State explicit, you could construct a database view which computes
> this flag instead, backed by a different model with Options.managed = False.
>
> That's the view from my armchair, anyway!
> Steven.

Thanks - yeah if I can't figure it out I may have to go for adding
another field into the model. It would have to be another datetime
field rather than an is_current flag because an is_current flag
wouldn't help me for queries in the past (if that makes sense).

-- 
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: confusing query involving time ranges

2010-08-13 Thread Emily Rodgers
On Aug 12, 8:26 pm, Alec Shaner  wrote:
> Hopefully some django sql guru will give you a better answer, but I'll take
> a stab at it.
>
> What you describe does sound pretty tricky. Is this something that has to be
> done in a single query statement?

It doesn't have to be, but I would like to try to use a single query
that I can index the database for if possible.

>  If you just need to build a list of
> objects you could do it in steps, e.g.:
>
> # Get all State objects that span the requested dt
> q1 = State.objects.filter(first_dt__lte=dt, last_dt__gte=dt)
>
> # Get all State objects where foo is not already in q1, but have a last_dt
> prior to requested dt
> q1_foo = q1.values_list('foo')
> q2 =
> State.objects.exclude(foo__in=q1_foo).filter(last_dt__lt=dt).order_by('-last_dt')
>
> But q2 would not have unique foo entries, so some additional logic would
> need to be applied to get the first occurrence of each distinct foo value in
> q2.
>
> Probably not the best solution, but maybe it could give you some hints to
> get started.
>

Thanks. I may have to do this if I can't figure out a single
statement.


> On Thu, Aug 12, 2010 at 12:51 PM, Emily Rodgers <
>
> emily.kate.rodg...@gmail.com> wrote:
> > Hi,
>
> > I am a bit stuck on this and can't seem to figure out what to do.
>
> > I have a model that (stripped down for this question) looks a bit like
> > this:
>
> > class State(models.Model):
> >    first_dt = models.DateTimeField(null=True)
> >    last_dt = models.DateTimeField(null=True)
> >    foo = models.CharField(FooModel)
> >    bar = models.ForeignKey(BarModel, null=True)
> >    meh = models.ForeignKey(MehModel, null=True)
>
> > This is modeling / logging state of various things in time (more
> > specifically a mapping of foo to various other bits of data). The data
> > is coming from multiple sources, and what information those sources
> > provide varies a lot, but all of them provide foo and a date plus some
> > other information.
>
> > What I want to do, is given a point in time, return all the 'states'
> > that span that point in time. This seems trivial except for one thing
> > - a state for a particular 'foo' may still be persisting after the
> > last_dt until the next 'state' for that 'foo' starts. This means that
> > if there are no other 'states' between the point in time and the start
> > of the next state for a given foo, I want to return that state.
>
> > I have built a query that kindof explains what I want to do (but
> > obviously isn't possible in its current form):
>
> > dt = '2010-08-12 15:00:00'
>
> > lookups = State.objects.filter(
> >    Q(
> >        Q(first_dt__lte=dt) & Q(last_dt__gte=dt) |
> >        Q(first_dt__lte=dt) &
>
> > Q(last_dt=State.objects.filter(foo=F('foo')).filter(first_dt__lte=dt).latest('last_dt'))
> >    )
> > )
>
> > I know this doesn't work, but I think it illustrates what I am trying
> > to do better than words do.
>
> > Does anyone have any advice? Should I be using annotate or something
> > to show what the last_dt for each foo is? I might be being really
> > stupid and completely missing something but I have been trying to
> > figure this out for too long!
>
> > Cheers,
> > Emily
>
> > --
> > 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: confusing query involving time ranges

2010-08-13 Thread Emily Rodgers
On Aug 12, 10:00 pm, Paulo Almeida 
wrote:
> Can you sequentially add the states for each foo? I'm thinking of something
> like:
>
> states = []
> for foo in foos:
>     foo_state = State.objects.filter(foo=foo, first_dt__lte=dt,
> last_dt__gte=dt)
>     if foo_state:
>         states.append(foo_state)
>     else:
>         states = State.objects.filter(foo=foo, last_dt__lte=dt):
>         states.append(state.latest)
>
> Of course you would have to define latest in the model Meta.
>
> - Paulo

The thing is, there could be say 3000 distinct foos in the table. It
would take ages to return the results if I did this. I was hoping to
do it in one query. Might have to revert to SQL if I can't do it using
the django ORM.

>
> On Thu, Aug 12, 2010 at 8:26 PM, Alec Shaner  wrote:
> > Hopefully some django sql guru will give you a better answer, but I'll take
> > a stab at it.
>
> > What you describe does sound pretty tricky. Is this something that has to
> > be done in a single query statement? If you just need to build a list of
> > objects you could do it in steps, e.g.:
>
> > # Get all State objects that span the requested dt
> > q1 = State.objects.filter(first_dt__lte=dt, last_dt__gte=dt)
>
> > # Get all State objects where foo is not already in q1, but have a last_dt
> > prior to requested dt
> > q1_foo = q1.values_list('foo')
> > q2 =
> > State.objects.exclude(foo__in=q1_foo).filter(last_dt__lt=dt).order_by('-last_dt')
>
> > But q2 would not have unique foo entries, so some additional logic would
> > need to be applied to get the first occurrence of each distinct foo value in
> > q2.
>
> > Probably not the best solution, but maybe it could give you some hints to
> > get started.
>
> > On Thu, Aug 12, 2010 at 12:51 PM, Emily Rodgers <
> > emily.kate.rodg...@gmail.com> wrote:
>
> >> Hi,
>
> >> I am a bit stuck on this and can't seem to figure out what to do.
>
> >> I have a model that (stripped down for this question) looks a bit like
> >> this:
>
> >> class State(models.Model):
> >>    first_dt = models.DateTimeField(null=True)
> >>    last_dt = models.DateTimeField(null=True)
> >>    foo = models.CharField(FooModel)
> >>    bar = models.ForeignKey(BarModel, null=True)
> >>    meh = models.ForeignKey(MehModel, null=True)
>
> >> This is modeling / logging state of various things in time (more
> >> specifically a mapping of foo to various other bits of data). The data
> >> is coming from multiple sources, and what information those sources
> >> provide varies a lot, but all of them provide foo and a date plus some
> >> other information.
>
> >> What I want to do, is given a point in time, return all the 'states'
> >> that span that point in time. This seems trivial except for one thing
> >> - a state for a particular 'foo' may still be persisting after the
> >> last_dt until the next 'state' for that 'foo' starts. This means that
> >> if there are no other 'states' between the point in time and the start
> >> of the next state for a given foo, I want to return that state.
>
> >> I have built a query that kindof explains what I want to do (but
> >> obviously isn't possible in its current form):
>
> >> dt = '2010-08-12 15:00:00'
>
> >> lookups = State.objects.filter(
> >>    Q(
> >>        Q(first_dt__lte=dt) & Q(last_dt__gte=dt) |
> >>        Q(first_dt__lte=dt) &
>
> >> Q(last_dt=State.objects.filter(foo=F('foo')).filter(first_dt__lte=dt).latest('last_dt'))
> >>    )
> >> )
>
> >> I know this doesn't work, but I think it illustrates what I am trying
> >> to do better than words do.
>
> >> Does anyone have any advice? Should I be using annotate or something
> >> to show what the last_dt for each foo is? I might be being really
> >> stupid and completely missing something but I have been trying to
> >> figure this out for too long!
>
> >> Cheers,
> >> Emily
>
> >> --
> >> 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.

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



confusing query involving time ranges

2010-08-12 Thread Emily Rodgers
Hi,

I am a bit stuck on this and can't seem to figure out what to do.

I have a model that (stripped down for this question) looks a bit like
this:

class State(models.Model):
first_dt = models.DateTimeField(null=True)
last_dt = models.DateTimeField(null=True)
foo = models.CharField(FooModel)
bar = models.ForeignKey(BarModel, null=True)
meh = models.ForeignKey(MehModel, null=True)

This is modeling / logging state of various things in time (more
specifically a mapping of foo to various other bits of data). The data
is coming from multiple sources, and what information those sources
provide varies a lot, but all of them provide foo and a date plus some
other information.

What I want to do, is given a point in time, return all the 'states'
that span that point in time. This seems trivial except for one thing
- a state for a particular 'foo' may still be persisting after the
last_dt until the next 'state' for that 'foo' starts. This means that
if there are no other 'states' between the point in time and the start
of the next state for a given foo, I want to return that state.

I have built a query that kindof explains what I want to do (but
obviously isn't possible in its current form):

dt = '2010-08-12 15:00:00'

lookups = State.objects.filter(
Q(
Q(first_dt__lte=dt) & Q(last_dt__gte=dt) |
Q(first_dt__lte=dt) &
Q(last_dt=State.objects.filter(foo=F('foo')).filter(first_dt__lte=dt).latest('last_dt'))
)
)

I know this doesn't work, but I think it illustrates what I am trying
to do better than words do.

Does anyone have any advice? Should I be using annotate or something
to show what the last_dt for each foo is? I might be being really
stupid and completely missing something but I have been trying to
figure this out for too long!

Cheers,
Emily

-- 
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: model inheritance, abtract=True

2010-08-05 Thread Emily Rodgers


On Aug 5, 1:50 pm, Roald de Vries  wrote:
> Dear all,
>
> I have the following error, and don't know what it means:
>
>      Error: One or more models did not validate:
>      update.personupdate: 'address' has a relation with model Address,  
> which has either not been installed or is abstract.
>
> I did a pretty big refactoring, but I think the problems started when  
> I separated my Person class into an abstract base class PersonProfile  
> and a derived class Person, and added the class PersonUpdate, deriving  
> from PersonProfile too.
>
> Can anybody help?
>
> Thanks in advance, cheers,
>
> Roald

Can you provide some code snippets from your model definitions?

-- 
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 foreign key fields be empty?

2010-07-19 Thread Emily Rodgers


On Jul 19, 3:00 pm, rmschne  wrote:
[snip]
> The pointer you gave, thanks very much, explains how to set the data
> model to allow nulls, which I've done already.  Further, as I
> originally mentioned, I'm not using Django to control data entry, so
> the None=True in the data model doesn't really have any impact, I
> think.  Perhaps i'm wrong on that; but no matter because the data with
> null parent fields are indeed in the database.
>
> My problem, perhaps badly explained, was to extract with Django
> queryset all those records in the without parents.  That's what's
> vexing me.

Hi,

I think the query you are looking for is quite simple.

>From what I understand (correct me if I have got it wrong), your
models are something like this:

class ChildModel(models.Model):
foo = models.CharField(max_length=20)
parent = models.ForeignKey(Parent, null=True,
related_name="child")

class ParentModel(models.Model):
bar = models.CharField(max_length=20)

To get children without parents, you just do:

ChildModel.objects.filter(parent__isnull=True)

The first time I read your question I was really confused (I think
because you had got so many replies that weren't answering your
question, I thought it was more complicated than it actually was), and
thought you had got your child / parent analogy the wrong way and were
actually asking how to do the query from the other side (ie actually
getting childless parents), which is a bit more complicated, but not
much, so I figured out how to do that too (if you care).

To get the childless parents you do:

childless= ParentModel.objects.filter(child__isnull=True)

Be warned though, if you want to use it to find the parents that have
children (ie aren't childless), you *don't* want to do this:

parents = ParentModel.objects.filter(child__isnull=False)  # won't
give you what you expect

because if the foreign key is not one to one, then you will get the
multiplicity for want of a better word. i.e. if you have one parent
record that is a ForeignKey from two children, then that parent will
be returned twice. To eliminate these duplicates, you should do:

parents = ParentModel.objects.filter(child__isnull=False).distinct()

Hope that helps in some way (rather than confuses),
Em

-- 
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: Passenger 57 - a Django query problem

2010-02-18 Thread Emily Rodgers


On Feb 18, 9:25 am, Atamert Ölçgen  wrote:
> Hi Sithembewena,
>
> On Thursday 18 February 2010 00:27:10 Sithembewena Lloyd Dube wrote:> Emily 
> provided an answer according to what she understood from the OP. No
> > harm in doing that, at least not worse than no attempt at giving a
> > solution..
>
> > I think that people who have a problem with posts, even vague ones, should
> > stay away from them - let those that would try to help, to do so
> > unhindered..
>
> > We have no interest in your personal coding style: attempt to help, or stay
> > away.
>
> Bruno is trying to help in his own way. Let's not be unkind to each other like
> that.

I think he stopped helping when he started using phrases like 'crystal
ball' and 'wild-guess programming'. They are hostile responses.

The django-users group used to be a friendly place where people could
ask sometimes daft, sometimes difficult questions and get a useful
reply (in either case). This has been happening less and less lately.
People get responses telling them to learn how to post a question, or
just critising them for not being specific enough about what they want
to know, and this is just a bit too hostile IMO. If you think someone
hasn't provided enough information, it is helpful to ask them direct
questions that they can answer to provide a useful context (without
making them feel stupid). Often they aren't familiar with django /
python / web development, and don't really know what is required for a
useful answer to be given. It is our job to help them, not scare them
away.

One of the (many) great things about django is the community. Please
can we be friendly and helpful here instead of answering questions
with unhelpful responses?

> Also, please use your e-mail app's **draft** feature and send your reply when
> it's **done**.

I suspect that was unintentional :-)

>
> --
> Saygılarımla,
> Atamert Ölçgen
>
>  -+-
>  --+
>  +++
>
> www.muhuk.com
> mu...@jabber.org

-- 
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: Passenger 57 - a Django query problem

2010-02-17 Thread Emily Rodgers


On Feb 17, 11:20 am, bruno desthuilliers
 wrote:
> On Feb 17, 10:12 am, Emily Rodgers 
> wrote:> On Feb 16, 4:50 pm, bruno desthuilliers
> > > I'm afraid I don't really get what difference it would make. Note that
> > > my question was genuine - I know zilch about the problem domain, I
> > > don't have the fisrt clue about what an "Alliance" might be, so I
> > > don't know if that relationship is redundant or if it's totally
> > > distinct from what you'd get thru the passenger/flight/operator/
> > > memberships link.
>
> > My assumptions
> (snip)
> > If this is Derek's meaning then
> (snip)
> >  Also, and
> > airline may be
>
> (snip)
>
> Sorry but that's WAY too much assumptions for me. I don't do wild-
> guess programming, it's just a waste of everyone's time.

As I said, we aren't doing his coding for him, more giving examples of
ways to query this kind of thing. Sometimes (particularly if you are a
newbie) it is difficult to explain all of your requirements for a
problem in a concise way to a news group in order to satisfy people
who don't do 'wild-guess programming', and have to simplify things a
lot as it is because you may not want to share your code with the
world. Often in order to give a helpful reply to these types of
questions (rather than a dismissive response) you have to make some
assumptions. Presumably the OP will be able to tell if these
assumptions are reasonable, and if not, this discussion may help to
improve his design.

>
> > I may be completely wrong of course,
>
> !-)
>
> > and it would be interesting to
> > hear from the OP what his thoughts are.
>
> Indeed.

-- 
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: Passenger 57 - a Django query problem

2010-02-17 Thread Emily Rodgers


On Feb 16, 4:50 pm, bruno desthuilliers
 wrote:
> On Feb 16, 4:54 pm, Emily Rodgers 
> wrote:
>
>
>
> > On Feb 16, 3:39 pm, bruno desthuilliers
>
> >  wrote:
> > > On Feb 16, 2:56 pm, Derek  wrote:
> > [snip]
> > > Ain't that "memberships" relationship redundant with passenger->flight-
>
> > > >operator->memberships ?
>
> > I reckon he probably wants to do is split passenger up:
>
> > class Passenger(models.Model):
> >     customer = models.ForeignKey(User)
> >     flight = models.ForeignKey(Flight)
>
> > and have memberships as an attribute of the user.
>
> I'm afraid I don't really get what difference it would make. Note that
> my question was genuine - I know zilch about the problem domain, I
> don't have the fisrt clue about what an "Alliance" might be, so I
> don't know if that relationship is redundant or if it's totally
> distinct from what you'd get thru the passenger/flight/operator/
> memberships link.

My assumptions came from analogous cases in the real world. Often
companies group together to give some kind of club that customers can
sign up to to get benefits of discounts from all companies in the
group (reward cards are the most obvious case I can think of).

If this is Derek's meaning then the passenger (or I think user) may
have memberships to any number of such reward schemes. Also, and
airline may be in more than one alliance (or group that offers a
certain discount for members). The purpose of the query is to see
which reward schemes the passenger is a member of, and what discount
they qualify for (the maximum discount would normally prevail). In my
mind, the membership sits with the user object, and a passenger record
is merely showing that the user is booked onto a flight (so could be
renamed 'FlightBooking').

I may be completely wrong of course, and it would be interesting to
hear from the OP what his thoughts are.


>
>
>
> > > > So, if Passenger 57 books a flight with, say, AIA, which is a member of 
> > > > the
> > > > Star and Western alliances, how can I tell if this qualifies for a
> > > > discount?
>
> > > How could we know ? There's zero documentation about your models
> > > fields, and zero documention about the business rules - specially the
> > > ones one relating to "discount" and "qualification". Or are we
> > > supposed to use a crystal ball ?
>
> > You do have a point, but I think he is wanting a vague idea of how to
> > go about it rather than for us to write his code for him. Or maybe get
> > a discussion going about the pros and cons of different ways of
> > querying.
>
> Here again, my point is that answering the OP question requires some
> (implicit) knowledge of the domain that I just don't have - and I'm
> probably not the only one here lacking that knowledge.

-- 
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: Passenger 57 - a Django query problem

2010-02-16 Thread Emily Rodgers


On Feb 16, 3:39 pm, bruno desthuilliers
 wrote:
> On Feb 16, 2:56 pm, Derek  wrote:
[snip]
> Ain't that "memberships" relationship redundant with passenger->flight-
>
> >operator->memberships ?

I reckon he probably wants to do is split passenger up:

class Passenger(models.Model):
customer = models.ForeignKey(User)
flight = models.ForeignKey(Flight)

and have memberships as an attribute of the user. Then you would want
to pass the flight number to the function that determines the
discount.


> > So, if Passenger 57 books a flight with, say, AIA, which is a member of the
> > Star and Western alliances, how can I tell if this qualifies for a
> > discount?
>
> How could we know ? There's zero documentation about your models
> fields, and zero documention about the business rules - specially the
> ones one relating to "discount" and "qualification". Or are we
> supposed to use a crystal ball ?

You do have a point, but I think he is wanting a vague idea of how to
go about it rather than for us to write his code for him. Or maybe get
a discussion going about the pros and cons of different ways of
querying.

-- 
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: Passenger 57 - a Django query problem

2010-02-16 Thread Emily Rodgers


On Feb 16, 1:56 pm, Derek  wrote:
> (not a movie trivia problem!)
>
> The question I need to resolve here is "does Passenger 57 qualify for a
> discount"?
>
> Given the following models:
>
> class Alliance(models.Model):
>     name = models.CharField(max_length=100)
>     #e.g. Star, Western, Pacific, European
>     discount = models.FloatField()
>
> class Airline(models.Model):
>     name = models.CharField(max_length=100)
>     #e.g. AIA, Northwest, Cathay, KLM
>     membership = models.ManyToManyField(Alliance)
>
> class Flight(models.Model):
>     name = models.CharField(max_length=100)
>     operator = models.ForeignKey(Airline)
>
> class Passenger(models.Model):
>     name = models.CharField(max_length=100)
>     flight = models.ForeignKey(Flight)
>     memberships = models.ManyToManyField(Alliance)
>
> So, if Passenger 57 books a flight with, say, AIA, which is a member of the
> Star and Western alliances, how can I tell if this qualifies for a
> discount?  Assume, for purpose of this query, that the logged in user_id is
> the same as the passenger_id (i.e. 57).

How about creating this as a method of the passenger model:

def calculateDiscount(self):
max_discount = 0
# discount_with = None
flight_allies = self.flight.operator.membership.all()
# you may want to make the above "memberships" (with an s) to be
consistent or it will come back to bite you in the bum!
users_allies = self.memberships.all()
for fa in flight_allies:
if fa in users_allies:
if fa.discount > max_discount:
max_discount = fa.discount
# discount_with = fa
return max_discount

I put the 'discount_with' variable in so that if you wanted to know
which membership was used for a discount you can (just need to figure
out the best way to return it - I tend to use objects or dicts). I
haven't in any way tested it, so there may be silly errors, but you
get the idea. There are probably also better (more efficient) ways,
but this is what would occur to me!

To use this form a view, you would do something like:

passenger = Passenger.objects.get(pk=57)
discount = passenger.calculateDiscount()

Presumably you know how to get the id of the logged in user (you would
just put that in instead of 57).

Em

-- 
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: You're seeing this error because you have DEBUG = True in your Django settings file.

2010-02-04 Thread Emily Rodgers


On Feb 4, 3:54 am, punwaicheung  wrote:
> Page not found (404)
> Request Method: GET
> Request URL:http://www.cadal.zju.edu.cn/djvu_ulib/16003525/0001.djvu
>
> Using the URLconf defined in cadal.urls, Django tried these URL
> patterns, in this order:
>
> ^personal/?$
> ^personal/Eng/?$
> ^personal/addrule/book/?
> ^personal/delrule/(\d+)/?$
> ^personal/addfld/([^/]+)/?$
> ^personal/renrule/(\d+)/([^/]+)/?$
> ^personal/hotbooks/?$
> ^personal/hotbooks/Eng/?$
> ^personal/quicksearch/(\w+)/?$
> ^personal/mytags/?$
> ^personal/mytags/Eng/?$
> ^personal/mybookmarks/?$
> ^personal/mybookmarks/Eng/?$
> ^personal/mybookmarks/(?P\d{8})/?$
> ^personal/info/?$
> ^personal/password/?$
> ^personal/subtree/?
> ^personal/quickadd/?
> ^fulltext/search/?$
> ^fulltext/text/(?P\d+)/(?P\d+)/?$
> ^book/(?P\d+)/$
> ^book/(?P\d+)/Eng/$
> ^book/(?P\d+)/(?P\d+)/$
> ^book/(?P\d+)/(?P\d+)/Eng/$
> ^book/(?P\d+)/(?P\d+)/list/$
> ^book/(?P\d+)/(?P\d+)/list/Eng/$
> ^book/(?P\d+)/catalog/$
> ^book/(?P\d+)/sidebar/$
> ^book/(?P\d+)/sidebar/Eng/$
> ^book/(?P\d+)/navigator/$
> ^book/(?P\d+)/navigator/Eng/$
> ^book/(?P\d+)/submitComment/$
> ^book/(?P\d+)/delComment/$
> ^book/(?P\d+)/submitMeta/$
> ^book/(?P\d+)/allComments/$
> ^book/(?P\d+)/allComments/Eng/$
> ^book/(?P\d+)/addBookmark/$
> ^book/(?P\d+)/deleteBookmark/$
> ^book/(?P\d+)/tags/$
> ^book/(?P\d+)/tags/Eng/$
> ^book/(?P\d+)/delTag/(?P[^/]+)/$
> ^book/tags/(?P[^/]+)/$
> ^book/tags/(?P[^/]+)/Eng/$
> ^book/tags/(?P[^/]+)/(?P\d+)/$
> ^book/tags/(?P[^/]+)/(?P\d+)/Eng/$
> ^book/(?P\d+)/submitTag/$
> ^book/(?P\d+)/recommendation/$
> ^book/(?P\d+)/recommendation/Eng/$
> ^class/$
> ^class/(?P[^/]+)/$
> ^class/(?P[^/]+)/(?P\d+)/$
> ^class/(?P[^/]+)/cards/(?P\d+)/$
> ^account/login/(?P\d+)/(?P\d+)/$
> ^account/login/Eng/(?P\d+)/(?P\d+)/$
> ^account/login/$
> ^account/login/Eng/$
> ^account/logout/$
> ^account/logout/Eng/$
> ^account/register/Eng/$
> ^account/register/$
> ^auth/(?P\d{8})/?$
> ^auth/user/?$
> ^admin/?$
> ^admin/login/?$
> ^admin/logout/?$
> ^admin/group_auth/?$
> ^admin/show_ug/?$
> ^admin/add_ug/?$
> ^admin/del_ug/?$
> ^admin/show_rg/?$
> ^admin/show_rg/(?P\w+)/?$
> ^admin/show_rg/(?P\w+)/(?P\d+)/?$
> ^admin/add_rg/?$
> ^admin/del_rg/?$
> ^admin/modify_rg_view/?$
> ^admin/modify_rg/?$
> ^admin/show_books/(?P\d+)/?$
> ^admin/show_books/(?P\d+)/(?P\d+)/?$
> ^admin/add_book_rg_view/?$
> ^admin/add_book_rg/?$
> ^admin/del_book_rg/(?P\d+)/?$
> ^admin/addtogroup/?$
> ^admin/show_ACL/?$
> ^admin/show_users/(?P\d+)/?$
> ^admin/show_IPs/(?P\d+)/?$
> ^admin/add_group_ip/?$
> ^admin/del_group_ip/?$
> ^admin/add_user2group/?$
> ^admin/del_group_user/?$
> ^admin/search_user/?$
> ^admin/show_scancenter/?$
> ^djvu/(?P\d+)/(?P\d{8})(?P\w{7}).djvu/?$
> ^djvu/get_mask/(?P\d+)/(?P\d{8})/?$
> ^djvu/(?P\d+)/(?P\d+).tif/?$
> ^cover/(?P\d{8})
> ^tag/(?P\d{8})/?$
> ^captcha/image/?$
> ^captcha/?$
> ^captcha/en/?$
> ^captcha/en/image/?$
> ^meta/page/(\d{8})/?$
> ^html/(?P\d+)/(?P\d+).htm/?$
> ^html/(?P\d+)/(?P[\-\d]+).gif/?$
> ^html/(?P\d+)/(?P[\-\d]+).jpg/?$
> ^flexSupport/(?P\d+)/(?P[\-\d]+).jpg/?$
> ^ulib/(?P\d+)/?$
> ^Reader\.action
> ^ReaderEng\.action
> ^personal/imagesearch/(?P[^/]*)/(?P\d+)/?
> ^personal/callisearch/(?P[^/]*)/(?P\d+)/?
> ^catalogsearch/?$
> ^catalogsearch/detail/(\d{8})/?
> ^personal/recsysdemo/?$
> The current URL, /djvu_ulib/16003525/0001.djvu, didn't match any
> of these.
>
> You're seeing this error because you have DEBUG = True in your Django
> settings file. Change that to False, and Django will display a
> standard 404 page.

To actually help you though, /djvu_ulib/16003525/0001.djvu isn't
being matched because there isn't a regex for it in the list!

There are two similar regexes in your list:

> ^ulib/(?P\d+)/?$
> ^djvu/(?P\d+)/(?P\d{8})(?P\w{7}).djvu/?$

Presumably you meant the second, but it wouldn't match because it has
8 chars before .djvu not 7, and the url has djvu/ not djvu_ulib/.
Also, I don't think you need to put "/?" at the end of the url even if
you may send it GET data.

It looks like you need to either change your url or the regex for it.

There is also a lot of inconsistency in your naming conventions for
the groups in the regex (sometimes page_id sometimes pageId). It is
usually best to decide to use one and stick to it so you don't have to
keep going back to check which it should be.

HTH,
Emily

-- 
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: looping through non-null fields

2010-02-03 Thread Emily Rodgers
On Feb 3, 3:48 pm, Shawn Milochik  wrote:
> How about using the key/value pairs in self.__dict__ that have a value?

That does pretty much the same as above (although granted it doesn't
give me the meta fields I don't care about).

> Alternately, have a look at the help of instance._meta and see if that has 
> anything useful for you.

Thanks for the suggestion. I have managed to get the field names at
least from self._meta.

Cheers,
Em

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



looping through non-null fields

2010-02-03 Thread Emily Rodgers
Hi,

As per usual, I am probably just being really dappy, but I can't see a
good way to do this.

I have a model that has about 10 fields, and I may be populating each
record with at least one field, but probably less that 4 (could be any
4 of the 10 though). The others will be null or empty strings. Some of
the fields are foreign keys, and some are text.

Anyway, I wish the unicode method of the model to return:
"""
field_a = value_of_a,
field_c = some_other_value
"""
where field_a, and field_c are the only not null fields (or fields
where the strings are not empty) for the record (if that makes sense).

The only way I can figure out how to do it (apart from lots of
"if,elif"s, hard coding the fields) is:

non_null = [(attr, getattr(self, attr)) for attr in vars(self) if
attr != 'id' and attr[0] != '_' and getattr(self, attr) and getattr
(self, attr) != '']

This returns the data I want but it is returning the raw values from
the database which is a bit nasty, and I would have to do a lot of
post processing to make both the field name and the value pretty.

Is there a nicer way to loop through the model attributes (rather than
db fields) that would give the objects for the foreign keys instead of
the ids?

Em


-- 
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: Handling Facebook development in Django

2010-01-25 Thread Emily Rodgers


On Jan 25, 8:26 am, Hassan Baig  wrote:
> Howdy folks,
>
> I was wondering if you could give me any pointers in this regard. I'm a
> Facebook developer and I'm facing the following problem:
>
> I have a flash file which calls up a url sayhttp://test.com/createXML/which
> is caught and used up by a python/django code and it creates and redirects
> to an XML. which is loaded by flash, to get values from the database.
>
> The setup works fine when outside facebook, but as soon as I put the setup
> in facebook, it stops loading the XML completely.
>
> Any clues?

Not sure I know how to help, but I don't think you are giving enough
information for those who may be able to help to answer this.

What happens? does the url actually get called (and fail to return
useful data)? Is something being returned that isn't valid xml?

If the url isn't actually getting requested, then the problem is
probably outside of django.

Em

-- 
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: popup forms

2009-10-13 Thread Emily Rodgers



On Oct 13, 1:20 pm, andreas schmid  wrote:
> thank you very much for pointing me to the right path!!
> ill try to understand the behaviour and report about my progress...
>
> Andrew Ingram wrote:
> > I'm assuming you are doing this somewhere other than the admin, or in
> > custom views, so I'll explain how the admin stuff works.
>
> > Basically, when you create the popup window you give it a name which
> > can be used the uniquely identify the field that is using the popup
> > (some variant on the field id would be ideal). Your main page (not the
> > popup) should also have a javascript function to be called after the
> > new author is saved (in the case of django admin, this function is
> > called dismissAddAnotherPopup and is in RelatedObjectLookup.js).
>
> > Now the clever part (which I had to hunt around for when I needed this
> > functionality, you can find it around line 608 in
> > django.contrib.admin.options.py), is that when you successfully save
> > the new author, you return an HttpResponse that consists of nothing
> > but a script tag that executes
> > owner.yourFunctionName(window_name,new_object_id (in the case of the
> > django admin this would be owner.dismissAddAnotherPopup), window_name
> > is the unique identifier you passed in originally.
>
> > This causes the browser to execute the function in the owner window
> > (the one that created the popup) with the parameters you specified -
> > which includes the ID of the new object. Django's code also provides
> > the representation string of the object so it can be added to the
> > select box.
>
> > Then you just make your JS function close the popup with 
> > window_name.close().
>
> > I may not have explained it that well, but the key parts are in
> > RelatedObjectLookup.js and options.py (near line 608).
>
> > I hope this helps.
>
> > - Andrew Ingram
>
> > 2009/10/13 nabucosound :
>
> >> This is the default behaviour in Django Admin, dude...
>
> >> On Oct 13, 9:43 am, andreas schmid  wrote:
>
> >>> hi,
>
> >>> how can i achieve a behaviour like in the admin backend where i can add
> >>> a related object through a popup window and have it selectable after i
> >>> saved the related form?
>
> >>> for example:
> >>> im copleting the form book and i have to select the author but it doesnt
> >>> exist yet... so i click on the + (add) button and a popup window appears
> >>> where i create the editor object, and i can select it in the book form
> >>> right after i saved and closed this popup window.
>
> >>> can somebody point me to the code?
>
> >>> thank you in advance...

You might find this helpful: 
http://www.hoboes.com/Mimsy/hacks/replicating-djangos-admin/

Em
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: QuerySets with annonate, count() and multiple fields

2009-10-08 Thread Emily Rodgers



On Oct 8, 8:36 am, Emily Rodgers 
wrote:
> On 8 Oct, 01:31, Russell Keith-Magee  wrote:
>
>
>
> > On Thu, Oct 8, 2009 at 1:43 AM, Emily Rodgers
>
> >  wrote:
>
> > > Hello,
>
> > > I am a bit stuck on something that I think ought to be really easy (so
> > > I am probably being really stupid!).
>
> > > I am trying to write a view for a model such that I can pass the view
> > > (via post data) a (or an unknown) number of fields of that model, and
> > > receive back a list of dictionaries of distinct values for those
> > > fields and the number of times that combination of values appears.
>
> > > So, suppose the model was for holding data about cars, and it had
> > > fields 'manufacturer', 'model', 'fuel_type', 'colour', 'n_of_doors',
> > > etc where the fields had appropriate field types (a mixture of
> > > different field types), I would want to be able to pass the view for
> > > example groupBy=['colour', 'fuel_type'], and it would return a dict of
> > > distinct colour/fuel type combinations and how many cars there are in
> > > the db with those combinations, eg. [{'colour': 'red', 'fuel_type:
> > > 'diesel', 'count': 14}, ...].
>
> > > To me it seems like the kind of thing you would want to use annotate
> > > and Count for, except Count takes one field not multiple fields.
>
> > Depending on the exact result you're looking for, this may not be a
> > problem. The following query may do the job:
>
> > Car.objects.values('make','model').annotate(count=Count('id'))
>
> > will give you a list of  (make, model, count) indicating how many
> > instances of each make-model pair there are.
>
> > The complication here is exactly what you want to count. Are you looking 
> > for:
> >  * The number of rows that have every make/model combination?
> > or
> >  * The number of distinct combinations for every make/model combination?
>
> > Consider the following data:
>
> > Ford | Explorer | Black
> > Ford | Explorer | Black
> > Ford | Explorer | Blue
> > Ford | Explorer | Red
> > Dodge | Charger | Red
>
> > The query I gave you will return (Ford, Explorer, 4), (Dodge, Charger,
> > 1). However, if you want to collapse the two "black Ford Explorer"
> > entries and only return a count of 3, you're out of luck. For that you
> > need to specify multiple columns to the Count(), which Django doesn't
> > support. If this is what you need, you'll need to fall back on using
> > raw SQL.
>
> > Yours,
> > Russ Magee %-)
>
> Ah your suggestion is exactly what I am after :)
>
> Although, I think if there are foreign keys (or choices for the field)
> etc, values() tends to return the id of the value, which means I have
> to go figure out which model it relates to, then find that record, and
> get the user friendly data (I am returning this using JSON to a ExtJS
> script). This starts to make it expensive again.
>
> I will have a play with your suggestion though - thanks :)
>
> Emily

Realised I was being dumb, and you can follow the foreign keys to get
more useful values by specifying them when you pass the strings to
values() :-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: QuerySets with annonate, count() and multiple fields

2009-10-08 Thread Emily Rodgers



On 8 Oct, 01:31, Russell Keith-Magee  wrote:
> On Thu, Oct 8, 2009 at 1:43 AM, Emily Rodgers
>
>
>
>  wrote:
>
> > Hello,
>
> > I am a bit stuck on something that I think ought to be really easy (so
> > I am probably being really stupid!).
>
> > I am trying to write a view for a model such that I can pass the view
> > (via post data) a (or an unknown) number of fields of that model, and
> > receive back a list of dictionaries of distinct values for those
> > fields and the number of times that combination of values appears.
>
> > So, suppose the model was for holding data about cars, and it had
> > fields 'manufacturer', 'model', 'fuel_type', 'colour', 'n_of_doors',
> > etc where the fields had appropriate field types (a mixture of
> > different field types), I would want to be able to pass the view for
> > example groupBy=['colour', 'fuel_type'], and it would return a dict of
> > distinct colour/fuel type combinations and how many cars there are in
> > the db with those combinations, eg. [{'colour': 'red', 'fuel_type:
> > 'diesel', 'count': 14}, ...].
>
> > To me it seems like the kind of thing you would want to use annotate
> > and Count for, except Count takes one field not multiple fields.
>
> Depending on the exact result you're looking for, this may not be a
> problem. The following query may do the job:
>
> Car.objects.values('make','model').annotate(count=Count('id'))
>
> will give you a list of  (make, model, count) indicating how many
> instances of each make-model pair there are.
>
> The complication here is exactly what you want to count. Are you looking for:
>  * The number of rows that have every make/model combination?
> or
>  * The number of distinct combinations for every make/model combination?
>
> Consider the following data:
>
> Ford | Explorer | Black
> Ford | Explorer | Black
> Ford | Explorer | Blue
> Ford | Explorer | Red
> Dodge | Charger | Red
>
> The query I gave you will return (Ford, Explorer, 4), (Dodge, Charger,
> 1). However, if you want to collapse the two "black Ford Explorer"
> entries and only return a count of 3, you're out of luck. For that you
> need to specify multiple columns to the Count(), which Django doesn't
> support. If this is what you need, you'll need to fall back on using
> raw SQL.
>
> Yours,
> Russ Magee %-)

Ah your suggestion is exactly what I am after :)

Although, I think if there are foreign keys (or choices for the field)
etc, values() tends to return the id of the value, which means I have
to go figure out which model it relates to, then find that record, and
get the user friendly data (I am returning this using JSON to a ExtJS
script). This starts to make it expensive again.

I will have a play with your suggestion though - thanks :)

Emily
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



QuerySets with annonate, count() and multiple fields

2009-10-07 Thread Emily Rodgers

Hello,

I am a bit stuck on something that I think ought to be really easy (so
I am probably being really stupid!).

I am trying to write a view for a model such that I can pass the view
(via post data) a (or an unknown) number of fields of that model, and
receive back a list of dictionaries of distinct values for those
fields and the number of times that combination of values appears.

So, suppose the model was for holding data about cars, and it had
fields 'manufacturer', 'model', 'fuel_type', 'colour', 'n_of_doors',
etc where the fields had appropriate field types (a mixture of
different field types), I would want to be able to pass the view for
example groupBy=['colour', 'fuel_type'], and it would return a dict of
distinct colour/fuel type combinations and how many cars there are in
the db with those combinations, eg. [{'colour': 'red', 'fuel_type:
'diesel', 'count': 14}, ...].

To me it seems like the kind of thing you would want to use annotate
and Count for, except Count takes one field not multiple fields.

I tried using values() to limit the fields, then python to do the
counting / distinct bit, but it is annoying because I want to be able
to tell it to return the unicode values for foreign keys etc. rather
than ids that would then need to be looked up. Also it is way too
slow.

I am trying to figure a way to do this that is reasonably fast because
I am trying to filter a lot of data. Am I missing something? I haven't
been using python / django much lately so I am probably thinking the
wrong way!

Any help would be appreciated :)

Em

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: request.FILES empty... only with IE!

2009-08-24 Thread Emily Rodgers



On Aug 23, 11:31 pm, OnurCelebi  wrote:
> Hi all,
> I have a very strange behaviour. I have an upload form like this:
>
> var upform = document.createElement('form');
> upform.setAttribute('action','/engine/users/avatar/');
> upform.setAttribute('enctype','multipart/form-data');
> upform.setAttribute('method','post');
>
> created dynamically with JS.
> With Chrome and Firefox, it works fine. But with IE, I obtain an empty
> request.FILES, it seems that the filename and its location (on clients
> machine! ) goes to request.POST:
>
> POST: \toto07_61.jpg']}>,
>
> Is this a bug?
> Is there a way to fetch the file through POST's dictionary?

Hi,

I don't think you have given us enough information to figure out what
is happening. How are you creating and populating the form fields and
what are they?

Em
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Override __init__()

2009-08-17 Thread Emily Rodgers



On Aug 14, 4:26 pm, Daniel Roseman  wrote:
> On Aug 14, 3:50 pm, Léon Dignòn  wrote:
>
> > Hi Emily,
>
> > thanks so far!
>
> > unfortunately this line:
>
> > > instance = getattr(kwargs, 'instance')
> > throws this error:
> > > Exception Value: 'dict' object has no attribute 'instance'
>
> > what next?
>
> That should be:
>
> instance = kwargs.get('instance')
> --
> DR.

Yeah sorry - was writing it in a hurry before going somewhere. Oops!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Override __init__()

2009-08-14 Thread Emily Rodgers



On Aug 14, 12:14 pm, Léon Dignòn  wrote:
> Hi,
>
> I try override a ModelForms init to claim the variable instance. After
> that I call super.__init__().
> It's almost working, but there is no form shown in the browser.  Any
> ideas what might be wrong?
>
> class ProfileForm(ModelForm):
>     first_name = forms.CharField(required=False, max_length=30)
>     last_name = forms.CharField(required=False, max_length=30)
>
>     class Meta:
>         model = UserProfile
>         exclude = ('user',) # User will be filled in by the view.
>
>     def __init__(self, data=None, files=None, auto_id='id_%s',
> prefix=None, initial=None,
>                  error_class=None, label_suffix=':',
> empty_permitted=False, instance=None):
>         f = open('debug.txt', 'w')
>         f.write("%s \n\n-\n\n" % instance.user.first_name) # Bob
>         f.write("%s \n\n-\n\n" % instance.user.last_name) # Marley
>         super(ProfileForm, self).__init__(data, files, auto_id,
> prefix, initial, error_class, label_suffix, empty_permitted, instance)

Rather than listing all the key word arguments (kwargs) like that, you
are better doing it like this:

import logging # probably a better way than writing to debug.txt, but
clearly it is personal choice

def __init__(self, *args, **kwargs):
instance = getattr(kwargs, 'instance')
logging.debug("First name: %s" % instance.user.first_name) # I
like to know what it thinks it is printing!
logging.debug("Last name: %s" % instance.user.last_name) #
obviously you can change str if you like
super(ProfileForm, self).__init__(data, *args, **kwargs)

I don't know if this will fix your problem (hard to say without
visibility of the view), but it may be that you have forgotten one of
the kwargs. If you want to add extra parameters, or set them to
specific values you can still do this before calling init.

HTH,
Em

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 much python do i need to know to learn/use Django?

2009-08-14 Thread Emily Rodgers



On Aug 14, 9:42 am, Wayne Koorts  wrote:
> > I currently know zero Python and want to start a project with Django
> > ASAP.  I've got the opportunity through my work to either take a 5-day
> > Python bootcamp or a Django bootcamp - not both.
>
> I don't really think this is a useful question on its own.  A more
> appropriate question would be "How much programming experience do I
> need?".  If you have prior programming experience in another language
> then I'm sure you'll find Python quick and easy to pick up.  In that
> case going through the tutorial and playing around with it in an
> afternoon should be enough to prep you for a Django book or course.
>
> If you have no programming experience at all then out of the two
> options it would be better to take the Python one.  Any pure Django
> course would assume a certain amount of Python knowledge.  But even if
> you take a Python course you need to know if the particular course
> assumes prior programming experience of some kind of is more of an
> "Introduction to Programming Using Python".  If you take a Django
> course with no programming experience at all then you will be wasting
> your time.  If you have experience in some kind of programming and
> then take a Django course with no Python experience then you might be
> able to get by.
>
> Regards,
> Wayne

I would second this. but also if you do the django course, take a
python book with you - then if you don't get something you can just
look it up in the book quickly (the python website would also do, it
just depends on whether you prefer to learn from books or the web).
Remember, the people teaching the django course will know python, so
will be able to give you a bit of guidance if you get really stuck,
but if you go on the python course, it won't necessarily help get you
up and running with django. The poll tutorial on the django website is
brilliant for showing the different features and getting you started
though.

If you have no programming experience and don't know python, the
django course will be a lot to take in at once.

Em
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: field order:ModelForm

2009-08-05 Thread Emily Rodgers

2009/8/5 Ludwik  Trammer :
>
>> I tried adding a fields attribute to the Meta class (which I think is
>> what you would do in the dev version), but that didn't work.
>
> Django 1.1 stable is out and supports this feature, so if you can
> upgrade it will probably be the easiest solution.

OK I will try that - thanks :-)

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



field order:ModelForm

2009-08-05 Thread Emily Rodgers

Hi,

I am using django 1.0.2, and I was wondering if it is possible to
change the order of the fields (it seems you can do this in the dev
version)?

I have added an extra field in my form (that doesn't actually
correspond with a field in the model). It is being listed after the
model fields, and I would like it to go before.

I tried adding a fields attribute to the Meta class (which I think is
what you would do in the dev version), but that didn't work.

Is the only way to do this to just create a normal form and do the
model instance interface manually? I am using an extJS frontend and
JSON to pass the values across (using the ExtJsonEncoder from django
snippets).

I think I am having a slow brain day so please excuse me if I am being
really dumb!

Em
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Please help me design Model

2009-07-24 Thread Emily Rodgers



On Jul 23, 11:06 pm, urosh  wrote:
> Hi.
>
> I want to create phone book. I want that this phone book list will be
> ordered by number of dialing this number. I think of using two tables
> one with phone numbers and one for phone dialing statistics (how many
> times user dialed number). Each user has his own ordering rule based
> on his user-name. I will populate this phonebook statistics with other
> function regular running.
>
> This is what I have so far.
>
> class phonebook(models.Model):
>         person_company = models.CharField(blank=True,max_length=30)
>         address = models.CharField(blank=True,max_length=50)
>         e_mail = models.EmailField(blank=True,max_length=70)
>         number = models.CharField(unique=True,max_length=15)
>         dialed = models.ForeignKey('phonebook_stat')
>         def __unicode__(self):
>                 return self.person_company
>
> class phonebook_stat(models.Model):
>         username = models.CharField(max_length=30)
>         number = models.CharField(max_length=15)
>         dialed_times = models.IntegerField(max_length=10)
>         class Admin:
>                 pass
> in admin.py
> class PhonebookAdmin(admin.ModelAdmin):
>         def queryset(self, request):
>                 qs = super(PhonebookAdmin, self).queryset(request)
>                 global caller_id
>                 caller_id = str(request.user)
>                 return qs
>         list_per_page = 20
>         search_fields = ('person_company','number')
>         list_display = ['person_company','number','address',]
>         fields = ('person_company','number','address','e_mail',)
>         #ordering = (order_common_used,)
>
> THANK YOU in advance.

Hello,

Wouldn't you want the 'dialed' to be a many to many field so that one
phonebook entry could be used for more than one user?

class Phonebook(models.Model):
person_company = models.CharField(blank=True,max_length=30)
address = models.CharField(blank=True,max_length=50)
e_mail = models.EmailField(blank=True,max_length=70)
number = models.CharField(unique=True,max_length=15)
dialed = models.ManyToManyField('PhonebookStat')
def __unicode__(self):
return self.person_company

class PhonebookStat(models.Model):
username = models.CharField(max_length=30)
number = models.CharField(max_length=15)
dialed_times = models.IntegerField(max_length=10)
class Admin:
pass

I haven't really used the admin app for ages, so probably not the best
person to advise on that, but I can't see how the code you have
written would work. You need to have some kind of filter on the dialed
field.

HTH a bit,
Em
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: forms with django and extjs 3.0.0

2009-07-24 Thread Emily Rodgers

2009/7/24 Russell Keith-Magee :
>
> On Thu, Jul 23, 2009 at 5:43 PM, Emily
> Rodgers wrote:
>>
>> Hi all,
>>
>> I am currently working on some web apps that use django for the back
>> end, and extjs for the front end (using JSON to pass data between the
>> two).
>>
>> I am getting to the point where I am going to have to start doing some
>> form integration. Has anyone done this lately (with the latest version
>> of extjs)? If so, how did you go about it? I have looked on the web,
>> but most of the extjs / modelform examples are using either an old
>> version of django or an old version of extjs, both of which have
>> undergone fairly backwards incompatible changes in recent revisions. I
>> just thought that I would ask here before spending lots of time trying
>> to figure it out from scratch.
>
> I can't speak for ExtJS, but Django hasn't had any backwards
> incompatible changes in almost a year - and the areas where you are
> delving here (i.e., view and forms handling) have been stable for much
> longer.
>
> So - you shouldn't have any problems (from a Django point of view)
> with any tutorial that is a year old.

Yep, but a lot of the examples / how-tos I have found are from 2007
before the forms changed in django. Admittedly, extjs has changed a
lot more than django (they pretty much scrapped the original design
and restructured the object heirarchy for extjs 2).

> I can't offer much advice than that, though. Firstly, I'm not that
> familar with ExtJS; secondly, there isn't that much to explain.
>  * You write a Django view.
>  * That view serves a HTML page.
>  * The HTML page contains some javascript.
>  * The javascript makes a call on another Django view.
>  * The second Django view serves JSON, or some other raw data format.
>  * The javascript running on the first page uses that data to modify
> in-situ the original page.
>
> And boom, you have an AJAX website. To be sure, there is some
> complexity in getting your Javascript working - but that complexity is
> almost 100% a function of your JS toolkit of choice. From Django's
> perspective, all you ever do is serve individual pages - either HTML
> for human consumption, or JSON/some other format for automated
> Javascript consumption.

Yep - as I said, I am fairly familiar with django, I have been using
it for over a year and have built 3 or 4 fairly big apps. I have
already been using django with extjs for displaying data (pretty much
how you describe above), however the thing that is slightly more
tricky is how best to handle forms.

Extjs does its own form handling (validation / widgets etc), and it is
tricky to know whether it is best to get django to do the translation
into extjs like data (maybe create an as_ext() method, analogous to
as_table() for rendering the form), or get extjs to understand the
django form data. I also need to consider what to do about validation
(it doesn't seem very dry to make extjs do the validation, but it can
do 'as you type' validation which is quite nice for the user
interface).  Has anyone had actually done this before recently? If so,
do they have any advice on which way to go? Or unforseen problems with
m2m fields etc?

On the extjs forums, the django examples are aimed at people who are
familiar with ext js but not django and don't really offer a lot of
help for the actual integration, so I was hoping that on the
django-users forum, there might be someone who would be able to offer
advice for someone familiar with django, but less so with extjs.

I will post a how-to somewhere when I have figured out what the best
way is (currently reading up / playing with extjs forms a bit more).

Em

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



forms with django and extjs 3.0.0

2009-07-23 Thread Emily Rodgers

Hi all,

I am currently working on some web apps that use django for the back
end, and extjs for the front end (using JSON to pass data between the
two).

I am getting to the point where I am going to have to start doing some
form integration. Has anyone done this lately (with the latest version
of extjs)? If so, how did you go about it? I have looked on the web,
but most of the extjs / modelform examples are using either an old
version of django or an old version of extjs, both of which have
undergone fairly backwards incompatible changes in recent revisions. I
just thought that I would ask here before spending lots of time trying
to figure it out from scratch.

I have been using django for a year or so, but I am fairly new to
extjs, and the oo style of coding javascript (more like java / C#), so
I am playing catch up, and any help or advice would be gratefully
received.

Em
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: accessing multiple dbs?

2009-07-16 Thread Emily Rodgers



On Jul 15, 5:43 pm, Alex Gaynor  wrote:
> On Wed, Jul 15, 2009 at 11:35 AM, Emily Rodgers <
>
>
>
> emily.kate.rodg...@googlemail.com> wrote:
>
> > On Jul 15, 4:19 pm, Emily Rodgers 
> > wrote:
> > > On Jul 15, 2:46 pm, "Richard E. Cooke"  wrote:
>
> > > > OK.  Before I get flamed!
>
> > > > I neglected to search THIS group before I posted.
>
> > > > So, I see some chatter about being able to instansiate a second DB
> > > > connector.  Great.
>
> > > > Now, how about where the best examples of that are?
>
> > > > And what impact, if any, does this have on the rest of Django?
>
> > > > My boss is starting to weaken too:  "Maybe its not so bad having
> > > > Django tables added"
>
> > > Hi Richard,
>
> > > I have been having a go at this lately [1], and what I posted seems to
> > > work to an extent, but I am currently having some m2m field problems
> > > (not problems with foreign keys though), so what I posted may be
> > > flawed.
>
> > > Alex G is working on getting proper support added to django for google
> > > summer of code 2009, so hopefully it will be in a future release of
> > > django :-)
>
> > > Em
>
> > > [1]
> >http://groups.google.com/group/django-users/browse_thread/thread/af3a...
>
> > I have figured out why the m2m field problems were happening (although
> > not fixed it elegantly yet). When I figure out how to prevent the
> > problem, I will reply to the other thread (where my suggested
> > workaround it).
>
> > Em
>
> Unfortunately because of the way m2ms are done in Django right now working
> with any db besides the default is nearly impossible (they import a raw
> connection and do queries).  I have a branch on github where I've rewritten
> m2ms to use an internal model so we don't have this problem.
> 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
> "Code can always be simpler than you think, but never as simple as you want"
> -- Me

I think for my system it isn't too much of a problem because I only
need to add / delete m2m relationships from my main database (not
secondary), but I will have to make sure I document it well! As I have
said before, I am so happy that someone is working on this because it
will make django so much more flexible. Thanks for your work Alex, it
is much appreciated.

Em :-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: accessing multiple dbs?

2009-07-15 Thread Emily Rodgers



On Jul 15, 4:19 pm, Emily Rodgers 
wrote:
> On Jul 15, 2:46 pm, "Richard E. Cooke"  wrote:
>
> > OK.  Before I get flamed!
>
> > I neglected to search THIS group before I posted.
>
> > So, I see some chatter about being able to instansiate a second DB
> > connector.  Great.
>
> > Now, how about where the best examples of that are?
>
> > And what impact, if any, does this have on the rest of Django?
>
> > My boss is starting to weaken too:  "Maybe its not so bad having
> > Django tables added"
>
> Hi Richard,
>
> I have been having a go at this lately [1], and what I posted seems to
> work to an extent, but I am currently having some m2m field problems
> (not problems with foreign keys though), so what I posted may be
> flawed.
>
> Alex G is working on getting proper support added to django for google
> summer of code 2009, so hopefully it will be in a future release of
> django :-)
>
> Em
>
> [1]http://groups.google.com/group/django-users/browse_thread/thread/af3a...

I have figured out why the m2m field problems were happening (although
not fixed it elegantly yet). When I figure out how to prevent the
problem, I will reply to the other thread (where my suggested
workaround it).

Em
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: accessing multiple dbs?

2009-07-15 Thread Emily Rodgers



On Jul 15, 2:46 pm, "Richard E. Cooke"  wrote:
> OK.  Before I get flamed!
>
> I neglected to search THIS group before I posted.
>
> So, I see some chatter about being able to instansiate a second DB
> connector.  Great.
>
> Now, how about where the best examples of that are?
>
> And what impact, if any, does this have on the rest of Django?
>
> My boss is starting to weaken too:  "Maybe its not so bad having
> Django tables added"

Hi Richard,

I have been having a go at this lately [1], and what I posted seems to
work to an extent, but I am currently having some m2m field problems
(not problems with foreign keys though), so what I posted may be
flawed.

Alex G is working on getting proper support added to django for google
summer of code 2009, so hopefully it will be in a future release of
django :-)

Em


[1] 
http://groups.google.com/group/django-users/browse_thread/thread/af3a77225594a28c
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Will future Django releases support multiple databases?

2009-07-14 Thread Emily Rodgers



On Jul 13, 4:51 pm, Emily Rodgers 
wrote:
> On Jul 3, 6:36 pm, Emily Rodgers 
> wrote:
>
>
>
> > 2009/7/3 Alex Gaynor :
>
> > > On Fri, Jul 3, 2009 at 12:25 PM, Emily Rodgers
> > >  wrote:
>
> > >> On Jul 3, 3:29 pm, Emily Rodgers 
> > >> wrote:
> > >> > On Jul 1, 3:44 pm, Alex Gaynor  wrote:
>
> > >> > > On Wed, Jul 1, 2009 at 9:39 AM, Emily Rodgers <
>
> > >> > > emily.kate.rodg...@googlemail.com> wrote:
>
> > >> > > > On Jul 1, 3:22 pm, Alex Gaynor  wrote:
> > >> > > > > On Wed, Jul 1, 2009 at 9:16 AM, Emily Rodgers <
>
> > >> > > > > emily.kate.rodg...@googlemail.com> wrote:
>
> > >> > > > > > On Jun 25, 6:45 pm, Alex Gaynor  wrote:
> > >> > > > > > > On Thu, Jun 25, 2009 at 10:24 AM, Tim Chase
> > >> > > > > > > wrote:
> > >> > > > > > > > > Right now, Django doesn't seem to support the multiple
> > >> > > > > > > > > databases on the same server or different servers.  Will
> > >> > > > > > > > > that
> > >> > > > > > > > > feature be available out of the box for future releases?
>
> > >> > > > > > > > You may want to eavesdrop on the Django Developers group 
> > >> > > > > > > > (as
> > >> > > > > > > > opposed to this Django Users group) where Alex Gaynor has
> > >> > > > > > > > been
> > >> > > > > > > > posting updates on his GSoC project to add multi-DB support
> > >> > > > > > > > to
> > >> > > > > > > > Django[1].  There are several aspects to multi-DB 
> > >> > > > > > > > support[2]
> > >> > > > > > > > but
> > >> > > > > > > > I believe he's addressing some of the more common 
> > >> > > > > > > > use-cases.
> > >> > > > > > > >  You
> > >> > > > > > > > can even follow along if you like to live dangerously as I
> > >> > > > > > > > believe he's got a public repository for his code on 
> > >> > > > > > > > GitHub.
>
> > >> > > > > > > > -tim
>
> > >> > > > > > > > [1]
>
> > >> > > > >http://groups.google.com/group/django-developers/search?group=django-.
> > >> > > > > > ..
>
> > >> > > > > > > > [2]
>
> > >> > > > >http://groups.google.com/group/django-users/browse_thread/thread/6630.
> > >> > > > > > ..
> > >> > > > > > > > for my posted concerns
>
> > >> > > > > > > I have both a public code repository on github at
> > >> > > > > > github.com/alex/django/ as
> > >> > > > > > > well as a branch in Django's SVN at branches/soc2009/multidb.
> > >> > > > > > >  The
> > >> > > > best
> > >> > > > > > > place to find out about the work is the django-developers
> > >> > > > > > > list, where
> > >> > > > I
> > >> > > > > > have
> > >> > > > > > > sent any number of emails discussing both the overall design,
> > >> > > > > > > as well
> > >> > > > as
> > >> > > > > > the
> > >> > > > > > > status.
>
> > >> > > > > > > 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
>
> > >> > > > > > Hi,
>
> > >> > > > > > Alex - do you know roughly when this is likely to be
> > >> >

Re: Will future Django releases support multiple databases?

2009-07-13 Thread Emily Rodgers



On Jul 3, 6:36 pm, Emily Rodgers 
wrote:
> 2009/7/3 Alex Gaynor :
>
>
>
>
>
> > On Fri, Jul 3, 2009 at 12:25 PM, Emily Rodgers
> >  wrote:
>
> >> On Jul 3, 3:29 pm, Emily Rodgers 
> >> wrote:
> >> > On Jul 1, 3:44 pm, Alex Gaynor  wrote:
>
> >> > > On Wed, Jul 1, 2009 at 9:39 AM, Emily Rodgers <
>
> >> > > emily.kate.rodg...@googlemail.com> wrote:
>
> >> > > > On Jul 1, 3:22 pm, Alex Gaynor  wrote:
> >> > > > > On Wed, Jul 1, 2009 at 9:16 AM, Emily Rodgers <
>
> >> > > > > emily.kate.rodg...@googlemail.com> wrote:
>
> >> > > > > > On Jun 25, 6:45 pm, Alex Gaynor  wrote:
> >> > > > > > > On Thu, Jun 25, 2009 at 10:24 AM, Tim Chase
> >> > > > > > > wrote:
> >> > > > > > > > > Right now, Django doesn't seem to support the multiple
> >> > > > > > > > > databases on the same server or different servers.  Will
> >> > > > > > > > > that
> >> > > > > > > > > feature be available out of the box for future releases?
>
> >> > > > > > > > You may want to eavesdrop on the Django Developers group (as
> >> > > > > > > > opposed to this Django Users group) where Alex Gaynor has
> >> > > > > > > > been
> >> > > > > > > > posting updates on his GSoC project to add multi-DB support
> >> > > > > > > > to
> >> > > > > > > > Django[1].  There are several aspects to multi-DB support[2]
> >> > > > > > > > but
> >> > > > > > > > I believe he's addressing some of the more common use-cases.
> >> > > > > > > >  You
> >> > > > > > > > can even follow along if you like to live dangerously as I
> >> > > > > > > > believe he's got a public repository for his code on GitHub.
>
> >> > > > > > > > -tim
>
> >> > > > > > > > [1]
>
> >> > > > >http://groups.google.com/group/django-developers/search?group=django-.
> >> > > > > > ..
>
> >> > > > > > > > [2]
>
> >> > > > >http://groups.google.com/group/django-users/browse_thread/thread/6630.
> >> > > > > > ..
> >> > > > > > > > for my posted concerns
>
> >> > > > > > > I have both a public code repository on github at
> >> > > > > > github.com/alex/django/ as
> >> > > > > > > well as a branch in Django's SVN at branches/soc2009/multidb.
> >> > > > > > >  The
> >> > > > best
> >> > > > > > > place to find out about the work is the django-developers
> >> > > > > > > list, where
> >> > > > I
> >> > > > > > have
> >> > > > > > > sent any number of emails discussing both the overall design,
> >> > > > > > > as well
> >> > > > as
> >> > > > > > the
> >> > > > > > > status.
>
> >> > > > > > > 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
>
> >> > > > > > Hi,
>
> >> > > > > > Alex - do you know roughly when this is likely to be
> >> > > > > > incorporated into
> >> > > > > > django? I am working on a project that is going to need to
> >> > > > > > connect to
> >> > > > > > multiple databases (I am just planning / designing at the
> >> > > > > > moment), and
> >> > > > > > I want to know whether I should start investigating how to do
> >> > > > > > this
> >> > > > > > using django 1.0.2 or if that would be a waste of my ti

Re: Will future Django releases support multiple databases?

2009-07-03 Thread Emily Rodgers

2009/7/3 Alex Gaynor :
>
>
> On Fri, Jul 3, 2009 at 12:25 PM, Emily Rodgers
>  wrote:
>>
>>
>>
>> On Jul 3, 3:29 pm, Emily Rodgers 
>> wrote:
>> > On Jul 1, 3:44 pm, Alex Gaynor  wrote:
>> >
>> >
>> >
>> > > On Wed, Jul 1, 2009 at 9:39 AM, Emily Rodgers <
>> >
>> > > emily.kate.rodg...@googlemail.com> wrote:
>> >
>> > > > On Jul 1, 3:22 pm, Alex Gaynor  wrote:
>> > > > > On Wed, Jul 1, 2009 at 9:16 AM, Emily Rodgers <
>> >
>> > > > > emily.kate.rodg...@googlemail.com> wrote:
>> >
>> > > > > > On Jun 25, 6:45 pm, Alex Gaynor  wrote:
>> > > > > > > On Thu, Jun 25, 2009 at 10:24 AM, Tim Chase
>> > > > > > > wrote:
>> > > > > > > > > Right now, Django doesn't seem to support the multiple
>> > > > > > > > > databases on the same server or different servers.  Will
>> > > > > > > > > that
>> > > > > > > > > feature be available out of the box for future releases?
>> >
>> > > > > > > > You may want to eavesdrop on the Django Developers group (as
>> > > > > > > > opposed to this Django Users group) where Alex Gaynor has
>> > > > > > > > been
>> > > > > > > > posting updates on his GSoC project to add multi-DB support
>> > > > > > > > to
>> > > > > > > > Django[1].  There are several aspects to multi-DB support[2]
>> > > > > > > > but
>> > > > > > > > I believe he's addressing some of the more common use-cases.
>> > > > > > > >  You
>> > > > > > > > can even follow along if you like to live dangerously as I
>> > > > > > > > believe he's got a public repository for his code on GitHub.
>> >
>> > > > > > > > -tim
>> >
>> > > > > > > > [1]
>> >
>> > >
>> > > > >http://groups.google.com/group/django-developers/search?group=django-.
>> > > > > > ..
>> >
>> > > > > > > > [2]
>> >
>> > >
>> > > > >http://groups.google.com/group/django-users/browse_thread/thread/6630.
>> > > > > > ..
>> > > > > > > > for my posted concerns
>> >
>> > > > > > > I have both a public code repository on github at
>> > > > > > github.com/alex/django/ as
>> > > > > > > well as a branch in Django's SVN at branches/soc2009/multidb.
>> > > > > > >  The
>> > > > best
>> > > > > > > place to find out about the work is the django-developers
>> > > > > > > list, where
>> > > > I
>> > > > > > have
>> > > > > > > sent any number of emails discussing both the overall design,
>> > > > > > > as well
>> > > > as
>> > > > > > the
>> > > > > > > status.
>> >
>> > > > > > > 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
>> >
>> > > > > > Hi,
>> >
>> > > > > > Alex - do you know roughly when this is likely to be
>> > > > > > incorporated into
>> > > > > > django? I am working on a project that is going to need to
>> > > > > > connect to
>> > > > > > multiple databases (I am just planning / designing at the
>> > > > > > moment), and
>> > > > > > I want to know whether I should start investigating how to do
>> > > > > > this
>> > > > > > using django 1.0.2 or if that would be a waste of my time.
>> >
>> > > > > > If it is going to be a while, where would you suggest I start
>> > > > > > looking
>> > > 

Re: Will future Django releases support multiple databases?

2009-07-03 Thread Emily Rodgers



On Jul 3, 3:29 pm, Emily Rodgers 
wrote:
> On Jul 1, 3:44 pm, Alex Gaynor  wrote:
>
>
>
> > On Wed, Jul 1, 2009 at 9:39 AM, Emily Rodgers <
>
> > emily.kate.rodg...@googlemail.com> wrote:
>
> > > On Jul 1, 3:22 pm, Alex Gaynor  wrote:
> > > > On Wed, Jul 1, 2009 at 9:16 AM, Emily Rodgers <
>
> > > > emily.kate.rodg...@googlemail.com> wrote:
>
> > > > > On Jun 25, 6:45 pm, Alex Gaynor  wrote:
> > > > > > On Thu, Jun 25, 2009 at 10:24 AM, Tim Chase
> > > > > > wrote:
> > > > > > > > Right now, Django doesn't seem to support the multiple
> > > > > > > > databases on the same server or different servers.  Will that
> > > > > > > > feature be available out of the box for future releases?
>
> > > > > > > You may want to eavesdrop on the Django Developers group (as
> > > > > > > opposed to this Django Users group) where Alex Gaynor has been
> > > > > > > posting updates on his GSoC project to add multi-DB support to
> > > > > > > Django[1].  There are several aspects to multi-DB support[2] but
> > > > > > > I believe he's addressing some of the more common use-cases.  You
> > > > > > > can even follow along if you like to live dangerously as I
> > > > > > > believe he's got a public repository for his code on GitHub.
>
> > > > > > > -tim
>
> > > > > > > [1]
>
> > >http://groups.google.com/group/django-developers/search?group=django-.
> > > > > ..
>
> > > > > > > [2]
>
> > >http://groups.google.com/group/django-users/browse_thread/thread/6630.
> > > > > ..
> > > > > > > for my posted concerns
>
> > > > > > I have both a public code repository on github at
> > > > > github.com/alex/django/ as
> > > > > > well as a branch in Django's SVN at branches/soc2009/multidb.  The
> > > best
> > > > > > place to find out about the work is the django-developers list, 
> > > > > > where
> > > I
> > > > > have
> > > > > > sent any number of emails discussing both the overall design, as 
> > > > > > well
> > > as
> > > > > the
> > > > > > status.
>
> > > > > > 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
>
> > > > > Hi,
>
> > > > > Alex - do you know roughly when this is likely to be incorporated into
> > > > > django? I am working on a project that is going to need to connect to
> > > > > multiple databases (I am just planning / designing at the moment), and
> > > > > I want to know whether I should start investigating how to do this
> > > > > using django 1.0.2 or if that would be a waste of my time.
>
> > > > > If it is going to be a while, where would you suggest I start looking
> > > > > if I need to understand how to do it with django 1.0.2?
>
> > > > > Cheers,
> > > > > Em
>
> > > > It will, at a minimum not occur until the end of the summer.  Beyond 
> > > > that
> > > I
> > > > can't make any really useful guesses, other than to say that the
> > > aggregation
> > > > GSOC project from last summer
> > > > ultimately made it's way into django trunk in January, about 3-4 months
> > > > after the official end of GSOC.  That may or may not ultimately be
> > > > representative of how long it will take multi-db to make it's way back
> > > into
> > > > Django.  A lot of it probably depends on how the 1.2/1.3 releases are
> > > > scheduled.  For example is 1.2 ends up being a smaller release that's 
> > > > put
> > > > out in Novemberish I wouldn't expect multi-db to be considered for trunk
> > > > until 1.3.  Like I said all of that's rather speculative :)
>
> > > > Alex
> > > > --
> > > > "I disapprove of what you say, but I will defend to the death your right
> > > to
> > > > s

useful django resources for newbies

2009-07-03 Thread Emily Rodgers

Hi,

I only recently realised that a django subreddit existed, and since
then I have been learning interesting new things from it, so I thought
I would share it for the benefit of those of you that don't read
reddit:

http://www.reddit.com/r/django/

Em
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Will future Django releases support multiple databases?

2009-07-03 Thread Emily Rodgers



On Jul 1, 3:44 pm, Alex Gaynor  wrote:
> On Wed, Jul 1, 2009 at 9:39 AM, Emily Rodgers <
>
>
>
> emily.kate.rodg...@googlemail.com> wrote:
>
> > On Jul 1, 3:22 pm, Alex Gaynor  wrote:
> > > On Wed, Jul 1, 2009 at 9:16 AM, Emily Rodgers <
>
> > > emily.kate.rodg...@googlemail.com> wrote:
>
> > > > On Jun 25, 6:45 pm, Alex Gaynor  wrote:
> > > > > On Thu, Jun 25, 2009 at 10:24 AM, Tim Chase
> > > > > wrote:
> > > > > > > Right now, Django doesn't seem to support the multiple
> > > > > > > databases on the same server or different servers.  Will that
> > > > > > > feature be available out of the box for future releases?
>
> > > > > > You may want to eavesdrop on the Django Developers group (as
> > > > > > opposed to this Django Users group) where Alex Gaynor has been
> > > > > > posting updates on his GSoC project to add multi-DB support to
> > > > > > Django[1].  There are several aspects to multi-DB support[2] but
> > > > > > I believe he's addressing some of the more common use-cases.  You
> > > > > > can even follow along if you like to live dangerously as I
> > > > > > believe he's got a public repository for his code on GitHub.
>
> > > > > > -tim
>
> > > > > > [1]
>
> >http://groups.google.com/group/django-developers/search?group=django-.
> > > > ..
>
> > > > > > [2]
>
> >http://groups.google.com/group/django-users/browse_thread/thread/6630.
> > > > ..
> > > > > > for my posted concerns
>
> > > > > I have both a public code repository on github at
> > > > github.com/alex/django/ as
> > > > > well as a branch in Django's SVN at branches/soc2009/multidb.  The
> > best
> > > > > place to find out about the work is the django-developers list, where
> > I
> > > > have
> > > > > sent any number of emails discussing both the overall design, as well
> > as
> > > > the
> > > > > status.
>
> > > > > 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
>
> > > > Hi,
>
> > > > Alex - do you know roughly when this is likely to be incorporated into
> > > > django? I am working on a project that is going to need to connect to
> > > > multiple databases (I am just planning / designing at the moment), and
> > > > I want to know whether I should start investigating how to do this
> > > > using django 1.0.2 or if that would be a waste of my time.
>
> > > > If it is going to be a while, where would you suggest I start looking
> > > > if I need to understand how to do it with django 1.0.2?
>
> > > > Cheers,
> > > > Em
>
> > > It will, at a minimum not occur until the end of the summer.  Beyond that
> > I
> > > can't make any really useful guesses, other than to say that the
> > aggregation
> > > GSOC project from last summer
> > > ultimately made it's way into django trunk in January, about 3-4 months
> > > after the official end of GSOC.  That may or may not ultimately be
> > > representative of how long it will take multi-db to make it's way back
> > into
> > > Django.  A lot of it probably depends on how the 1.2/1.3 releases are
> > > scheduled.  For example is 1.2 ends up being a smaller release that's put
> > > out in Novemberish I wouldn't expect multi-db to be considered for trunk
> > > until 1.3.  Like I said all of that's rather speculative :)
>
> > > 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
>
> > Thanks Alex. I don't think I can wait that long so it looks like I am
> > going to have to get my hands dirty!
>
> > Is this [1] a sensible starting point?
>
> > [1]
> >http://www.mechanicalgirl.com/view/multiple-database-connection-a-sim...
>
> That blog post is a good source of information, as 
> is:http://www.eflorenzano.com/blog/post/easy-multi-database-support-djan...
> unfortunately appears to be down right now).

Hi,

I have tried implementing this, but I am running into the problems
that others have about too many idle MySQL connections. Is there an
easy way to get around this?

Alex - you mention something here [1] about needing to track the
connections (that are not the default connection). Should I do
something analogous to the connection_counter attribute of the
django.db.models.Manager class?

Em


[1] 
http://groups.google.com/group/django-users/browse_thread/thread/6ed797f6b00dca90
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Using Django other-than as web framework.

2009-07-02 Thread Emily Rodgers

On Jul 2, 8:25 am, Harsha Reddy  wrote:
> I using Django from past one week.
>
> On the Django web site, I read that it is a high-level python web
> framework. Inspite of knowing this I am trying to use a Django
> application both as a web application as well as a CLI client.
>
> To know if this works out, I created a Django project named "pyMyApp"
> and added an application into it.
> I updated the:
>
>             settings.py to detect my application,
>             also models.py to create two tables.
>
> I have an other python file in the application which parses XML. This
> python file makes use of objects defined in the models.py to store the
> parsed values in those 2 tables.
>
> In the directory "../" where my "pyMyApp" resides, I created a file
> index.py added the code to test the parser code. Runnning this file
> yeilds:
>
> python index.py
> Traceback (most recent call last):
>   File "index.py", line 3, in ?
>     from pyAPP.translator.translate import *
>   File "/usr/src/pySCAF/translator/translate.py", line 3, in ?
>     from pySCAF.translator.models import duo, scenario
>   File "/usr/src/pySCAF/../pySCAF/translator/models.py", line 1, in ?
>     from django.db import models
>   File "/usr/lib/python2.4/site-packages/django/db/__init__.py", line
> 10, in ?
>     if not settings.DATABASE_ENGINE:
>   File "/usr/lib/python2.4/site-packages/django/utils/functional.py",
> line 269, in __getattr__
>     self._setup()
>   File "/usr/lib/python2.4/site-packages/django/conf/__init__.py",
> line 38, in _setup
>     raise ImportError("Settings cannot be imported, because
> environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
> ImportError: Settings cannot be imported, because environment variable
> DJANGO_SETTINGS_MODULE is undefined.
>
> By looking at the trace, I got a thought that "Django is designed to
> be used as web framework"
> if at all I want to use it both as cli and web apps, how to achieve
> this in the case above?

Often with my apps I need to have a python script that is not part of
the web app (poking data in from logs, housekeeping scripts, etc). I
don't really know how your cli works, but you probably need to put
this in the script that takes the user input:

from django.core.management import setup_environ
import settings
setup_environ(settings)

This will load your settings file.

HTH,
Em
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Will future Django releases support multiple databases?

2009-07-01 Thread Emily Rodgers



On Jul 1, 3:44 pm, Alex Gaynor  wrote:
> On Wed, Jul 1, 2009 at 9:39 AM, Emily Rodgers <
>
>
>
> emily.kate.rodg...@googlemail.com> wrote:
>
> > On Jul 1, 3:22 pm, Alex Gaynor  wrote:
> > > On Wed, Jul 1, 2009 at 9:16 AM, Emily Rodgers <
>
> > > emily.kate.rodg...@googlemail.com> wrote:
>
> > > > On Jun 25, 6:45 pm, Alex Gaynor  wrote:
> > > > > On Thu, Jun 25, 2009 at 10:24 AM, Tim Chase
> > > > > wrote:
> > > > > > > Right now, Django doesn't seem to support the multiple
> > > > > > > databases on the same server or different servers.  Will that
> > > > > > > feature be available out of the box for future releases?
>
> > > > > > You may want to eavesdrop on the Django Developers group (as
> > > > > > opposed to this Django Users group) where Alex Gaynor has been
> > > > > > posting updates on his GSoC project to add multi-DB support to
> > > > > > Django[1].  There are several aspects to multi-DB support[2] but
> > > > > > I believe he's addressing some of the more common use-cases.  You
> > > > > > can even follow along if you like to live dangerously as I
> > > > > > believe he's got a public repository for his code on GitHub.
>
> > > > > > -tim
>
> > > > > > [1]
>
> >http://groups.google.com/group/django-developers/search?group=django-.
> > > > ..
>
> > > > > > [2]
>
> >http://groups.google.com/group/django-users/browse_thread/thread/6630.
> > > > ..
> > > > > > for my posted concerns
>
> > > > > I have both a public code repository on github at
> > > > github.com/alex/django/ as
> > > > > well as a branch in Django's SVN at branches/soc2009/multidb.  The
> > best
> > > > > place to find out about the work is the django-developers list, where
> > I
> > > > have
> > > > > sent any number of emails discussing both the overall design, as well
> > as
> > > > the
> > > > > status.
>
> > > > > 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
>
> > > > Hi,
>
> > > > Alex - do you know roughly when this is likely to be incorporated into
> > > > django? I am working on a project that is going to need to connect to
> > > > multiple databases (I am just planning / designing at the moment), and
> > > > I want to know whether I should start investigating how to do this
> > > > using django 1.0.2 or if that would be a waste of my time.
>
> > > > If it is going to be a while, where would you suggest I start looking
> > > > if I need to understand how to do it with django 1.0.2?
>
> > > > Cheers,
> > > > Em
>
> > > It will, at a minimum not occur until the end of the summer.  Beyond that
> > I
> > > can't make any really useful guesses, other than to say that the
> > aggregation
> > > GSOC project from last summer
> > > ultimately made it's way into django trunk in January, about 3-4 months
> > > after the official end of GSOC.  That may or may not ultimately be
> > > representative of how long it will take multi-db to make it's way back
> > into
> > > Django.  A lot of it probably depends on how the 1.2/1.3 releases are
> > > scheduled.  For example is 1.2 ends up being a smaller release that's put
> > > out in Novemberish I wouldn't expect multi-db to be considered for trunk
> > > until 1.3.  Like I said all of that's rather speculative :)
>
> > > 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
>
> > Thanks Alex. I don't think I can wait that long so it looks like I am
> > going to have to get my hands dirty!
>
> > Is this [1] a sensible starting point?
>
> > [1]
> >http://www.mechanicalgirl.com/view/multiple-database-connection-a-sim...
>
> That blog post is a good source of information, as 
> is:http://www.eflorenzano.com/blog/post/easy-multi-database-support-djan...
> unfortunately appears to be down right now).
>
> 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

Thanks - it is great that you are working on this because it is one of
the few things that I find a little frustrating about django
(otherwise I am a big fan and often bore my co-workers who prefer to
code in perl - strange people).
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Will future Django releases support multiple databases?

2009-07-01 Thread Emily Rodgers



On Jul 1, 3:22 pm, Alex Gaynor  wrote:
> On Wed, Jul 1, 2009 at 9:16 AM, Emily Rodgers <
>
>
>
> emily.kate.rodg...@googlemail.com> wrote:
>
> > On Jun 25, 6:45 pm, Alex Gaynor  wrote:
> > > On Thu, Jun 25, 2009 at 10:24 AM, Tim Chase
> > > wrote:
> > > > > Right now, Django doesn't seem to support the multiple
> > > > > databases on the same server or different servers.  Will that
> > > > > feature be available out of the box for future releases?
>
> > > > You may want to eavesdrop on the Django Developers group (as
> > > > opposed to this Django Users group) where Alex Gaynor has been
> > > > posting updates on his GSoC project to add multi-DB support to
> > > > Django[1].  There are several aspects to multi-DB support[2] but
> > > > I believe he's addressing some of the more common use-cases.  You
> > > > can even follow along if you like to live dangerously as I
> > > > believe he's got a public repository for his code on GitHub.
>
> > > > -tim
>
> > > > [1]
>
> > > >http://groups.google.com/group/django-developers/search?group=django-.
> > ..
>
> > > > [2]
>
> > > >http://groups.google.com/group/django-users/browse_thread/thread/6630.
> > ..
> > > > for my posted concerns
>
> > > I have both a public code repository on github at
> > github.com/alex/django/ as
> > > well as a branch in Django's SVN at branches/soc2009/multidb.  The best
> > > place to find out about the work is the django-developers list, where I
> > have
> > > sent any number of emails discussing both the overall design, as well as
> > the
> > > status.
>
> > > 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
>
> > Hi,
>
> > Alex - do you know roughly when this is likely to be incorporated into
> > django? I am working on a project that is going to need to connect to
> > multiple databases (I am just planning / designing at the moment), and
> > I want to know whether I should start investigating how to do this
> > using django 1.0.2 or if that would be a waste of my time.
>
> > If it is going to be a while, where would you suggest I start looking
> > if I need to understand how to do it with django 1.0.2?
>
> > Cheers,
> > Em
>
> It will, at a minimum not occur until the end of the summer.  Beyond that I
> can't make any really useful guesses, other than to say that the aggregation
> GSOC project from last summer
> ultimately made it's way into django trunk in January, about 3-4 months
> after the official end of GSOC.  That may or may not ultimately be
> representative of how long it will take multi-db to make it's way back into
> Django.  A lot of it probably depends on how the 1.2/1.3 releases are
> scheduled.  For example is 1.2 ends up being a smaller release that's put
> out in Novemberish I wouldn't expect multi-db to be considered for trunk
> until 1.3.  Like I said all of that's rather speculative :)
>
> 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

Thanks Alex. I don't think I can wait that long so it looks like I am
going to have to get my hands dirty!

Is this [1] a sensible starting point?

[1] 
http://www.mechanicalgirl.com/view/multiple-database-connection-a-simple-use-case/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Will future Django releases support multiple databases?

2009-07-01 Thread Emily Rodgers



On Jun 25, 6:45 pm, Alex Gaynor  wrote:
> On Thu, Jun 25, 2009 at 10:24 AM, Tim Chase
> wrote:
> > > Right now, Django doesn't seem to support the multiple
> > > databases on the same server or different servers.  Will that
> > > feature be available out of the box for future releases?
>
> > You may want to eavesdrop on the Django Developers group (as
> > opposed to this Django Users group) where Alex Gaynor has been
> > posting updates on his GSoC project to add multi-DB support to
> > Django[1].  There are several aspects to multi-DB support[2] but
> > I believe he's addressing some of the more common use-cases.  You
> > can even follow along if you like to live dangerously as I
> > believe he's got a public repository for his code on GitHub.
>
> > -tim
>
> > [1]
>
> >http://groups.google.com/group/django-developers/search?group=django-...
>
> > [2]
>
> >http://groups.google.com/group/django-users/browse_thread/thread/6630...
> > for my posted concerns
>
> I have both a public code repository on github at github.com/alex/django/ as
> well as a branch in Django's SVN at branches/soc2009/multidb.  The best
> place to find out about the work is the django-developers list, where I have
> sent any number of emails discussing both the overall design, as well as the
> status.
>
> 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

Hi,

Alex - do you know roughly when this is likely to be incorporated into
django? I am working on a project that is going to need to connect to
multiple databases (I am just planning / designing at the moment), and
I want to know whether I should start investigating how to do this
using django 1.0.2 or if that would be a waste of my time.

If it is going to be a while, where would you suggest I start looking
if I need to understand how to do it with django 1.0.2?

Cheers,
Em

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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-Logging

2009-05-08 Thread Emily Rodgers



On May 8, 10:33 am, Raashid Malik  wrote:
> This means i have to call debug function with some message as argument. But
> my requirement is that all the django activity should be logged. Is there a
> way where in all operations of an application are logged.


Perhaps AuditTrail is what you are after? 
http://code.djangoproject.com/wiki/AuditTrail

Reversion may also be near what you are looking for:
http://code.google.com/p/django-reversion/


> On Fri, May 8, 2009 at 2:37 PM, K*K  wrote:
>
> > You can have try this snippet:
>
> >http://www.djangosnippets.org/snippets/16/
>
> > On May 8, 3:39 pm, Raashid Malik  wrote:
> > > Hello,
>
> > >    Please guid me to some good resource on django logging.
>
> > > Thanks,
> > > Raashid Malik
>
> --
> Thanks,
> Raashid Malik
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: urlize

2009-03-10 Thread Emily Rodgers



On Feb 10, 3:17 am, Malcolm Tredinnick 
wrote:
> On Mon, 2009-02-09 at 07:29 -0800, Emily Rodgers wrote:
> > Hi,
>
> > I have written a django app that manages 'change requests' (and
> > approvals) for IT infrastructure changes in our company, and I am
> > using theurlizefilter when displaying certain fields (like
> > description of change, test plan etc). This is so that if a user puts
> > a link to documentation for a system / change then it shows up as a
> > link.
>
> > This works reasonably well - in fact too well in some cases. As you
> > can imagine some of the descriptions contain lists of domains, and
> > these are all getting changed to links. I have logged a feature
> > request for my next release of my app to sort the problem out
> > (probably by wrapping lists of domain's in  tags, then
> > writing a custom filter tourlizestuff that is not surrounded by
> > these tags), but I was wondering if this might be something that other
> > django users would want, and if so, is it worth me raising a feature
> > request to get the functionality put in to the djangourlizefilter?
>
> Theurlizetag is designed to "urlize" anything that looks likely to be
> a link. That includes domains, since they can be valid links. If it
> doesn't work for your purposes, don't use it.
>
>
>
> > Or perhaps someone has a better suggestion for how to get around this
> > problem?
>
> Writing custom template tags is (by design) very easy. If any existing
> tag doesn't do what you're after, or you have some other use-case that
> requires special handling, then write the Python code to handle it.
>
> It's pretty much intentional that Django doesn't handle every situation
> out of the box. The universe of possibilities is too large (your example
> is a case in point: you want to exclude some things that are normally
> perfectly valid to be treated as URLs). Instead, we provide a lot of
> ways for people to build their own extensions.

Thanks for your help. I suspected that I would have to do this, but I
thought it would be a good idea to put it out there in case there was
a better way.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



urlize

2009-02-09 Thread Emily Rodgers

Hi,

I have written a django app that manages 'change requests' (and
approvals) for IT infrastructure changes in our company, and I am
using the urlize filter when displaying certain fields (like
description of change, test plan etc). This is so that if a user puts
a link to documentation for a system / change then it shows up as a
link.

This works reasonably well - in fact too well in some cases. As you
can imagine some of the descriptions contain lists of domains, and
these are all getting changed to links. I have logged a feature
request for my next release of my app to sort the problem out
(probably by wrapping lists of domain's in  tags, then
writing a custom filter to urlize stuff that is not surrounded by
these tags), but I was wondering if this might be something that other
django users would want, and if so, is it worth me raising a feature
request to get the functionality put in to the django urlize filter?

Or perhaps someone has a better suggestion for how to get around this
problem?

Em

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: 500.shtml

2008-08-26 Thread Emily Rodgers

Sorry, I am not sure I can help you wrt cookies :(

I think you need to get the logs some how.

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of Ronaldo 
> Zacarias Afonso
> Sent: 26 August 2008 12:49
> To: django-users@googlegroups.com
> Subject: Re: 500.shtml
> 
> 
> Hi Emily,
> 
> Thanks for your help. I'll ask my service provider to provide 
> me with a better logging system, but I think the problem I'm 
> facing is something related with cookies.  When the admin 
> interface tries to test the browser to check if it accepts 
> cookie, the dispatch.fgci process just dies. Have you face 
> something like that before?
> Ronaldo.
> 
> On Tue, Aug 26, 2008 at 5:36 AM, Emily Rodgers 
> <[EMAIL PROTECTED]> wrote:
> > Hi Ronaldo,
> >
> > I really think that your providers can give you more help 
> than we can 
> > at the moment because they have clearly got some scripts in 
> place to 
> > start / stop the webserver. I would ask them if there is an 
> errorlog 
> > file for the webserver, and if not ask them if they can set one up. 
> > Trying to debug web apps without an error log is very 
> tedious and wastes a lot of time.
> >
> > Em
> >
> > 
> > From: django-users@googlegroups.com 
> > [mailto:[EMAIL PROTECTED]
> > On Behalf Of James Matthews
> > Sent: 22 August 2008 22:00
> > To: django-users@googlegroups.com
> > Subject: Re: 500.shtml
> >
> > When i run on a shared provider i restart my server by 
> running touch 
> > /mywebdir/dispatch.fcgi
> >
> >
> > On Fri, Aug 22, 2008 at 6:45 AM, Emily Rodgers 
> <[EMAIL PROTECTED]>
> > wrote:
> >>
> >> Hi Ronaldo,
> >>
> >> It is not a python script, just a shell script that either runs 
> >> 'python manage.py runfcgi' with various options (the 
> errorlog being 
> >> one), or kills the django process if needed (I guess like you are 
> >> doing with "kill -HUP dispatch.pid").
> >>
> >> I think you need to speak to the person who set up your 
> webserver and 
> >> get them to specify an errorlog file, because it sounds like it is 
> >> just throwing an error. Or at least find out how they are starting 
> >> the webserver.
> >>
> >> Em
> >>
> >> > -Original Message-
> >> > From: django-users@googlegroups.com 
> >> > [mailto:[EMAIL PROTECTED] On Behalf Of Ronaldo 
> >> > Zacarias Afonso
> >> > Sent: 22 August 2008 13:45
> >> > To: django-users@googlegroups.com
> >> > Subject: Re: 500.shtml
> >> >
> >> >
> >> > Hi Emily,
> >> >
> >> > Well, in fact I don't start/stop/restart my webserver. As I am 
> >> > using a shared host, the company where I host my website 
> do those 
> >> > things for me.
> >> > When I do some modification to my site I only have to 
> issue a "kill 
> >> > -HUP dispatch.pid" command. Some thing that I notice is 
> that when I 
> >> > try to access the admin page, the dispach is killed (I 
> don't know 
> >> > why).
> >> > Can you send me the python script you have that log 
> things for you?
> >> >
> >> > ps) I don't know if that is the right way to deploy jdango, I'm 
> >> > just learning it.
> >> >
> >> > Thank you very much
> >> > Ronaldo.
> >> >
> >> > On Fri, Aug 22, 2008 at 4:54 AM, Emily Rodgers 
> >> > <[EMAIL PROTECTED]> wrote:
> >> > >
> >> > > How do you start / stop / restart your webserver? If you are 
> >> > > using fastcgi, you may not have it set up to give you 
> an error log.
> >> > >
> >> > > I have a script that starts / stops it, and I have
> >> > specified and error
> >> > > log for the django web server logs, and sent any errors
> >> > with my script
> >> > > commands to a file so that if it doesn't work I can see why:
> >> > >
> >> > > python ./manage.py runfcgi [...] errlog=/path/to/weblog >> 
> >> > > runfcgi_errors
> >> > > 2>&1
> >> > >
> >> > > Em
> >> > >
> >> > >> -Original Message-
> >> > >> From: django-users@googlegroups.com 

RE: 500.shtml

2008-08-26 Thread Emily Rodgers
Hi Ronaldo,
 
I really think that your providers can give you more help than we can at the 
moment because they have clearly got some scripts in place to start / stop the 
webserver. I would ask them if there is an errorlog file for the webserver, and 
if not ask them if they can set one up. Trying to debug web apps without an 
error log is very tedious and wastes a lot of time.
 
Em




From: django-users@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf 
Of James Matthews
Sent: 22 August 2008 22:00
To: django-users@googlegroups.com
Subject: Re: 500.shtml


When i run on a shared provider i restart my server by running touch 
/mywebdir/dispatch.fcgi



On Fri, Aug 22, 2008 at 6:45 AM, Emily Rodgers <[EMAIL PROTECTED]> 
wrote:



Hi Ronaldo,

It is not a python script, just a shell script that either runs 
'python
manage.py runfcgi' with various options (the errorlog being 
one), or kills
the django process if needed (I guess like you are doing with 
"kill -HUP
dispatch.pid").

I think you need to speak to the person who set up your 
webserver and get
them to specify an errorlog file, because it sounds like it is 
just throwing
an error. Or at least find out how they are starting the 
webserver.


Em

> -Original Message-
> From: django-users@googlegroups.com
> [mailto:[EMAIL PROTECTED] On Behalf Of Ronaldo

> Zacarias Afonso
> Sent: 22 August 2008 13:45
> To: django-users@googlegroups.com
> Subject: Re: 500.shtml
>
>
> Hi Emily,
>
> Well, in fact I don't start/stop/restart my webserver. As I
> am using a shared host, the company where I host my website
> do those things for me.
> When I do some modification to my site I only have to issue a
> "kill -HUP dispatch.pid" command. Some thing that I notice is
> that when I try to access the admin page, the dispach is
> killed (I don't know why).
> Can you send me the python script you have that log things 
for you?
>
> ps) I don't know if that is the right way to deploy jdango,
> I'm just learning it.
>
    > Thank you very much
> Ronaldo.
>
> On Fri, Aug 22, 2008 at 4:54 AM, Emily Rodgers
> <[EMAIL PROTECTED]> wrote:
> >
> > How do you start / stop / restart your webserver? If you 
are using
> > fastcgi, you may not have it set up to give you an error 
log.
> >
> > I have a script that starts / stops it, and I have
> specified and error
> > log for the django web server logs, and sent any errors
> with my script
> > commands to a file so that if it doesn't work I can see why:
> >
> > python ./manage.py runfcgi [...] errlog=/path/to/weblog >>
> > runfcgi_errors
> > 2>&1
> >
> > Em
> >
> >> -Original Message-
> >> From: django-users@googlegroups.com
> >> [mailto:[EMAIL PROTECTED] On Behalf Of
> Ronaldo Z. Afonso
> >> Sent: 22 August 2008 01:29
> >> To: django-users@googlegroups.com
> >> Subject: Re: 500.shtml
> >>
> >>
> >> Hi Erik,
> >>
> >> I'm using a shared host with fast-cgi ...
> >> I don´t know if I have a log ... I'll ask my hosting
> service provider.
> >>
> >>
> >> On Fri, 2008-08-22 at 03:24 +0300, Erik Allik wrote:
> >> > Did you check the web server log? If you're using the 
built
> >> in server,
> >> > just look at the console output it produces. B

RE: 500.shtml

2008-08-22 Thread Emily Rodgers

Hi Ronaldo,

It is not a python script, just a shell script that either runs 'python
manage.py runfcgi' with various options (the errorlog being one), or kills
the django process if needed (I guess like you are doing with "kill -HUP
dispatch.pid"). 

I think you need to speak to the person who set up your webserver and get
them to specify an errorlog file, because it sounds like it is just throwing
an error. Or at least find out how they are starting the webserver.

Em

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of Ronaldo 
> Zacarias Afonso
> Sent: 22 August 2008 13:45
> To: django-users@googlegroups.com
> Subject: Re: 500.shtml
> 
> 
> Hi Emily,
> 
> Well, in fact I don't start/stop/restart my webserver. As I 
> am using a shared host, the company where I host my website 
> do those things for me.
> When I do some modification to my site I only have to issue a 
> "kill -HUP dispatch.pid" command. Some thing that I notice is 
> that when I try to access the admin page, the dispach is 
> killed (I don't know why).
> Can you send me the python script you have that log things for you?
> 
> ps) I don't know if that is the right way to deploy jdango, 
> I'm just learning it.
> 
> Thank you very much
> Ronaldo.
> 
> On Fri, Aug 22, 2008 at 4:54 AM, Emily Rodgers 
> <[EMAIL PROTECTED]> wrote:
> >
> > How do you start / stop / restart your webserver? If you are using 
> > fastcgi, you may not have it set up to give you an error log.
> >
> > I have a script that starts / stops it, and I have 
> specified and error 
> > log for the django web server logs, and sent any errors 
> with my script 
> > commands to a file so that if it doesn't work I can see why:
> >
> > python ./manage.py runfcgi [...] errlog=/path/to/weblog >> 
> > runfcgi_errors
> > 2>&1
> >
> > Em
> >
> >> -Original Message-
> >> From: django-users@googlegroups.com
> >> [mailto:[EMAIL PROTECTED] On Behalf Of 
> Ronaldo Z. Afonso
> >> Sent: 22 August 2008 01:29
> >> To: django-users@googlegroups.com
> >> Subject: Re: 500.shtml
> >>
> >>
> >> Hi Erik,
> >>
> >> I'm using a shared host with fast-cgi ...
> >> I don´t know if I have a log ... I'll ask my hosting 
> service provider.
> >>
> >>
> >> On Fri, 2008-08-22 at 03:24 +0300, Erik Allik wrote:
> >> > Did you check the web server log? If you're using the built
> >> in server,
> >> > just look at the console output it produces. Because we
> >> can't help you
> >> > with the information you provided.
> >> >
> >> > Erik
> >> >
> >> >
> >> > On 22.08.2008, at 3:05, Ronaldo Z. Afonso wrote:
> >> >
> >> > >
> >> > > Hi all,
> >> > >
> >> > > This is my first post to this list. I'm trying to 
> access an Admin 
> >> > > page and I'm being redirected to a 500.shtml page. Does
> >> anyone know
> >> > > what could be happening?
> >> > > I'm using Django version 1.0.beta_1.
> >> > > Thanks in advance ...
> >> > >
> >> > > Ronaldo.
> >> > >
> >> > >
> >> > > >
> >> >
> >> >
> >> > >
> >>
> >>
> >> >
> >>
> >
> >
> >
> > >
> >
> 
> > 
> 



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



RE: noob: Where does print output go?

2008-08-22 Thread Emily Rodgers

You could use the python logging module
(http://docs.python.org/lib/module-logging.html) and do
logging.debug(list(product_list)). Then it will appear in your web logs.

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
> Sent: 22 August 2008 09:26
> To: Django users
> Subject: noob: Where does print output go?
> 
> 
> Hi All,
> 
> Can anybody tell me if there's a possibility to see output of 
> the regular print command when used in a view? fo instance to 
> a log file with a "tail -f"
> 
> The code:
> 
> def detail(request, id):
> p = get_object_or_404(Customer, pk=customer_id)
> product_list = p.product_set.all()
> print product_list
> 
> It's not going to stay there, but with commands like dir() 
> and help() I can get a lot of usefull info on the objects I'm 
> working (playing .. ;-) with.
> 
> Thanx a lot!
> 
> Regards,
> 
> Gerard.
> 
> > 
> 

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



RE: 500.shtml

2008-08-22 Thread Emily Rodgers

How do you start / stop / restart your webserver? If you are using fastcgi,
you may not have it set up to give you an error log.

I have a script that starts / stops it, and I have specified and error log
for the django web server logs, and sent any errors with my script commands
to a file so that if it doesn't work I can see why:

python ./manage.py runfcgi [...] errlog=/path/to/weblog >> runfcgi_errors
2>&1

Em

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of Ronaldo Z. Afonso
> Sent: 22 August 2008 01:29
> To: django-users@googlegroups.com
> Subject: Re: 500.shtml
> 
> 
> Hi Erik,
> 
> I'm using a shared host with fast-cgi ... 
> I don´t know if I have a log ... I'll ask my hosting service provider.
> 
> 
> On Fri, 2008-08-22 at 03:24 +0300, Erik Allik wrote:
> > Did you check the web server log? If you're using the built 
> in server, 
> > just look at the console output it produces. Because we 
> can't help you 
> > with the information you provided.
> > 
> > Erik
> > 
> > 
> > On 22.08.2008, at 3:05, Ronaldo Z. Afonso wrote:
> > 
> > >
> > > Hi all,
> > >
> > > This is my first post to this list. I'm trying to access an Admin 
> > > page and I'm being redirected to a 500.shtml page. Does 
> anyone know 
> > > what could be happening?
> > > I'm using Django version 1.0.beta_1.
> > > Thanks in advance ...
> > >
> > > Ronaldo.
> > >
> > >
> > > >
> > 
> > 
> > > 
> 
> 
> > 
> 



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



RE: how to locate the OS currently logged in user??

2008-08-21 Thread Emily Rodgers

 

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of PeteDK
> Sent: 21 August 2008 11:14
> To: Django users
> Subject: Re: how to locate the OS currently logged in user??
> 
> 
> > Have you tested the suggestion above with someone who is not sshed 
> > into the box, because if it is just the remote user of the app you 
> > want, you really don't want to be doing '/usr/bin/ who' 
> because that 
> > will return the users sshed onto the box (and *not* the 
> users logged 
> > into the web app via your authentication system!).
> >
> > I am basically doing what you are (authenticating against 
> LDAP), and 
> > the way you can access the remote user is 
> request.META['AUTHENTICATE_UID'].
> > I am not even using the django auth.User stuff for basic 
> web app usage 
> > (since the user must be authenticated already, I just look 
> to see who 
> > they are), only for the admin stuff. Only a very small number of 
> > people will be using the admin site so I am not to bothered 
> about them 
> > having to log in again (although if there is an easy way of passing 
> > credentials across I could use that!).
> >
> > HTH,
> > Emily
> 
> Hey. I haven't had a chance of testing it yet but it sounds 
> like your method is the one i am looking for :) The thing is, 
> i am not very good with server stuff (i am sure you have 
> figured this out already) ;-) But as i wrote in my last post. 
> The user logs onto the server using the username and password 
> stored in the active directory. This is required before they 
> can access anything on the server.
> 
> After they pass the login they are redirected to my django 
> app, where i would like to avoid having them to log in again.
> so all i really need is the username of the user logging in 
> to the server, so that i can (in the background) log them in 
> to the django app.
> 
> When it comes to the admin part of my django app they will 
> have to use a separate username and password. This is not a 
> problem however since this will be 2 or 3 users at the most.
> 
> I hope this made it more clear? :-)
> 
> but Emily??
> Do you think your method will work on debian linux, and do i 
> need to import something extra in order to get it to work?

I am not very technical either, so I am not entirely sure, but it doesn't
sound like an OS thing, it sounds like a webserver configuration thing. If
you have used PHP with apache before it is lke doing
$_SERVER['REMOTE_USER'].

When you say "The user logs onto the server", do you mean that users point
their browser at a url and a username / password box pops up saying
something like "A user name and password are being requested by
http://blah.com.";?

If the box is set up so that you have to authenticate to view the web pages,
then I would imagine it will work. The webserver will know who the remote
user is because they have authenticated (otherwise they would not be allowed
on), so it is just a matter of accessing this, and the data will be
somewhere in the request object. It is just a matter of finding it.

I think what I did to figure out how to get the user, was something like
logging.debug(vars(request.META)) (in my view), got a couple of people in my
office a link to my webapp, and hunted around from there.

To use logging.debug you need to do this:

import logging
logging.basicConfig(
level = logging.DEBUG,
format = '%(asctime)s %(levelname)s %(message)s',
)


If you are still stuck it is worth asking the person who set up the web
server to give you more details about it, and find out how the django server
is started (and let us know).

Em :)



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



RE: how to locate the OS currently logged in user??

2008-08-21 Thread Emily Rodgers

 

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of PeteDK
> Sent: 20 August 2008 17:54
> To: Django users
> Subject: Re: how to locate the OS currently logged in user??
> 
> 
> 
> 
> On 20 Aug., 17:56, "Emily Rodgers" <[EMAIL PROTECTED]> wrote:
> > > -Original Message-
> > > From: django-users@googlegroups.com
> > > [mailto:[EMAIL PROTECTED] On Behalf Of Steve Holden
> > > Sent: 20 August 2008 16:37
> > > To: django-users@googlegroups.com
> > > Subject: Re: how to locate the OS currently logged in user??
> >
> > > PeteDK wrote:
> > > > Hi.
> >
> > > > I want to retreive the name of the currently logged in user
> > > on the OS
> > > > on which my django app lives.
> > > > Is this possible?
> >
> > > > The thing is. The app is to be used in a private
> > > environment, so all
> > > > the users have to log on to the webserver first(this cant
> > > be changed).
> > > > I would be nice to avoid having them to log into the django app 
> > > > afterwards.
> >
> > > > So after they are logged into the webserver it would be
> > > fair to assume
> > > > they are authorised users and if i could just locate their
> > > OS username
> > > > somehow then i could use this username to login the current
> > > user, in
> > > > the background with a standard password.
> >
> > > > I hope you get my meaning:)
> >
> > > > i have looked into the python standard library, and a 
> module named
> > > > getpass() however i cant get i to work:-(
> >
> > > > i hope someone has a clever idea to solve this problem.
> >
> > > You seem to be assuming that the server is always accessed from a 
> > > browser running on the same machine. You should guarantee this by 
> > > running Django only on the 127.0.0.1 interface. As has 
> already been 
> > > pointed out, they need not be the only user logged on, however.
> >
> > It does seem like a really odd thing to do. Are you sure you don't 
> > just want to find out the user viewing the webapp via a 
> browser (who 
> > has already authenticated in a system other than django)?
> 
> Well yeah that is what i want. I'm sorry if i haven't 
> explained myself well enough.
> The system works like this: The user follows a link to the django app.
> The app is stored on a server which requires authentication. 
> (This way the users can use the same password for the server 
> as they use on the rest of the system.) What i want is i want 
> to know the user who is trying to view the django app, so 
> that i can, in the background, log this user into the django 
> app. This way they dont have to have 2 separate user accounts 
> with 2 separate passwords.
> 
> So i dont need to know the users password, just the username. 
> Because then i can use this to find a corresponding username 
> in the django app and log the user in this way. i hope i made 
> it more clear :-)
> 
> But actually i think the first solution would work find:
> 
> namelist = [line.split()[0] for line in 
> commands.getoutput("/usr/bin/ who").split("\n")] 
> userLoggingIn = namelist[-1]
> 
> unless there can be problems with using the latest user entry 
> in the namelist?


Have you tested the suggestion above with someone who is not sshed into
the box, because if it is just the remote user of the app you want, you
really don't want to be doing '/usr/bin/ who' because that will return
the users sshed onto the box (and *not* the users logged into the web
app via your authentication system!).

I am basically doing what you are (authenticating against LDAP), and the
way you can access the remote user is request.META['AUTHENTICATE_UID'].
I am not even using the django auth.User stuff for basic web app usage
(since the user must be authenticated already, I just look to see who
they are), only for the admin stuff. Only a very small number of people
will be using the admin site so I am not to bothered about them having
to log in again (although if there is an easy way of passing credentials
across I could use that!).

HTH,
Emily



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



RE: how to locate the OS currently logged in user??

2008-08-20 Thread Emily Rodgers

 

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of Steve Holden
> Sent: 20 August 2008 16:37
> To: django-users@googlegroups.com
> Subject: Re: how to locate the OS currently logged in user??
> 
> 
> PeteDK wrote:
> > Hi.
> > 
> > I want to retreive the name of the currently logged in user 
> on the OS 
> > on which my django app lives.
> > Is this possible?
> > 
> > The thing is. The app is to be used in a private 
> environment, so all 
> > the users have to log on to the webserver first(this cant 
> be changed).
> > I would be nice to avoid having them to log into the django app 
> > afterwards.
> > 
> > So after they are logged into the webserver it would be 
> fair to assume 
> > they are authorised users and if i could just locate their 
> OS username 
> > somehow then i could use this username to login the current 
> user, in 
> > the background with a standard password.
> > 
> > I hope you get my meaning:)
> > 
> > i have looked into the python standard library, and a module named
> > getpass() however i cant get i to work:-(
> > 
> > i hope someone has a clever idea to solve this problem.
> > 
> You seem to be assuming that the server is always accessed 
> from a browser running on the same machine. You should 
> guarantee this by running Django only on the 127.0.0.1 
> interface. As has already been pointed out, they need not be 
> the only user logged on, however.


It does seem like a really odd thing to do. Are you sure you don't just
want to find out the user viewing the webapp via a browser (who has
already authenticated in a system other than django)?

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



RE: how to populate data again after validation

2008-08-20 Thread Emily Rodgers

It is defintely worth using django where possible to do what it can
(otherwise why use django!). The form stuff can do loads for you (validation
for one).

http://www.djangoproject.com/documentation/modelforms/

and 

http://www.djangoproject.com/documentation/models/model_forms/

Are really useful. If the input tags don't display the way you like, you can
either write your own widgets, or define a class for them and use CSS
(depending on what you want to do).

Here is a really cut down version of what you can do to get django to
display a form from a model (not very well coded but simple).
In your view...

def my_view(request)
if request.method == 'POST':
f = ContactForm(request.POST)
if f.is_valid():
f.save()
return HttpResponseRedirect('/home/')
else:
f = ContactForm()
return render_to_response('contact.html', locals())


In the contact.html template

...


{{ f.as_table }







That should get you started, but the docs are good and it is worth going
through them.

Of course you don't have to do f.as_table, you can access the fields and
display them where you like, but best to start with the basics to understand
how django works first.

Em


> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of Will Rocisky
> Sent: 20 August 2008 12:03
> To: Django users
> Subject: Re: how to populate data again after validation
> 
> 
> actually I feel comfortable with custom html stuff.. thats why.
> ooopps yeah that was a typo since I typed everything while am 
> on-the- go :)
> 
> I am new to django so I don't really know what to do.
> could you please a little more?
> thanks
> 
> On Aug 20, 4:55 pm, "Emily Rodgers" <[EMAIL PROTECTED]> wrote:
> > Why are you using your own  tags (just out of interest!)? It 
> > might be that you have just provided a cut down version of 
> your code 
> > but from what I see, there are a few reasons why it may not 
> be working properly.
> >
> > It looks like you are only passing the errors to the 
> template, but not 
> > the other form values. If you want the previous data, you 
> will need to 
> > put it in your context.
> >
> > Is any validation working at all, and is it saving any data 
> to the db? 
> > It looks like you are calling is_valid on your POST data (not on an 
> > instance of your form object). If you want to pass your 
> POST data to 
> > the form, you need to do something like this:
> >
> > f = ContactForm(request.POST)
> >
> > Or if you need to put more data in (or munged data):
> >
> > contact_instance = Contact(att=value)
> > f = ContactForm(request.POST, instance=contact_instance)
> >
> > HTH
> >
> > Em
> >
> > > -Original Message-
> > > From: django-users@googlegroups.com
> > > [mailto:[EMAIL PROTECTED] On Behalf Of Will Rocisky
> > > Sent: 20 August 2008 11:24
> > > To: Django users
> > > Subject: Re: how to populate data again after validation
> >
> > > I am just using...
> >
> > > model...
> > > class Contact(models.Model):
> > >    Name = models.CharField(max_length=100)
> > >    email = models.CharField(max_length=100)
> > >    comments = models.TextField(blank=False)
> >
> > > form...
> > > class ContactForm(ModelForm):
> > >    Name = forms.CharField(label='Name')
> > >    email = forms.EmailField(label='Email')
> > >    comments =
> > > forms.CharField(label='Comments',widget=forms.Textarea)
> >
> > >    class Meta:
> > >            model = Contact
> >
> > > views...
> > > f = ContactForm()
> > > f = request.POST
> > > if f.is_valid():
> > >     f.save()
> > >     return HttpResponseRedirect('/home/')
> > > else:
> > >     ctx = {}
> > >     ctx['errors'] = f.errors
> > >     return render_to_response('contact.html',ctx)
> >
> > > when it doesn't save because validation failed, it renders 
> > > contact.html again, but blank. All previous data lost.
> >
> > > On Aug 20, 4:07 pm, "Emily Rodgers" <[EMAIL PROTECTED]> wrote:
> > > > Hello,
> >
> > > > How are you doing your validation? Is the form 
> populating a model 
> > > > instance or doing something else?
> >
> > > > I would be helpful to see some of the function in your 
> views file.
> >
> &g

RE: how to populate data again after validation

2008-08-20 Thread Emily Rodgers

Why are you using your own  tags (just out of interest!)? It might be
that you have just provided a cut down version of your code but from what I
see, there are a few reasons why it may not be working properly.

It looks like you are only passing the errors to the template, but not the
other form values. If you want the previous data, you will need to put it in
your context.

Is any validation working at all, and is it saving any data to the db? It
looks like you are calling is_valid on your POST data (not on an instance of
your form object). If you want to pass your POST data to the form, you need
to do something like this:

f = ContactForm(request.POST)

Or if you need to put more data in (or munged data):

contact_instance = Contact(att=value)
f = ContactForm(request.POST, instance=contact_instance)

HTH

Em

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of Will Rocisky
> Sent: 20 August 2008 11:24
> To: Django users
> Subject: Re: how to populate data again after validation
> 
> 
> I am just using...
> 
> model...
> class Contact(models.Model):
>   Name = models.CharField(max_length=100)
>   email = models.CharField(max_length=100)
>   comments = models.TextField(blank=False)
> 
> form...
> class ContactForm(ModelForm):
>   Name = forms.CharField(label='Name')
>   email = forms.EmailField(label='Email')
>   comments = 
> forms.CharField(label='Comments',widget=forms.Textarea)
> 
>   class Meta:
>   model = Contact
> 
> views...
> f = ContactForm()
> f = request.POST
> if f.is_valid():
> f.save()
> return HttpResponseRedirect('/home/')
> else:
> ctx = {}
> ctx['errors'] = f.errors
> return render_to_response('contact.html',ctx)
> 
> when it doesn't save because validation failed, it renders 
> contact.html again, but blank. All previous data lost.
> 
> On Aug 20, 4:07 pm, "Emily Rodgers" <[EMAIL PROTECTED]> wrote:
> > Hello,
> >
> > How are you doing your validation? Is the form populating a model 
> > instance or doing something else?
> >
> > I would be helpful to see some of the function in your views file.
> >
> > Em
> >
> > > -Original Message-
> > > From: django-users@googlegroups.com
> > > [mailto:[EMAIL PROTECTED] On Behalf Of Will Rocisky
> > > Sent: 20 August 2008 10:45
> > > To: Django users
> > > Subject: how to populate data again after validation
> >
> > > I am not using builtin {{form}} to print form in template. I am 
> > > using my own  things.
> > > Now, after validation, when it shows error and comes back 
> to form, 
> > > all the data has disappeared.
> > > How can I keep data in fields even after validation.
> >
> > > I am using render_to_response
> > 
> 



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



RE: how to populate data again after validation

2008-08-20 Thread Emily Rodgers

Hello,

How are you doing your validation? Is the form populating a model instance
or doing something else?

I would be helpful to see some of the function in your views file.

Em

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of Will Rocisky
> Sent: 20 August 2008 10:45
> To: Django users
> Subject: how to populate data again after validation
> 
> 
> I am not using builtin {{form}} to print form in template. I 
> am using my own  things.
> Now, after validation, when it shows error and comes back to 
> form, all the data has disappeared.
> How can I keep data in fields even after validation.
> 
> I am using render_to_response
> > 
> 



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



RE: How to tiger mail

2008-08-20 Thread Emily Rodgers

This explained it all to me when I first started using cron.

http://www.unixgeeks.org/security/newbie/unix/cron-1.html

I also put this at the top of my crontab file to remind me what is what:

#minute (0-59),
#   hour (0-23),
#   day of month (1-31),
#   month of the year (1-12),
#   day of the week (0-6 with 0=Sunday),
#   cmd

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of laspal
> Sent: 20 August 2008 06:58
> To: Django users
> Subject: Re: How to tiger mail
> 
> 
> Can anyone give a link for doing corn job.
> 
> Thanks
> 
> On Aug 19, 4:43 pm, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> > Wiadomość napisana w dniu 2008-08-19, o godz. 13:31, przez laspal:
> >
> >
> >
> > > hi,
> > > I wanted to know how can I automatically tiger mail if 
> some task is 
> > > overdue by 1 day.
> > > I have idea of using send_mail but wanted to send mail 
> when the task 
> > > is overdue...
> >
> > You have to use some kind of cron job to check things like that.
> > Django itself has no "scheduler" mechanism.
> >
> > --
> > We read Knuth so you don't have to. - Tim Peters
> >
> > Jarek Zgoda
> > [EMAIL PROTECTED]
> > 
> 



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



RE: limit choices to logged-in user

2008-08-19 Thread Emily Rodgers

 

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of patrickk
> Sent: 19 August 2008 14:12
> To: Django users
> Subject: limit choices to logged-in user
> 
> 
> is there a way to limit choices (using foreign key) to the 
> logged-in user?
> 
> I´ve tried  limit_choices_to = {'user': request.user}, but 
> that is obviously not working since "request" is not available.
> 
> any ideas?

What are you trying to do exactly? Is this to auto populate some kind of
form, or just for data integrity?

If I have a model that has a user field, and I want it to be the remote
user, I normally just set this in my view. Not sure if this is the best
thing to do but it seems to work for me.



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



RE: "remote models" with django?

2008-07-11 Thread Emily Rodgers

So you want it to interact with the db that app A would normally interact
with (not just copy your schema / methods)?

I don't really know how you can do that :( 

I have managed to interact with my db, via my django models in an app
installed in project 'my_proj', from an external script using:

from django.core.management import setup_environ
import my_proj.settings
setup_environ(my_proj.settings)

But I don't know who you could go about this without effecting your existing
django environment :(

Unless of course you use an external script to do your interacting with app
A, and have some kind of interface into it?

Not really sure I can be of much help...

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of lgr888999
> Sent: 11 July 2008 12:48
> To: Django users
> Subject: Re: "remote models" with django?
> 
> 
> I was looking for something like rails activeresources
> 
> In app A, just a regular model
> 
> class Bar(models.Model):
> text = models.CharField(_('text'), max_length=140)
> 
> in app B
> 
> #ok i cant figure out any better name than RemoteModel atm 
> class Bar(models.RemoteModel):
>site = 'http://1.2.3.4/foo/bar
> 
> 
> in some view:
> Bar.objects.filter()
> Bar.objects.get(pk=2).delete()
> Bar(text='foo').save()
> etc and it will perform http GET, POST, PUT, DELETE etc to 
> http://1.2.3.4/foo/bar
> 
> 
> Obviously, it will only work with relations that already is 
> on app A, this is mosly for denormalizing stuff to be able to 
> scale in all directions.
> 
> 
> 
> On 11 Juli, 12:35, "Emily Rodgers" <[EMAIL PROTECTED]> wrote:
> > Also, what do you mean by 'a restful model backend instead of a 
> > database backend'?
> >
> > What are you trying to do? I have some ideas, but I may be 
> barking up 
> > the wrong tree!!
> >
> >
> >
> > > -Original Message-
> > > From: django-users@googlegroups.com
> > > [mailto:[EMAIL PROTECTED] On Behalf Of lgr888999
> > > Sent: 11 July 2008 11:10
> > > To: Django users
> > > Subject: Re: "remote models" with django?
> >
> > > nope different sites on different IPs
> >
> > > On 11 Juli, 11:44, "Emily Rodgers" <[EMAIL PROTECTED]> wrote:
> > > > Are they in the same project?
> >
> > > > > -Original Message-
> > > > > From: django-users@googlegroups.com 
> > > > > [mailto:[EMAIL PROTECTED] On Behalf Of lgr888999
> > > > > Sent: 11 July 2008 10:33
> > > > > To: Django users
> > > > > Subject: "remote models" with django?
> >
> > > > > Lets say i have two django apps A and B. Lets say A has
> > > some models,
> > > > > Foo and Bar.
> >
> > > > > Now i know there are plenty of implementations to make
> > > Foo and Bar
> > > > > restfuly available via http but is there anything built
> > > yet to make
> > > > > Foo and Bar available as Models on B via http? Ie a restful 
> > > > > model backend instead of a database backend.
> >
> > --
> > IMPORTANT NOTICE: The contents of this email and any 
> attachments are confidential and may also be privileged. If 
> you are not the intended recipient, please notify the sender 
> immediately and do not disclose the contents to any other 
> person, use it for any purpose, or store or copy the 
> information in any medium.  Thank you.
> > 
> 



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



RE: "remote models" with django?

2008-07-11 Thread Emily Rodgers

Also, what do you mean by 'a restful model backend instead of a database
backend'?

What are you trying to do? I have some ideas, but I may be barking up
the wrong tree!!

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of lgr888999
> Sent: 11 July 2008 11:10
> To: Django users
> Subject: Re: "remote models" with django?
> 
> 
> nope different sites on different IPs
> 
> On 11 Juli, 11:44, "Emily Rodgers" <[EMAIL PROTECTED]> wrote:
> > Are they in the same project?
> >
> > > -Original Message-
> > > From: django-users@googlegroups.com
> > > [mailto:[EMAIL PROTECTED] On Behalf Of lgr888999
> > > Sent: 11 July 2008 10:33
> > > To: Django users
> > > Subject: "remote models" with django?
> >
> > > Lets say i have two django apps A and B. Lets say A has 
> some models, 
> > > Foo and Bar.
> >
> > > Now i know there are plenty of implementations to make 
> Foo and Bar 
> > > restfuly available via http but is there anything built 
> yet to make 
> > > Foo and Bar available as Models on B via http? Ie a restful model 
> > > backend instead of a database backend.
> > 
> 

-- 
IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium.  Thank you.



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



RE: How to display the images in the template page under the django development server

2008-07-11 Thread Emily Rodgers
Try doing 
 

 
Ideally you want your media url to be available in all of your templates (so
you can do  in your templates).
To do this kind of thing you can set up a context processor. There is a good
example here:
http://www.b-list.org/weblog/2006/jun/14/django-tips-template-context-proces
sors/.
 
Hope this helps,
Em



  _  

From: django-users@googlegroups.com [mailto:[EMAIL PROTECTED]
On Behalf Of Eric Liu
Sent: 11 July 2008 10:37
To: django-users@googlegroups.com
Subject: How to display the images in the template page under the django
development server


Hi all
I have a lot of green in Django.When I create a app and try to show a
image in the the html ,I ran into trouble
that is the images can't be shown in the page.following is my page code:



{%block title%}{%endblock%}


My helpful timestamp site:

{%block content%}{%endblock%}

{% block footer %}

Thanks for visiting my site.
{% endblock %}






by the way,before I send this email ,I search many documents,like,someone
said following steps can help me,
http://www.djangoproject.com/documentation/static_files/

I do it step by step.but the problem still exist.

following is my configuration:

in urls.py:


from django.conf.urls.defaults import *
from mysite.view import current_time,ahead_hours
from django.conf import settings

urlpatterns = patterns('',
 (r'^time/$', current_time),

(r'^site_media/(?P.*)$', 'django.views.static.serve',
{'document_root': 'D:/test/mysite/mysite_media'}),
)

and in settings.py:

MEDIA_ROOT = "D:/test/mysite/mysite_media"
MEDIA_URL = 'http://localhost:8080/mysite_media/'



I store the CSS ,JS,and Image in the folder "mysite_media"


Is there something wrong with me?

I'd really appreciate it if you can help me.

Thanks 







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



RE: "remote models" with django?

2008-07-11 Thread Emily Rodgers

Are they in the same project? 

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of lgr888999
> Sent: 11 July 2008 10:33
> To: Django users
> Subject: "remote models" with django?
> 
> 
> Lets say i have two django apps A and B. Lets say A has some 
> models, Foo and Bar.
> 
> 
> Now i know there are plenty of implementations to make Foo 
> and Bar restfuly available via http but is there anything 
> built yet to make Foo and Bar available as Models on B via 
> http? Ie a restful model backend instead of a database backend.
> > 
> 



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



RE: how does {% url %} work?

2008-07-11 Thread Emily Rodgers

> That is what I meant when I said ('^clients/$',
> include('project_name.app_name.urls'))  - I just forgot to 
> take out the $!!

Ir even when I said

(r'^coosci/$', include('coosci.webapp.urls')),

It is way too early for my little brain!



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



RE: how does {% url %} work?

2008-07-11 Thread Emily Rodgers

 

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of V
> Sent: 11 July 2008 09:31
> To: Django users
> Subject: Re: how does {% url %} work?
> 
> 
> > > but it gives only
> > > /projects/join/6/
> >
> > That's exactly what's expected.
> 
> Have you ever checked the docs (http://www.djangoproject.com/ 
> documentation/templates/#url)? This /clients/client/123/ is expected!
> 
> if I do
> (r'^coosci/$', include('coosci.webapp.urls')), it won't work 
> as $ closes the regex, so this is where the url should end, I 
> think this is simply wrong (I even tried it, and it was wrong)
> 
> I tried to replicate the setting in the docs at 
> http://www.djangoproject.com/documentation/templates/#url
> 0. cd to my_project dir
> 1. python manage.py startapp app_name
> 2. add the urls.py snippet ('^clients/',
> include('my_project.app_name.urls')) to the main urls.py 3. 
> create a new urls.py under app_name, and add to it 
> ('^client/(\d+)/ $', 'app_views.client') 4. create 
> app_views.py and define a view that simply shows the url with 
> {% url app_views.client client.id %}
> 
> then at http://127.0.0.1:8000/clients/client/1 I get a 
> ViewDoesNotExist error, for some reason the app_view.py file 
> isn't treated as a module, and it can't be imported.
> There is an __init__.py in the directory as created by startapp.
> 
> I think what happens is that in django/core/urlsresolvers.py 
> get_callable finds properly the mod_name=app_name and 
> func_name=client, but its import statement (line 47) fails as 
> app_name in itself can't be seen from the project_root for example.
> 
> I was playing with it a bit, and what worked is the following:
> 3. create a new urls.py under app_name, and add to it 
> ('^client/(\d+)/ $', 'app_name.app_views.client') 4. create 
> app_views.py and define a view that simply shows the url with 
> {% url app_name.app_views.client client.id %}
> 
> I hope this will help someone as well!
> 
> In the meantime I just realised that my problem was another 
> row in the main urls.py:
> #(r'^$', include('coosci.main_app.urls')), --> this was the 
> problem, so django docs was indeed correct except for the {% 
> url %} syntax
> ('^clients/', include('project_name.app_name.urls'))
> 
> Cheers, V

That is what I meant when I said ('^clients/$',
include('project_name.app_name.urls'))  - I just forgot to take out the $!!

Sorry!



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



RE: how does {% url %} work?

2008-07-10 Thread Emily Rodgers

I think that you need to do  

(r'^coosci/$', include('coosci.webapp.urls')),

In your myproject/urls.py file for that to work (but I could be wrong!).

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of Viktor Nagy
> Sent: 10 July 2008 17:10
> To: django-users@googlegroups.com
> Subject: how does {% url %} work?
> 
> 
> Hi 5!
> 
> I have the following files
> myproject/urls.py with a line
> 
> (r'^$', include('coosci.webapp.urls')),
> 
> then I have
> myproject/coosci/urls.py with a line
> (r'^projects/join/(?P\d+)/$', 'join_project'),
> 
> and finally in my template
> {% url webapp.views.join_project project_id=project.project.id %}
> 
> as far as I understand
> (http://www.djangoproject.com/documentation/templates/#url) 
> this should give back a link to /coosci/projects/join/6/
> 
> but it gives only
> /projects/join/6/
> 
> is there something I miss? how can I get the "proper" link?
> I'm using the SVN version
> 
> thanks, V
> 
> > 
> 

-- 
IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium.  Thank you.



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



RE: problem serving image [ERROR: Page not found: /usr/lib/python2.5/site-packages/djangotrunk/django/contrib/admin/media/amazon.gif]

2008-07-10 Thread Emily Rodgers

Try changing your directory (and paths) to something like myapp_media
instead of media. Media is used by the admin interface for the css / js
files there, which is why it is getting confused.

Em 

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of reyjexter
> Sent: 10 July 2008 16:37
> To: Django users
> Subject: problem serving image [ERROR: Page not found: 
> /usr/lib/python2.5/site-packages/djangotrunk/django/contrib/ad
> min/media/amazon.gif]
> 
> 
> I tried following the documentation but I cant seem to serve an image.
> I'm getting this error:
> 
> ERROR: Page not found: /usr/lib/python2.5/site-packages/djangotrunk/
> django/contrib/admin/media/amazon.gif
> 
> when trying to browse http://localhost:8080/amazon.gif
> 
> I run the server using this:
> 
> ./manage.py runserver localhost:8080
> 
> this is my urls.py:
> 
> from django.conf.urls.defaults import *
> from django.conf import settings
> 
> urlpatterns = patterns('',
> 
> (r'^media/(.*)$', 'django.views.static.serve', 
> {'document_root': '/ home/user/workspace/mysite/media/'}),
> 
> )
> 
> 
> and this is my MEDIA and MEDIA_URL:
> 
> MEDIA_ROOT = '/home/user/workspace/mysite/media/'
> MEDIA_URL = 'http://localhost:8080/media/'
> 
> 
> 
> 
> > 
> 

-- 
IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium.  Thank you.



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



RE: XML and django

2008-07-10 Thread Emily Rodgers

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of Ahmad Akkaoui
> Sent: 10 July 2008 16:19
> To: django-users@googlegroups.com
> Subject: XML and django
> 
> 
> Hello everyone,
> 
> I would like to know how to I would go about parsing an xml 
> string in Django. Is there a built in XML library or am I 
> going to have to rely on external parsers.
> 
> Thanks!
> 
> > 
> 

I think you want to be looking at the python libs:
http://docs.python.org/lib/markup.html

I have used the python html parser successfully, and I assume the xml one is
similar, but it looks like you need this too: http://www.libexpat.org/



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



RE: Django and DateBase refresh

2008-07-10 Thread Emily Rodgers

 

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of maria
> Sent: 10 July 2008 12:41
> To: Django users
> Subject: Django and DateBase refresh
> 
> 
> I am really new in Django but I really want to know what 
> should I do to build web application, which would be reload 
> automatically because datebase would be changing continuously.
> Could somebody help me?
> plx
> 
> > 
> 

Hi Maria,

Are you sure this is what you want to do? It is the kind of thing that
should only really happen if a user wants to open one page and leave it
there for a long period of time (without navigating between pages), but have
it update as soon as new data comes in. The only real life example of this I
can think of is gmail.

If this is really what you want to do, it sounds like you need to use some
client-side scripting, or AJAX. If you are wanting a web app that will
refresh every 5 or so minutes (for example), you could just set some kind of
script that will tell the users browser to refresh on a timer. This is not a
great idea because it is quite disruptive for the user - and the javascript
can be evil. Using AJAX would be less disruptive to the user, but quite
complicated. What would probably happen, is the client-side javascript would
query the server-side script (your python code) every so often, to query the
db, and see if any new data has been entered, then your server-side script
would present the data in text, html or xml (if there is new data) back to
the client-side script, which would put it where you want on the page. If
you do go down this route, I would use something like Protoculous. There is
a good django / AJAX tutorial here: http://www.willarson.com/blog/?p=36.

I tend to use AJAX for fetching extra info on a page, performing an action
without navigating away (think poking of facebook), or creating dynamic
dropdown lists based on user actions or something.

If your user is going to navigate between pages, the pages will be generated
using the data in the db at time of loading, so it should be reasonably up
to date. This is what most webapps do in my experience, and also what most
users expect to happen.

HTH,
Em



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



RE: The Lost Fingers

2008-06-27 Thread Emily Rodgers

I am listening to Django and Stephane right now (and using Django) :)


> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> [EMAIL PROTECTED]
> Sent: 27 June 2008 03:04
> To: Django users
> Subject: Re: The Lost Fingers
> 
> 
> While definitely off-topic, I appreciate the heads up. I live 
> in a world where the framework and the guitarist often intersect.
> 
> On Jun 26, 9:01 am, Dan <[EMAIL PROTECTED]> wrote:
> > This isn't related to Django the framework but Django the 
> musician, I 
> > figure you'd find it interesting anyway.
> >
> > I saw in the newspaper this morning that a group from Quebec called 
> > The Lost Fingers released an album called Lost in the 80's 
> where they 
> > play well known songs in Django Reinhardt style. The album 
> costs $40 
> > on Amazon but only $15 if you buy it from a Quebec Label / 
> Discstore 
> :http://www.archambault.ca/store/product.asp?sku=002106354&typ
> e=1&lang...
> >
> > Or just use bittorrent :)
> > 
> 



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



RE: Url tag issues

2008-06-23 Thread Emily Rodgers

 

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of Rajesh Dhawan
> Sent: 20 June 2008 19:06
> To: Django users
> Subject: Re: Url tag issues
> 
> 
> Hi Emily,
> 
> 
> 
> > > >
> > > > The problems I am hitting are mainly to do with the {% url 
> > > > app.views.function keyword=optval %} tags to generate urls
> > > for my link bar.
> 
> 
> Firstly, as phillc suggests, it's a good idea to first name 
> your index page so it's easier to reference it in your url tags.
> 
> > > >
> > > > The combinations or parameters I want to use are:
> > > >
> > > > id
> > > > id + filter
> > > > filter
> > > > and sort_by (alone, or with any of the above combinations)
> 
> Since you need that kind of flexibility in which parameters 
> and combinations you can have, consider using query string 
> parameters instead of url path parameters.

This is what I would normally have done, but I got the impression that
this kinda went again what django is about, so I was trying to do it in
a more djangoesque way!! Perhaps I will just do it how I would have
before!!

Thanks for pointing out the obvious (that I had been stupidly
disregarding) to me :)

Em

-- 
IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium.  Thank you.



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



RE: Url tag issues

2008-06-20 Thread Emily Rodgers

Cheers, I have been thinking of that, but also using includes. Still haven't
managed to make it work the way I want :(

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of phillc
> Sent: 19 June 2008 20:31
> To: Django users
> Subject: Re: Url tag issues
> 
> 
> use of named urls will probably make that a ton easier
> 
> On Jun 19, 11:45 am, "Emily Rodgers" <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I have been hitting a brick wall so many times now on this 
> that it is 
> > starting to hurt!! Please help if you can...
> >
> > I have an index page, and I want my function for it (in 
> views.py) to 
> > take a number of parameters to decide what to display, but I can't 
> > figure out how to do it.
> >
> > The kinds of options I want to give it are things like, pkid of the 
> > thing I want to select (for more details), a filter to apply to the 
> > list of things shown on the index page, the name of the attribute I 
> > want to sort the index table by.
> >
> > The problems I am hitting are mainly to do with the {% url 
> > app.views.function keyword=optval %} tags to generate urls 
> for my link bar.
> >
> > The combinations or parameters I want to use are:
> >
> > id
> > id + filter
> > filter
> > and sort_by (alone, or with any of the above combinations)
> >
> > I have managed to write a regex to understand these options and my 
> > views function does what I want, but with that regex, the 
> {% url blah 
> > thing %} just doesn't work at all. Do I need to just write loads of 
> > separate regexes (for different combinations!)?
> >
> > The regex that works (reading urls), but doesn't generate urls is 
> > something along the lines of:
> >
> > 
> r'^co(|(?P\d*)/)(|/filter/(?P\w*)/)(|sort/(?P\
> > w*)/)$
> > '
> >
> > The kinds of url tag things I have been using are:
> >
> > {% url myapp.views.index id=3 %}
> > {% url myapp.views.index filter_by="comp" %} {% url 
> myapp.views.index 
> > filter_by="comp",sort_by="date" %}
> >
> > But they just evaluate to an empty string :(
> >
> > The problem is the option thing. Am I just being lazy / stupid?
> >
> > Em
> >
> > Information Security Analyst, ARM Ltd, 110 Fulbourn Road, Cambridge 
> > CB1 9NJ, UK
> > Tel: +44 (0) 1223 406 365
> > 
> 



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Url tag issues

2008-06-19 Thread Emily Rodgers

Hi,

I have been hitting a brick wall so many times now on this that it is
starting to hurt!! Please help if you can...

I have an index page, and I want my function for it (in views.py) to take a
number of parameters to decide what to display, but I can't figure out how
to do it.

The kinds of options I want to give it are things like, pkid of the thing I
want to select (for more details), a filter to apply to the list of things
shown on the index page, the name of the attribute I want to sort the index
table by.

The problems I am hitting are mainly to do with the {% url
app.views.function keyword=optval %} tags to generate urls for my link bar.

The combinations or parameters I want to use are:

id
id + filter
filter
and sort_by (alone, or with any of the above combinations)

I have managed to write a regex to understand these options and my views
function does what I want, but with that regex, the {% url blah thing %}
just doesn't work at all. Do I need to just write loads of separate regexes
(for different combinations!)?

The regex that works (reading urls), but doesn't generate urls is something
along the lines of:

r'^co(|(?P\d*)/)(|/filter/(?P\w*)/)(|sort/(?P\w*)/)$
'

The kinds of url tag things I have been using are:

{% url myapp.views.index id=3 %}
{% url myapp.views.index filter_by="comp" %}
{% url myapp.views.index filter_by="comp",sort_by="date" %}

But they just evaluate to an empty string :(

The problem is the option thing. Am I just being lazy / stupid?

Em

Information Security Analyst, ARM Ltd,
110 Fulbourn Road, Cambridge CB1 9NJ, UK
Tel: +44 (0) 1223 406 365 



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



RE: sending data back to template out of a function

2008-06-06 Thread Emily Rodgers
Yes, but python cares about types (a lot!!). If you have {% if blah %} in
your template, the template parser will have to evaluate blah. If blah is a
string, it will evaluate true unless it is empty. I am not totally sure how
it will be evaluated if it is not a string (or a list / dict / bool), so it
is good to know what you are trying to make it evaluate.
 
>From looking at the code you have given, it looks like the most likely
problem is with zipcode variable, or how you are calling the function.
 
Em


  _  

From: django-users@googlegroups.com [mailto:[EMAIL PROTECTED]
On Behalf Of chris hendrix
Sent: 06 June 2008 15:46
To: django-users@googlegroups.com
Subject: Re: sending data back to template out of a function


Hi Em -

I'm not really specifying anything about type @ the moment.. .i'm just
trying to figure out how to pass stuff back to the template (ie stuff that's
NOT form validation related)


BR


On Fri, Jun 6, 2008 at 10:40 AM, Emily Rodgers <[EMAIL PROTECTED]>
wrote:



I can't see anything work in your code (but there could be something I
haven't spotted!!).

My instinct would be to ensure that zipcode is a string. What did you do to
check that the zipcode is being passed in?

Em

> -Original Message-
> From: django-users@googlegroups.com
> [mailto:[EMAIL PROTECTED] On Behalf Of Bobby Roberts
> Sent: 06 June 2008 15:31
> To: Django users
> Subject: sending data back to template out of a function
>
>
> Hi all -
>
> Thanks for your continued support as I find my Django legs.
>
> on my form submission, i send to a view that checks for
> validation and for now all i want to do is send the data that
> was entered right back and show it to the user, but not in
> the form field.  I'm breaking my code out into two functions,
> one that does the form validation and one that does the
> return.  The reason is that I will be querying UPS
> information and just want a separate function to do that...
> the function passing back to the template is as such:
>
>
> def return_ziplookup(zipcode):
> zipquery = zipcode
> return render_to_response("upsratelookup.html",
> {'zipquery':zipquery})
>
> I have confirmed in fact that zipcode is getting passed in fine.
>
>
> In my template I have this:
>
> {% if zipquery %}
> Now Showing UPS Rates for zipcode {{ zipquery|escape }}
> {% else %}
> NO ZIPCODE RESULTS FOUND
> {% endif %}
>
>
> the template, on form submission always shows NO ZIPCODE
> RESULTS FOUND. Do you see anything i'm doing wrong?
>
> Thanks for helping me learn.
>
> 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



RE: sending data back to template out of a function

2008-06-06 Thread Emily Rodgers

 

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of Emily Rodgers
> Sent: 06 June 2008 15:41
> To: django-users@googlegroups.com
> Subject: RE: sending data back to template out of a function
> 
> 
> I can't see anything work in your code (but there could be 
> something I haven't spotted!!).

I mean't to make it not work!!

Hayfever has broken my brain 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



RE: sending data back to template out of a function

2008-06-06 Thread Emily Rodgers

I can't see anything work in your code (but there could be something I
haven't spotted!!).

My instinct would be to ensure that zipcode is a string. What did you do to
check that the zipcode is being passed in?

Em

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of Bobby Roberts
> Sent: 06 June 2008 15:31
> To: Django users
> Subject: sending data back to template out of a function
> 
> 
> Hi all -
> 
> Thanks for your continued support as I find my Django legs.
> 
> on my form submission, i send to a view that checks for 
> validation and for now all i want to do is send the data that 
> was entered right back and show it to the user, but not in 
> the form field.  I'm breaking my code out into two functions, 
> one that does the form validation and one that does the 
> return.  The reason is that I will be querying UPS 
> information and just want a separate function to do that... 
> the function passing back to the template is as such:
> 
> 
> def return_ziplookup(zipcode):
> zipquery = zipcode
> return render_to_response("upsratelookup.html",
> {'zipquery':zipquery})
> 
> I have confirmed in fact that zipcode is getting passed in fine.
> 
> 
> In my template I have this:
> 
> {% if zipquery %}
> Now Showing UPS Rates for zipcode {{ zipquery|escape }}
> {% else %}
> NO ZIPCODE RESULTS FOUND
> {% endif %}
> 
> 
> the template, on form submission always shows NO ZIPCODE 
> RESULTS FOUND. Do you see anything i'm doing wrong?
> 
> Thanks for helping me learn.
> 
> 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



RE: Help - m2m field in my model

2008-06-06 Thread Emily Rodgers

 

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of M.Ganesh
> Sent: 06 June 2008 14:19
> To: django-users@googlegroups.com
> Subject: Help - m2m field in my model
> 
> 
> Hi,
> 
> Excuse me for the dumb question.
> 
> My model :
> 
> class phonenumber(models.Model):
> location_type = models.ForeignKey(location_type)
> location_description = models.CharField(max_length=50, blank=True)
> 
> def __unicode__(self):
> if self.location_description:
> retval = self.location_description + ' - '
> else:
> retval = self.location_type + ' - '
> return retval
>   
> class Meta:
> app_label = 'contacts'
> 
> 
> I get an error saying :
> TypeError at /contacts/phonenumber/
> unsupported operand type(s) for +: 'location_type' and 'str'
> 
> How do I get the location_type __unicode__ for the fk?

self.location_type is a ForeignKey object (linked to your location_type
model subclass) not a string, so you either need to do
self.location_type.foo where foo is an attribute of the location_type class
with type str, or define a __str__ method of the location_type object.

If you call your phonenumber class PhoneNumber, and your location_type class
LocationType, it will help make it clearer what is an object and what is a
variable. In particular this line will be clearer:

 location_type = models.ForeignKey(LocationType)

(location_type is variable, LocationType is class name)

Hope this is not confusing (/ wrong!!).

Em





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



RE: forms - WTF

2008-06-05 Thread Emily Rodgers

 

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of Peter Rowell
> Sent: 05 June 2008 17:08
> To: Django users
> Subject: Re: forms - WTF
> 
> 
> On Jun 5, 8:50 am, "Emily Rodgers" <[EMAIL PROTECTED]> wrote:
> 
> > IMPORTANT NOTICE: The contents of this email and any 
> attachments are confidential and may also be privileged. If 
> you are not the intended recipient, please notify the sender 
> immediately and do not disclose the contents to any other 
> person, use it for any purpose, or store or copy the 
> information in any medium.  Thank you.
> 
> There's an old saying that goes something like: Two people 
> can keep a secret only if one of them is dead. I'm not sure 
> how that scales to the (approximately) 1 billion (with a 'b') 
> people who have access to the Internet, but I think it 
> involves thermonuclear war or a dozen monkeys.
> 
> You might want to disable/delete the boilerplate when posting 
> to a newsgroup.
> 
> Just a thought. :-)


Not sure I can :( it is not part of my signature, and gets appended to
everything coming out of the company. I will ask about though!!

The only alternative is to use an out of work email, or a google logon,
but then I have to keep checking it (which is disruptive!)

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



RE: forms - WTF

2008-06-05 Thread Emily Rodgers
ah. Right we need to see the view func then ;) as_table is a method of a
form class. You need to call it on an instance of the form object.
 
def myFormFunc(request):
title = 'This is My Form'
if request.method == 'POST':
foo = MyForm(request.POST) # foo is now an instance of MyForm
populated by the post data
if foo.is_valid():
foo.save()
return HttpResponseRedirect('/yourpath/')
else:
foo = MyForm()   # foo is now an instance of MyForm
return render_to_response('template.html', {'foo': foo, 'title':
title})
 
 
then in your template you can put

 {{ foo.as_table }}


does this make it clearer where foo/form comes from? It is just the
variable name you define in the context (the dict that is the second
parameter for the render_to_response function)
 
What I did (when it was only displaying my submit button and no form)
was forget to put () on MyForm().
 
Hope this helps.
 
Em
 
PS if you need to add some (but not all) fields of a model to a form,
and then do some data munging to fill in some of the other required
fields, do shout if you get stuck - this took me a while to figure out!!




From: django-users@googlegroups.com
[mailto:[EMAIL PROTECTED] On Behalf Of chris hendrix
Sent: 05 June 2008 16:59
To: django-users@googlegroups.com
Subject: Re: forms - WTF


Hi Em -

I'm taking baby steps at the moment and simply don't understand
how the form.as_table works... ie when i put that in the template (see
my template below), how does it know which form to show?



    BR
    

On Thu, Jun 5, 2008 at 11:50 AM, Emily Rodgers
<[EMAIL PROTECTED]> wrote:



Hi,

It seems familiar to an issue I had last week.

Can we see the function in your views file? I am
guessing that you need
to instantiate your ziplookup object or something (I
think this is what
I did wrong). Try changing {{ form.as_table }} to {{
form }}, just to
see what it prints...

I could be worng (I taught myself to code so have plenty
of bad
habits!!), but I think the convention when defining
classes is to use
CamelCase: http://en.wikipedia.org/wiki/CamelCase for
the class name -
it helps to differentiate between function calls and
object
instantiations when reading your code.

Em :)

PS python rocks.


> -Original Message-
> From: django-users@googlegroups.com
> [mailto:[EMAIL PROTECTED] On Behalf Of
Bobby Roberts
> Sent: 05 June 2008 16:36
> To: Django users
> Subject: forms - WTF
>
>
> hey -
>
> I'm new to Django so bear with me and thank you in
advance
> for any help you can lend.  I can't seem to get my
hands
> around the model/form/ view/template thing.  I LOVE
the idea
> but you have to understand i'm a MS ASP programmer who
is
> switching over to python.
>

> Now with that being said here is my understanding in a
nutshell:
>
> 1.  models - show the db table structure which is used
by the views.
>
> 2.  templates - allow you to separate html and code -
at
> least for the most part
>
> 3.  views  - contain the functions which interact with
the
> models and templates to perform some sort of
interaction.
>
> 4.  forms - allow data to be input into the website
etc
>
> I understand the basics but can't for the life of me
figure
> out how to make it all work together in a land of joy
and
> joyness (ie Charlie the Unicorn vid)
>
> I'm building a UPS rate lookup service.  I am
including my
> template and form below.
>
> when i visit the page below, only the input button
shows...
> no other form elements
>
>
> [template.html]
>
> {% extends "ups_rates

RE: forms - WTF

2008-06-05 Thread Emily Rodgers
Forms are quite confusing in django. When trying to find help on the
interweb last week I came across this that made me giggle:
http://leahculver.com/2007/04/23/django-forms-im-dumping-you/.
 
After a day or two of getting cross, I eventually stamped my feet and
insisted on having our work version of django upgraded to the lastest
SVN release so that I could use ModelForm!!




From: django-users@googlegroups.com
[mailto:[EMAIL PROTECTED] On Behalf Of chris hendrix
Sent: 05 June 2008 16:52
To: django-users@googlegroups.com
Subject: Re: forms - WTF


yeah i'm looking at chapter 7 now to try to understand forms






On Thu, Jun 5, 2008 at 11:47 AM, Daniel Mahoney
<[EMAIL PROTECTED]> wrote:



Bobby, did you work through the tutorials on the
djangoproject web site,
or some of the other Django tutorials available on the
web? They can
seem like slow going sometimes, but if you take your
time going through
them they can help a LOT!

Bobby Roberts wrote:
> hey -
>
> I'm new to Django so bear with me and thank you in
advance for any
> help you can lend.  I can't seem to get my hands
around the model/form/
> view/template thing.  I LOVE the idea but you have to
understand i'm a
> MS ASP programmer who is switching over to python.
>
Oh, ghod, I am SO sorry :) About the ASP part, not the
switching to
Python part. You'll find Python to be a whole new
wonderful world.










-- 
IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium.  Thank you.



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



RE: forms - WTF

2008-06-05 Thread Emily Rodgers

Hi,

It seems familiar to an issue I had last week.

Can we see the function in your views file? I am guessing that you need
to instantiate your ziplookup object or something (I think this is what
I did wrong). Try changing {{ form.as_table }} to {{ form }}, just to
see what it prints...

I could be worng (I taught myself to code so have plenty of bad
habits!!), but I think the convention when defining classes is to use
CamelCase: http://en.wikipedia.org/wiki/CamelCase for the class name -
it helps to differentiate between function calls and object
instantiations when reading your code.

Em :)

PS python rocks.

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of Bobby Roberts
> Sent: 05 June 2008 16:36
> To: Django users
> Subject: forms - WTF
> 
> 
> hey -
> 
> I'm new to Django so bear with me and thank you in advance 
> for any help you can lend.  I can't seem to get my hands 
> around the model/form/ view/template thing.  I LOVE the idea 
> but you have to understand i'm a MS ASP programmer who is 
> switching over to python.
> 
> Now with that being said here is my understanding in a nutshell:
> 
> 1.  models - show the db table structure which is used by the views.
> 
> 2.  templates - allow you to separate html and code - at 
> least for the most part
> 
> 3.  views  - contain the functions which interact with the 
> models and templates to perform some sort of interaction.
> 
> 4.  forms - allow data to be input into the website etc
> 
> I understand the basics but can't for the life of me figure 
> out how to make it all work together in a land of joy and 
> joyness (ie Charlie the Unicorn vid)
> 
> I'm building a UPS rate lookup service.  I am including my 
> template and form below.
> 
> when i visit the page below, only the input button shows... 
> no other form elements
> 
> 
> [template.html]
> 
> {% extends "ups_rates/ups_lookup_base.html" %} {% load i18n %}
> 
> {% block content %}
>
> 
>{% trans "Estimate UPS Shipping 
> Rates" %} span>
> 
>
> 
>  {{ form.as_table }}
> 
>  
> 
>
>
> 
>   
>this is a place holder for my rates table
>   
> 
> 
>
> 
> {% trans "* UPS rates presented on this page are 
> estimates only based solely on the provided zip-code and not 
> your full shipping address.  Your final shipping rates will 
> be displayed on the payment page when you submit your credit 
> card information." %}
> 
>  value="Close Window" onClick="myPopup()"> {% endblock %}
> 
> 
> 
> [forms.py]
> 
> from django import newforms as forms
> class ziplookup(forms.Form):
> zipcode=forms.CharField(max_length=15, required=True, 
> help_text='Please enter your zipcode')
> 
> 
> 
> 
> Is there anyone out there who can take me to Candy Mountain 
> (another Charlie the Unicorn reference)
> 
> 
> 
> 
> > 
> 

-- 
IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium.  Thank you.



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



'add another' popup from ModelForm?

2008-06-05 Thread Emily Rodgers

Hi,

I have been playing with Django for about a week, and I am really
impressed. I love python, but had previously been using php for my web
apps (LAMP). This is a big step forward :)

I have been having a few problems though...

I would like to use the 'add another' popup functionality (that is
automatically given to widgets for foreign key fields in the admin
interface) in my main web interface. Does anyone know of an easy way to
do this? I am currently using ModelForms to create my forms.

After a bit of snooping, I found the javascript
(django/contrib/admin/media/js/admin/RelatedObjectLookups.js) and html
(django/contrib/admin/templates/widget/foreign.html) that does it, but I
am unsure of the best way of adapting it. Is there a flag or something
that I don't know about, that I can set from within my ModelForm
subclass definition to use it already (I don't necessarily want it on
all of the foreign key dropdowns, so a flag seems like an appropriate
way)?

If not, I think my way to do it should be something like this:

Define a new widget that has the appropriate html, then add this to
urlpatterns in my app's urls.py file: 

('^([^/]+)/([^/]+)/add/$', 'django.contrib.admin.views.main.add_stage')
- not sure if this will work!!

Or

Add a similar tuple pointing to a hacked version of add_stage in my
app's views file so I don't run into permissions problems.

Am I heading in the right direction or completely barking up the wrong
tree?

Cheers,
Emily

PS

This is the version of Django I am using:
>>> django.VERSION
(0, 97, 'pre')


ARM Ltd, 110 Fulbourn Road, 
Cambridge CB1 9NJ, UK
Tel: +44 (0) 1223 406 365 

-- 
IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium.  Thank you.



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