Accidentally creating a model with "def unicode(self):" will crash django with no stack trace

2008-10-22 Thread Brian

This might seem obvious, and I just spend a couple hours straining
over it, so I thought I'd share.

If you have a model, e.g.:

def MyModel(models.Model):
# ...
# with a unicode function likeso:
def unicode(self):
   return 'something'

This will crash Django, without a stack trace.

Of course, the function is supposed to be "def __unicode__(self):",
but it'd have been awful nice to be able to figure that out without
rehashing the entire codebase (it seems like such an innocuous
addition to the model at the time haha).

Hopefully this will save someone some pain. :)

All the best,
Brian
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Accidentally creating a model with "def unicode(self):" will crash django with no stack trace

2008-10-23 Thread Brian

I should be more precise. :) Here's a simplified excerpt of the
problematic code - when a Django (1.0) template tries to turn it into
text with its default unicode function, Python (2.5.1) crashes (on Mac
OS X 10.5):

  from django.db import models
  from people import Person

  class Letter(models.Model):
  to = models.ManyToManyField(Person, related_name="%
(class)s_related")
  author = models.ForeignKey(Person)
  content = models.TextField()

  def unicode(self):
  date = unicode(self.dated)
  author = self.author
  to = ", ".join([ unicode(r) for r in self.to.all()])
  return "Letter dated %s from %s to %s" % (date, author, to)

  @models.permalink
  def get_absolute_url(self):
  return ('letter_detail', [self.pk])

The fix being, of course, changing "unicode" to "__unicode__".

On Oct 22, 10:14 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, Oct 22, 2008 at 9:45 PM, Brian <[EMAIL PROTECTED]> wrote:
>
> > This might seem obvious, and I just spend a couple hours straining
> > over it, so I thought I'd share.
>
> > If you have a model, e.g.:
>
> > def MyModel(models.Model):
> >    # ...
> >    # with a unicode function likeso:
> >    def unicode(self):
> >       return 'something'
>
> > This will crash Django, without a stack trace.
>
> > Of course, the function is supposed to be "def __unicode__(self):",
> > but it'd have been awful nice to be able to figure that out without
> > rehashing the entire codebase (it seems like such an innocuous
> > addition to the model at the time haha).
>
> > Hopefully this will save someone some pain. :)
>
> It will crash when you do what?  I don't see a crash, I just see models
> reverting to being reported as "xzy object" in the Admin.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Configuring multiple Django installs transparently via FastCGI mutiplexing

2008-11-26 Thread Brian

Hi everyone,

Here's a questions I just posted on stackoverflow.com (because I like
that forum's layout) - but I thought posting it here might lead to
more / better coverage.  See: http://stackoverflow.com/questions/322694/

Multiple installs of Django - How to configure transparent multiplex
through the webserver (Lighttpd)?

Hi Everyone,

This question flows from the answer to: How does one set up multiple
accounts with separate databases for Django on one server? (http://
stackoverflow.com/questions/314515)

I haven't seen anything like this on Google or elsewhere (perhaps I
have the wrong vocabulary), so I think input could be a valuable
addition to the internet discourse.

How could one configure a server likeso:

* One installation of Lighttpd
* Multiple Django projects running as FastCGI
* The Django projects may be added/removed at will, and ought not to
require restarting the webserver
* Transparent redirection of all requests/responses to a particular
Django installation depending on the current user

I.e. Given Django projects (with corresponding FastCGI socket):

* Bob (/tmp/bob.fcgi)
* Sue (/tmp/sue.fcgi)
* Joe (/tmp/joe.fcgi)

The Django projects being started with a (oversimplified) script
likeso:

#!/bin/sh
NAME=bob

SOCKET=/tmp/$NAME.fcgi

PROTO=fcgi
DAEMON=true

/django_projects/$NAME/manage.py runfcgi protocol=$PROTO socket=
$SOCKET
  daemonize=$DAEMON
#  end

I want traffic to http://www.example.com/ to direct the request to the
correct Django application depending on the user that is logged in.

In other words, http://www.example.com should come "be" /tmp/bob.fcgi
if bob is logged in, /tmp/joe.fcgi if joe is logged in, /tmp/sue.fcgi
if sue is logged in. If no-one is logged in, it should redirect to a
login page.

I've contemplated a demultiplexing "plexer" FastCGI script with the
following algorithm:

1. If the cookie $PLEX is set, pipe request to /tmp/$PLEX.fcgi

2. Otherwise redirect to login page (which sets the cookie PLEX based
on a many-to-one mapping of Username => PLEX)

Of course as a matter of security $PLEX should be taint checked, and
$PLEX shouldn't give rise to any presumption of trust.

A Lighttpd configuration would be likeso (though Apache, Nginx, etc.
could be used just as easily):

fastcgi.server = ( "plexer.fcgi" =>
   ( "localhost" =>
 (
   "socket" => "/tmp/plexer.fcgi",
   "check-local" => "disable"
 )
   )
 )
#  end

Input and thoughts, helpful links, and to know how to properly
implement the FastCGI plexer would all be appreciated.

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: Configuring multiple Django installs transparently via FastCGI mutiplexing

2008-11-26 Thread Brian

Hi Graham,

Thanks for the reply. No, I'm not stuck using Lighttpd at all - I just
like it because it's simple and fast. :)

Here's a link to a description of what I'd like to see:
http://stackoverflow.com/questions/314515

The situation is this: I'm creating a web-site with a bunch of
accounts - each account having its own database. I want people to go
to the site (i.e. www.example.com/) and when they log in the
application gets all its requests/responses from their account's
database. For the moment, all accounts will be using the same Django
applications, though that is subject to change so I'd prefer not to
rely on a solution that precludes that possibility.

I suspect (but am happy to be corrected...) that the easiest and
safest way to do this is to have a Django instance running in FastCGI
mode with a socket for each account. When a user is logged in, their
requests/responses are mapped to/from the proper Django socket via the
multiplexing solution I've suggested in my original post.

As mentioned, accounts may crop up and disappear, and shouldn't
require restarting the web-server. There could be dozens of accounts
(which means lots of Django instances).

Is there any more information that would be helpful?

Cheers & thank you,
Brian


On Nov 26, 10:32 pm, Graham Dumpleton <[EMAIL PROTECTED]>
wrote:
> On Nov 27, 2:06 pm, Brian <[EMAIL PROTECTED]> wrote:
>
> > Hi everyone,
>
> > Here's a questions I just posted on stackoverflow.com (because I like
> > that forum's layout) - but I thought posting it here might lead to
> > more / better coverage.  See:http://stackoverflow.com/questions/322694/
>
> > Multiple installs of Django - How to configure transparent multiplex
> > through the webserver (Lighttpd)?
>
> Are you stuck with using Lighttpd?
>
> Can you explain the background of the situation you have that requires
> such a setup? May help in working out what to suggest.
>
> Graham
>
> > Hi Everyone,
>
> > This question flows from the answer to: How does one set up multiple
> > accounts with separate databases for Django on one server? (http://
> > stackoverflow.com/questions/314515)
>
> > I haven't seen anything like this on Google or elsewhere (perhaps I
> > have the wrong vocabulary), so I think input could be a valuable
> > addition to the internet discourse.
>
> > How could one configure a server likeso:
>
> > * One installation of Lighttpd
> > * Multiple Django projects running as FastCGI
> > * The Django projects may be added/removed at will, and ought not to
> > require restarting the webserver
> > * Transparent redirection of all requests/responses to a particular
> > Django installation depending on the current user
>
> > I.e. Given Django projects (with corresponding FastCGI socket):
>
> > * Bob (/tmp/bob.fcgi)
> > * Sue (/tmp/sue.fcgi)
> > * Joe (/tmp/joe.fcgi)
>
> > The Django projects being started with a (oversimplified) script
> > likeso:
>
> > #!/bin/sh
> > NAME=bob
>
> > SOCKET=/tmp/$NAME.fcgi
>
> > PROTO=fcgi
> > DAEMON=true
>
> > /django_projects/$NAME/manage.py runfcgi protocol=$PROTO socket=
> > $SOCKET
> >   daemonize=$DAEMON
> > #  end
>
> > I want traffic tohttp://www.example.com/todirect the request to the
> > correct Django application depending on the user that is logged in.
>
> > In other words,http://www.example.comshouldcome "be" /tmp/bob.fcgi
> > if bob is logged in, /tmp/joe.fcgi if joe is logged in, /tmp/sue.fcgi
> > if sue is logged in. If no-one is logged in, it should redirect to a
> > login page.
>
> > I've contemplated a demultiplexing "plexer" FastCGI script with the
> > following algorithm:
>
> > 1. If the cookie $PLEX is set, pipe request to /tmp/$PLEX.fcgi
>
> > 2. Otherwise redirect to login page (which sets the cookie PLEX based
> > on a many-to-one mapping of Username => PLEX)
>
> > Of course as a matter of security $PLEX should be taint checked, and
> > $PLEX shouldn't give rise to any presumption of trust.
>
> > A Lighttpd configuration would be likeso (though Apache, Nginx, etc.
> > could be used just as easily):
>
> > fastcgi.server = ( "plexer.fcgi" =>
> >                            ( "localhost" =>
> >                              (
> >                                "socket" => "/tmp/plexer.fcgi",
> >                                "check-local" => "disable"
> >                              )
> >                            )
> >                  )
> > #  end
>
> > Input and thoughts, helpful links, and to know how to properly
> > implement the FastCGI plexer would all be appreciated.
>
> > 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: Configuring multiple Django installs transparently via FastCGI mutiplexing

2008-11-26 Thread Brian

Accounts could be created as often as hourly. I'd be very bad to have
the webserver go down while people use the system (unless it was for
less than a second or two... but even then, it's still be very
bad :) ).


On Nov 26, 11:31 pm, Graham Dumpleton <[EMAIL PROTECTED]>
wrote:
> On Nov 27, 3:17 pm, Brian <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi Graham,
>
> > Thanks for the reply. No, I'm not stuck using Lighttpd at all - I just
> > like it because it's simple and fast. :)
>
> > Here's a link to a description of what I'd like to 
> > see:http://stackoverflow.com/questions/314515
>
> > The situation is this: I'm creating a web-site with a bunch of
> > accounts - each account having its own database. I want people to go
> > to the site (i.e.www.example.com/) and when they log in the
> > application gets all its requests/responses from their account's
> > database. For the moment, all accounts will be using the same Django
> > applications, though that is subject to change so I'd prefer not to
> > rely on a solution that precludes that possibility.
>
> > I suspect (but am happy to be corrected...) that the easiest and
> > safest way to do this is to have a Django instance running in FastCGI
> > mode with a socket for each account. When a user is logged in, their
> > requests/responses are mapped to/from the proper Django socket via the
> > multiplexing solution I've suggested in my original post.
>
> > As mentioned, accounts may crop up and disappear, and shouldn't
> > require restarting the web-server. There could be dozens of accounts
> > (which means lots of Django instances).
>
> How often would accounts be changed and if not that often, why would
> restarting the web server be a problem?
>
> Graham
>
> > Is there any more information that would be helpful?
>
> > Cheers & thank you,
> > Brian
>
> > On Nov 26, 10:32 pm, Graham Dumpleton <[EMAIL PROTECTED]>
> > wrote:
>
> > > On Nov 27, 2:06 pm, Brian <[EMAIL PROTECTED]> wrote:
>
> > > > Hi everyone,
>
> > > > Here's a questions I just posted on stackoverflow.com (because I like
> > > > that forum's layout) - but I thought posting it here might lead to
> > > > more / better coverage.  See:http://stackoverflow.com/questions/322694/
>
> > > > Multiple installs of Django - How to configure transparent multiplex
> > > > through the webserver (Lighttpd)?
>
> > > Are you stuck with using Lighttpd?
>
> > > Can you explain the background of the situation you have that requires
> > > such a setup? May help in working out what to suggest.
>
> > > Graham
>
> > > > Hi Everyone,
>
> > > > This question flows from the answer to: How does one set up multiple
> > > > accounts with separate databases for Django on one server? (http://
> > > > stackoverflow.com/questions/314515)
>
> > > > I haven't seen anything like this on Google or elsewhere (perhaps I
> > > > have the wrong vocabulary), so I think input could be a valuable
> > > > addition to the internet discourse.
>
> > > > How could one configure a server likeso:
>
> > > > * One installation of Lighttpd
> > > > * Multiple Django projects running as FastCGI
> > > > * The Django projects may be added/removed at will, and ought not to
> > > > require restarting the webserver
> > > > * Transparent redirection of all requests/responses to a particular
> > > > Django installation depending on the current user
>
> > > > I.e. Given Django projects (with corresponding FastCGI socket):
>
> > > > * Bob (/tmp/bob.fcgi)
> > > > * Sue (/tmp/sue.fcgi)
> > > > * Joe (/tmp/joe.fcgi)
>
> > > > The Django projects being started with a (oversimplified) script
> > > > likeso:
>
> > > > #!/bin/sh
> > > > NAME=bob
>
> > > > SOCKET=/tmp/$NAME.fcgi
>
> > > > PROTO=fcgi
> > > > DAEMON=true
>
> > > > /django_projects/$NAME/manage.py runfcgi protocol=$PROTO socket=
> > > > $SOCKET
> > > >   daemonize=$DAEMON
> > > > #  end
>
> > > > I want traffic tohttp://www.example.com/todirecttherequest to the
> > > > correct Django application depending on the user that is logged in.
>
> > > > In other words,http://www.example.comshouldcom

Re: Configuring multiple Django installs transparently via FastCGI mutiplexing

2008-11-26 Thread Brian
fferent mechanism than the accounts'
respective databases. That's easy enough thanks to the delightfully
decoupled user authentication system in Django.

I hold out hope that there is a brilliant, simple solution to this
problem via Django. However, my searches and inquiries suggest that
it's not a common problem, nor especially obvious. Failing a safe,
sensible way to change the database settings in a running Django
process (or some other intelligent way to demultiplex user requests to
their respective datasets; essentially semantic, mutually exclusive
sharding), I believe you've astutely pointed out that this isn't a
Django issue, and I should meander over to the webserver forums. I'd
prefer a Django solution to a webserver one, though, because it's the
right place to do it.

I hope that clarifies the explanation some, and makes this vein of
inquiry of some value to the body of Django knowledge. If it's not
something that's a workable Django solution, I'd be happy to have some
certitude about that, too.

Thank you, and best regards,

Brian


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Configuring multiple Django installs transparently via FastCGI mutiplexing

2008-11-27 Thread Brian

Hi Graham,

Sorry I didn't respond earlier - for some reason your last reply with
the questions didn't show up until late today. Very odd -- didn't mean
to ignore your question or give the impression that I was ignoring it.
I most certainly am interested in potential solutions.

> I don't know how lighttpd works, but if one does a graceful restart
> (or even a restart) with Apache, in the main it isn't noticeable to
> the user as the listener socket is never released and so new
> connections just queue up and aren't outright refused, ie., server
> isn't actually completely stopped. The issue is more the startup time
> of Django instances and whether a restart will cause active login
> sessions to be terminated based on how application is written. This is
> because on a restart, active instances which are still required are
> restarted regardless.

I know little about webservers, but I'm relieved to hear that the
restarts are graceful. I believe this gracefulness was a recent
addition to Lighttpd, also.

Incidentally, I simply chose Lighttpd because I've never used it
before, and I figure it'd be fun to learn how to set it up.

I would think the Django processes ought to be persistent in the
background (unless the webserver is starting/stopping them).

> The actual Django application is something the users themselves are
> just a user of? There is no requirement for them to be able to make
> changes to a segment of code base and force their own restarts of
> their instance to pick up changes.

Yes, they're just Users, and will never restart the instance.

> For each account, through what do they login initially? Are you
> expecting to use Django based login mechanisms for that, or do you
> front it all with HTTP Basic Authentication. If you are going to
> somehow switch based on their identity it presumably needs to be done
> outside of the context of the target Django instance else you will not
> know which to go to.

This is a good question, and I haven't come to a conclusion. Probably
it'll be the Django built-in application-based authentication,
particular to each Django instance. There will be a master map of all
users to their respective Django instance.

> Does the account have a distinct UNIX account associated with it, or
> would all Django instances run as same user and you are then just
> mapping a logical account name to a specific instance attached to a
> specific database.

I'm thinking they'll all run as the same Unix user, and it's just a
logical mapping from an account to a database.

This could change.

> Would there be a calculable cap on the number of accounts you would
> have active at any one time. Or would it at least be acceptable that
> if there is a preconfigured number of instances you can switch between
> and that limit is reached, that restarting web server would then be
> seen as okay?

Yes, a cap on the number of accounts is definitely possible in the
short term.

> Sorry, if I seem to be asking a lot of questions, but believe might
> have a manageable solution for you, but want to be clear on these
> things so know if will be or not and what configuration would need to
> be.

That's quite exciting. :o) Thank you, in advance for any solution you
may be able to suggest.

Brian

> > On Nov 26, 11:31 pm, Graham Dumpleton <[EMAIL PROTECTED]>
> > wrote:
>
> > > On Nov 27, 3:17 pm, Brian <[EMAIL PROTECTED]> wrote:
>
> > > > Hi Graham,
>
> > > > Thanks for the reply. No, I'm not stuck using Lighttpd at all - I just
> > > > like it because it's simple and fast. :)
>
> > > > Here's a link to a description of what I'd like to 
> > > > see:http://stackoverflow.com/questions/314515
>
> > > > The situation is this: I'm creating a web-site with a bunch of
> > > > accounts - each account having its own database. I want people to go
> > > > to the site (i.e.www.example.com/) and when they log in the
> > > > application gets all its requests/responses from their account's
> > > > database. For the moment, all accounts will be using the same Django
> > > > applications, though that is subject to change so I'd prefer not to
> > > > rely on a solution that precludes that possibility.
>
> > > > I suspect (but am happy to be corrected...) that the easiest and
> > > > safest way to do this is to have a Django instance running in FastCGI
> > > > mode with a socket for each account. When a user is logged in, their
> > > > requests/responses are mapped to/from the proper Django socket via the
> > > > multiplexing solution I'v

Re: Configuring multiple Django installs transparently via FastCGI mutiplexing

2008-11-27 Thread Brian

> > This is a good question, and I haven't come to a conclusion. Probably
> > it'll be the Django built-in application-based authentication,
> > particular to each Django instance. There will be a master map of all
> > users to their respective Django instance.
>
> That seems a bit like a chicken and egg problem. At the point that you
> need to make the decision as to which Django instance to use, you
> haven't yet logged in them in. Thus if you are going to try and use
> their own instance to log them in, that can't work.

If usernames are unique, e.g. email addresses, there can be a map,
e.g.:
[EMAIL PROTECTED] => DjangoInstanceA,
[EMAIL PROTECTED] => DjangoInstanceB,

This User-Instance mapping could happen prior to authentication if,
when the user submits login-information from a form, a process
(demultiplexer) decides based upon the username which Django instance
to direct the login-request to. The Django instance then handles all
subsequent requests.

I don't know if this will actually work.

> If you use one special Django instance to handle login, then issue is
> having any session information in that instance also used by the other
> instances such that when you go to actual instance on subsequent
> requests, it knows you are allowed to access it.

Perhaps HTTP Basic authentication might be the simplest solution. :)

> I'll describe any solution in terms of HTTP Basic authentication first
> and then can let you think about authentication when you see how the
> multiplexing is achieved.

That'd be great!

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



Beginners questions on forms containing multiple related model types.

2008-12-15 Thread Brian

Hi,

I'm new to django and have been working hard to find "the right way"
or at least "a good way" to do things.  I'm running into a few
problems though that I can't get answers for.

The following post describes my situation very clearly.  It may be
long-winded but hopefully it's unambiguous.  I'm sure there'll be
nothing difficult to the experienced django user here, but some
answers could be helpful to me and other beginners.

In my django model I have the following classes: Person and
BankAccount.  There are other model types too, but these should
suffice to illustrate my problem.

Person:
  person_id
  first_name
  surname

BankAccount:
  bank_account_id
  person_id (ForeignKey)
  bank_code
  account_number

A Person may have ZERO or ONE BankAccounts.
I want to be able to create or edit the details for a Person
(including their associated BankAccount, should it exist) on the one
html form.  I've created some ModelForm types to help with this:

class PersonForm(ModelForm):
class Meta:
model = Person

class BankAccountForm(ModelForm):
class Meta:
model = BankAccount
exclude = ('person',) #Avoid the dropdown menu

I've been advised (on IRC #django) that "create new" should be handled
at one URL and "edit existing" at a separate URL.  I handle the URLs
at different view functions.  So in url.py:
url(r'person/add/$', 'person_add', 'person_add'),
url(r'person/(?P\d+)/$', 'person_edit',
name='person_edit'),

The "person_add" view function is easy to implement.  For request.GET
for I simply create a new PersonForm and a new BankAccountForm and
expose them to the template via the context.  The request.POST is easy
too - however I only save the BankAccount data if non-blank data was
supplied.

The "person_edit" view function raises some problems though:
1) I may be editing a Person that has no associated BankAccount.  So
basically I'm supplying a form with "edit existing" functionality for
the Person model and "create new" functionality for the BankAccount.
This doesn't cause a problem in itself, but it does break the paradigm
of separating "create new" and "edit existing" functionality - if such
a paradigm is indeed correct.

2) When a GET request to /person/5/ is received, I retrieve the
relevant Person from the db.  In a separate db query I then have to
try to get an associated BankAccount.  If I do:
BankAccount.objects.get(person=person_id)
and the BankAccount doesn't exist a DoesNotExist exception is
thrown... This really surprised me.  Thinking about it from a db query
perspective I would have expected an empty list.  I notice however if
I do:
BankAccount.objects.filter(person=person_id)
I receive an empty list when there is no match.  I presume this is by
design, I just wonder what the logic of that design is.  Any ideas?

3) When a POST request to /person/5/ is received the URL tells me I'm
editing Person "5", but I also need to know if I'm editing or creating
a BankAccount too.  I can obviously query the BankAccount table for a
record matching person_id=5, but again there is a db roundtrip
overhead here.  Alternatively, I think I could have included a hidden
bank_account_id field when I received the GET request for /person/5/
so that upon POST I would "know" the bank_account_id - with some
security concerns though.  What is best-practice in this situation?

4) You might notice that the relationship between Person and
BankAccount is modelled as a One-To-Many, however my business logic
requires One-To-(Zero or One).  I wondered if I could use the
models.OneToOneField for this, but the documentation seemed to imply
that django would expect exactly one record on BOTH sides of
relationship, so it may not be suitable for the One-To-Zero case.
Again, if anyone has advice on what I should actually do here, please
let me know.

Obviously this is a simple example and I could code a solution that
would work.  However, my real problem involves several similar
relationships on the one form.  The POST handling code could get very
hairy if I don't do it well.

If you got this far, thanks for taking the time to read this.

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



Re: Your IDE of choice

2009-01-06 Thread Brian

For Python/Django I tend to like Komodo's Editor, as I am a fan of
auto-complete and $free.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



no objects found

2009-01-14 Thread Brian

Django 1.0.2-1

If I do:

>>> object=models.software.objects.get(id=267)
>>> print models.software_installation.objects.filter(software=object)
[]
>>> print models.software_installation.objects.filter(software=object).count()
10

Huh? First statement says there are no results, next one says there
are 10.



If I spy on the packets, I see this in the SQL for the first
statement:

... LEFT OUTER JOIN `inventory_license_key` ON
(`inventory_software_installation`.`license_key_id` =
`inventory_license_key`.`id`)  INNER JOIN `inventory_license` ON
(`inventory_license_key`.`license_id` = `inventory_license`.`id`) ...

If I remove the inner join part (and the reference to it in the order
part), and run the SQL on the server, then it works.

`inventory_software_installation`.`license_key_id` == NULL on the rows
in question (the model specifies null=True).

I have a suspicion that the above SQL doesn't work because it requires
a inventory_license object, however there is no inventory_license_key
object there is no inventory_license object.

The relevant definitions (I can provide more details on request) are:

class software_installation(models.Model):
[...]
software = models.ForeignKey(software)
[...]
license_key = models.ForeignKey(license_key,null=True,blank=True)
[...]

class license_key(models.Model):
[...]
license  = models.ForeignKey(license)
[...]

class license(models.Model):
[...]


Any ideas?

Is this a django bug? If so is it a known issue?


Thanks

Brian May

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



Django crashes Python without traceback on Mac OS X (Release 1.0)

2008-10-18 Thread Brian

Hi there,

Django is crashing Python on my machine for one particular application
of my Django project (the other applications are unaffected). It's on
the Django 1.0 development server, Mac OS X 10.5.5, stock Python
2.5.1.

There is no trace-back. Removing cookies and .pyc files does not
resolve the problem. I'm not sure how to go about debugging it.
Thought I'd share. :)

Thanks & best,
Brian

Process: Python [5921]
Path:/System/Library/Frameworks/Python.framework/Versions/
2.5/Resources/Python.app/Contents/MacOS/Python
Identifier:  Python
Version: ??? (???)
Code Type:   X86 (Native)
Parent Process:  Python [5918]

Date/Time:   2008-10-18 17:44:39.232 -0230
OS Version:  Mac OS X 10.5.5 (9F33)
Report Version:  6

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0xbff4
Crashed Thread:  1

Thread 0:
0   libSystem.B.dylib   0x933415e2 select$DARWIN_EXTSN + 10
1   org.python.python   0x0018d806 PyEval_EvalFrameEx +
17116
2   org.python.python   0x0018d9e8 PyEval_EvalFrameEx +
17598
3   org.python.python   0x0018d9e8 PyEval_EvalFrameEx +
17598
4   org.python.python   0x0018f45b PyEval_EvalCodeEx + 1638
5   org.python.python   0x0018da85 PyEval_EvalFrameEx +
17755
6   org.python.python   0x0018f45b PyEval_EvalCodeEx + 1638
7   org.python.python   0x00139c27 PyFunction_SetClosure +
2646
8   org.python.python   0x0011fd3d PyObject_Call + 50
9   org.python.python   0x0018dfb8 PyEval_EvalFrameEx +
19086
10  org.python.python   0x0018f45b PyEval_EvalCodeEx + 1638
11  org.python.python   0x00139c27 PyFunction_SetClosure +
2646
12  org.python.python   0x0011fd3d PyObject_Call + 50
13  org.python.python   0x0018dfb8 PyEval_EvalFrameEx +
19086
14  org.python.python   0x0018d9e8 PyEval_EvalFrameEx +
17598
15  org.python.python   0x0018d9e8 PyEval_EvalFrameEx +
17598
16  org.python.python   0x0018f45b PyEval_EvalCodeEx + 1638
17  org.python.python   0x0018da85 PyEval_EvalFrameEx +
17755
18  org.python.python   0x0018f45b PyEval_EvalCodeEx + 1638
19  org.python.python   0x0018f548 PyEval_EvalCode + 87
20  org.python.python   0x001a69ec PyErr_Display + 1896
21  org.python.python   0x001a7016 PyRun_FileExFlags + 135
22  org.python.python   0x001a8982 PyRun_SimpleFileExFlags
+ 421
23  org.python.python   0x001b3c03 Py_Main + 3095
24  org.python.pythonapp0x1fca 0x1000 + 4042

Thread 1 Crashed:
0   org.python.python   0x00152c88 _PyString_Eq + 36
1   org.python.python   0x00146d1c PyDict_New + 972
2   org.python.python   0x001472b3 PyDict_GetItem + 208
3   org.python.python   0x00149724 PyDict_GetItemString +
46
4   org.python.python   0x001a0792 PyImport_ReloadModule +
904
5   org.python.python   0x001a0a80 PyImport_ReloadModule +
1654
6   org.python.python   0x001a103a PyImport_ReloadModule +
3120
7   org.python.python   0x001a11ea
PyImport_ImportModuleLevel + 50
8   org.python.python   0x0018442d PyAST_FromNode + 5362
9   org.python.python   0x0011fd3d PyObject_Call + 50
10  org.python.python   0x00188b15
PyEval_CallObjectWithKeywords + 211
11  org.python.python   0x0018cc21 PyEval_EvalFrameEx +
14071
12  org.python.python   0x0018d9e8 PyEval_EvalFrameEx +
17598
13  org.python.python   0x0018d9e8 PyEval_EvalFrameEx +
17598
14  org.python.python   0x0018f45b PyEval_EvalCodeEx + 1638
15  org.python.python   0x00139c27 PyFunction_SetClosure +
2646
16  org.python.python   0x0011fd3d PyObject_Call + 50
17  org.python.python   0x001285f8 PyMethod_New + 2457
18  org.python.python   0x0011fd3d PyObject_Call + 50
19  org.python.python   0x0018dfb8 PyEval_EvalFrameEx +
19086
20  org.python.python   0x0018f45b PyEval_EvalCodeEx + 1638
21  org.python.python   0x00139c27 PyFunction_SetClosure +
2646
22  org.python.python   0x0011fd3d PyObject_Call + 50
23  org.python.python   0x0018dfb8 PyEval_EvalFrameEx +
19086
24  org.python.python   0x0018f45b PyEval_EvalCodeEx + 1638
25  org.python.python   0x0018da85 PyEval_EvalFrameEx +
17755
26  org.python.python   0x0018f45b PyEval_EvalCodeEx + 1638
27  org.python.python   0x00139c27 PyFunction_SetClosure +
2646
28  org.python.python  

Re: no objects found

2009-01-14 Thread Brian

On Jan 15, 1:57 pm, Malcolm Tredinnick 
wrote:
> Please open a ticket for this and assign it to me (mtredinnick in Trac),

Ok, done. Thanks.

<http://code.djangoproject.com/ticket/10028>

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



Model Form Field Ordering

2009-02-04 Thread Brian

I have a ModelForm subclass where I define a special field. How do I
make that special field appear first in the rendered form (using a
form.as_* method)?

Here is an example:

class MyModelForm(forms.ModelForm):
mySpecialField = forms.ChoiceField(label='Special', choices=(('a',
'aa')))
class Meta:
model = MyModelType

The problem is mySpecialField is rendering last, but I wish it to
appear first.

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



Bookmark URL with form data

2009-02-22 Thread Brian

My experience level: basic. I'm not a developer by trade and do it as
a hobby. I'm pretty familiar with basic web development--HTML, CSS and
js. I have explored PHP and other technologies to improve my
development. Now I've started developing using Django+App Engine
Datastore. I've got an application to do various things working--
submit data, delete data, edit data, view data, etc. Right now I'm
stuck on something that seems like it should be relatively simple...

On my index page I have a search form (along with data and other
stuff). I've got it so the user can enter a search, select type, and
then get data and other stuff on a new page. Form field IDs are
id_search and id_type. Action is "/search/". On the results page I'd
like the URL to include the search data so the user can bookmark this
and open it at a later date. I've read various topics on the django
approach to formatting URLs to make them more readable and to put
thought into the best long-term approach. I haven't been able to
figure out how to change the URL that shows up in the browser to
include the search data. I'm pretty sure I can handle this bookmark
URL through URLCONF once I get to that point. Please direct me to some
reading to get me through this--I'm probably not using the right
search terms for this topic when I google.

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



Saving Deserialized Objects -- Help Needed

2009-03-09 Thread Brian

I'm having trouble saving deserialied model objects. My setup is that
I have two django instances, let's call them A and B. The intial
request comes into server A which then serializes some objects and
sends them off to server B for the results of some computation. When
server B tries to save the objects sent by A it fails.

I believe the save is failing because the objects already have primary
keys set from server A's database, but are not contained in server B's
database. I could be wrong that this is the reason.

Both django instances are operating the same projects with the same
models. I do need the objects saved, since their relationships are
described in their foreign key relationships, that are used for the
computation.

Any assistance would be very appreciated.

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



Re: raise ValidationError has no effect

2009-04-08 Thread brian

I think I'm having the same issue.  Did you ever find a solution?

On Feb 14, 5:06 pm, Karen Tracey  wrote:
> On Sat, Feb 14, 2009 at 11:07 AM, Alistair Marshall <
>
> runninga...@googlemail.com> wrote:
>
> > I have been trying to create a custom field that allows the user to
> > enter a flowrate and clean the data back to kg/s or mol/s.
>
> > I though I had everything sorted, when I type '10 tones/year', it
> > correctly did the conversion however when I type something that does
> > not validate such as 'twenty' or '5 mph' the code runs till the raise
> > validation error, however nothing else happens and the overall forms
> > clean function gets called (which doesn't have all the fields in its
> > clean_data attribute.
>
> Nothing else happens as opposed to what?  What are you expecting to
> happen?   One field raising a validation error doe not prevent the overall
> form clear() from being called, this is covered here:
>
> http://docs.djangoproject.com/en/dev/ref/forms/validation/
>
> where it states:
>
> As mentioned, any of these methods can raise a ValidationError. For any
> field, if the Field.clean() method raises a ValidationError, any
> field-specific cleaning method is not called. However, the cleaning methods
> for all remaining fields are still executed.
>
> The clean() method for the Form class or subclass is always run. If that
> method raises a ValidationError, cleaned_data will be an empty dictionary.
>
> The previous paragraph means that if you are overriding Form.clean(), you
> should iterate through self.cleaned_data.items(), possibly considering the
> _errors dictionary attribute on the form as well. In this way, you will
> already know which fields have passed their individual validation
> requirements.
>
> The idea is to get all the problems identified, as far as possible, and not
> let the first error encountered stop the process.  That way (hopefully) all
> the problems can be noted with error messages in one go-round with the user,
> rather than having submit, here's an error, fix one error, resubmit, here's
> a 2nd error, fix, resubmit, here's a 3rd error, etc.
>
> Karen

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



Re: Running Django on Tornado's HTTP server

2009-09-14 Thread Brian

I have a small Django app under development and was able to get this
running using the github update. My app runs and is very responsive
with Tornado.

Some of my admin site layout is out of whack, but it may be my
settings or my bug.  Formatting and CSS I created on my own looks good
(e.g. graphics and tables created using the Google Visualization API.)
My app is able to go out onto the web, get files downloaded through
Tornado - it feels fast ...

It's terrific to have a Python-based server that could work in both
development and production. (Tornado installs/runs fine on a Netbook
with Ubuntu!)

The real-time / asynchronous capabilities look great. Any way Django
apps can take advantage of that functionality?

Thanks for open sourcing this!

-- Brian

On Sep 13, 4:26 pm, Bret Taylor  wrote:
> I am one of the authors of Tornado (http://www.tornadoweb.org/), the
> web server/framework we built at FriendFeed that we open sourced last
> week (seehttp://bret.appspot.com/entry/tornado-web-server).
>
> The underlying non-blocking HTTP server is fairly high performance, so
> I have been working this weekend to get other frameworks like Django
> and web.py working on Tornado's server so existing projects could
> potentially benefit from the performance. To that end, I just checked
> in change to Tornado that enables you to run any WSGI-compatible
> framework on Tornado's HTTP server. You can find it in a class called
> WSGIContainer in our wsgi.py:
>
> http://github.com/facebook/tornado/blob/master/tornado/wsgi.py#L188
>
> You will have to check out Tornado from github to get the change; it
> is not yet included in the tarball distribution.
>
> Here is a template for running a Django app on Tornado's server using
> the module:
>
>     import django.core.handlers.wsgi
>     import os
>     import tornado.httpserver
>     import tornado.ioloop
>     import tornado.wsgi
>
>     def main():
>         os.environ["DJANGO_SETTINGS_MODULE"] = 'myapp.settings'
>         application = django.core.handlers.wsgi.WSGIHandler()
>         container = tornado.wsgi.WSGIContainer(application)
>         http_server = tornado.httpserver.HTTPServer(container)
>         http_server.listen()
>         tornado.ioloop.IOLoop.instance().start()
>
>     if __name__ == "__main__":
>         main()
>
> I have only done very basic tests using the new module, so if any of
> you are interested and start using Tornado with your Django projects,
> please let us know what bugs you find so we can fix them. Any and all
> feedback is appreciated.
>
> Bret

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



Re: Running Django on Tornado's HTTP server

2009-09-15 Thread Brian

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

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

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

-- Brian

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



Dynamically content in include statement not working

2010-05-12 Thread Brian
Help:

Chapter 4: The Django Template System
http://www.djangobook.com/en/1.0/chapter04/

This example includes the contents of the template whose name is
contained in the variable template_name:
{% include template_name %}


All i'm trying to do is dynamically include an html template file:

This works just fine:
{% load "FooterMessage.htm" %}

This will NOT work for me:
{% load "{{inpage.footer}}" %}

fyi: (I know that inpage.footer == "FooterMessage.htm")

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



Dynamically content in include statement not working

2010-05-12 Thread Brian
Help:

Chapter 4: The Django Template System
http://www.djangobook.com/en/1.0/chapter04/

This example includes the contents of the template whose name is
contained in the variable template_name:
{% include template_name %}


All i'm trying to do is dynamically include a html template file

This works just fine:
{% include "FooterMessage.htm" %}


This will NOT work for me:
{% include "{{inpage.footer}}" %}

(I know that inpage.footer == "FooterMessage.htm")

-- 
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: Dynamically content in include statement not working

2010-05-12 Thread Brian
Tom, I'm sorry
I am using include and it's not working:
Dynamically content in include statement not working:

This works just fine:
{% include "FooterMessage.htm" %}


This will NOT work for me:
{% include "{{inpage.footer}}" %}

(I know that inpage.footer == "FooterMessage.htm")




On May 12, 11:19 am, Tom Evans  wrote:
> On Wed, May 12, 2010 at 4:10 PM, Brian  wrote:
> > Help:
>
> > Chapter 4: The Django Template System
> >http://www.djangobook.com/en/1.0/chapter04/
>
> > This example includes the contents of the template whose name is
> > contained in the variable template_name:
> > {% include template_name %}
>
> > All i'm trying to do is dynamically include an html template file:
>
> > This works just fine:
> > {% load "FooterMessage.htm" %}
>
> > This will NOT work for me:
> > {% load "{{inpage.footer}}" %}
>
> > fyi: (I know that inpage.footer == "FooterMessage.htm")
>
> This
>   {% load "{{inpage.footer}}" %}
> isn't valid syntax. You can't do variable interpolation inside
> template tags. Furthermore, the {% load %} tag is for loading custom
> template tag libraries, not including extra content. You want the {%
> include %} tag, as you correctly state in the first paragraph.
>
> It isn't usually necessary. In this case, this should work:
>   {% include inpage.footer %}
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: Dynamically content in include statement not working

2010-05-12 Thread Brian
Tom
Thank you, Thanks you, Thank you.
 {% include inpage.footer %} works just fine. The {{}} is unnecessary
as I had it.

Sometime the brain is not working.
Thanks again.


On May 12, 11:36 am, Tom Evans  wrote:
> On Wed, May 12, 2010 at 4:31 PM, Brian  wrote:
> > Tom, I'm sorry
> > I am using include and it's not working:
> > Dynamically content in include statement not working:
>
> > This works just fine:
> > {% include "FooterMessage.htm" %}
>
> > This will NOT work for me:
> > {% include "{{inpage.footer}}" %}
>
> > (I know that inpage.footer == "FooterMessage.htm")
>
> > On May 12, 11:19 am, Tom Evans  wrote:
> >> On Wed, May 12, 2010 at 4:10 PM, Brian  wrote:
> >> > Help:
>
> >> > Chapter 4: The Django Template System
> >> >http://www.djangobook.com/en/1.0/chapter04/
>
> >> > This example includes the contents of the template whose name is
> >> > contained in the variable template_name:
> >> > {% include template_name %}
>
> >> > All i'm trying to do is dynamically include an html template file:
>
> >> > This works just fine:
> >> > {% load "FooterMessage.htm" %}
>
> >> > This will NOT work for me:
> >> > {% load "{{inpage.footer}}" %}
>
> >> > fyi: (I know that inpage.footer == "FooterMessage.htm")
>
> >> This
> >>   {% load "{{inpage.footer}}" %}
> >> isn't valid syntax. You can't do variable interpolation inside
> >> template tags. Furthermore, the {% load %} tag is for loading custom
> >> template tag libraries, not including extra content. You want the {%
> >> include %} tag, as you correctly state in the first paragraph.
>
> >> It isn't usually necessary. In this case, this should work:
> >>   {% include inpage.footer %}
>
> >> Cheers
>
> >> Tom
>
> Did you read my email at all? I clearly explained why that method does
> not work, and clearly gave you an alternative that should work.
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Empty QueryDict on POST

2010-05-31 Thread Brian
Hello!

I could use some help tracking down a problem here. I have a view that
starts as follows:

@login_required
@json_response
def save_exercise_week( request, week_id ):
formID = request.POST['formID']

But this returns a 500 error because the QueryDict is empty --
MultiValueDictKeyError at ... "Key 'formID' not found in " In fact, according to the Django error page, there is no GET, POST,
or FILES data.

I've checked my HTML form over several times and it looks fine. In
Firebug, it says the POST sent is:

csrfmiddlewaretoken: ...
fatPercentage: 10
formID: formWeek4
weekNumber: 17
weight: 150.0
year: 2010

which is correct. So, it looks like somewhere between the sending of
the request and the calling of the view, the POST data is lost. I am
using an XHR request to retrieve this view, but that's working fine
for other views in my project. I would appreciate any ideas about what
might be causing this. I've attached more data below from the error.
Thank you!


CSRF_COOKIE '...'
DOCUMENT_ROOT   '...'
GATEWAY_INTERFACE   'CGI/1.1'
HTTP_ACCEPT 'text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8'
HTTP_ACCEPT_CHARSET 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'
HTTP_ACCEPT_ENCODING'gzip,deflate'
HTTP_ACCEPT_LANGUAGE'en-us,en;q=0.5'
HTTP_CONNECTION 'close'
HTTP_COOKIE 'csrftoken=6cd4642c36c8ff19dcb0c734a2d45fb6;
sessionid=8c8ddb6631837ba811a62c8076f7521f; logintheme=cpanel;
cprelogin=no;
cpsession=HVb7EJsM_GibQJqkt_Z2NvUxRp0F0VNWv1qQNRTqYwc09MfDogZU7pbsZjbGjmuf'
HTTP_HOST   '...'
HTTP_USER_AGENT 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-
US; rv:1.9.0.10) Gecko/2009042315 Firefox/3.0.10'
PATH'/usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/courier-imap/
sbin:/usr/lib/courier-imap/bin:/usr/local/sbin:/usr/local/bin:/sbin:/
bin:/usr/sbin:/usr/bin:/usr/X11R6/bin'
PATH_INFO   u'...'
PATH_TRANSLATED 'redirect:/cgi-bin/gfnn.fcgi/v2/exercise/save/week/4//
exercise/save/week/4/'
QUERY_STRING''
REDIRECT_STATUS '200'
REDIRECT_TZ 'America/Los_Angeles'
REDIRECT_UNIQUE_ID  'TAO30K6EpiIAAFFKYocAAAKQ'
REDIRECT_URL'...'
REMOTE_ADDR '217.41.238.90'
REMOTE_PORT '53799'
REQUEST_METHOD 'GET'
REQUEST_URI '/v2/exercise/save/week/4/'
SCRIPT_FILENAME '.../cgi-bin/gfnn.fcgi'
SCRIPT_NAME u''
SERVER_ADDR '174.132.166.58'
SERVER_ADMIN'...'
SERVER_NAME '...'
SERVER_PORT '80'
SERVER_PROTOCOL 'HTTP/1.1'
SERVER_SIGNATURE'Apache mod_fcgid/2.3.5
mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server
at gofitnow.net Port 80\n'
SERVER_SOFTWARE 'Apache mod_fcgid/2.3.5 mod_auth_passthrough/2.1
mod_bwlimited/1.4 FrontPage/5.0.2.2635'
TZ  'America/Los_Angeles'
UNIQUE_ID   'TAO30K6EpiIAAFFKYocAAAKQ'
wsgi.errors 
wsgi.input  
wsgi.multiprocess   False
wsgi.multithreadTrue
wsgi.run_once   False
wsgi.url_scheme 'http'
wsgi.version(1, 0)

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



move up tree in {% include "/dir/name.html" %} statement

2010-11-09 Thread Brian
Thanks for the help.

I'm using Python 2.5 and Django Template 1.1

I can't seem to move up the directory tree for inserting of html files
using  {% include file %} statement

Sample dir structure:

---/lib/Top.html
---/lib/
root/
---/main/
---/main/include/HomeLogo.html
---/main/HOME.html

Inside HOME.html I can use {% include "/include/HomeLogo.html" %} =
Works just fine to any where up the tree.

BUT

I can not find a way to include the top.html file in home.html.
I tried {% include "/lib/Top.html" %}, {% include "lib/Top.html" %} ,
{% include "../lib/Top.html" %}, {% include "./lib/Top.html" %}
can not find a way to insert the html in.

Thanks again.




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



Can't move down then up the directory tree for inserting of html files

2010-11-09 Thread Brian
Thanks for the help.
I'm using Python 2.5 and Django Template 1.1

I can't seem to move down then up the directory tree for inserting of
html files using  {% include file %} statement

Sample dir structure:
root/
root/lib/
root/lib/Top.html
root/main/
root/main/include/HomeLogo.html
root/main/HOME.html

Inside HOME.html I can use {% include "/include/HomeLogo.html" %} =
Works just fine to any where up the tree.
BUT
I can not find a way to include the top.html file in home.html.
I tried {% include "/lib/Top.html" %}, {% include "lib/Top.html" %} ,
{% include "../lib/Top.html" %}, {% include "./lib/Top.html" %}
can not find a way to insert the html in.
Thanks again.

-- 
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't move down then up the directory tree for inserting of html files

2010-11-10 Thread Brian
Dan, Thanks for the reply.

I just can not get it to work. Works just fine in same or any
directory under the dir that the .py file is in.

I played with TEMPLATE_DIRS setting without any luck, tested to the
root dir and still does not work even with "../Top.html" in the dir
under it.

On Nov 10, 4:07 am, Daniel Roseman  wrote:
> On Nov 10, 2:32 am, Brian  wrote:
>
>
>
>
>
>
>
>
>
> > Thanks for the help.
> > I'm using Python 2.5 and Django Template 1.1
>
> > I can't seem to move down then up the directory tree for inserting of
> > html files using  {% include file %} statement
>
> > Sample dir structure:
> > root/
> > root/lib/
> > root/lib/Top.html
> > root/main/
> > root/main/include/HomeLogo.html
> > root/main/HOME.html
>
> > Inside HOME.html I can use {% include "/include/HomeLogo.html" %} =
> > Works just fine to any where up the tree.
> > BUT
> > I can not find a way to include the top.html file in home.html.
> > I tried {% include "/lib/Top.html" %}, {% include "lib/Top.html" %} ,
> > {% include "../lib/Top.html" %}, {% include "./lib/Top.html" %}
> > can not find a way to insert the html in.
> > Thanks again.
>
> You can't include files in directories that are not in your template
> path. If you need to include templates in both lib and main, either
> include both directories in your TEMPLATE_DIRS setting, or include the
> parent directory (root) and refer to them as "main/include/
> HomeLogo.html" and "lib/Top.html".
> --
> DR.

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



Re: Can't move down then up the directory tree for inserting of html files

2010-11-14 Thread Brian
Thanks for the help, Still can not get it to work.

I changed TEMPLATE_DIRS setting 30 ways.

I can't seem to move down the dir tree for inserting of html files
using  {% include "file" %} statement, Works just fine to any where up
the tree, i can go up 3,4 levels just fine, but can not go down even 1
{% include "../LOGO.html" %}


Sample dir structure:

root/lib/LOGO.html  (1 level down then 1 level up, not working )
root/LOGO.html  (1 level down, not working)
root/main/home.html <--tried: {% include "../LOGO.html" %} ,{% include
"root/lib/LOGO.html" %} , {% include "/root/lib/logo.html" %}
root/main/start.py
root/main/LOGO.html (works fine)
root/main/include/LOGO.html (works fine)

To test I put just directory text inside the html file so I know what
is displaying



Thanks.






On Nov 10, 4:51 pm, Shawn Milochik  wrote:
> On Wed, Nov 10, 2010 at 4:42 PM, Brian  wrote:
> > Dan, Thanks for the reply.
>
> > I just can not get it to work. Works just fine in same or any
> > directory under the dir that the .py file is in.
>
> > I played with TEMPLATE_DIRS setting without any luck, tested to the
> > root dir and still does not work even with "../Top.html" in the dir
> > under it.
>
> Have you tried using the full path to the template? The paths you use
> in the templates are based on the TEMPLATE_DIRS value in settings.py.
>
> So if you have:
>
> TEMPLATE_DIRS = (
>         '/home/me/abc',
>         '/home/other/def',
> )
>
> Where abc contains a folder named app01 and def contains a folder
> named 'app02,' then in a template in app01 you should be able to do
> this: {% include "app02/template.html" %}

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



Re: Can't move down then up the directory tree for inserting of html files

2010-11-14 Thread Brian
Daniel, thanks for the help!, I really appreciate it.

Believe me, I simplified this to nothing:

1) I have LOGO.html in all directories with only the current directory
name in the html file (/lib = directory of LOGO.html file)
2) the home.html file has about 30 deferent include statements so I
can see from what directory its  included the LOGO file from. (  {%
include "LOGO.html" %},  {% include "/LOGO.html" %} {% include "lib/
LOGO.html" %}  {% include "/lib/LOGO.html" %} etc
3) I tried TEMPLATE_DIRS setting 30 ways:
Currently:
SITE_ROOT = os.path.realpath(os.path.dirname(__file__))
TEMPLATE_DIRS = ( os.path.join(SITE_ROOT, ''),
The log file is showing the correct root path with this but I tried
coding this 20 ways, including; 'root', c:\root, /root, \\root, "../",
"lib", /lib", "/", "\\"

I hate waisting time on this as I could be more productive coding, but
I will try a new project with this on Monday, someone also said
something about Python 2.6 being better at relative paths.(I'm on 2.5
with 1.1 of templates)

FYI: I have no problem including .py code from all kinds of relative
paths down & up the tree.

Thanks again.









On Nov 14, 9:56 am, Daniel Roseman  wrote:
> On Nov 14, 1:28 pm, Brian  wrote:
>
>
>
>
>
>
>
>
>
> > Thanks for the help, Still can not get it to work.
>
> > I changed TEMPLATE_DIRS setting 30 ways.
>
> > I can't seem to move down the dir tree for inserting of html files
> > using  {% include "file" %} statement, Works just fine to any where up
> > the tree, i can go up 3,4 levels just fine, but can not go down even 1
> > {% include "../LOGO.html" %}
>
> > Sample dir structure:
>
> > root/lib/LOGO.html  (1 level down then 1 level up, not working )
> > root/LOGO.html      (1 level down, not working)
> > root/main/home.html <--tried: {% include "../LOGO.html" %} ,{% include
> > "root/lib/LOGO.html" %} , {% include "/root/lib/logo.html" %}
> > root/main/start.py
> > root/main/LOGO.html (works fine)
> > root/main/include/LOGO.html (works fine)
>
> > To test I put just directory text inside the html file so I know what
> > is displaying
>
> You do not seem to have taken my or Shawn's advice at all. What does
> your TEMPLATE_DIRS setting look like now? As I said above, you can't
> reference templates that don't fall under a directory within that
> setting. Additionally, there are no relative paths when referencing
> from one template to another. You always need to reference the full
> path from the base template dir to the actual template path.
>
> So, assuming your TEMPLATE_DIRS setting is:
>     TEMPLATE_DIRS = (
>         'root',
>     )
> you render your 'home.html' as 'main/home.html'. Then you can do {%
> include "lib/logo.html" %}.
> --
> DR.

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



Re: Can't move down then up the directory tree for inserting of html files

2010-11-15 Thread Brian
Tom

1) the LOGO.html file contains the name of the directory it's in. (ex:
Logo.html in the root will display C:\ROOT) So when I run the web page
it displays all the Logo files that got included. When I run I have
multiple Logo files from up the tree but none from down.

2) I tried multiple tuple values in the TEMPLATE_DIRS, I tried 30
value with forward and backward / & \, I like to go to the root with
relative path.

3) Performance is not a issue, just trying to get this to work.

Thank for the info.



On Nov 15, 4:55 am, Tom Evans  wrote:
> On Sun, Nov 14, 2010 at 10:34 PM, Brian  wrote:
> > Daniel, thanks for the help!, I really appreciate it.
>
> > Believe me, I simplified this to nothing:
>
> > 1) I have LOGO.html in all directories with only the current directory
> > name in the html file (/lib = directory of LOGO.html file)
>
> How does that help you work out the correct settings, surely you've
> just shotgunned your debugging process? If it does get included, how
> do you know which one got included?
>
> > 2) the home.html file has about 30 deferent include statements so I
> > can see from what directory its  included the LOGO file from. (  {%
> > include "LOGO.html" %},  {% include "/LOGO.html" %} {% include "lib/
> > LOGO.html" %}  {% include "/lib/LOGO.html" %} etc
>
> From a performance perspective, thats a bit nuts.
>
> > 3) I tried TEMPLATE_DIRS setting 30 ways:
> > Currently:
> > SITE_ROOT = os.path.realpath(os.path.dirname(__file__))
> > TEMPLATE_DIRS = ( os.path.join(SITE_ROOT, ''),
> > The log file is showing the correct root path with this but I tried
> > coding this 20 ways, including; 'root', c:\root, /root, \\root, "../",
> > "lib", /lib", "/", "\\"
>
> Above TEMPLATE_DIRS in my settings.py it says this:
>
>     # Put strings here, like "/home/html/django_templates" or
> "C:/www/django/templates".
>     # Always use forward slashes, even on Windows.
>     # Don't forget to use absolute paths, not relative paths.
>
> Looks like none of the things you tried conform to that.
>
>
>
> > I hate waisting time on this as I could be more productive coding, but
> > I will try a new project with this on Monday, someone also said
> > something about Python 2.6 being better at relative paths.(I'm on 2.5
> > with 1.1 of templates)
>
> > FYI: I have no problem including .py code from all kinds of relative
> > paths down & up the tree.
>
> > Thanks again.
>
> Yeah, it's a shame to waste time on something.
>
> Templates are not python. Changing to python 2.6 will not make you
> able to include templates using relative paths, it just is not
> possible using django templates.
>
> When you say
>
> {% include "foo/bar.html" %}
>
> what django does is to step through each value in
> settings.TEMPLATE_DIRS, appends the string in the include tag to the
> value, and checks to see if the file is present. If it is not, then it
> continues with the next values from settings.TEMPLATE_DIRS and so on.*
>
> Therefore, YOU should be able to work out why it isn't working.
>
> If, as you say, you only have one value in TEMPLATE_DIRS, it should be
> quite clear what file will get included. If the file can't be found,
> you even get a lovely debug message explaining exactly what paths it
> tried, which should make it even easier for you to work out where it
> is trying to include from, and you can fix your settings so they are
> correct.
>
> Cheers
>
> Tom
>
> * Actually, that's what the default template loader does, you can add
> additional loaders to settings.TEMPLATE_LOADERS which load templates
> in different ways, read the manual for more info.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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't move down then up the directory tree for inserting of html files

2010-11-15 Thread Brian
Tom, Thanks again.

If so, stop trying - you cannot do -->  just to be clear:
I like to do this:
src
├── settings.py
│
├── templates
│   ├── logos
│   │   ├── logo1.html
│   │   └── logo2.html
│   └── titles
│   ├── title1.html
│   └── title2.html
├── main
│   ├── page.html <-- in here I like to say {% include "../templates/
logos/logo1.html" %} or {% include "templates/logos/logo1.html" %}
│   └── start.py (runs application and calls page.html)


Thanks Brian



On Nov 15, 9:11 am, Tom Evans  wrote:
> On Mon, Nov 15, 2010 at 1:49 PM, Brian  wrote:
> > Tom
>
> > 1) the LOGO.html file contains the name of the directory it's in. (ex:
> > Logo.html in the root will display C:\ROOT) So when I run the web page
> > it displays all the Logo files that got included. When I run I have
> > multiple Logo files from up the tree but none from down.
>
> So you want something like this?
>
> templates
> ├── logo.html
> ├── subdir
> │   ├── logo.html
> │   └── page.html
> └── subdir2
>     ├── logo.html
>     └── page.html
>
> and have (eg) subdir/page.html like so:
>
> {% include "logo.html" %}
>
> and have that include "subdir/logo.html"?
>
> If so, stop trying - you cannot do that with the django's template
> loaders. You could implement your own loader to do that, but it would
> subvert how regular templates are loaded, and you probably wouldn't be
> able to run things like django admin or other 3rd party apps.
>
> At some point in your view, you must know which template you are
> rendering. Why not simply pass that information into the template in
> the context, and include logo.html based upon that variable.
>
>
>
> > 2) I tried multiple tuple values in the TEMPLATE_DIRS, I tried 30
> > value with forward and backward / & \, I like to go to the root with
> > relative path.
>
> I'll repeat it again, since it is relevant:
>
> TEMPLATE_DIRS should have _absolute_ paths only, and should use
> _forward slashes_ only.
>
>
>
> > 3) Performance is not a issue, just trying to get this to work.
>
> It's never an issue until it is :)
>
> Cheers
>
> Tom

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



No module named urls

2010-02-07 Thread Brian
Hi all,

I'm putting together a Django application from scratch and have
created my models. I'm trying to activate the admin site now and am
getting the above error. I've tried everything I found on mailing
lists with no luck. This includes the old style settings.py (which is
commented out now) as well as the new. Note, the model has synced to
the database correctly.

Here is the contents of the admin.py file which resides in my app
directory (triagedb/triagedb_app):

from triagedb.triagedb_app.models import Address, TriageGroup, Nurse,
PhysGroup, Physician
from django.contrib import admin

admin.site.register(Address)
admin.site.register(TriageGroup)
admin.site.register(Nurse)
admin.site.register(PhysGroup)
admin.site.register(Physician)

Here is my settings file:

# Django settings for triagedb_app project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', 'your_em...@domain.com'),
)

MANAGERS = ADMINS

DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql',
'mysql',

# 'sqlite3' or 'oracle'.
DATABASE_NAME = '/Users/Tarka/triagedb/triagedb.sqlite' # Or path to
database file if

  # using sqlite3.
DATABASE_USER = 'triagedb_app' # Not used with sqlite3.
DATABASE_PASSWORD = 'triageapp#1' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost.
Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not
used with sqlite3.

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as
your
# system time zone.
TIME_ZONE = 'America/Vancouver'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as
not
# to load the internationalization machinery.
USE_I18N = True

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use
a
# trailing slash if there is a path component (optional in other
cases).
# Examples: "http://media.lawrence.com";, "http://example.com/media/";
MEDIA_URL = ''

# URL prefix for admin media -- CSS, JavaScript and images. Make sure
to use a
# trailing slash.
# Examples: "http://foo.com/media/";, "/media/".
ADMIN_MEDIA_PREFIX = '/media/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = '[edited]'

# List of callables that know how to import templates from various
sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source',
)

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)

ROOT_URLCONF = 'triagedb_app.urls'

TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/
django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)

INSTALLED_APPS = (
#'django.contrib.auth',
#'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'triagedb.triagedb_app',
)

Here is my urls..py file:

from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
# Example:
# (r'^triagedb_app/', include('triagedb_app.foo.urls')),

# Uncomment the admin/doc line below and add
'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
# (r'^admin/', include(admin.site.urls)),
(r'^admin/(.*)', admin.site.root),
)

And finally, here is the error message:

Traceback (most recent call last):

  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/site-packages/django/core/servers/basehttp.py", line
279, in run
self.result = application(self.environ, self.start_response)

  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/site-packages/django/core/servers/basehttp.py", line
651, in __call__
return self.application(environ, start_response)

  File "/opt/local/Library/Frameworks/Python.f

Re: No module named urls

2010-02-08 Thread Brian
Aaargh! I knew it had to be something like that!

Thanx Karen.

On Feb 7, 5:20 pm, Karen Tracey  wrote:
> On Sun, Feb 7, 2010 at 4:27 PM, Brian  wrote:
> > Hi all,
>
> > I'm putting together a Django application from scratch and have
> > created my models. I'm trying to activate the admin site now and am
> > getting the above error. I've tried everything I found on mailing
> > lists with no luck. This includes the old style settings.py (which is
> > commented out now) as well as the new. Note, the model has synced to
> > the database correctly.
>
> > Here is the contents of the admin.py file which resides in my app
> > directory (triagedb/triagedb_app):
>
> > [snip]
> > Here is my settings file:
> > [snip]
>
> > ROOT_URLCONF = 'triagedb_app.urls'
>
> > [snip]
>
> > INSTALLED_APPS = (
> >    #'django.contrib.auth',
> >    #'django.contrib.contenttypes',
> >    'django.contrib.sessions',
> >    'django.contrib.sites',
> >    'django.contrib.admin',
> >    'triagedb.triagedb_app',
> > )
>
> > Here is my urls..py file:
> > [snip]
>
> The urls.py file you show looks like it is a base project urls.py file,
> auto-created perhaps when you ran django-admin.py startproject triagedb.
> That file would have been place in triagedb/urls.py. Yet your ROOT_URLCONF
> settings is ''triagedb_app.urls", which will be looking to load
> triagedb_app/urls.py from somewhere in the Python path. Where exactly is
> this urls.py file located?  If it is really in triagedb/urls.py then the
> URLCONF setting should be 'triagedb.urls'.
>
> Karen

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Possible bug with django 1.2, postgresql and aggregates?

2010-02-08 Thread Brian
It may indeed be that the MAX clause is using "mat_foo" instead of the
assigned correlation U0. What happens if you paste the two SQLs into a
query window in PgAdmin 3 and execute them. If the 1.2 query fails
with the same error message, I'd report a bug.

If it doesn't fail, it's still a Django issue, but I have no idea what
it could be. I'm very new to Django; not new to databases.

Brian

On Feb 8, 9:32 am, Mathieu Pillard  wrote:
> Hi,
>
> I have been testing the 1.2 beta1 and think I found a bug, but since
> the query I'm using is a bit complicated I wanted to run it through
> the list first.
>
> The model I'm using:
>
> from django.db import models
> from django.contrib.auth.models import User
>
> class Foo(models.Model):
>     subject = models.CharField(max_length=120)
>     sender = models.ForeignKey(User, related_name='sent_foo')
>     recipient = models.ForeignKey(User, related_name='received_foo')
>     conversation = models.ForeignKey('self', null=True, blank=True)
>
> It's a basic messaging system, in which you can group messages by
> conversations : when saving a new Foo object, you can give it an
> existing Foo id to form a conversation. I want to display the "inbox"
> for a user, which should be a list with the last message from each
> conversation. The following code works in 1.1:
>
> from django.db.models import Max
>
> def conversations(self, user):
>     tmp = 
> Foo.objects.values('conversation').annotate(Max('id')).values_list('id__max',
> flat=True).order_by( 'conversation')
>     return Foo.objects.filter(id__in=tmp.filter(recipient=user))
>
> However, in 1.2 beta 1, with postgresql_psycopg2, it fails with:
> DatabaseError: aggregates not allowed in WHERE clause
> LINE 1: ...d" FROM "mat_foo" WHERE "mat_foo"."id" IN (SELECT MAX("mat_f...
>
> The generated SQL queries are a bit different. Here is django 1.2:
> SELECT "mat_foo"."id", "mat_foo"."subject", "mat_foo"."sender_id",
> "mat_foo"."recipient_id", "mat_foo"."conversation_id" FROM "mat_foo"
> WHERE "mat_foo"."id" IN (SELECT MAX("mat_foo"."id") AS "id__max" FROM
> "mat_foo" U0 WHERE U0."recipient_id" = 1  GROUP BY
> U0."conversation_id")
>
> And here is django 1.1:
> SELECT "mat_foo"."id", "mat_foo"."subject", "mat_foo"."sender_id",
> "mat_foo"."recipient_id", "mat_foo"."conversation_id" FROM "mat_foo"
> WHERE "mat_foo"."id" IN (SELECT MAX(U0."id") AS "id__max" FROM
> "mat_foo" U0 WHERE U0."recipient_id" = 1  GROUP BY
> U0."conversation_id")
>
> The only difference is in the MAX() clause. Anyone can enlighten me
> about what's happening ? Is that a (known?) django 1.2 bug or am I
> pushing the ORM a little too far? It looks like sqlite doesn't
> complain with the same code, but I didn't test if the results were
> right.
>
> Thanks

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



Re: Complex Django Hosting

2008-04-25 Thread Brian

I've been a Slicehost customer for about 3 months now, and will second
the recommendation. Granted, I only run Django in FCGI mode with
lighttpd on their 256 slice, but they've been extremely reliable, and
it "just works." If I needed to host something larger, I'd definitely
use them. The fact that they don't oversell (or at least they say they
don't) makes it much more responsive than my previous VPS host, where
the servers would slow down over time as they'd continue piling the
customers on.

Brian

On Apr 25, 8:44 am, Josh <[EMAIL PROTECTED]> wrote:
> I'm working on what will end up being a large, high-traffic, multi-
> site project. Currently we're just using a basic Webfaction account
> for hosting during development and testing, but I'm trying to figure
> out what would be the best approach to hosting moving forward.
>
> Ideally, we would have multiple individual servers, a database server,
> a media server, and either a server for the Django sites, or multiple
> servers each with some number of sites (starting with 4 or 5, but
> theoretically growing to many more).
>
> Does anyone have any recommendation for the best approach to hosting
> here, and what hosting company might be a good fit? I know that
> MediaTemple can certainly accommodate our needs, but I've had a lot of
> trouble in the past getting Django running on MediaTemple (in fact,
> I've never been successful at doing so). Having used Webfaction for a
> little while now, they seem like a pretty good host, but how well
> would they be able to accommodate the sort of setup that we want?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Render raw image

2008-04-28 Thread Brian

Have you considered creating a separate view for that particular
image? You'd have a view designed to grab that image and return it
with the proper MIME type. Then you could, in your Welcome method,
return a dynamically generated path to that URL using the reverse()
method, which you'd use in your  tag in your template.

On Apr 28, 2:54 pm, hareesh <[EMAIL PROTECTED]> wrote:
> (I'm a django n00b).
>
> Through a database, I get the raw contents of an image and the image's
> mimetype:
>
> def Welcome(request):
>   (mime, blob) = d.GetMedia()
>   ...
>   return shortcuts.render_to_response('welcome.html', { 'msg'  :
> 'Welcome!', 'logo' : blob }) # Line 3
>
> Now clearly, this (Line 3) doesn't work as I intend it to. So what is
> the best way of showing the raw image? Must I write it to my "static
> files" directory and then pass the full path of the newly written
> image, to the context dict in render_to_response?
>
> 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
-~--~~~~--~~--~--~---



Unique Users Per Site in 'users' & 'sites' Frameworks

2008-05-07 Thread Brian

I'm building an application where each customer has an account in the
system. That account has multiple users in it, each with their own
username and password. Every account is a separate entity which will
have no knowledge of other accounts or their data.

Since each customer has their own subdomain, the sites framework seems
like it would work nicely as an account model. I'd also like to use
the built in user authentication system instead of rolling my own.
However, I'm running into a problem: let's say that AccountA
(a.example.com) has a user named UserA. How can AccountB
(b.example.com) also have a distinct user named UserA? Will I need to
set up a whole new database and settings.py for each site?

Thanks in advance,

Brian
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Unique Users Per Site in 'users' & 'sites' Frameworks

2008-05-07 Thread Brian

I have a feeling we'll be rolling our own for this one. That's a lot
of time to invest though :-/ At least the admin will still be usable.
Has anybody else run into a similar scenario?

On May 7, 1:41 pm, "Jonas Oberschweiber" <[EMAIL PROTECTED]>
wrote:
> I'm at a very similar point in development. To me the only way seems
> to be to alter the user database and roll my own login methods. This
> would probably work, but just does not feel right. I'm pretty new to
> Django, is there something I'm missing? Or is rolling your own really
> the only way to implement this?
>
> Regards
>
> Jonas
>
> On Wed, May 7, 2008 at 12:06 PM, Brian <[EMAIL PROTECTED]> wrote:
>
> >  I'm building an application where each customer has an account in the
> >  system. That account has multiple users in it, each with their own
> >  username and password. Every account is a separate entity which will
> >  have no knowledge of other accounts or their data.
>
> >  Since each customer has their own subdomain, the sites framework seems
> >  like it would work nicely as an account model. I'd also like to use
> >  the built in user authentication system instead of rolling my own.
> >  However, I'm running into a problem: let's say that AccountA
> >  (a.example.com) has a user named UserA. How can AccountB
> >  (b.example.com) also have a distinct user named UserA? Will I need to
> >  set up a whole new database and settings.py for each site?
>
> >  Thanks in advance,
>
> >  Brian
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Unique Users Per Site in 'users' & 'sites' Frameworks

2008-05-07 Thread Brian

I have a feeling we'll be rolling our own for this one. It's a lot of
extra work though :-/ Has anybody else run into this issue?

On May 7, 1:41 pm, "Jonas Oberschweiber" <[EMAIL PROTECTED]>
wrote:
> I'm at a very similar point in development. To me the only way seems
> to be to alter the user database and roll my own login methods. This
> would probably work, but just does not feel right. I'm pretty new to
> Django, is there something I'm missing? Or is rolling your own really
> the only way to implement this?
>
> Regards
>
> Jonas
>
> On Wed, May 7, 2008 at 12:06 PM, Brian <[EMAIL PROTECTED]> wrote:
>
> >  I'm building an application where each customer has an account in the
> >  system. That account has multiple users in it, each with their own
> >  username and password. Every account is a separate entity which will
> >  have no knowledge of other accounts or their data.
>
> >  Since each customer has their own subdomain, the sites framework seems
> >  like it would work nicely as an account model. I'd also like to use
> >  the built in user authentication system instead of rolling my own.
> >  However, I'm running into a problem: let's say that AccountA
> >  (a.example.com) has a user named UserA. How can AccountB
> >  (b.example.com) also have a distinct user named UserA? Will I need to
> >  set up a whole new database and settings.py for each site?
>
> >  Thanks in advance,
>
> >  Brian
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Caching: Memcached vs locmem

2008-05-16 Thread Brian

Can someone run down the differences between using Memcached vs
locmem?

The docs indicate Memcached is "the best" solution, but seems
considerably harder to setup. Just curious what the trade-offs are.

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



TypeError: Cannot resolve keyword 'slug' into field

2008-05-17 Thread Brian

I've searched for this, but people think it is either fixed or very
hard to reproduce. In my case it is 100% reproducible, and I wonder if
it is my own fault.

I have a model for a mp3 set (a set of mp3s). Individual mp3's are
associated with the set via a Foreign key.

I recently added a slug field to the mp3 after the fact, and I think I
have manually added it to the MySQL database to match what Django
thinks should be there. Now, when I try to edit a mp3 set in the admin
page and hit save, I always get:

TypeError at /django/admin/band/mp3_set/3/
Cannot resolve keyword 'slug' into field. Choices are: mp3, id, date,
title, text

Here are the models:

class Mp3_Set(models.Model):
   date = models.DateField(auto_now_add = True, editable = False)
   title = models.CharField(max_length = 64)
   text = models.TextField()

   def __unicode__(self):
  return self.title

   class Admin:
  list_filter = ('date', )
  list_display = ('title', 'date')

   class Meta:
  ordering = ('date', )
  verbose_name = "MP3 Set"

class Mp3(models.Model):
   mp3_set = models.ForeignKey(Mp3_Set, edit_inline = models.TABULAR,
num_in_admin = 5, num_extra_on_change = 5)
   title = models.CharField(max_length = 64, core = True)
   desc = models.CharField(max_length = 128, blank = True)
   file = models.FileField(upload_to = 'mp3s/%Y/%m/%d/')
   slug = models.SlugField(unique = True, prepopulate_from = ('title',
'desc'))

   def __unicode__(self):
  return self.title

   class Admin:
  pass

   class Meta:
  ordering = ('title', )
  verbose_name = "MP3"

And here is the export SQL for the two tables:

CREATE TABLE `band_mp3_set` (
  `id` int(11) NOT NULL auto_increment,
  `date` date NOT NULL,
  `title` varchar(64) collate latin1_general_ci NOT NULL,
  `text` longtext collate latin1_general_ci NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci
AUTO_INCREMENT=4 ;

CREATE TABLE `band_mp3` (
  `id` int(11) NOT NULL auto_increment,
  `mp3_set_id` int(11) NOT NULL,
  `title` varchar(64) collate latin1_general_ci NOT NULL,
  `desc` varchar(128) collate latin1_general_ci NOT NULL,
  `file` varchar(100) collate latin1_general_ci NOT NULL,
  `slug` varchar(50) collate latin1_general_ci NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `band_mp3_slug` (`slug`),
  KEY `band_mp3_mp3_set_id` (`mp3_set_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci
AUTO_INCREMENT=11 ;


Here is a trace back:
Traceback:
File "C:\Python25\Lib\site-packages\django\core\handlers\base.py" in
get_response
  82. response = callback(request, *callback_args,
**callback_kwargs)
File "C:\Python25\Lib\site-packages\django\contrib\admin\views
\decorators.py" in _checklogin
  62. return view_func(request, *args, **kwargs)
File "C:\Python25\Lib\site-packages\django\views\decorators\cache.py"
in _wrapped_view_func
  44. response = view_func(request, *args, **kwargs)
File "C:\Python25\Lib\site-packages\django\contrib\admin\views
\main.py" in change_stage
  334. errors = manipulator.get_validation_errors(new_data)
File "C:\Python25\Lib\site-packages\django\oldforms\__init__.py" in
get_validation_errors
  62. errors.update(field.get_validation_errors(new_data))
File "C:\Python25\Lib\site-packages\django\oldforms\__init__.py" in
get_validation_errors
  379. self.run_validator(new_data, validator)
File "C:\Python25\Lib\site-packages\django\oldforms\__init__.py" in
run_validator
  369. validator(new_data.get(self.field_name, ''),
new_data)
File "C:\Python25\Lib\site-packages\django\utils\functional.py" in
_curried
  55. return _curried_func(*(args+moreargs), **dict(kwargs,
**morekwargs))
File "C:\Python25\Lib\site-packages\django\db\models\fields
\__init__.py" in manipulator_validator_unique
  47. old_obj = self.manager.get(**{lookup_type: field_data})
File "C:\Python25\Lib\site-packages\django\db\models\manager.py" in
get
  69. return self.get_query_set().get(*args, **kwargs)
File "C:\Python25\Lib\site-packages\django\db\models\query.py" in get
  261. obj_list = list(clone)
File "C:\Python25\Lib\site-packages\django\db\models\query.py" in
__iter__
  114. return iter(self._get_data())
File "C:\Python25\Lib\site-packages\django\db\models\query.py" in
_get_data
  486. self._result_cache = list(self.iterator())
File "C:\Python25\Lib\site-packages\django\db\models\query.py" in
iterator
  180. select, sql, params = self._get_sql_clause()
File "C:\Python25\Lib\site-packages\django\db\models\query.py" in
_get_sql_clause
  501. joins2, where2, params2 = self._filters.get_sql(opts)
File "C:\Python25\Lib\site-packages\django\db\models\query.py" in
get_sql
  723. joins2, where2, params2 = val.get_sql(opts)
File "C:\Python25\Lib\site-packages\django\db\models\query.py" in
get_sql
  774. return parse_lookup(self.

Re: Caching: Memcached vs locmem

2008-05-17 Thread Brian

On May 17, 7:37 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I managed to get memcached up and running in about 5 minutes, so
> whilst it does involve more setup than locmem I wouldn't say it's
> difficult to the point of not being worth doing.

Thanks for that. I'll likely give it a try.

> Memcached is basically more efficient in general and supports
> clustering which makes it much better for scalability

But if you aren't clustering, say you have only a single server, is
there an advantage?

I turned on locmem today, but I don't think it is working. How can I
tell? I looked at my site with two browsers, one logged into admin,
and the other as anonymous. I made changes to the site as admin, and
the anonymous guy picked them up immediately.

Here are my settings:

CACHE_BACKEND = 'locmem:///?timeout=3600'
CACHE_MIDDLEWARE_SECONDS = 3600
CACHE_MIDDLEWARE_KEY_PREFIX = ''
CACHE_MIDDLEWARE_ANONYMOUS_ONLY = False

MIDDLEWARE_CLASSES = (
'django.middleware.cache.CacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Caching: Memcached vs locmem

2008-05-18 Thread Brian

On May 18, 12:55 pm, "Brett Hoerner" <[EMAIL PROTECTED]> wrote:
> On Sat, May 17, 2008 at 8:12 PM, Brian <[EMAIL PROTECTED]> wrote:
> > But if you aren't clustering, say you have only a single server, is
> > there an advantage?
>
> Yes, locmem is memory local to a single Python process.  If you're
> running Django in some sort of multi-process server (as most people
> do) e.g. Apache with the prefork MPM, each Python process will have to
> cache for itself.  If you use memcached then all of your Python
> processes will speak to another process (memcached) and thus have the
> same cache state at any given time.

Thanks, this makes sense. So each process has its own locmem cache.
But if you use memcached all processes would share memcached. Gotcha.

>
> > I turned on locmem today, but I don't think it is working. How can I
> > tell? I looked at my site with two browsers, one logged into admin,
> > and the other as anonymous. I made changes to the site as admin, and
> > the anonymous guy picked them up immediately.
>
> Is this using Django runserver, or under a 'production' setup such as
> Apache?  If you're using Apache this could be an example of the above,
> your other user's request went to a different process which hadn't
> cached the page yet in its own local memory.

Yes this is under a production Apache server. 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: TypeError: Cannot resolve keyword 'slug' into field

2008-05-18 Thread Brian

On May 18, 6:01 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
> Based on the choices the error message lists, it appears you have added code
> that tries to access the slug field in an Mp3_Set model instance.  However,
> you have added the slug field to the other model, Mp3.
>
> Karen

Where would that code be? This is in the admin page when I am editing
an Mp3_Set. The Mp3's appear inline on that page. I can edit Mp3's on
their own admin page just fine. 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: TypeError: Cannot resolve keyword 'slug' into field

2008-05-19 Thread Brian

On May 19, 8:19 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> Ah, sorry, I missed the fact that it was admin causing the error.  The error
> looks to be in the old manipulator/validator code for the slugfield.  With
> newforms-admin this code is on its way out, so unlikely to get much
> attention for figuring out what exactly is going wrong.  I tried your models
> under newforms-admin, and I don't see any problem there with saving an
> Mp3_Set with inline-edited Mp3 instances. So one option for you would be to
> convert to newforms-admin.  

How does one cut over to newforms-admin? I didn't see anything about
that on the docs page.

>Note that the prepoulate_from bit for the slug
> field doesn't work for inline-edited models (in either old or new admin
> case), see:
>
> http://code.djangoproject.com/ticket/957

Yes I have noticed it doesn't reliably work.

Thanks again.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: un-escaping params

2008-05-19 Thread Brian
On Tue, May 20, 2008 at 12:44 AM, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> I'm parsing a URI manually, and trying to extract the GET params.
>
> What does django use to un-escape the params? Yah know to go from %20
> to " " in unicode?
>
> Thanks,
> Ivan
> tipjoy.com
> >
>
I'm not sure if this is how django does it, but I would use
urllib.unquote(params).  If you give it unicode, it returns unicode.

Brian

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



Django developers NYC???

2006-11-13 Thread Brian

Hi,

New to the group.  I just took over the website for a smaller, weekly
newspaper in NYC, and I am looking at completely rebuilding the system
with a Django framework.  Do you have any suggestions how I can find a
good lead Django developer in NYC.  Are there job boards etc, besides
this I should check out (I also posted on gypsyjobs)?   More
importantly, if any of you are interested in this gig please contact me

at 


bkroski at observer d0t com


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



Server error no httpresponse implementing htmx active search

2022-12-09 Thread Brian
I'm trying to implement the active search functionality with htmx but am 
getting a server error. I'd really appreciate any help on this. Googling 
the problem resulted in people either not using return before render or an 
indentation problem. I've checked these.

Thanks in advance,
Brian
```
ValueError: The view Striker.views.search_player didn't return an 
HttpResponse object. It returned None instead.
```
view.py
```
def search_player(request):
  print(request)
  search_text = request.POST.get("search")
  results = Player.objects.filter(name__icontains=search_text)
  context = {'results': results}
  return render(request, 'Striker/partials/player-search-results.html', 
context)
```
player-search-results.html
```
{% if results %}
  {% csrf_token %}
  {% for player in results %}

  

  {{ player.name }}
  


  GP: {{ player.gp|intword 
}}
  Toons: {{ 
player.gpChar|intword }}
  Ships: {{ 
player.gpShip|intword|intcomma }}
  Allycode: https://swgoh.gg/p/{{ player.allycode }}" Title="Link 
to SWGOH.gg">{{ player.allycode }}
.gg
  

  

  {% endfor %}
{% else %}
  No search results
{% endif % }
```
called from 
```
{% load humanize %}


  
  {% csrf_token %}
  
  





```
urls.py
```
path('striker/search-player', views.search_player, name='search-player'),
```

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5c4eb0ed-8d4b-4294-83d3-1955b7b431b5n%40googlegroups.com.


Re: Server error no httpresponse implementing htmx active search

2022-12-09 Thread Brian
Yes it was a type, otherwise nothing would work lol. Thanks for the reply. 
Mysteriously it is not giving me the server error. I did simplify the html 
so there must have been something in that. Now I'm having a different 
problem. I'm getting "Method Not Allowed: /players/search-player/". I've 
updated the view to 
```
def search_player(request):  
  def post(self, request, **kwargs):
search_text = request.POST.get("search")
results = Player.objects.filter(name__icontains=search_text)
context = {'results': results}
return render(request, 'Striker/players', context)
```
```
path('striker/players/search-player/', views.search_player, 
name='search-player'),
```
And the simplified template
```
{% extends './base.html' %}
{% load humanize %}

{% block content %}

  

  
Current Members

  
{% for player in players %}

  

  {{ player.name }}
  


  GP: {{ 
player.gp|intword }}
  Toons: {{ 
player.gpChar|intword }}
  Ships: {{ 
player.gpShip|intword|intcomma }}
  Allycode: https://swgoh.gg/p/{{ player.allycode }}" 
Title="Link to SWGOH.gg">{{ player.allycode }}
.gg
  

  

{% endfor %}
  
  

  


{% endblock content %}
```
On Friday, December 9, 2022 at 4:15:46 PM UTC-7 Ryan Nowakowski wrote:

>
>
> On December 9, 2022 12:10:23 PM CST, Brian  wrote:
> >```
> >ValueError: The view Striker.views.search_player didn't return an 
> >HttpResponse object. It returned None instead.
> >```
> >view.py
> >```
> >def search_player(request):
> > print(request)
> > search_text = request.POST.get("search")
> > results = Player.objects.filter(name__icontains=search_text)
> > context = {'results': results}
> > return render(request, 'Striker/partials/player-search-results.html', 
> >context)
> >```
>
> I assume view.py is a typo and you really meant views.py above? If you've 
> got both a view.py and a views.py maybe that's your issue.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e277f97d-cbc8-421b-8a59-fc8aeb0ce840n%40googlegroups.com.


template tag that iterates over list with for loop

2012-02-19 Thread brian
Is it possible to create a template tag that will create a list that a
for loop can loop over? I know I can create a template tag that will
store the list in a variable and then iterate over that variable.  I
want to do it in one step.

For example the template tag with be “list_print” that will create a
list.  I want something like the following in the template:
{% for a in list_print %}

Below is my code.  When I call it the loop never iterates.
@register.tag(name="list_print")
def do_list_print(parser, token):
#test that don't have arguments
try:
tokenList = token.split_contents()

except Exception:
raise template.TemplateSyntaxError("%r tag throw unexpected
exception(token.split_contents)" % token.contents.split()[0])

if len(tokenList)>1:
raise template.TemplateSyntaxError("%r tag does not take
arguments" % token.contents.split()[0])

return ListPrintNode()

class ListPrintNode(Node):
"""
thread safe version based on CycleNode from
https://docs.djangoproject.com/en/dev/howto/custom-template-tags/
"""

def __init__(self):
self.myList = ['a', 'b']

def render(self, context):

if self not in context.render_context:
context.render_context[self] =
itertools.cycle(self.myList)

    cycle_iter = context.render_context[self]
return cycle_iter.next()

Brian

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



find django template developers

2012-03-20 Thread brian
What are the resources to find django template developers?

I've posted my project to:
https://www.elance.com
http://www.getacoder.com
https://www.odesk.com
https://www.freelancer.com

I've read on the forums about http://djangogigs.com/ but they seem
over priced and doesn't seem to have a lot of activity.  I've also
read about http://www.donanza.com/jobs/django but that just seems like
a screen scraper.

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



get all models for app with ContentType

2012-03-27 Thread brian
How do I get all the models for an app with ContentType?

I have this code the works on the local server but throws
“DoesNotExist: ContentType matching query does not exist” in
production:
ct = ContentType.objects.get(app_label=app_label, name=modelName)

This works:
ct = ContentType.objects.get(app_label)

So it has to be something to do with the modelName.  How do can I
print out all the models for this app with ContentType.

I've tried the following at the model appears to be there:
app = get_app(app_label)
for model in get_models(app):

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



scroll to form on error

2012-05-11 Thread brian
I have form that is toward the bottom of a web page.  If someone
submits some bad data, I want the page to scroll to the form.
Currently if the data is bad, I can see the page get refreshed and the
browser scrolls to the top of the screen.  When I get an error in a
submitted form, how do I get it to scroll to the form?

I found this [1] where it scrolls after the form is submitted.  I only
want it to scroll when the form has an error.  After the form is
submitted successfully, I redirect to a thank you page.

One idea I had in the view was to do something like:
-
if form.is_valid():
  ….
else:
  return HttpResponseRedirect(request.path + '#formId')
-
The form doesn't show the error fields when I do this.  Also this
seems to break the MTV model since I putting the div id in the view.

Brian

[1] 
http://stackoverflow.com/questions/3036273/django-how-do-i-position-a-page-when-using-django-templates

-- 
You received this message because you are subscribed to the Google 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: scroll to form on error

2012-05-12 Thread brian
The redirect method isn't working.  I use middleware to insert a form
into the context for each page.  When I try to redirect with a
fragment identifier, then the page scrolls but I don't see the form
errors.  If I remove the error form redirect then I see the errors but
this removes the scroll.

Here is my code:
---
class reqInfoMiddleWare(object):
"""
inserts the req info form in content and also handles form
processing

based on: 
http://stackoverflow.com/questions/2734055/putting-a-django-login-form-on-every-page
"""

def process_request(self, request):
if request.method == 'POST':

form = forms.reqInfo(request.POST)

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

return HttpResponseRedirect('/thanks')

else:
#if error then scroll to where the form is
return HttpResponseRedirect(request.path +
'#learnMoreId')

else:
form = forms.reqInfo()

# attach the form to the request so it can be accessed within
the templates
request.req_info_form = form

---

With this, I see the scroll but my form errors aren't being shown.  In
my form template I have <{% if form.errors %}>.

If I comment out the line < return HttpResponseRedirect(request.path +
'#learnMoreId')> and the else before it, then I get the scroll but I
don't get the form errors.

I'm developing on Django 1.3.

I don't want to use the iframe since it is going to make resizing the
form for errors difficult.  I prefer to stay away from javascript and
ajax if possible.  I also thought redirect with just a url was a
shortcut for  HttpResponseRedirect so it does the same thing.

Thank you for your help!!

Brian

-- 
You received this message because you are subscribed to the Google 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: brute force protection

2012-08-31 Thread brian
 

For my long term plans I want it to be app based. To start with I want to 
give 3 tries and then lockout. For my use case this will work. Long term I 
like to add IP and move over to a captcha after 3 tries and a delay like 
2^tryNumber.


Brian

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/g_lZU7WgOQkJ.
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.



Sporadic Currency formatting is not possible using the 'C' locale

2012-10-05 Thread Brian
I get this error sporadically. If I refresh the screen 3 or 4 times it 
loads without the error.
 
It is making me nuts trying to figure out why sometimes it's fine other 
times it fails.
 
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/2PXA_CemRPgJ.
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.



Attach EmailMultiAlternatives message to an e-mail

2011-09-01 Thread brian
How do I attached a  EmailMultiAlternatives email as an attachment to
another e-mail?  I want to create a  EmailMultiAlternatives and send
it.  Then I want to create another e-mail and attach the previous
email to this one.

For example:

parameterDict = {today:'monday', month:'june'}

txt_content= myCreateTxt( parameterDict )
html_content = myCreateHtml( parameterDict )

clientEmailMsg = EmailMultiAlternatives(xxx, myTxtHtml, ….)
clientEmailMsg.attach_alternative(html_content, "text/html")
clientEmailMsg.send()

own_contentTxt = 'created e-mail with %s'%parameterDict
own_contentHtml = 'created e-mail with %s'%parameterDict
ownEmailMsg = EmailMultiAlternatives(xxx, own_contentTxt, ….)
ownEmailMsg.attach_alternative(own_contentHtml, "text/html")

#this is where problem happens:
ownEmailMsg.attach(clientEmailMsg)
ownEmailMsg.send()


I get the exception 'assert content is not None'.  I assume I need to
convert ownEmailMsg to a MIMEBase but I'm not sure how.

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



static app on development server

2011-10-06 Thread brian
I can't get the static files to be served from an app dir.

I have myApp/static/styles2.css

The template myApp\templates\myApp\ver1\tmpl.html has

{% load static %}



In the settings file I have STATICFILES_FINDERS →
'django.contrib.staticfiles.finders.AppDirectoriesFinder'

In the url I have urlpatterns += staticfiles_urlpatterns().

Any suggestions of what I'm doing wrong?  I eventually want the css to
be:  myApp/static/myApp/ver1/styles.css

-- 
You received this message because you are subscribed to the Google 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: static app on development server

2011-10-06 Thread brian
Nevermind.  My ide doesn't do auto server restarts so django wasn't
getting restarted.

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



run form save in background

2011-12-02 Thread brian
I'm having problems with a save method taking too long and the user
thinking there is a problem with the website so they hit refresh which
causes the data to be submitted multiple times.

I have this in the view:
-
if form.is_valid():
  form.save()
  return HttpResponseRedirect('/thanks/')
-

The save method takes a little time.  It saves to db, sends a couple
of emails, and interfaces with another software package(which is the
time hog).  I want to be able to show the thanks page and then call
the save method.

It seems like celery(http://www.celeryproject.org/) is the best
choice.  When I read the doc it said because of race conditions, be
careful of passing models to celery tasks.  With my form I want it to
save a unique instance for every time the form is submitted so I think
I can pass the form to the task.

Does anyone have suggestions or other recommendations about this?  Is
there an easier way to do this?

Brian

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



change charfield choices from within a ModelForm

2011-12-18 Thread brian
How do I change the CharField choices from within a ModelForm?

Here is  the stripped down version of what I have:
-
class myModel(models.Model):
test = models.CharField(max_length=3,
verbose_name='test choices',
 )

class myForm( ModelForm ):

class Meta:
model = myModel

-


One thing I tried was this but the choices didn't get added to the
form.  Note: I haven't ran this version of the code.
---
class myModel(models.Model):
test = models.CharField(max_length=3,
verbose_name='test choices',
 )

def changeChoices(self, choiceTuple):
field = self._meta.get_field_by_name( 'test' )
[0]
field._choices = choiceTuple

class myForm( ModelForm ):
def __init__(self, *args, **kwargs):

super(myForm, self).__init__(*args, **kwargs)

choices = (
('a', 'choice a'),
('b', 'choice b'),
)

self.instance.changeChoices(choices)

class Meta:
model =
myModel

--

One thing I thought about was passing a parameter to the model init
but I'm not sure how to do that.  I found this article that would seem
to work if I could figure out how to send params to the model's init:
http://blog.yawd.eu/2011/allow-lazy-dynamic-choices-djangos-model-fields/

Another thing I thought about was modifying the field in the form.  In
the forms init do something like self.fields[ 'test' ]... but I'm not
sure where to access the choices.

Brian

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



Transition from VPS(WHM/CPanel) to EC2

2012-01-22 Thread brian
I'm in the process of transitioning from a VPS (WHM/CPanel) to EC2.
I've found some great how to's on setting up a machine for the
cloud[1] but I'm not sure the best setup to add some of the WHM/CPanel
features.

Here are some of the features of cpanel I use:
1. Cpanel monitors the services (i.e. apache) and restarts them if
they crash.  I'm thinking about using supervisord for this.  Does
anyone have experience with this or is there other tools I should be
looking at?
2. I'm running a custom DNS(BIND).  I'm planning on switching to
Amazon Route 53.
3. I'm switching to PostgreSQL and I'd like to have something similar
to myPhpAdmin.
4. Creating a  backup script seems pretty straight forward.
5. What is the best way to create a firewall to block certain IPs?
I'll have an nginx server in front of apache.

How have others implemented these features?  Is there anything else I
should be thinking about?  I don't mind a command line interface.

Brian

[1] 
http://blip.tv/pycon-us-videos-2009-2010-2011/django-deployment-workshop-3651591

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



retrieve model instance from database without model instance

2012-01-23 Thread brian
How do I retrieve a model instance from the database without a model
instance?

For example from the doc[1] it has:
  product = Product.objects.get(name='Venezuelan Beaver Cheese')

I want something like getInstance( 'Product',  'Venezuelan Beaver
Cheese' )

Here are the details of what I'm doing.  I have multiple form models
that are all handled by the same post processing class.  I'm using
django-celery to do the processing.

I want to do something like this in my view:
  dbSave = form.save()
  processTask.delay('Product', dbSave.pk)

Then in the task:
 class processTask(Task):
def run(self, modelName, pk):
instance =  getInstance( modelName, pk )
….

>From what I've read about django-celery, I shouldn't pass class
instances to the task so I need a way to pass/retrieve this info via
basic datatypes.

Brian


[1] 
https://docs.djangoproject.com/en/dev/ref/models/instances/#updating-attributes-based-on-existing-fields

-- 
You received this message because you are subscribed to the Google 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: Trying to figure out ManyToManyField on a legacy database

2013-05-11 Thread brian
Thanks Kevin, that did the trick. 

This is going to be an interesting project. There are 3 different
database types with DJ's song info involved. Each DJ has their private
database. 

Can I have different models, and have a way to link the different DJ's
databases to the correct model for their database type?

Brian
 
On Sat, 2013-05-11 at 16:37 -0700, kevin wrote:
> Hi Brian,
> 
> It seems like you don't really have an Many To Many relationship
> between your "Song" and "Played" objects.  I can see how you would
> have multiple plays for one song, but considering that the Played
> model has a track_id, would you ever have multiple songs for a single
> Play?It appears that "track_id" is intended to be a foreign key
> into the Song table, so maybe you could consider using a ForeignKey
> field to refer to your Song through your Played object.  Django will
> automatically create 2-way references so you can get to your played
> objects from your song object::
> 
> 
> class Played(models.Model):
>   played_id = models.IntegerField(primary_key=True)
>   track = models.ForeignKey('Song')
>   date_played = models.DateTimeField()
>   played_by = models.CharField(max_length=255L)
>   played_by_me = models.IntegerField()
>   class Meta:
>db_table = 'played'
> 
> 
> 
> class Song(models.Model):
> 
>   id = models.IntegerField(primary_key=True)
>   title = models.CharField(max_length=255L, blank=True)
>   class Meta:
>   db_table = 'song'
> 
> 
> Then, you should be able to get all of the Plays for a particular
> song::  
> 
> 
> 
> 
> s = Song.objects.get(id=1229)
> s.title # should be OK still
> s.played_set.all() # should be a list of plays.



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




Forcing group_by on a field other than id

2013-05-14 Thread brian
I'm trying to do a query that needs a group_by on a field other than id.

I've tried this:

s=Song.objects.using('bmillham').annotate(Count('played__date_played')).order_by('-played__date_played')

the generated query is:

>>> print s.query
SELECT `song`.`id`, `song`.`file`, `song`.`catalog`, `song`.`album`,
`song`.`album`, `song`.`year`, `song`.`artist`, `song`.`artist`,
`song`.`title`, `song`.`bitrate`, `song`.`rate`, `song`.`mode`,
`song`.`size`, `song`.`time`, `song`.`track`, `song`.`update_time`,
`song`.`addition_time`, COUNT(`played`.`date_played`) AS
`played__date_played__count` FROM `song` LEFT OUTER JOIN `played` ON
(`song`.`id` = `played`.`track_id`) GROUP BY `song`.`id` ORDER BY
`played`.`date_played` DESC

I tried adding

s.query.group_by = [('played', 'date_played')] 

but that doesn't change the query.

Am I missing something here, or can't this be done?

Thanks!
Brian

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




Scripts to update Django tables

2013-05-29 Thread Brian
I'm new to Django (and frameworks in general) and having an issue with a 
project I'm working on.  Basically, I want to scrape data from a sports 
league website on a regular schedule and add updated stats into my 
database.  All of the Django tutorials for models I've looked at seem to 
give me information on how to add table data manually using the manage.py 
shell, fixtures, or fields on an admin page, but I cannot find anything 
about doing this more automatically through a script.  Is there something 
I'm missing, or am I trying to use Django models for something they aren't 
meant to be used for? 

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




Meta class ordering by related field in ManyToMany model?

2013-09-09 Thread Brian
I'm setting up a database for data related to sporting event stats.  My 
database has a Game model, which is linked to a TeamGame model (stats 
related specifically to each team that played in that game). These two 
models are linked as ManyToMany, as we're going to have multiple games and 
each game is going to have multiple Teams.  I would like both of these 
models to be ordered by the game's date, which is a column in the Game 
table but I'm having trouble figuring out how to set a Meta class to do 
this in the TeamGame model.  Here's the relevant code for each - can 
someone please help me with the syntax that I'd need to use in the TeamGame 
model to sort by date (and also so that home/away classification doesn't 
interfere with the date sorting)?

class Game(models.Model):
game_id = models.IntegerField(primary_key = True)
date = models.DateField()

team_home = models.ForeignKey(TeamGame, related_name='home')
team_away = models.ForeignKey(TeamGame, related_name='away')

class Meta:
 ordering = ['date']

class TeamGame(models.Model):

team = models.ForeignKey(Team)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


slice QuerySet and keep as QuerySet

2013-10-31 Thread brian
 

*How do I slice a QuerySet and keep it as a QuerySet*


 *If I do*

* a = qs[:3]*

*then I get a list back. I want a QuerySet. * 


 *I'm wanting to get the first x items in the query set and the last x 
items in the query set.*

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b349138c-47f7-41fd-9fcf-db3fba7c40f9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


performance of model instgance save()

2011-05-09 Thread Brian
Hi,

I've been writing a testing to backfill a database (postgres) with a
year's history to test the performance and I've been a bit surprised
by the length of time it takes to run. I have a simple model that
contains only a single datetime value and it seems (based on timing
1000 operations) that creating and saving an instance takes about
100ms, where as running "EXPLAIN ANALYZE" on a corresponding INSERT
via psql claims that to take 0.1ms.

Does anyone have an idea as to whether that ratio sounds reasonable?
If so, is there any way to speed up the saving process?

Thanks for any advice you can offer,

Brian

-- 
You received this message because you are subscribed to the Google 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: performance of model instgance save()

2011-05-10 Thread Brian
Having hauled myself a few feet up out of the abyss of ignorance, I can 
answer my own question (which might be of benefit to others getting started 
with django). To clarify the problem, I have a standalone script that 
imports the django settings and uses its ORM pleasantness to populate one of 
the model's tables with a history of 2 million entries.

My initial version was really slow and eventually ran out of memory. After a 
little searching I found two useful things:
- batch the inserts into transactions - the default behaviour is to commit 
after each save() and bundling several hundred per transaction seems to 
speed things up for me by a factor of 7
- switch DEBUG to False in the settings (something I read in the tutorial 
that wasn't relevant at the time...). This is mentioned in the FAQ
  
(http://docs.djangoproject.com/en/dev/faq/models/#why-is-django-leaking-memory)

-- 
You received this message because you are subscribed to the Google 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: performance of model instgance save()

2011-05-10 Thread Brian
Sure - it's just that bit more convenient and readable to use the ORM 
approach. If I get the chance, I must try substituting direct calls to 
psycopg and see if that makes it significantly faster again. I'd guess 
there's maybe another factor of 2 to be had.

-- 
You received this message because you are subscribed to the Google 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: performance of model instgance save()

2011-05-16 Thread Brian
> > I'd think you'll find it's significantly more than a factor of 2. For bulk
> > inserts, raw SQL is often several orders of magnitude faster.
>
> You might want to check outhttp://pypi.python.org/pypi/dse/. My tests
> using postgres showed a 3Xperformancegain on inserts compared to
> using the orm and nearly 10X when doing heavy updates on existing
> data. It takes care of creating SQL for you and respects default
> values defined in your models.

Common sense is telling me that any further performance gains I get
for this test script will be more than
offset by the time I've spent on them :-)

I switched to using psycopg2 directly to do the inserts (committing in
batches of several thousand) and found
roughly another factor of 2. For what it's worth, that single sample
point is in the same ballpark as the 10x improvement
mentioned for dse.

One thing that was confusing for a while was that the first batch of
inserts takes 5 times as long
as subsequent  batches. I didn't really get to the bottom of why that
might be. It might be fixed by using a server-side
cursor (maybe the first batch expands the client-side memory
inefficiently, but hangs on to it for subsequent
batches), but when I seemed to hit a bug when I tried using a named
cursor (psycopg2 2.2.1).

And then I climbed back out of the rabbit hole.

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



spawning threads within test cases in django test framework

2011-05-31 Thread Brian
I've got a django app with a periodically scheduled background task that 
updates the database. I've written a bunch of tests for its principal class 
that are run as part of the django unit test framework. I want to convert 
the class to do its work using multiple threads, but I'm having trouble 
getting the tests to run against the multi-threaded version.

I've tried sqlite3 and postgres as back-ends, but to no avail. Is there a 
problem where the testing framework uses transactions to rollback any 
changes from one test to the next and so the evolving state of the database 
in that transaction is hidden from the other threads? Can the database 
connection (and hence transaction) be shared between the threads? Has anyone 
encountered this problem before? (And, ideally, came up with a really neat 
solution...)

Thanks,

Brian 

-- 
You received this message because you are subscribed to the Google 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: spawning threads within test cases in django test framework

2011-06-01 Thread Brian
Thanks for the replies. I realised that I could reorganise the code so that 
all the database updating was done in the main thread. Re 
TransactionTestCases, I knew I'd read something related to that but didn't 
find it when I went looking yesterday evening; it sounds like that would 
have worked in this case.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/RGQ0THdUdF9NaHdK.
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.



auth.LoginTest seems to require sites

2011-06-09 Thread Brian
Hi,

When I run the unit tests, I get a failure (stack trace below) 
from django.contrib.auth.tests.views.LoginTest. 
test_current_site_in_context_after_login calls Site.objects.get_current() 
which fails because I'm not using that app. If I include it in the list of 
installed apps, then the test passes. However, then a bunch of the tests 
that I've written fail; I think that's because they are using fixtures that 
are not valid with respect to the schema defined the inclusion of sites, but 
I haven't confirmed this.

The standard apps that I'm using are:
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',

Is the test broken or is there something that I'm doing that makes the sites 
app mandatory?

Thanks for any help you can give,

Brian

=

ERROR: test_current_site_in_context_after_login 
(django.contrib.auth.tests.views.LoginTest)
--
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/views.py", 
line 182, in test_current_site_in_context_after_login
site = Site.objects.get_current()
  File "/usr/lib/pymodules/python2.6/django/contrib/sites/models.py", line 
22, in get_current
current_site = self.get(pk=sid)
  File "/usr/lib/pymodules/python2.6/django/db/models/manager.py", line 132, 
in get
return self.get_query_set().get(*args, **kwargs)
  File "/usr/lib/pymodules/python2.6/django/db/models/query.py", line 336, 
in get
num = len(clone)
  File "/usr/lib/pymodules/python2.6/django/db/models/query.py", line 81, in 
__len__
self._result_cache = list(self.iterator())
  File "/usr/lib/pymodules/python2.6/django/db/models/query.py", line 269, 
in iterator
for row in compiler.results_iter():
  File "/usr/lib/pymodules/python2.6/django/db/models/sql/compiler.py", line 
672, in results_iter
for rows in self.execute_sql(MULTI):
  File "/usr/lib/pymodules/python2.6/django/db/models/sql/compiler.py", line 
727, in execute_sql
cursor.execute(sql, params)
  File "/usr/lib/pymodules/python2.6/django/db/backends/sqlite3/base.py", 
line 200, in execute
return Database.Cursor.execute(self, query, params)
DatabaseError: no such table: django_site

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/NVb0a5A1C2cJ.
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: auth.LoginTest seems to require sites

2011-06-16 Thread Brian
In case anyone else has the same issue, the problem stopped when I upgraded 
django from 1.2 to 1.3.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/QwG2RwRBrM0J.
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.



audit changes to models

2011-06-16 Thread Brian
Hi,

I need to add a basic audit capability to a django app. There seem to be 
lots of superficially similar apps and modules around: django-audit, 
django-audit-log, AuditTrail, SimpleHistory. Does anyone have any experience 
with these or recommendations?

The models I need to track are quite simple: A, B, C where A has a 
many-to-one relationship with B, and B has a many-to-one relationship with 
C. I'd like to track create/update/delete operations together with the name 
of the user making the change, and present a table that can be filtered by 
the name of a C instance, or by the name of the user/editor.

Thanks for any advice you can offer,

Brian

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/ZjWvsBbrmS0J.
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.



TimeField with minute-resolution in forms

2011-07-25 Thread Brian
Hi,

I have a form with a TimeField and I'd like it to only accept values
in the form hh:mm, as opposed to hh:mm:ss.

The form is a ModelForm and I've overridden the 'time' field with a
TimeField where I've specified the input_formats as ['%H:%M']. This
works fine when entering value for a new instance of the model, but
when I edit an existing instance, the value that I entered as '12:30'
is rendered as '12:30:00' and so the instance fails to save.

Without much hope of success (and that proved wildly optimistic), I
tried changing the rendering of the form as follows:
 {% if field.label == "Time" %}
 {{ field | time:"H:i" }}
 {% else %}
{{ field }}
 {%endif%}
But that didn't work even a little bit.

Do I need to subclass TimeField? Is there a method that controls the
"output_formats"?
Or maybe that's not the way to do it. Could anyone offer any advice?

Thanks in advance,

Brian

-- 
You received this message because you are subscribed to the Google 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: TimeField with minute-resolution in forms

2011-07-25 Thread Brian
Is that not the opposite problem? I enter a value, which is correctly 
rejected if I specify a non-zero seconds value, but when I try to edit it 
again, the value in the form's entry-box has been rendered as "hh:mm:00". 
Surely its the "from_python" method that I need to override - if such a 
thing exists? 

Brian

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/j4xBfHyqpAUJ.
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.



Include Django form in PHP based website

2011-07-27 Thread brian
I'm learning Django and was hoping to get some advice on an
application I want to try.

I'm trying to create a Django form that is included in a php based
website.

I'm working on a php based website that has a 'contact us' form that
was created with http://wufoo.com/.  In the php website there is a
little code to include the wufoo form.  The form is created in wufoo
and they manage the e-mails and storing the data.

I want to replace the wufoo form with my Django form.  My plan was to
host the Django form on a new domain.  My reason behind wanting to use
Django is so that when the contact is submitted I can store the info
in a database, send an e-mail, and write the data to another program.
I don't care about wufoo's automatic form building; My plan is to hand
write the form code.

I bought the book 'The Definitive Guide to Django: Web Development
Done Right' and I've read about half of it.  It seems creating the
form is really easy but I'm not sure the best way to include that form
in the php website.

Do you have any suggestions about creating a Django form that will be
included in a php website?  In the php website, I'd prefer not to use
javascript.

Brian

-- 
You received this message because you are subscribed to the Google 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: Include Django form in PHP based website

2011-07-27 Thread brian
I'm doing this to add features like better submitted data management
and writing the data to another program.

Brian

-- 
You received this message because you are subscribed to the Google 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: TimeField with minute-resolution in forms

2011-07-28 Thread Brian
Just in case anyone else has the same problem and finds their way here...

The answers were there in the documentation once I rooted around for a 
while. I just need to override the default form field provided for my time 
model field and explicitly specify the allowed formats.

class EntryForm(ModelForm):
time = TimeField(required=True,
 error_messages = {'invalid' :
   "Please enter a time of the form 
HH:MM"},
 widget=TimeInput(format='%H:%M'),
 input_formats=['%H:%M'])
class Meta:
model = Entry
# time is a models.TimeField in entry/models.py

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/EDD9Y_G4czAJ.
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.



same form model with separate admins and data

2011-08-09 Thread brian
I've created a form with Model->ModelForm flow.  Django is running on
a sub-domain and I'm putting separate instances of the form on
multiple php websites via iframe.

How can I use the same form model but have independent forms?

For example I want:
form1 to be at: example.com/form1
form2 to be at: example.com/form2

form1 admin to be at: example.com/form1Admin
form2 admin to be at: example.com/form2Admin

I want form1 and form2 to use the same model but act independent of
each other.  For example I want form1 data to only be present in
form1Admin. I believe I can add options in the url.py file for the
different forms but I'm not sure how specify keeping the data separate
in the database and setup the admin page.

-- 
You received this message because you are subscribed to the Google 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: same form model with separate admins and data

2011-08-10 Thread brian
Hi Michal,

Can you provide details about the QuerySets part?  I'm new to Django.

One of the ideas I had was using inheritance.  For example:
---
myBaseModel(models.Model)
   …

class form1( myBaseModel ):
pass
---

The problem I'm seeing is that when I use form1 the data gets put in
form1 and myBaseModel.

Thank you for your help!!!!

Brian

-- 
You received this message because you are subscribed to the Google 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: same form model with separate admins and data

2011-08-10 Thread brian
I'm using the Model->ModelForm flow.  I was starting with the model
and working my way up.  Once I get the model I was going to switch to
the form and then the view.

Brian

-- 
You received this message because you are subscribed to the Google 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: same form model with separate admins and data

2011-08-11 Thread brian
Hi Landy,

You understand the problem correctly.  I'm not sure how to implement
your suggestion.  I'm seeing a  when I do
similar to the following:
-
class myModel(models.Model):
first_name   = models.CharField( max_length=100,
verbose_name='first')

class abstractForm( ModelForm ):
class Meta:
model = myModel

class myForm(abstractForm):
class Meta(myForm.Meta):
model.table_name = 'test_model'
-

Also, would db sync work with this approach or would I have to
manually add the table?

Thank you for your help

Brian

-- 
You received this message because you are subscribed to the Google 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: same form model with separate admins and data

2011-08-12 Thread brian
I've figured a way that I think will work best for me for the model
and form but I'm having trouble with writing the view.  Here is my
pseudo code

models.py
-
class baseModel(models.Model):
first_name   = models.CharField( max_length=100,
verbose_name='first')

class form1Model( baseModel):
pass

class form2Model( baseModel):
pass
-


forms.py
-
class baseForm(ModelForm):


class form1( baseForm ):
class Meta(baseForm.Meta):
model = models.form1Model

class form2( baseForm ):
class Meta(baseForm.Meta):
model = models.form2Model

-


view.py
-
def form1View(request):

if request.method == 'POST':
form = form1(request.POST)

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

return HttpResponseRedirect('/thanksForm1/')

else:
form = form1()


return render_to_response('form_template.html', {'form': form} )

-

I'm not sure how to create a view that can be reused.  The only
difference is the form name and the 'thank you' page.  I thought about
a Decorators but it doesn't seem like that is the right tool to use.

-- 
You received this message because you are subscribed to the Google 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: same form model with separate admins and data

2011-08-13 Thread brian
Hi  Landy,

I'm seeing separate database tables created.  The tables that are
created are _.  I've tested in the latest
Django, python 2.7 and on windows with a sqlite3 database.

Thank you for your help  You have given me a lot of great ideas.

Brian

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



inherit adminSite and get 404 when click model

2011-08-13 Thread brian
I have multiple models.  I'm trying to create an admin site for all
models (using admin.site) and an admin site for each model (by
inheriting from AdminSite).

The admin.site is working as expected.  The AdminSite will load the
app as normal but when I click on the model, I get a 404 error.

I'm following very closely 'How to have 2 different admin sites in a
Django project'(http://stackoverflow.com/questions/3206856/how-to-
have-2-different-admin-sites-in-a-django-project).

Here is the pseudo code of what I'm doing:
model.py
---
class myBaseModel(models.Model):
first_name   = models.CharField( max_length=100)

class myModel1( myBaseModel ):
class Meta(myBaseModel .Meta):
verbose_name = 'my model 1 info'

class myModel2( myBaseModel ):
class Meta(myBaseModel .Meta):
verbose_name = 'my model 2 info'
---

admin.py
---
admin.site.register( myModel1)
admin.site.register(myModel2)
---

myModel1Admin.py
---
class myModel1Site(AdminSite):
pass

adminModel1 = myModel1Site()
adminModel1.register( myModel1 )
---

url.py
---
from django.contrib import admin
admin.autodiscover()

from .myModel1Admin import adminModel1

urlpatterns = patterns('',

url(r'^masterAdmin/', include(admin.site.urls)),
url(r'^model1Admin/$', include(adminModel1.urls)),
)
---

The url   is working as expected.  When I go to
 the page looks as I would expect but when I click on
'my model 1 info' I get a 404 error.

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



Customize Admin Advice

2014-02-02 Thread brian
 

I'm hoping to get advice about customizing the admin. 


 I have a series of filters I need to run and then I want the ability to 
loop though this list. I'm thinking of starting with a form where I can 
select the filter options. I want a next/previous buttons when I'm looping. 


 How would I implement this? I'm just looking for high level advice. 


 I know I can set index_template in AdminSite to create the first page. I 
know there is the SimpleListFilter but I don't think I can use it since I 
want multiple filters that need to be configured. Also I don't want to have 
to select all the models to loop though them. I plan on writing a custom 
add/change view. 


 I'm not sure how to go from the selected filter options to looping though 
each of the selected models. I'm not sure if I can pass and store a query 
set for when I loop though each model. Some of the options I've thought 
about is storing the filter parameters in the url and the current model 
number. Another thing I thought about is storing the results in database 
and recalling it.


 Brian

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/740d97fd-26e2-48ec-91fb-516b24bb812f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Django Model form not saving items to database

2019-07-01 Thread brian
Model

class Products(models.Model):

UNIT = (
('whole', 'whole unit'),
('item', 'per single item'),
)


# category = models.ForeignKey(Category, related_name='products', 
on_delete=models.CASCADE)
ProductName = models.CharField(max_length=255)
user = models.ForeignKey(User, on_delete=models.CASCADE)
ProductDescription = models.TextField(max_length=500, blank=True)
price = models.FloatField()
location = models.CharField(choices = COUNTIES, max_length=300)
# category = models.CharField( choices = CATEGORIES, max_length=10, 
default='other')
category = models.ForeignKey(Category, related_name='products', 
on_delete=models.CASCADE)

unitofsale = models.CharField(max_length=10, choices=UNIT)
image = models.FileField(upload_to='products_images/', blank=True)
sublocation = models.CharField(max_length=100)
created= models.DateTimeField(auto_now_add=True)
# slug = models.SlugField(max_length=200,db_index=True)

class Meta:
ordering = ('-created',)
# index_together = (('id', 'slug'),)


template


{% csrf_token %}



Product Name
{{  form.ProductName}}







Product Price
{{ form.price }}






County
{{  form.location}}







Sub-location
{{ form.sublocation }}






Category
{{  form.category}}







Unit of Sale
{{ form.unitofsale }}






Product Description
{{  form.ProductDescription}}







Upload Product Image
{{ form.image }}






 Sell 










{##}


view 

def sell(request):
 if request.method == 'POST':
  form = ProductsForm()
  form = ProductsForm(request.POST, request.FILES, instance = 
request.user)
  if form.is_valid():
  print('form is valid')
  form = form.save(commit=True)
  user = request.user
  form.user = user
  form.save()
  return redirect('home')

 else:
 form = ProductsForm()
 return render(request, 'sell/products_form.html', {'form': form})

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4b2be89e-f505-4ad5-80eb-b6c2965d35a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django form not saving items to database

2019-07-01 Thread brian
model

class Products(models.Model):

UNIT = (
('whole', 'whole unit'),
('item', 'per single item'),
)


# category = models.ForeignKey(Category, related_name='products', 
on_delete=models.CASCADE)
ProductName = models.CharField(max_length=255)
user = models.ForeignKey(User, on_delete=models.CASCADE)
ProductDescription = models.TextField(max_length=500, blank=True)
price = models.FloatField()
location = models.CharField(choices = COUNTIES, max_length=300)
# category = models.CharField( choices = CATEGORIES, max_length=10, 
default='other')
category = models.ForeignKey(Category, related_name='products', 
on_delete=models.CASCADE)

unitofsale = models.CharField(max_length=10, choices=UNIT)
image = models.FileField(upload_to='products_images/', blank=True)
sublocation = models.CharField(max_length=100)
created= models.DateTimeField(auto_now_add=True)
# slug = models.SlugField(max_length=200,db_index=True)

class Meta:
ordering = ('-created',)
# index_together = (('id', 'slug'),)

view

def sell(request):
 if request.method == 'POST':
  form = ProductsForm()
  form = ProductsForm(request.POST, request.FILES, instance = 
request.user)
  if form.is_valid():
  print('form is valid')
  form = form.save(commit=True)
  user = request.user
  form.user = user
  form.save()
  return redirect('home')

 else:
 form = ProductsForm()
 return render(request, 'sell/products_form.html', {'form': form})

template


{% csrf_token %}



Product Name
{{  form.ProductName}}







Product Price
{{ form.price }}






County
{{  form.location}}







Sub-location
{{ form.sublocation }}






Category
{{  form.category}}







Unit of Sale
{{ form.unitofsale }}






Product Description
{{  form.ProductDescription}}







Upload Product Image
{{ form.image }}






 Sell 










{##}



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f69eafee-4247-42b9-9db9-a741d84a02ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


can django support chinese search?

2017-06-04 Thread brian
today i use a forum as Misago,and i set language use chinese,but when i 
search chinese chart, Misago can't response anything ,so,i emailed to 
Misago manager team,and them asked me,text search use django search 
module,so, i think may i can get help at here

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a80d5b90-1b77-46ed-9714-1ab9726fe73e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Can the Django PostgreSQL module support Chinese search?

2017-06-06 Thread brian
I am the most I use a misago forum, set Chinese language, use the search 
function, did not return any data, the data is actually, I asked my Misago 
team, said they are using Django full text retrieval module, let me ask 
Django team, so that someone can help me?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f878944e-848b-4860-985f-37daa731e23f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Power BI integration with django

2019-11-27 Thread Brian
Does anyone know how to integrate a Power BI dashboard with a web page, 
without the user having to log in to the power BI account

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e807c75c-e976-4ec3-8389-5a5011aaecf2%40googlegroups.com.


Re: Cannot get user profile working.

2008-10-24 Thread Brian Neal

On Oct 24, 2:23 pm, kylewild <[EMAIL PROTECTED]> wrote:
> I'm having this same issue and the fix here, as best I can attempt to
> apply it, didn't work for me
>
> I had AUTH_PROFILE_MODULE set to "myproject.UserProfile"
>
> After reading this thread, I changed it to "chat.UserProfile" -- to no
> avail
>
> In my "chat" directory, I have the model "UserProfile" defined in
> models.py -- doesn't that mean "chat" is the name of the app?
>

Read this:
http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users

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



Re: Cannot get user profile working.

2008-10-24 Thread Brian Neal

On Oct 24, 3:01 pm, kylewild <[EMAIL PROTECTED]> wrote:
> thanks brian, good call
>
> I had read that and somehow not parsed it!
>
> However, I'm still having the issue after changing it to:
>
> AUTH_PROFILE_MODULE = 'chat.userprofile'
>
> (i tried myproject.userprofile as well)
>
> 'NoneType' object has no attribute '_default_manager'
> /home/mochat/webapps/django/lib/python2.5/django/contrib/auth/
> models.py in get_profile, line 293
>

We really need more info before anyone can even guess. Try posting
some code, including your model code and the call site where you are
calling .get_profile().

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



Re: tinymce help

2008-10-26 Thread Brian Neal

On Oct 25, 8:47 pm, Bobby Roberts <[EMAIL PROTECTED]> wrote:
> hi.  I'm using django 1.0 over at webfaction.  I have the following
> setup
>
> /static   (serves js, css, flash, images etc)
> /www   (my django app)
>
> I have tiny_mce loaded to /static/js/tiny_mce/
>
> I have followed the steps at this page:  
> http://code.djangoproject.com/wiki/AddWYSIWYGEditor
> in this order:
>
> 1.  Install tiny_mce on your server some where
> 2.  create a textareas.js file  (placed in /static/js/tiny_mce/)
> 3.  created an admin.py file  in my website located at www/learn/ as
> follows:
>
> from django.contrib.flatpages.models import FlatPage
> from django.contrib.flatpages.admin import FlatPageAdmin as
> FlatPageAdminOld
>
> class FlatPageAdmin(FlatPageAdminOld):
>     class Media:
>         js = ('js/tiny_mce/tiny_mce.js',
>               'js/tiny_mce/textareas.js',)
>
> # We have to unregister it, and then reregister
> admin.site.unregister(FlatPage)
> admin.site.register(FlatPage, FlatPageAdmin)
>
> step3 i'm confused on.  This is for newforms with flatpages per the
> documentation.  It is my  understanding that django 1 uses newforms.
> Why won't the admin show the tinymce in place of text areas?

I take it you mean the flat pages part of step 3? I am using TinyMCE
for admin text areas, and it works great. I've never tried it with
flat pages yet. But the reason you have to do that unregister and
register step (for flat pages only), is that because flat pages are a
contributed app, and existing code is already registering a model
admin class for it. If you want to use TinyMCE for flat pages, you
have to create your own model admin for it with the appropriate media
class, undo what the flat pages app already did by unregistering it,
then replacing it with your own.

You don't have to do all that unregister/register stuff for the models
you write.

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

2008-10-28 Thread Brian Neal

On Oct 27, 8:03 pm, unklbeemer <[EMAIL PROTECTED]> wrote:
> I did some searching and found nothing. I was wondering if anyone knew
> of any django applications out there for receiving donations and/or
> tracking those donations (capital campaign progress, pledges donated,
> etc.)
>
> Thanks

I'll be porting, well that may be too strong a word...creating a
django app based on the functionality of the (don't laugh) PHP-Nuke
Donations module/block soon. I'm going to use the IPN code that Paul
Kenjora kindly posted here: http://blog.awarelabs.com/?p=74.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Test failures with SQLite :memory: database - contenttypes, auth and sites

2008-10-28 Thread Brian Gershon

Hi Chris,

I just ran into this same issue.  I eventually figured out that adding
TEST_DATABASE_NAME to settings.py (to prevent Django from using the
default memory database for sqlite) works around the issue.

As far as debugging the memory database problem, I was getting the
"IntegrityError: django_content_type.name may not be NULL" error.

I traced this down to this line:

emit_post_sync_signal(models.get_models(), verbosity, interactive)

in /django/core/management/commands/flush.py

If I comment out that line, the error does not arise.

-Brian

On Oct 25, 9:50 am, "Chris H." <[EMAIL PROTECTED]> wrote:
> I've noticed at work and with my personal code that since the upgrade
> to Django 1.0 that I'm getting test failures when I run the unit tests
> under a SQLite :memory: database.
>
> I thought it might be something to do with those two codebases, so
> this morning I started a fresh project and I'm seeing the same
> problem.
>
> Is anyone else seeing this... the steps I took to reproduce were:
> 1. django-admin startproject sqlitetest
> 2. Edit sqlitetest/settings.py:
> DATABASE_ENGINE = 'mysql'
> DATABASE_NAME = 'sqlitetest_local'
> DATABASE_USER = '(your awesome username)'
> DATABASE_PASSWORD = '(your awesome password)'
> DATABASE_HOST = ''
> DATABASE_PORT = ''
>
> INSTALLED_APPS = (
>     'django.contrib.admin',
>     'django.contrib.admindocs',
>     'django.contrib.auth',
>     'django.contrib.contenttypes',
>     'django.contrib.sessions',
>     'django.contrib.sites',
> )
> 3. django-admin.py syncdb
> 4. django-admin.py test
> (tests pass)
> 5. Create a settings_test.py file:
> from settings import *
> DATABASE_ENGINE = 'sqlite3'
> DATABASE_NAME = ':memory:'
> DATABASE_USER = ''
> DATABASE_PASSWORD = ''
> DATABASE_HOST = ''
> DATABASE_PORT = ''
> 6. Run tests, get 3 errors (the rest pass):
> IntegrityError: django_site.domain may not be NULL
> IntegrityError: auth_permission.name may not be NULL
> IntegrityError: django_content_type.name may not be NULL
>
> It's kind of a bummer because the tests run so much faster against
> a :memory: database and I didn't know if anyone had encountered this
> yet?
>
> Thanks,
>
> Chris H.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



  1   2   3   4   5   6   7   8   9   10   >