ModelForm witn ImageField, how to add file programmatically?

2009-04-15 Thread bashu

Hello,

I have a form derived from ModelForm with ImageField inside. How to
select file to upload for a generated FileInput field
programmatically?

Could this be done by passing file object as one of initial values,
when I create a form object?
...
from = Form(initial={'image.field.name' : file.object})
...

Or there is another solution available, e.g. after form has been
created?

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



Need help first user of django..

2009-04-15 Thread Aaron

Hi, I am trying to learn how to use if statements.

I need a form to appear on 2 pages.

Also how does flatpages work?

I was given by my workplace a zip file that contains the flatpages
html pages.

I used  the admin to add flatpages and I added a template. I then have
4 pages.

Currently these pages are missing some contect. I can see images
appearing on each page right.

Yet I can't see forms nore any text which ends up to be in the html
files that are stored in the flatpages.

How can I have the forms delcared in the flatpages html files ?

I also need to know how I can use a if equal with 2 arguements meaing
if either 2 of the pages are loaded then load the form.

I am new to django and I did look at the documentation.

How can I use a if statement to show only a request form to only 2
pages?


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

2009-04-15 Thread Luc Saffre

On 16.04.2009 0:04, Daniel Joshua Worth wrote:
> I'm trying to learn unit test and have a unit test for a model in
> test.py and have a test set up to fail.
> When I run manage.py test it returns that all tests are OK.
> If I run manage.py test  it returns OK.
> If I run manage.py test . it returns OK.
> If I run manage.py test .. if Fails.
> What gives. Am I missing something as far as unittests are concerned? It
> should Fail every time or it's not much of a test.

Can you send your test.py file to the list?
You should rather not name it "test.py" because there is a standard
Python module with that name.

Luc

--~--~-~--~~~---~--~~
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: Is django-users available via NNTP?

2009-04-15 Thread Eugene Lazutkin

Go to http://gmane.org and read using their web UI. There are different
ways to read/write, and I use NNTP. You can find more information on
that here: http://dir.gmane.org/gmane.comp.python.django.user In general
you just tell your NNTP reader (I use Thunderbird) to get news from
news.gmane.org uysing NNTP, and after that you can subscribe to whatever
interests you through the UI of your reader.

Hint: if some groups are not available on gmane (e.g., a mailing list of
your favorite project), you can ask for it. So far I saw nothing but the
desire to help from the maintainer.

Eugene Lazutkin
http://lazutkin.com/

On 04/15/2009 08:27 PM, Phil Mocek wrote:
> On Wed, Apr 15, 2009 at 07:49:00PM -0500, Eugene Lazutkin wrote:
>> I use NNTP provided by gmane. The group is gmane.comp.python.django.user.
> 
> That group isn't carried by my Usenet provider, Giganews.  Are you
> connecting directly to a Gmane server, or do you get it through your own
> Usenet provider?
> 


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



Re: request.urlconf does not get used in URL template tag

2009-04-15 Thread Sean Brant

I knew I couldn't be that easy. Thanks for the heads up. Any other
work around? besides the patch mentioned.

On Apr 15, 11:17 pm, Alex Gaynor  wrote:
> On Thu, Apr 16, 2009 at 12:15 AM, Sean Brant  wrote:
>
> > If you set request.urlconf in say a Middleware then the reverse
> > function and the url tag will not work because those try to match
> > based on your ROOT_URLCONF. I was trying to find a solution to this
> > problem and came across this ticket.
> >http://code.djangoproject.com/ticket/5034
>
> > Then It dawned on me what if I also override settings.ROOT_URLCONF in
> > my middleware when I am setting request.urlconf. This seemed to solve
> > my problems.
>
> > I now wonder If what I did is a good and solid idea. If anyone out
> > there has come across this let me know. It seems to work fine for now
> > though.
>
> It's a bad idea because your application is not threadsafe at all, if  you
> try to run your application in a threaded enviroment you will get lots of
> reverses that return incorrect data since the settings are shared state.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: request.urlconf does not get used in URL template tag

2009-04-15 Thread Alex Gaynor
On Thu, Apr 16, 2009 at 12:15 AM, Sean Brant  wrote:

>
> If you set request.urlconf in say a Middleware then the reverse
> function and the url tag will not work because those try to match
> based on your ROOT_URLCONF. I was trying to find a solution to this
> problem and came across this ticket.
> http://code.djangoproject.com/ticket/5034
>
> Then It dawned on me what if I also override settings.ROOT_URLCONF in
> my middleware when I am setting request.urlconf. This seemed to solve
> my problems.
>
> I now wonder If what I did is a good and solid idea. If anyone out
> there has come across this let me know. It seems to work fine for now
> though.
>
>
> >
>
It's a bad idea because your application is not threadsafe at all, if  you
try to run your application in a threaded enviroment you will get lots of
reverses that return incorrect data since the settings are shared state.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



request.urlconf does not get used in URL template tag

2009-04-15 Thread Sean Brant

If you set request.urlconf in say a Middleware then the reverse
function and the url tag will not work because those try to match
based on your ROOT_URLCONF. I was trying to find a solution to this
problem and came across this ticket. http://code.djangoproject.com/ticket/5034

Then It dawned on me what if I also override settings.ROOT_URLCONF in
my middleware when I am setting request.urlconf. This seemed to solve
my problems.

I now wonder If what I did is a good and solid idea. If anyone out
there has come across this let me know. It seems to work fine for now
though.


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



manage.py loaddata fails to report error [was: Why does dumpdata, flush, loaddata cycle not result in same db content?]

2009-04-15 Thread Phil Mocek

On Thu, Apr 16, 2009 at 11:03:33AM +0800, Russell Keith-Magee wrote:
> Loaddata doesn't take input from stdin - it loads files that are
> specified on the command line.

Thanks, Russell.

I should have read the documentation for the loaddata command more
closely, but this is quite counter-intuitive.  Can someone tell me
what the rationale for this syntax is?

The built-in usage help shows that the filename argument (called a
fixture for reasons that I have not yet researched) is mandatory:

Usage: manage.py loaddata [options] fixture [fixture ...]

However, manage.py does not report an error when a fixture is not
specified:

$ ./manage.py loaddata 
$ echo $?
0

Only when I bump the verbosity up from 0 to 2 is an error
reported, and the return code still indicates success:

$ ./manage.py loaddata --verbosity=1 ; echo $?
0
$ ./manage.py loaddata --verbosity=2 ; echo $?
No fixtures found.
0

This is pretty bad unless there's a preferred method of loading
data in a non-interactive manner.


Possibly-relevant tickets found with a search of the Django Trac
(for "manage.py loaddata") include:

#6724 (loaddata w/ errors displays no warnings or error in output)
closed as duplicate of #4499 (integrity error silently failing with 
postgres and loaddata)

#4431 (manage.py loaddata should have better error reporting)
closed as fixed with r6936

#4371 (fixture loading fails silently in testcases)
closed as fixed with r7595

#10200 (loaddata command does not raise CommandError on errors)
new

-- 
Phil Mocek

--~--~-~--~~~---~--~~
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: Issue saving model in latest Django 1.1-beta-1

2009-04-15 Thread tm

Strangely, if I do this before the second save, it saves:

  ...
  foo.title = 'my_new_title
  foo.username = '%s' % ('awesome_user')
  foo.save()

But if I don't explicitly copy 'awesome_user' into a string then save,
it saves username as the user id.  I should also note that  foo.id
from my previous post is a ForeignKey to the users table.  I'm
guessing it's getting stepped on b/c of that, but I'm not sure if it's
a bug or just bad practice on my part.


On Apr 15, 10:06 pm, tm  wrote:
> Hello, I just updated to the latest django dev version and it changed
> the behavior of my code (not suprisingly :)  Get data from a form,
> save it to the DB, then in the same save function get the id from what
> was just saved, update a values and save it again.  I need to do this
> to get the id of what was just saved, so I can update a field in that
> record based on that ID  Now instead of maintaining the username on
> the second save, it overwrites it with the user_id.  Here is the an
> outline of the code that used to work:
>
> class EditFooForm(ModelForm):
>   class Meta:
>     model = Foo
>
> def save(self, ):
>   foo = Foo()
>   foo.id = some_user_id
>   foo.username='awesome_user'
>   foo.title = 'my great title'
>   foo.submit_date=datetime.datetime.now()
>   foo.save()
>
>   # We're OK here!
>   # The DB has username as 'awesome_user' and user_id as '1234'
>
>   my_new_title = '%s_%s' % ( foo.id, some_file_name  )
>   foo.title = my_new_title
>   foo.save()
>
>   #Issue:  username for that record in the DB is now '1234'
>
> I am by no means a Django expert, but this code has worked for months
> so I'm sure I'm missing something simple.  Any help would be greatly
> appreciated!
>
> Thanks,
>
> T
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Issue saving model in latest Django 1.1-beta-1

2009-04-15 Thread tm

Hello, I just updated to the latest django dev version and it changed
the behavior of my code (not suprisingly :)  Get data from a form,
save it to the DB, then in the same save function get the id from what
was just saved, update a values and save it again.  I need to do this
to get the id of what was just saved, so I can update a field in that
record based on that ID  Now instead of maintaining the username on
the second save, it overwrites it with the user_id.  Here is the an
outline of the code that used to work:

class EditFooForm(ModelForm):
  class Meta:
model = Foo

def save(self, ):
  foo = Foo()
  foo.id = some_user_id
  foo.username='awesome_user'
  foo.title = 'my great title'
  foo.submit_date=datetime.datetime.now()
  foo.save()

  # We're OK here!
  # The DB has username as 'awesome_user' and user_id as '1234'

  my_new_title = '%s_%s' % ( foo.id, some_file_name  )
  foo.title = my_new_title
  foo.save()

  #Issue:  username for that record in the DB is now '1234'

I am by no means a Django expert, but this code has worked for months
so I'm sure I'm missing something simple.  Any help would be greatly
appreciated!

Thanks,

T
--~--~-~--~~~---~--~~
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: Why does dumpdata, flush, loaddata cycle not result in same db content?

2009-04-15 Thread Russell Keith-Magee

On Thu, Apr 16, 2009 at 10:43 AM, Phil Mocek
 wrote:
>
> I have a simple project using the flatpages app.  If I use
> manage.py to run dumpdata (with no command line arguments,
> redirecting output to a file), then flush, then loaddata (with no
> command line arguments, redirecting input from a file),

You were going well till this point.

Loaddata doesn't take input from stdin - it loads files that are
specified on the command line. Your database is empty because you have
specified no fixtures to load.

The sequence needs to go something like:

$ ./manage.py dumpdata > mydata.json
$ ./manage.py flush
... follow the prompts
$ ./manage.py loaddata mydata.json

>    The output of dumpdata can be used as input for loaddata.

This is correct, but in a different way than you have interpreted. The
output of dumpdata is in a format that loaddata can use - but that
doesn't mean it accepts input from stdin.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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
-~--~~~~--~~--~--~---



setting a model field to null

2009-04-15 Thread rvr

How can I set a model field to null after it has had a non-null value?

--
class Blah(models.Model):
foo = models.IntegerField(null=True)

blah = Blah()
blah.foo = 5

# now set it to null
blah.foo = ???
--

None doesn't seem to work and I don't seem to be able to figure this
out from the documentation. Thanks for your help.

~rvr
--~--~-~--~~~---~--~~
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: Stuck in Tutorial Part 2: can't find django/contrib/admin/templates

2009-04-15 Thread David Chambers

I had the same problem. Thanks very much for taking the time to post
the solution, Alex.


On Apr 8, 12:36 pm, "ab3...@gmail.com"  wrote:
> Thanks! You have unlocked the rest of the tutorial for me. I
> appreciate your help.
>
> On Apr 7, 12:57 pm, Alex Gaynor  wrote:
>
> > On Tue, Apr 7, 2009 at 2:42 PM, ab3...@gmail.com  wrote:
>
> > > I'm working through the tutorial and got stuck near the end of part 2.
> > > It says:
>
> > > "Now copy the template admin/base_site.html from within the default
> > > Django admin template directory (django/contrib/admin/templates) into
> > > an admin subdirectory ..."
>
> > > I cannot figure out what they mean by directory django/contrib/admin/
> > > templates
>
> > > This looks like a relative path, but relative to what? When I created
> > > my project there were no subdirectories called django.
>
> > > What are they talking about?
>
> > It's relative to wherever you installed Django itself.  If you aren't sure
> > where django is intalled on your system(perhaps a package manager installed
> > it) you can do import django; django.__file__ which shows the __init__ file
> > in the django/ directory of that path.
>
> > Alex
>
> > --
> > "I disapprove of what you say, but I will defend to the death your right to
> > say it." --Voltaire
> > "The people's good is the highest law."--Cicero

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



Why does dumpdata, flush, loaddata cycle not result in same db content?

2009-04-15 Thread Phil Mocek

I have a simple project using the flatpages app.  If I use
manage.py to run dumpdata (with no command line arguments,
redirecting output to a file), then flush, then loaddata (with no
command line arguments, redirecting input from a file), my sqlite3
database file is different than a backup copy I made of it, and
when I run the app, it seems to be reset to an empty-database
condition.  Why is this?

The dump file appears to contain the content of my database.

The Django docs [1] say:

dumpdata

django-admin.py dumpdata 

Outputs to standard output all data in the database associated
with the named application(s).

If no application name is provided, all installed applications
will be dumped.

The output of dumpdata can be used as input for loaddata.

[1]: 

In the root directory of my project, I'm running:

./manage.py dumpdata >data.json
./manage.py flush
# (answer yes to flush, no to create superuser)
./manage.py loaddata http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is django-users available via NNTP?

2009-04-15 Thread Phil Mocek

On Wed, Apr 15, 2009 at 07:49:00PM -0500, Eugene Lazutkin wrote:
> I use NNTP provided by gmane. The group is gmane.comp.python.django.user.

That group isn't carried by my Usenet provider, Giganews.  Are you
connecting directly to a Gmane server, or do you get it through your own
Usenet provider?

-- 
Phil Mocek

--~--~-~--~~~---~--~~
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: Is django-users available via NNTP?

2009-04-15 Thread Eugene Lazutkin

I use NNTP provided by gmane. The group is gmane.comp.python.django.user.

Eugene Lazutkin
http://lazutkin.com/

On 04/15/2009 07:24 PM, Phil Mocek wrote:
> Is this list available via NNTP on Usenet?  Google Groups started
> out as a Web interface to Usenet.  It's unclear now where the line
> between mailing list and newsgroup lies with Google Groups.
> 


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



Is django-users available via NNTP?

2009-04-15 Thread Phil Mocek

Is this list available via NNTP on Usenet?  Google Groups started
out as a Web interface to Usenet.  It's unclear now where the line
between mailing list and newsgroup lies with Google Groups.

-- 
Phil Mocek

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



How to download archives for this mailing list?

2009-04-15 Thread Phil Mocek

How can I download a complete archive of this list?  Various Web
searches for combinations of "google groups," "list," "archive,"
"download," etc., have not turned up the answer.  I'd like to be
able to search and browse the list using my own MUA instead of
having to go through Google's Web interface.

-- 
Phil Mocek

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

2009-04-15 Thread Russell Keith-Magee

On Thu, Apr 16, 2009 at 5:04 AM, Daniel Joshua Worth
 wrote:
> I'm trying to learn unit test and have a unit test for a model in test.py
> and have a test set up to fail.
> When I run manage.py test it returns that all tests are OK.
> If I run manage.py test  it returns OK.
> If I run manage.py test . it returns OK.
> If I run manage.py test .. if Fails.
> What gives. Am I missing something as far as unittests are concerned? It
> should Fail every time or it's not much of a test.

Without specifics it isn't possible to know the exact problem.
However, my guess would be that the specific test that is failing is
at fault - probably due to an external test dependency that is
satisfied by a different test in your suite. The different ways of
invoking test cases doesn't mean anything different from the
perspective of the test itself. All you are specifying is the list of
tests that will be exectued. If a test fails in isolation, but not in
the suite, then the test is probably at fault.

For example, say your suite has one test case with two tests, A and B.
A creates an object X. In order for B to pass, X must exist. If you
run both tests (either as the full suite, or as the test case), A runs
before B, and X is available. If you just run B, then X isn't
available, and the test fails.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Serving Static Files - Pics work, but CSS doesn't

2009-04-15 Thread Anthony

Thanks.

I was just trying to get the stylesheet to show up.  I have a full CSS
template I got from somewhere else that I'll be using now that it's
being successfully pulled in.

On Apr 15, 4:06 pm, Wayne Koorts  wrote:
> >> > The picture shows up, but the text doesn't turn green like I think it
> >> > should.
>
> See if it helps changing your code and CSS as follows (basically
> making it XHTML compliant - not sure what you're aiming at
> specifically with what you've done):
>
> 
>     
>     Test paragraph.
> 
>
> p.baseline {
>     color: green;
>     border: solid red;
>
> }
>
> Also just another tip: it is a good idea to not use named colour
> values ("green" / "red" etc.) as each CSS rendering engine might
> interpret it differently.  For green you could use: "color: rgb(0,
> 255, 0);" and for red you could use: "color: rgb(255, 0, 0);".
>
> Regards,
> Wayne
--~--~-~--~~~---~--~~
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: Serving Static Files - Pics work, but CSS doesn't

2009-04-15 Thread Wayne Koorts

>> > The picture shows up, but the text doesn't turn green like I think it
>> > should.

See if it helps changing your code and CSS as follows (basically
making it XHTML compliant - not sure what you're aiming at
specifically with what you've done):



Test paragraph.


p.baseline {
color: green;
border: solid red;
}

Also just another tip: it is a good idea to not use named colour
values ("green" / "red" etc.) as each CSS rendering engine might
interpret it differently.  For green you could use: "color: rgb(0,
255, 0);" and for red you could use: "color: rgb(255, 0, 0);".

Regards,
Wayne

--~--~-~--~~~---~--~~
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: Serving Static Files - Pics work, but CSS doesn't

2009-04-15 Thread Alex Gaynor
On Wed, Apr 15, 2009 at 6:59 PM, Anthony  wrote:

>
> Yes, they are right next to each other in the same folder.
>
> On Apr 15, 3:55 pm, Alex Gaynor  wrote:
> > On Wed, Apr 15, 2009 at 6:50 PM, Anthony  wrote:
> >
> > > Hello,
> >
> > > I'm pretty new to CSS as well as Django, so I'm sure I'm doing
> > > something simple wrong.  Anyway, I'm able to serve up a test pic that
> > > I placed in the media folder, but I can't get the html to use the CSS
> > > template.
> >
> > >
> > > >
> > >My Site
> > >
> >
> > >
> > >
> > >Test paragraph.
> > >
> >
> > > My CSS file looks like this:
> >
> > >P.baseline {
> > >color : green;
> > >border : solid red;
> > >}
> >
> > > The picture shows up, but the text doesn't turn green like I think it
> > > should.
> >
> > > Any help would be appreciated!
> >
> > Where is your CSS file located?  Specifically is it in the same directory
> as
> > the image.
> >
> > Alex
> >
> > --
> > "I disapprove of what you say, but I will defend to the death your right
> to
> > say it." --Voltaire
> > "The people's good is the highest law."--Cicero
> >
>
Is the rel="baseline" correct?  I was under the impression that "stylesheet"
was the correct value.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: Serving Static Files - Pics work, but CSS doesn't

2009-04-15 Thread Anthony

Yes, they are right next to each other in the same folder.

On Apr 15, 3:55 pm, Alex Gaynor  wrote:
> On Wed, Apr 15, 2009 at 6:50 PM, Anthony  wrote:
>
> > Hello,
>
> > I'm pretty new to CSS as well as Django, so I'm sure I'm doing
> > something simple wrong.  Anyway, I'm able to serve up a test pic that
> > I placed in the media folder, but I can't get the html to use the CSS
> > template.
>
> >    
> >    
> >    My Site
> >    
>
> >    
> >    
> >    Test paragraph.
> >    
>
> > My CSS file looks like this:
>
> >    P.baseline {
> >    color : green;
> >    border : solid red;
> >    }
>
> > The picture shows up, but the text doesn't turn green like I think it
> > should.
>
> > Any help would be appreciated!
>
> Where is your CSS file located?  Specifically is it in the same directory as
> the image.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Java-doc style api docs.

2009-04-15 Thread Eddified

Are there up-to-date java-doc style api docs like this: 
http://djangoapi.matee.net/
anywhere on the official django site? I've looked high and low and
can't find it...

--~--~-~--~~~---~--~~
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: Serving Static Files - Pics work, but CSS doesn't

2009-04-15 Thread Alex Gaynor
On Wed, Apr 15, 2009 at 6:50 PM, Anthony  wrote:

>
> Hello,
>
> I'm pretty new to CSS as well as Django, so I'm sure I'm doing
> something simple wrong.  Anyway, I'm able to serve up a test pic that
> I placed in the media folder, but I can't get the html to use the CSS
> template.
>
>
> >
>My Site
>
>
>
>
>Test paragraph.
>
>
>
> My CSS file looks like this:
>
>P.baseline {
>color : green;
>border : solid red;
>}
>
> The picture shows up, but the text doesn't turn green like I think it
> should.
>
> Any help would be appreciated!
> >
>
Where is your CSS file located?  Specifically is it in the same directory as
the image.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Serving Static Files - Pics work, but CSS doesn't

2009-04-15 Thread Anthony

Hello,

I'm pretty new to CSS as well as Django, so I'm sure I'm doing
something simple wrong.  Anyway, I'm able to serve up a test pic that
I placed in the media folder, but I can't get the html to use the CSS
template.



My Site




Test paragraph.



My CSS file looks like this:

P.baseline {
color : green;
border : solid red;
}

The picture shows up, but the text doesn't turn green like I think it
should.

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



Re: Does QuerySet have a refresh to catch when database data changes underneath running django?

2009-04-15 Thread Darrell Silver

Indeed, this is due to transaction management w/in MySQL.  The table
type was InnoDB.  The thread you pointed me toward,
http://groups.google.com/group/django-users/browse_thread/thread/e25cec400598c06d
has all the answers.

Thanks so much! And speedy it was!

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



Help writing a record/table display view function?

2009-04-15 Thread kjarsenal

I've created model class "Record", with a few CharFields (job_number,
client_job_number, project_name), an IntegerField and a DateTimeField.

It utilizes the ModelForm class.

Its view is defined as "def record_add(request):", which returns
"render_to_response('record_add.html'). The .html is a child template
that extends the css formatted base.

I'd like it to return a view of the newly created record, with fields
populated with the appropriate data.
Also, on the blank form, it should be possible to submit either a job
number or project name and
return a display of the corresponding record.

All of these views will utilize the same data so I would think there
would be no need to create
additional models. I just know how to write the additional view
functions.

--~--~-~--~~~---~--~~
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: finding out what SQL Django generated

2009-04-15 Thread Alex Gaynor
On Wed, Apr 15, 2009 at 5:39 PM, Justin Bronn  wrote:

>
> > If it's docs links you want :) :
> >
> > http://docs.djangoproject.com/en/dev/faq/models/#how-can-i-see-the-ra...
>
> This isn't in the docs, but it also works:
>
> >>> qs = Foo.objects.all()
> >>> qs.query.as_sql()
>
> It returns a two-element tuple comprised of the generated SQL and
> parameters, respectively.  Personally, I prefer it over the
> connection.queries approach because you can look at the SQL without
> having to execute it.
>
> -Justin
> >
>
Using query.as_sql() doesn't work for any query which doesn't return a
queryset, include aggregate(), count() and update().

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: finding out what SQL Django generated

2009-04-15 Thread Justin Bronn

> If it's docs links you want :) :
>
> http://docs.djangoproject.com/en/dev/faq/models/#how-can-i-see-the-ra...

This isn't in the docs, but it also works:

>>> qs = Foo.objects.all()
>>> qs.query.as_sql()

It returns a two-element tuple comprised of the generated SQL and
parameters, respectively.  Personally, I prefer it over the
connection.queries approach because you can look at the SQL without
having to execute it.

-Justin
--~--~-~--~~~---~--~~
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 wrap my head around nested regroups or other ways to handle ordered ForeignKey stuff

2009-04-15 Thread Kevin Cole



On Apr 14, 6:32 pm, Daniel Roseman 
wrote:
> On Apr 14, 6:11 pm, Kevin Cole  wrote:
> > Hi,
>
> > First let me say I've looked at documentation, but feel a bit dyslexic
> > when it comes to this stuff.
>
> > The situation: I have three tables: a service provider table with
> > city, state abbreviation and country abbreviation (among other other
> > info), a states table with state names, abbreviations, and other state
> > info, and a country table with country names, abbreviations and other
> > country info.  I want an output like:
> > ___
>
> > FULL COUNTRY NAME
>
> >    Full State Name
> >            City. Provider
> >                        Provider
> >            City. Provider
>
> >     Full State Name
> >            City. Provider
> >                        Provider
> >            City. Provider
>
> > FULL COUNTRY NAME
> > ___
>
> > I only want Country and State headings for countries and states having
> > providers.  Experimenting at the shell, it appears my model is okay:
>
> > For the next 5 days, a whittled down version of what I thought I was
> > trying to do lives on dpaste.com:
>
> >http://dpaste.com/32704/model.pyhttp://dpaste.com/32755/views.pyhttp:...template
>
> > However my later experiments in the manage.py shell (above) lead me to
> > suspect maybe I'm bass-ackwards about the whole thing.  Unfortunately,
> > suspecting that is still not enough to get me where I'm trying to go.
>
> I very much doubt that select_related is the answer to your problem,
> as proposed in your other post. select_related is purely for query
> optimisation, and doesn't actually change the results of your queries.
>
> That said, I am having trouble working out what your actual problem
> is. If I understand correctly, it's how to order multiple nested query
> sets. But in what way does the code you have posted fail to give the
> right output? What does it actually give?

The order of the output was completely random, or so it appeared.  A
country would show up, with a few randomly selected states, and the
corresponding cities. After a few records from another country, the
first would appear again.  In other words, it didn't appear to be
sorted at all.  Since adding the select_related, and changing my
template the following, I now get the correct results:

{% regroup providers by country.name as nations %}

{% for nation in nations reversed %}
 

  {{nation.grouper|upper}}
  
  {% regroup nation.list by state.name as provinces %}
  {% for province in provinces
%}
 

{{province.grouper}}

{% regroup province.list by city as towns
%}
{% for town in towns
%}
  
  {{town.grouper}}
  
  {% for unit in town.list %}

> I can say that this line in your view:
>     providers = Provider.objects.order_by("country").order_by
> ("state").order_by("city")
> does nothing at all. Each successive order_by will override the one
> before.

I had originally tried it without the order_by in the view.py. I
removed it when I added the select_related.

> I'm also intrigued by the way you've set up your tables. Are they
> based on an already existing database schema? If not, I would
> seriously reconsider the way you have the foreign keys set up to
> reference character fields in the related model. Better to leave these
> as the default so that Django manages the relationship with the
> automatic 'id' field. (What happens if two states in different
> countries have the same abbreviation?)

Good point.  At the moment, only US and Canada, from the country table
are being used, but I suppose in an ideal world, the list of service
providers could expand...

> Looking closer, I suspect that the problem is that both state and
> country are related to provider, instead of relying on the
> relationship between state and country. I would leave out the FK from
> provider to country, so the relationship goes like this:
> provider -> state -> country

> You might even think about having another intermediate model for City,
> so the provider only has a relationship with that.
>
> Finally, I would leave out all the 'regroup' tags. Your data is
> already grouped, since it is in a set of nested relationships.
>
> In the view, get all the countries that have providers:
> countries = Country.objects.filter(state__provider__isnull=False)
>
> And in the template, without all the table tags:
> {% for country in countries %}
>   {{ country.name }}
>   {% for state in country.state_set.all %}
>     {{ state.name }}
>     {% for provider in state.provider_set.all %}
>         {{ provider.name }}
>     {% endfor %}
>   {% endfor %}
> {% endfor %}

Me likey. Thanks.  (At some point I tried going from country to state
to provider as you've just shown, but bolloxed that up too.)

>
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django 

Re: Django request.POST is truncating data when 'Content-Encoding', 'gzip' is set in client request

2009-04-15 Thread Graham Dumpleton



On Apr 16, 6:20 am, usaar33  wrote:
> Ah, I suspect the request.form code in mod_python must do doing block
> read.  Either way, it worked for me.

It will work with Apache/mod_wsgi as well, but by doing so you are
breaking WSGI 1.0 standard. Use a different WSGI hosting mechanism and
it may not work though. It works in Apache/mod_wsgi as it sensibly
implements end of stream indicator by returning empty string. As I
said, that isn't a requirement of WSGI 1.0 however.

> So in conclusion, it sounds like there is either an issue with A)
> mod_deflate not modifying the header or

It can't modify the header as when streaming it will not know the new
content length until stream is uncompressed. At that point the
original headers have been long gone. For it to buffer the
uncompressed stream to calculate the new header length wouldn't be
practical as would have to save it to file as could be too big to hold
in memory.

> B) WSGI 1.0 being wrong.

WGSI 1.0 is deficient.

> Interestingly, there was a large debate on this 4 years ago with
> tomcat:https://issues.apache.org/bugzilla/show_bug.cgi?id=34526
>
> Is the best answer for me to simply not provide content-length, which
> under WSGI should figure it out?

If you mean remove content length in request from client, the answer
is no. This is because for normal post you are required to have it.
You can avoid it if using chunked request content, however WSGI 1.0
doesn't support chunked request content, nor does mod_python. Apache/
mod_wsgi 3.0 does allow chunked request content, but again, to make
use of it you are stepping outside of what WSGI 1.0 allows.

Graham

> On Apr 15, 3:55 am, Graham Dumpleton 
> wrote:
>
> > Oh, reading past content length also will not necessarily work in
> > mod_python due to bugs it has:
>
> >  http://issues.apache.org/jira/browse/MODPYTHON-212
>
> > If you read in blocks may be okay, but not if you try and read all
> > data in one go.
>
> > Graham
>
> > On Apr 15, 8:44 pm, Graham Dumpleton 
> > wrote:> On Apr 15, 7:44 pm, usaar33  wrote:
>
> > > > I just looked at the source code.  This is a django bug.
> > > > Ticket filed @http://code.djangoproject.com/ticket/10819
>
> > > When Apache is decompressing the content you run up against a
> > > limitation in way mutating input filters are dealt with.
>
> > > Namely, when request content is decompressed, the content length in
> > > the headers isn't updated to the actual final length of data. Thus, if
> > > an application only reads up to content length, rather than all
> > > available input, then it will truncate the data.
>
> > > The only problem is that WSGI specification, which I know you aren't
> > > using here, forbids you reading more than content length. Thus Django
> > > cannot be changed in the way that ticket suggests as by ignoring
> > > content length it would be in violation of WSGI specification and may
> > > not work on all WSGI hosting mechanisms.
>
> > > This is an issue which will hopefully be dealt with in WSGI 2.0
> > > specification.
>
> > > Graham
>
> > > > On Apr 15, 1:41 am, usaar33  wrote:
>
> > > > > Hello,
> > > > >   For my application, I am using using gzip content-encoding to
> > > > > compress POSTDATA that the client is giving to django.  The actual
> > > > > content-type is multipart/form-data (although django is screwing up on
> > > > > any content-type).  mod_deflate is used to decompress data coming in
> > > > > from the client.
> > > > >   I have verified that with mod_python that all postdata is there (it
> > > > > is even split correctly into req.form correctly).
>
> > > > >   Unfortunately, django appears to be truncating the data in its
> > > > > parsing.  Only a fixed amount (perhaps 200ish bytes?) are being placed
> > > > > into request.POST; some fields are missing and the last field in the
> > > > > dictionary is being truncated.
>
> > > > > Without ciient-side compression this does not occur.
>
> > > > > Has anyone seen this behavior? Does anyone know how to fix it?
>
> > > > > Best,
> > > > > Aaron Staley
--~--~-~--~~~---~--~~
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: Does QuerySet have a refresh to catch when database data changes underneath running django?

2009-04-15 Thread Alex Gaynor
On Wed, Apr 15, 2009 at 5:30 PM, Karen Tracey  wrote:

> On Wed, Apr 15, 2009 at 5:18 PM, Darrell Silver 
> wrote:
>
>>
>> I've been searching high and low for an answer to this question, but
>> haven't had any luck.  If the database data changes somehow, my django
>> process, happily running, doesn't see the data if it's already got a
>> cache someplace.  I believe this cache is stored in QuerySet.
>>
>> The closest conversation I've found (http://groups.google.com/group/
>> django-users/browse_thread/thread/214719757b8831c2/c05a51eb074151af?
>> 

Re: Does QuerySet have a refresh to catch when database data changes underneath running django?

2009-04-15 Thread Karen Tracey
On Wed, Apr 15, 2009 at 5:18 PM, Darrell Silver wrote:

>
> I've been searching high and low for an answer to this question, but
> haven't had any luck.  If the database data changes somehow, my django
> process, happily running, doesn't see the data if it's already got a
> cache someplace.  I believe this cache is stored in QuerySet.
>
> The closest conversation I've found (http://groups.google.com/group/
> django-users/browse_thread/thread/214719757b8831c2/c05a51eb074151af?
> 

Re: Sending large, generated files

2009-04-15 Thread Graham Dumpleton



On Apr 16, 1:36 am, Rick Wagner  wrote:
> > From memory, file wrappers at django level, in order to work across
> > different hosting mechanisms supported, only allow a file name to be
> > supplied. At the WSGI level the file wrapper actually takes a file
> > like object. If you were doing this in raw WSGI, you could run your
> > tar ball creation as a separately exec'd pipeline and rather than
> > create a file in the file system, have tar output to the pipeline,
> > ie., use '-' instead of filename. The file object resulting from the
> > pipeline could then be used as input to the WSGI file wrapper object.
>
> > So, if this operation isn't somehow bound into needing Django itself,
> > and this is important to you, maybe you should create a separate
> > little WSGI application just for this purpose.
>
> > Actually, even if bound into needing Django you may still be able to
> > do it. Usingmod_wsgi, you could even delegate the special WSGI
> > application to run in same process as Django and mount it at a URL
> > which appears within Django application. Because though you are side
> > stepping Django dispatch, you couldn't though have it be protected by
> > Django based form authentication.
>
> > Graham
>
> Hi,
>
> First, the FileWrapper class in django.core.servers.basehttp.py
> accepts file-like objects,

Okay, then I am confusing it with changes proposed as part of a ticket
which would allow a way of sending back a file response using
optimised methods provided by hosting mechanism. For WSGI this is
wsgi.file_wrapper, but for mod_python the sendfile() function only
takes a file name. As such, the high level interface for that way of
returning a file could only take a file name and not a file like
object.

The ticket is:

  http://code.djangoproject.com/ticket/2131

Graham

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



Does QuerySet have a refresh to catch when database data changes underneath running django?

2009-04-15 Thread Darrell Silver

I've been searching high and low for an answer to this question, but
haven't had any luck.  If the database data changes somehow, my django
process, happily running, doesn't see the data if it's already got a
cache someplace.  I believe this cache is stored in QuerySet.

The closest conversation I've found (http://groups.google.com/group/
django-users/browse_thread/thread/214719757b8831c2/c05a51eb074151af?

Unittests

2009-04-15 Thread Daniel Joshua Worth
I'm trying to learn unit test and have a unit test for a model in test.py
and have a test set up to fail.
When I run manage.py test it returns that all tests are OK.
If I run manage.py test  it returns OK.
If I run manage.py test . it returns OK.
If I run manage.py test .. if Fails.
What gives. Am I missing something as far as unittests are concerned? It
should Fail every time or it's not much of a test.

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



Re: Adding a "View" Link (similar to add and change links) to the admin

2009-04-15 Thread Adam Olsen
>
> You'd need to overide the admin template to do this, as documented here:
> http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-admin-templates
>
> Alex


I guess I should be more specific.  I've already got this working, but I'm
wondering if someones come up with a better looking method.  A better icon?
Also, the template override is kind of ugly, see:

http://rafb.net/p/qtVGDI52.html

-- 
Adam Olsen
SendOutCards.com
http://www.vimtips.org
http://last.fm/user/synic

--~--~-~--~~~---~--~~
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: finding out what SQL Django generated

2009-04-15 Thread Chris Curvey

On Apr 15, 4:25 pm, Alex Gaynor  wrote:
> On Wed, Apr 15, 2009 at 4:23 PM, Chris Curvey  wrote:
>
> > I'm getting unexpected results from a database query that was
> > generated by Django, and I'm sure the problem is that I'm mis-using
> > the API.  Is there a way to get Django to tell me what SQL was sent to
> > the database server?
>
> > (Sorry if this is a FAQ, I've been looking for a while.  Pointers to
> > docs gladly accepted.)
>
> > -Chris
>
> If it's docs links you want :) :
>
> http://docs.djangoproject.com/en/dev/faq/models/#how-can-i-see-the-ra...
>
> Alex

And of course, it's in a FAQ.  Duh!

Thank you, Alex.


>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django-grappelli setup problem

2009-04-15 Thread Lars Stavholm

patrickk wrote:
> line 53 of base.html is {% get_help request.path %}.
> 
> I´m not exactly sure what´s happening here and I´m not able to
> reproduce this error.
> you might wanna try to debug ... request.user seems to work (because
> that´s a couple of lines before), so request.path should also work.
> 
> but I´ve never tested this locally, so I´m not sure if that can cause
> the error (we´re having test/development-servers to do this).
> 
> if you dig a little depper and you think you´ve found a bug - then
> please report it using the google-code issue tracker.

No bug (as far as I can see), just newbie-ness. Turns out that
there's some sort of conflict with other apps, namely the batchadmin
app, possibly more (I removed them all). In addition, being a newbie,
I neglected to tell you that I'm running the development server. I
followed the instructions by Chris Scott, and after a bit of fiddling,
presto, I can see the light:)

It looks brilliant!

/L

> On 15 Apr., 20:14, Lars Stavholm  wrote:
>> patrickk wrote:
>>> in order to use the admin, just use /admin/ (grappelli doesn´t change
>>> the admin-urls).
>> Thanks, but that got me in to some other problem:
>>
>> TemplateSyntaxError at /admin/
>> Caught an exception while rendering: Failed lookup for key [request] in
>> u"[{'root_path': u'/admin/', 'app_list': [{'app_url': 'asset/',
>>
>> [snip]
>>
>> Request Method: GET
>> Request URL:http://localhost:8000/admin/
>> Exception Type: TemplateSyntaxError
>> Exception Value:
>>
>> Caught an exception while rendering: Failed lookup for key [request] in
>>
>> [snip]
>>
>> Exception Location:
>> /usr/lib/python2.6/site-packages/django/template/debug.py in
>> render_node, line 81
>> Python Executable:  /usr/bin/python
>> Python Version: 2.6.0
>> Python Path:['/home/stava/proj/bfact',
>> '/home/stava/lib/Trac-0.11.1-py2.5.egg', '/home/stava/lib',
>> '/home/stava/proj', '/usr/lib/python26.zip', '/usr/lib/python2.6',
>> '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk',
>> '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload',
>> '/usr/lib/python2.6/site-packages',
>> '/usr/lib/python2.6/site-packages/Numeric',
>> '/usr/lib/python2.6/site-packages/PIL',
>> '/usr/local/lib/python2.6/site-packages',
>> '/usr/lib/python2.6/site-packages/gtk-2.0',
>> '/usr/lib/python2.6/site-packages/wx-2.8-gtk2-unicode']
>> Server time:Wed, 15 Apr 2009 20:07:53 +0200
>> Template error
>>
>> In template /home/stava/proj/bfact/templates/admin/base.html, error at
>> line 53
>>
>> My ursl.py looks like this:
>>
>> from django.conf.urls.defaults import *
>> from django.contrib import admin
>> admin.autodiscover()
>>
>> urlpatterns = patterns('',
>>   (r'^grappelli/', include('grappelli.urls')),
>>   (r'^admin/(.*)', admin.site.root),
>> )
>>
>> /L
>>
>>> On 15 Apr., 10:06, Lars Stavholm  wrote:
 patrickk wrote:
> which URL causes that error?
 http://localhost:8000/grappelli/admin/
> please note that in order to use grappelli you have to setup the admin-
> site before, 
> seehttp://docs.djangoproject.com/en/dev/ref/contrib/admin/#ref-contrib-a
> maybe this should be mentioned in the docs, but I guess it´s pretty
> obvious.
 I guess it is, admin up and running nicely without grappelli.
 /L
> On Apr 14, 8:36 pm, Lars Stavholm  wrote:
>> Hi All,
>> I'm trying to get django-grappelli running, but after following
>> the installation instructions, I end up with a 404 and the following:
>> Using the URLconf defined in bfact.urls, Django tried these URL
>> patterns, in this order:
>>1. ^admin/(.*)
>>2. ^grappelli/ ^bookmark/add/$
>>3. ^grappelli/ ^bookmark/remove/$
>>4. ^grappelli/ ^help/(?P\d+)/$
>>5. ^grappelli/ ^help
>>6. ^grappelli/ ^obj_lookup/$
>>7. ^grappelli/ ^related_lookup/$
>>8. ^grappelli/ ^m2m_lookup/$
>>9. ^accounts/login/$
>>   10. ^accounts/logout/$
>> Notice the space after "grappelli/".
>> Anyone else out there using django-grappelli?
>> Any ideas as to what causes this?
>> I'm using django-1.0.2 on Linux with latest grappelli from trunk.
>> Any ideas appreciated
>> /Lars
>>
> > 
> 


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



custom Field for Model choice

2009-04-15 Thread Christopher Dodd

Once I populated my database with thousands and thousands of rows the
widgets available for manipulating the data on the Admin site became
virtually unusable.

So I have written a custom forms.Field that is a simple TextField that
maps to a (hopefully) unique char field on a Model. The Field
validates that the text maps to a single entry in the model, and
provides a function that can be called from the Form that will reset
the field's initial value to be the unique field (rather than the pk
id).

This has major speed and some usability advantages over the existing
widgets/fields.

It works pretty well, but I'm not so keen on the code and would
appreciate advice for cleaning it up and making it easier to use. I
especially don't like having to call fix_initial_form_value() from the
form. Are there better ways to do this?

Here is the custom Field code, followed by an example using it.

#
# A Field that acts as a TextField but must match an entry in the
given
# queryset/field.
#
class ModelChoiceTextField(forms.Field):
def __init__(self, model, unique_field_name, attrs=None, *args,
**kwargs):
kwargs['widget'] = forms.widgets.TextInput(attrs)
super(ModelChoiceTextField, self).__init__(*args, **kwargs)
self.queryset = model.objects
self.unique_field_name = unique_field_name

def clean(self, value):
if not value and not self.required:
return None
try:
return self.queryset.get(**{self.unique_field_name: value})
except self.queryset.model.DoesNotExist:
raise forms.ValidationError("Please enter a valid %s." %
(self.queryset.model._meta.verbose_name,))
except self.queryset.model.MultipleObjectsReturned:
raise forms.ValidationError("Please enter a unique %s." %
(self.queryset.model._meta.verbose_name,))

#
# Change the form's intial value for this field to it's chosen
# member of the object.
#
# This assumes the field is for a Foriegn key and the initial
value will
# be a pk.
#
def fix_initial_form_value(self, form, field_name):
if field_name in form.initial and form.initial[field_name]:
obj = self.queryset.get(**{'pk': form.initial[field_name]})
form.initial[field_name] = getattr(obj, self.unique_field_name)

Example usage:

class PackageFileForm(forms.ModelForm):

file = ModelChoiceTextField(OSFile,
unique_field_name='file_name',
attrs={'size':'60'})

def __init__(self, *args, **kwargs):
super(ArgusPackageFileForm, self).__init__(*args, **kwargs)

self.fields['file'].fix_initial_form_value(self, 'file')


I'd also like for the field to set the 'required' flag automagically
based on its field's 'blank' flag. But that may not be doable in the
Field?
Advice, comments and ideas welcome.

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



Re: how to require/validate minimum number of forms in formset?

2009-04-15 Thread patrickk

this is strange (at least to me), but the clean-method doesn´t seem to
be called when _all_ forms are marked for deletion.

patrick


On 15 Apr., 22:05, patrickk  wrote:
> to be more precise:
>
> class AmountBaseFormset(formsets.BaseFormSet):
>
>     def clean(self):
>         (pseudo-code) if number of forms equal number of deleted
> forms:
>         raise forms.ValidationError(u'At least one Item is required.')
>
> question is: how do I figure out the number of forms resp. the number
> of delete forms here.
> or is this approach the wrong way?
>
> thanks,
> patrick
>
> On 15 Apr., 21:03, patrickk  wrote:
>
> > I´m allowing the forms within a formset to be deleted. but I need at
> > least one form to save the formset. is it possible to require at least
> > one form? if yes, how do I achieve this?
>
> > thanks,
> > patrick
>
>
--~--~-~--~~~---~--~~
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: Sending large, generated files

2009-04-15 Thread Alex Loddengaard
Thanks for the responses, guys.

Regarding my deployment, I've been doing my development on my local machine
using manage.py.  I'll give this a go in WSGI and see what happens.

Graham, I totally agree that there are ways to get around my problem outside
of trying to send HTTP headers before the message body.  A simple way would
be to give the user a "please wait" page while the tarball is generated.
I'm mostly just lazy and don't want to do that, haha.  That said, thanks for
the suggestion.

Rick, the issue with your suggestion is that I need to actually create the
tarball, which takes time.  I'm trying to avoid having the user wait while
the tarball is created by giving them the download dialogue before
generation happens.  Using your BigTarFileWrapper assumes that the tarball
has been created already, at least from what I can tell.

So again, I'll give this a go in WSGI and see what happens.  In the
meantime, I suppose the empty gzipped file gets the job done.

Thanks again for all the responses.  Go Django!

Alex

On Wed, Apr 15, 2009 at 8:36 AM, Rick Wagner wrote:

>
>
>
> On Apr 14, 6:55 pm, Graham Dumpleton 
> wrote:
> > On Apr 15, 7:49 am, Alex Loddengaard  wrote:
> >
> >
> >
> > > I've found several messages on this list discussing ways to send large
> files
> > > in a HttpResponse.  One can use FileWrapper, or one can use a generator
> and
> > > yield chunks of the large file.  What about the case when the large
> file is
> > > generated at HTTP request time?  In this case, it would be annoying to
> have
> > > the user wait for the page to generate the large file and then stream
> the
> > > file.  Instead we would want a way to start the HTTP response (so that
> the
> > > user gets the download dialogue), generate the large file, and then
> stream
> > > the file.  Let's take the following example:
> >
> > > def create_tarball():
> >
> > > >   path = create_some_big_tarball()
> >
> > > >   chunk = None
> > > >   fh = open(path, 'r')
> > > >   while True:
> > > > chunk = fh.read(1024 * 128)
> > > > if chunk == '':
> > > >   break
> > > > yield chunk
> >
> > > > def sample_view(request):
> > > >   response = HttpResponse(create_tarball(),
> > > > mimetype='application/x-compressed')
> > > >   response['Content-Disposition'] =
> "attachment;filename=mytarball.tar.gz"
> >
> > > The above example nearly accomplishes what we want, but it doesn't
> start the
> > > HTTP response before the tarball is created, hence making the user wait
> a
> > > long time before the download dialogue box shows up.  Let's try
> something
> > > like this (notice the addition of a noop yield):
> >
> > > def create_tarball():
> >
> > >   yield '' # noop to send the HTTP headers
> >
> > > >   path = create_some_big_tarball()
> >
> > > >   chunk = None
> > > >   fh = open(path, 'r')
> > > >   while True:
> > > > chunk = fh.read(1024 * 128)
> > > > if chunk == '':
> > > >   break
> > > > yield chunk
> >
> > > > def sample_view(request):
> > > >   response = HttpResponse(create_tarball(),
> > > > mimetype='application/x-compressed')
> > > >   response['Content-Disposition'] =
> "attachment;filename=mytarball.tar.gz"
> >
> > > The issue with the above example is that the "yield ''" seems to be
> > > ignored.  HTTP headers are not sent before the tarball is created.
> > > Similarly, "yield ' '" and "yield None" don't work, because they
> corrupt the
> > > tarball (HttpResponse calls str() on the iterable items given to the
> > > HttpResponse constructor).  As a temporary solution, we're writing an
> empty
> > > gzip file in the first yield.  Our large tarball is gzipped, and since
> gzip
> > > files can be concatenated to one and other, our hack seems to be
> working.
> > > In the above example, replace the first "yield ''" with:
> >
> > >   noop = StringIO.StringIO()
> >
> > > >   empty = gzip.GzipFile(mode='w', fileobj=noop)
> > > >   empty.write("")
> > > >   empty.close()
> > > >   yield noop.getvalue()
> >
> > > I'm wondering if there is a better way to accomplish this?  I don't
> quite
> > > understand why HTTP responses are written to stdout.  Possibly
> orthogonal to
> > > that, it seems like, in theory, yielding an empty value in the
> generator
> > > should work, because a flush is called after the HTTP headers are
> written.
> > > Any ideas, either on how to solve this problem with the Django API, or
> on
> > > why Django doesn't send HTTP headers on a "yield ''"?
> >
> > From memory, file wrappers at django level, in order to work across
> > different hosting mechanisms supported, only allow a file name to be
> > supplied. At the WSGI level the file wrapper actually takes a file
> > like object. If you were doing this in raw WSGI, you could run your
> > tar ball creation as a separately exec'd pipeline and rather than
> > create a file in the file system, have tar output to the pipeline,
> > ie., use '-' instead of 

Re: finding out what SQL Django generated

2009-04-15 Thread Alex Gaynor
On Wed, Apr 15, 2009 at 4:23 PM, Chris Curvey  wrote:

>
> I'm getting unexpected results from a database query that was
> generated by Django, and I'm sure the problem is that I'm mis-using
> the API.  Is there a way to get Django to tell me what SQL was sent to
> the database server?
>
> (Sorry if this is a FAQ, I've been looking for a while.  Pointers to
> docs gladly accepted.)
>
> -Chris
> >
>
If it's docs links you want :) :

http://docs.djangoproject.com/en/dev/faq/models/#how-can-i-see-the-raw-sql-queries-django-is-running

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



finding out what SQL Django generated

2009-04-15 Thread Chris Curvey

I'm getting unexpected results from a database query that was
generated by Django, and I'm sure the problem is that I'm mis-using
the API.  Is there a way to get Django to tell me what SQL was sent to
the database server?

(Sorry if this is a FAQ, I've been looking for a while.  Pointers to
docs gladly accepted.)

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



Re: Django request.POST is truncating data when 'Content-Encoding', 'gzip' is set in client request

2009-04-15 Thread usaar33

Ah, I suspect the request.form code in mod_python must do doing block
read.  Either way, it worked for me.

So in conclusion, it sounds like there is either an issue with A)
mod_deflate not modifying the header or B) WSGI 1.0 being wrong.
Interestingly, there was a large debate on this 4 years ago with
tomcat: https://issues.apache.org/bugzilla/show_bug.cgi?id=34526

Is the best answer for me to simply not provide content-length, which
under WSGI should figure it out?

On Apr 15, 3:55 am, Graham Dumpleton 
wrote:
> Oh, reading past content length also will not necessarily work in
> mod_python due to bugs it has:
>
>  http://issues.apache.org/jira/browse/MODPYTHON-212
>
> If you read in blocks may be okay, but not if you try and read all
> data in one go.
>
> Graham
>
> On Apr 15, 8:44 pm, Graham Dumpleton 
> wrote:> On Apr 15, 7:44 pm, usaar33  wrote:
>
> > > I just looked at the source code.  This is a django bug.
> > > Ticket filed @http://code.djangoproject.com/ticket/10819
>
> > When Apache is decompressing the content you run up against a
> > limitation in way mutating input filters are dealt with.
>
> > Namely, when request content is decompressed, the content length in
> > the headers isn't updated to the actual final length of data. Thus, if
> > an application only reads up to content length, rather than all
> > available input, then it will truncate the data.
>
> > The only problem is that WSGI specification, which I know you aren't
> > using here, forbids you reading more than content length. Thus Django
> > cannot be changed in the way that ticket suggests as by ignoring
> > content length it would be in violation of WSGI specification and may
> > not work on all WSGI hosting mechanisms.
>
> > This is an issue which will hopefully be dealt with in WSGI 2.0
> > specification.
>
> > Graham
>
> > > On Apr 15, 1:41 am, usaar33  wrote:
>
> > > > Hello,
> > > >   For my application, I am using using gzip content-encoding to
> > > > compress POSTDATA that the client is giving to django.  The actual
> > > > content-type is multipart/form-data (although django is screwing up on
> > > > any content-type).  mod_deflate is used to decompress data coming in
> > > > from the client.
> > > >   I have verified that with mod_python that all postdata is there (it
> > > > is even split correctly into req.form correctly).
>
> > > >   Unfortunately, django appears to be truncating the data in its
> > > > parsing.  Only a fixed amount (perhaps 200ish bytes?) are being placed
> > > > into request.POST; some fields are missing and the last field in the
> > > > dictionary is being truncated.
>
> > > > Without ciient-side compression this does not occur.
>
> > > > Has anyone seen this behavior? Does anyone know how to fix it?
>
> > > > Best,
> > > > Aaron Staley
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to require/validate minimum number of forms in formset?

2009-04-15 Thread patrickk

to be more precise:

class AmountBaseFormset(formsets.BaseFormSet):

def clean(self):
(pseudo-code) if number of forms equal number of deleted
forms:
raise forms.ValidationError(u'At least one Item is required.')

question is: how do I figure out the number of forms resp. the number
of delete forms here.
or is this approach the wrong way?

thanks,
patrick


On 15 Apr., 21:03, patrickk  wrote:
> I´m allowing the forms within a formset to be deleted. but I need at
> least one form to save the formset. is it possible to require at least
> one form? if yes, how do I achieve this?
>
> thanks,
> patrick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Adding a "View" Link (similar to add and change links) to the admin

2009-04-15 Thread Alex Gaynor
On Wed, Apr 15, 2009 at 3:13 PM, Adam Olsen  wrote:

>
> Sometimes I want to give people access to a report in the admin
> section, and I'd like it to fit in and look well with the rest of the
> models in the associated application.
>
> Look at this image, you'll see what I mean:
>
> http://www.exaile.org/report.png
>
> That view button is just some "search" icon I stole from Tango.  Has
> anyone found a better (and better looking) way to do something like
> this?
>
> Thanks in advance,
>
> Adam
>
> >
>
You'd need to overide the admin template to do this, as documented here:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-admin-templates

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Query puzzle

2009-04-15 Thread zayatzz

I need help understanding the results of following queries

Bacground. I have 4 trans objects in database. 2 which are related to
poll objects and 2 which are related to another content type. each of
those 2 has 1 objec where keel = 1 and 2 where keel = 2. I want this
single poll related Trans where keel = 1.

1) This gives me 2 results, while i think it should give just one:
q = ContentType.objects.get_for_model(self)
z = Trans.objects.get(content_type__pk=q.id, object_id=self.id).exclude
(keel=2)
t = z.name

2) this gives me no results, while i think it should give me one:
z = Trans.objects.filter(poll = self).exclude(keel = 2)
t = z.name

3) This also gives me 2 results while i want just one:
z = Trans.objects.filter(poll = self)
q = z.get(keel = 1)
t = q.name

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



Adding a "View" Link (similar to add and change links) to the admin

2009-04-15 Thread Adam Olsen

Sometimes I want to give people access to a report in the admin
section, and I'd like it to fit in and look well with the rest of the
models in the associated application.

Look at this image, you'll see what I mean:

http://www.exaile.org/report.png

That view button is just some "search" icon I stole from Tango.  Has
anyone found a better (and better looking) way to do something like
this?

Thanks in advance,

Adam

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



Re: can’t input @ sign on a Windows PC which I installed Portable Ubuntu -- which gives you linux on it

2009-04-15 Thread google torp

This group is for Django related subjects only, please help us keep
the posts on subject. I would suggest you asked this question in a
Portable Ubuntu group instead.

~Jakob

On 15 Apr., 20:58, bconnors  wrote:
> I have a Windows PC which I installed Portable Ubuntu -- which gives
> you linux on it. I’m trying to do
> Python manage.py syncdb so I can get Django working. Trouble is in
> Linux I’m not able to input @ sign
>
> 1       Tried  ascii representation of @ sign #64 and
> 2       Tried hex representation of @ sign 40
>
> I also tried 3 things that Ubuntu forum suggested:
>
> switched keyboard layout to "be" and keyboard model "pc105"
> ran « sudo dpkg-reconfigure -phigh xserver-xorg » and receive message
> that :
> xserver-xorg is not installed
> 4       tried switching to finnish keyboard
>
> 5       tried sudo apt-get install scim-bridge
>
> All 5 failed. Just want to be able to input @ sign.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



can’t input @ sign on a Windows PC which I installed Portable Ubuntu -- which gives you linux on it

2009-04-15 Thread bconnors

I have a Windows PC which I installed Portable Ubuntu -- which gives
you linux on it. I’m trying to do
Python manage.py syncdb so I can get Django working. Trouble is in
Linux I’m not able to input @ sign

1   Tried  ascii representation of @ sign #64 and
2   Tried hex representation of @ sign 40

I also tried 3 things that Ubuntu forum suggested:

switched keyboard layout to "be" and keyboard model "pc105"
ran « sudo dpkg-reconfigure -phigh xserver-xorg » and receive message
that :
xserver-xorg is not installed
4   tried switching to finnish keyboard


5   tried sudo apt-get install scim-bridge

All 5 failed. Just want to be able to input @ sign.

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



how to require/validate minimum number of forms in formset?

2009-04-15 Thread patrickk

I´m allowing the forms within a formset to be deleted. but I need at
least one form to save the formset. is it possible to require at least
one form? if yes, how do I achieve this?

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



Re: django-grappelli setup problem

2009-04-15 Thread patrickk

line 53 of base.html is {% get_help request.path %}.

I´m not exactly sure what´s happening here and I´m not able to
reproduce this error.
you might wanna try to debug ... request.user seems to work (because
that´s a couple of lines before), so request.path should also work.

but I´ve never tested this locally, so I´m not sure if that can cause
the error (we´re having test/development-servers to do this).

if you dig a little depper and you think you´ve found a bug - then
please report it using the google-code issue tracker.

patrick


On 15 Apr., 20:14, Lars Stavholm  wrote:
> patrickk wrote:
> > in order to use the admin, just use /admin/ (grappelli doesn´t change
> > the admin-urls).
>
> Thanks, but that got me in to some other problem:
>
> TemplateSyntaxError at /admin/
> Caught an exception while rendering: Failed lookup for key [request] in
> u"[{'root_path': u'/admin/', 'app_list': [{'app_url': 'asset/',
>
> [snip]
>
> Request Method:         GET
> Request URL:    http://localhost:8000/admin/
> Exception Type:         TemplateSyntaxError
> Exception Value:        
>
> Caught an exception while rendering: Failed lookup for key [request] in
>
> [snip]
>
> Exception Location:
> /usr/lib/python2.6/site-packages/django/template/debug.py in
> render_node, line 81
> Python Executable:      /usr/bin/python
> Python Version:         2.6.0
> Python Path:    ['/home/stava/proj/bfact',
> '/home/stava/lib/Trac-0.11.1-py2.5.egg', '/home/stava/lib',
> '/home/stava/proj', '/usr/lib/python26.zip', '/usr/lib/python2.6',
> '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk',
> '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload',
> '/usr/lib/python2.6/site-packages',
> '/usr/lib/python2.6/site-packages/Numeric',
> '/usr/lib/python2.6/site-packages/PIL',
> '/usr/local/lib/python2.6/site-packages',
> '/usr/lib/python2.6/site-packages/gtk-2.0',
> '/usr/lib/python2.6/site-packages/wx-2.8-gtk2-unicode']
> Server time:    Wed, 15 Apr 2009 20:07:53 +0200
> Template error
>
> In template /home/stava/proj/bfact/templates/admin/base.html, error at
> line 53
>
> My ursl.py looks like this:
>
> from django.conf.urls.defaults import *
> from django.contrib import admin
> admin.autodiscover()
>
> urlpatterns = patterns('',
>   (r'^grappelli/', include('grappelli.urls')),
>   (r'^admin/(.*)', admin.site.root),
> )
>
> /L
>
> > On 15 Apr., 10:06, Lars Stavholm  wrote:
> >> patrickk wrote:
> >>> which URL causes that error?
> >>http://localhost:8000/grappelli/admin/
>
> >>> please note that in order to use grappelli you have to setup the admin-
> >>> site before, 
> >>> seehttp://docs.djangoproject.com/en/dev/ref/contrib/admin/#ref-contrib-a
> >>> maybe this should be mentioned in the docs, but I guess it´s pretty
> >>> obvious.
> >> I guess it is, admin up and running nicely without grappelli.
>
> >> /L
>
> >>> On Apr 14, 8:36 pm, Lars Stavholm  wrote:
>  Hi All,
>  I'm trying to get django-grappelli running, but after following
>  the installation instructions, I end up with a 404 and the following:
>  Using the URLconf defined in bfact.urls, Django tried these URL
>  patterns, in this order:
>     1. ^admin/(.*)
>     2. ^grappelli/ ^bookmark/add/$
>     3. ^grappelli/ ^bookmark/remove/$
>     4. ^grappelli/ ^help/(?P\d+)/$
>     5. ^grappelli/ ^help
>     6. ^grappelli/ ^obj_lookup/$
>     7. ^grappelli/ ^related_lookup/$
>     8. ^grappelli/ ^m2m_lookup/$
>     9. ^accounts/login/$
>    10. ^accounts/logout/$
>  Notice the space after "grappelli/".
>  Anyone else out there using django-grappelli?
>  Any ideas as to what causes this?
>  I'm using django-1.0.2 on Linux with latest grappelli from trunk.
>  Any ideas appreciated
>  /Lars
>
>
--~--~-~--~~~---~--~~
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: Problem querying database

2009-04-15 Thread google torp

The two ways are pretty much the same, one picks a random
number to use for a slice, the other picks a random element in
a queryset. I would go for whatever you think is the easiest
to understand, when browsing through the code.

Also, if you're not sure that atleast 3 elements will come from
the query you would need an if statement in the randrange
version aswell.

~Jakob

On 15 Apr., 17:54, Baxter  wrote:
> On Apr 15, 10:44 am, google torp  wrote:> What I meant 
> was that you could do it like this
>
> > import random
> > sa = Article.objects.filter(...).order_by('-id')
> > random_choice = sa[random.randrange(2, len(sa))]
>
> Thanks Jakob. Is there an advantage to doing it that way rather than
> what I came up with, using choice() rather than random?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django-grappelli setup problem

2009-04-15 Thread Lars Stavholm

patrickk wrote:
> in order to use the admin, just use /admin/ (grappelli doesn´t change
> the admin-urls).

Thanks, but that got me in to some other problem:

TemplateSyntaxError at /admin/
Caught an exception while rendering: Failed lookup for key [request] in
u"[{'root_path': u'/admin/', 'app_list': [{'app_url': 'asset/',

[snip]

Request Method: GET
Request URL:http://localhost:8000/admin/
Exception Type: TemplateSyntaxError
Exception Value:

Caught an exception while rendering: Failed lookup for key [request] in

[snip]

Exception Location:
/usr/lib/python2.6/site-packages/django/template/debug.py in
render_node, line 81
Python Executable:  /usr/bin/python
Python Version: 2.6.0
Python Path:['/home/stava/proj/bfact',
'/home/stava/lib/Trac-0.11.1-py2.5.egg', '/home/stava/lib',
'/home/stava/proj', '/usr/lib/python26.zip', '/usr/lib/python2.6',
'/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk',
'/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload',
'/usr/lib/python2.6/site-packages',
'/usr/lib/python2.6/site-packages/Numeric',
'/usr/lib/python2.6/site-packages/PIL',
'/usr/local/lib/python2.6/site-packages',
'/usr/lib/python2.6/site-packages/gtk-2.0',
'/usr/lib/python2.6/site-packages/wx-2.8-gtk2-unicode']
Server time:Wed, 15 Apr 2009 20:07:53 +0200
Template error

In template /home/stava/proj/bfact/templates/admin/base.html, error at
line 53

My ursl.py looks like this:

from django.conf.urls.defaults import *
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
  (r'^grappelli/', include('grappelli.urls')),
  (r'^admin/(.*)', admin.site.root),
)

/L

> On 15 Apr., 10:06, Lars Stavholm  wrote:
>> patrickk wrote:
>>> which URL causes that error?
>> http://localhost:8000/grappelli/admin/
>>
>>> please note that in order to use grappelli you have to setup the admin-
>>> site before, 
>>> seehttp://docs.djangoproject.com/en/dev/ref/contrib/admin/#ref-contrib-a
>>> maybe this should be mentioned in the docs, but I guess it´s pretty
>>> obvious.
>> I guess it is, admin up and running nicely without grappelli.
>>
>> /L
>>
>>> On Apr 14, 8:36 pm, Lars Stavholm  wrote:
 Hi All,
 I'm trying to get django-grappelli running, but after following
 the installation instructions, I end up with a 404 and the following:
 Using the URLconf defined in bfact.urls, Django tried these URL
 patterns, in this order:
1. ^admin/(.*)
2. ^grappelli/ ^bookmark/add/$
3. ^grappelli/ ^bookmark/remove/$
4. ^grappelli/ ^help/(?P\d+)/$
5. ^grappelli/ ^help
6. ^grappelli/ ^obj_lookup/$
7. ^grappelli/ ^related_lookup/$
8. ^grappelli/ ^m2m_lookup/$
9. ^accounts/login/$
   10. ^accounts/logout/$
 Notice the space after "grappelli/".
 Anyone else out there using django-grappelli?
 Any ideas as to what causes this?
 I'm using django-1.0.2 on Linux with latest grappelli from trunk.
 Any ideas appreciated
 /Lars
>>
> > 
> 


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



How to make add a listbox to admin template?

2009-04-15 Thread Burcu Hamamcıoğlu


--~--~-~--~~~---~--~~
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: Converting from local DST to UTC

2009-04-15 Thread Jamie

On Apr 14, 9:34 pm, Brian Neal  wrote:
> This is how I am doing it (I'm also integrating with Google Calendar):

> tz = pytz.timezone(tz_name)  # create timezone
> local = tz.localize(d)  # make naive datetime localized
> zulu = local.astimezone(FixedOffset(0))  # convert to UTC
> s = zulu.strftime('%Y-%m-%dT%H:%M:%S.000Z')

tz.localize() did the trick.

I was using naive_datetime.replace(tzinfo = tz) to convert from naive
to a localized time. Once I changed that to tz.localize
(naive_datetime), it worked perfectly.

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



Re: Models.py - retrieve information from other models via ForeignKey field?

2009-04-15 Thread Adi

paste the code for your models

--~--~-~--~~~---~--~~
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: Problem querying database

2009-04-15 Thread Baxter



On Apr 15, 10:44 am, google torp  wrote:
> What I meant was that you could do it like this
>
> import random
> sa = Article.objects.filter(...).order_by('-id')
> random_choice = sa[random.randrange(2, len(sa))]
>
Thanks Jakob. Is there an advantage to doing it that way rather than
what I came up with, using choice() rather than random?
--~--~-~--~~~---~--~~
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: Problem querying database

2009-04-15 Thread google torp

What I meant was that you could do it like this

import random
sa = Article.objects.filter(...).order_by('-id')
random_choice = sa[random.randrange(2, len(sa))]

random.randrange will create a "random" number for you. Giving it
those arguments it can output a number of 2 (so the first wont be
selected) and number of articles -1 so there wont be in problem
getting a number that is too high.
This is just pure python functionality btw.

~Jakob

On 15 Apr., 16:54, Baxter  wrote:
> On Apr 15, 9:39 am, Baxter  wrote:
>
> > On Apr 15, 9:33 am, google torp  wrote:> Hi.
> > > You can just use the python random function, I believe it's in math,
> > > and generate a random number in range of the number of articles.
> > > You could do that before the slice even, and just get a random
> > > number with min value of 2 instead.
>
> > If I were smarter I'd understand what you're trying to tell me here.
>
> Well, it got me on the right track, I think. I'm not entirely sure
> what I've done here, so if it's stupid, someone please let me know:
>
> subcat_articles = Article.objects.filter(publication='Published',
> assigned_to=subcat).order_by('-id')[2:]
> if subcat_articles.count() > 0:
>                                 subcat.article = choice(subcat_articles)
--~--~-~--~~~---~--~~
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: Problem querying database

2009-04-15 Thread Baxter



On Apr 15, 9:39 am, Baxter  wrote:
> On Apr 15, 9:33 am, google torp  wrote:> Hi.
> > You can just use the python random function, I believe it's in math,
> > and generate a random number in range of the number of articles.
> > You could do that before the slice even, and just get a random
> > number with min value of 2 instead.
>
> If I were smarter I'd understand what you're trying to tell me here.

Well, it got me on the right track, I think. I'm not entirely sure
what I've done here, so if it's stupid, someone please let me know:

subcat_articles = Article.objects.filter(publication='Published',
assigned_to=subcat).order_by('-id')[2:]
if subcat_articles.count() > 0:
subcat.article = choice(subcat_articles)

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



Re: How do you retrieve a username that is not in the URL?

2009-04-15 Thread JL

Also, you might want to make sure you have an authenticated user (by
either decorating your view function with @login_required) or check
that the user in the request is either authenticated or not the
anonymous user (by including an if statement).

On Apr 14, 8:36 pm, James Bennett  wrote:
> On Tue, Apr 14, 2009 at 5:12 PM, stkpoi  wrote:
> >    if form.is_valid():
> >      submission = Submission.objects.get_or_create(
> >      title=form['title'],
> >      link=form['link'],
> >      user=request.user.username
> >      )
>
> And right there's your problem. The value to put into a ForeignKey is
> the actual User object itself, not its id or username or some other
> attribute. The error message you're seeing is a consequence of putting
> the wrong value in there.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem querying database

2009-04-15 Thread Baxter



On Apr 15, 9:33 am, google torp  wrote:
> Hi.
> You can just use the python random function, I believe it's in math,
> and generate a random number in range of the number of articles.
> You could do that before the slice even, and just get a random
> number with min value of 2 instead.
>
If I were smarter I'd understand what you're trying to tell me here.
--~--~-~--~~~---~--~~
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: Problem querying database

2009-04-15 Thread google torp

Hi.
You can just use the python random function, I believe it's in math,
and generate a random number in range of the number of articles.
You could do that before the slice even, and just get a random
number with min value of 2 instead.

~Jakob

On 15 Apr., 16:23, "bax...@gretschpages.com" 
wrote:
> I'm hoping someone can help me get the info I'm trying to get. This is
> the structure:
>
> I have Categories
>     Each Category has one or more subcategory
>     Articles have a M2M relationship with subcategory so they can turn
> up in more than one category as needed.
>
> I'm trying to get one random article for each category, but NOT the
> two most recent articles.
>
> I'm trying this:
>
> articles = Article.objects.filter(publication='Published',
> assigned_to=subcat).order_by('-id')[2:]
> subcat.article = articles.order_by('?')[0]
>
> Which should get all the articles for the subcat except the two most
> recent ones, then select one random one from that list, except I'm
> running into "AssertionError: Cannot reorder a query once a slice has
> been taken."
>
> So, how can I do 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: add 'link' to admin interface of model

2009-04-15 Thread Psihonavt



On 10 Кві, 12:18, "ramu...@gmail.com"  wrote:
> If I understand correctly the same problem solve by this code:
>
> 
> def colored_name(self):
>     return '%s %s' %
> (self.color_code, self.first_name, self.last_name)
> colored_name.allow_tags = True
> 
>
> manualhttp://docs.djangoproject.com/en/dev/ref/contrib/admin/#list-display
>
> On Apr 9, 8:31 pm,Psihonavt wrote:
>

forget to answer, but it works! thnx
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Problem querying database

2009-04-15 Thread bax...@gretschpages.com

I'm hoping someone can help me get the info I'm trying to get. This is
the structure:

I have Categories
Each Category has one or more subcategory
Articles have a M2M relationship with subcategory so they can turn
up in more than one category as needed.

I'm trying to get one random article for each category, but NOT the
two most recent articles.

I'm trying this:

articles = Article.objects.filter(publication='Published',
assigned_to=subcat).order_by('-id')[2:]
subcat.article = articles.order_by('?')[0]

Which should get all the articles for the subcat except the two most
recent ones, then select one random one from that list, except I'm
running into "AssertionError: Cannot reorder a query once a slice has
been taken."

So, how can I do 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
-~--~~~~--~~--~--~---



Changing raw_id_field from 'id'

2009-04-15 Thread Alfonso

Is there an easy way to change the raw_id_field in a foreign key
relationship?  I'd like to change an inline formset to display not the
item pk id alongside the raw_id_field 'magnifying glass' but a barcode
field instead.

Thanks

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



Re: Basic RSS in Django

2009-04-15 Thread Jeff FW

It looks like you're missing (or at least, didn't mention) the
templates. In documentation:

http://docs.djangoproject.com/en/dev/ref/contrib/syndication/#ref-contrib-syndication

make sure to read the paragraph starting with "One thing's left to do"
under "A simple example".

-Jeff

On Apr 15, 8:30 am, Oto Brglez  wrote:
> Hi all you Django users and developers!
>
> I have a question about RSS framework in Django. I want basic RSS.
> Nothing custom nothing advanced. Just RSS from my model for last 10
> imports in model. This is what i got:
>
> # Model:
>
> class Koda(models.Model):
>         naslov = models.CharField(max_length=50)
>         slug = models.SlugField(max_length=255,blank=True,null=True)
>         koda = models.TextField()
>         dodano = models.DateTimeField(default=datetime.datetime.now ,
> blank=True)
>         avtor = models.ForeignKey(User)
>
>         @permalink
>         def get_absolute_url(self):
>                 return ('koda_view', [self.slug])
>
>         def __unicode__(self):
>                 return self.jezik.ime + ' / '+ self.naslov
>
> #  RSS Model:
>
> class SvezaKoda(Feed):
>         title = "Rss title..."
>         link = "/rss/"
>         description = "Description..."
>
>         def items(self):
>                 return Koda.objects.order_by('-dodano')[:10]
>
>         def item_link(self,item):
>                 return '/'+ item.jezik.slug + '/' + item.slug
>
>         def item_author_name(self,item):
>                 return item.avtor
>
>         def item_pubdate(self,item):
>                 return item.dodano
>
> # URLs:
>
> feeds = {
>     'koda': SvezaKoda,
>
> }
>
> urlpatterns = patterns('',
>         (r'^rss/(?P.*)/$', 'django.contrib.syndication.views.feed',
> {'feed_dict': feeds}),
> ...
>
> ---
>
> Now. This works. But in content field i don't get content that i want.
> I want the field "koda" to be shown inside RSS content field. Insted
> of the content inside rss item i get value of __unicode__
>
> Can someone please help me.
>
> Oto
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



sanitizing the regex in Entry.objects.get(title__iregex=regex)

2009-04-15 Thread commander_coder

I have a question about escaping a db query that uses iregex.  I
wonder if there isn't just a function that I need to use that I don't
know how to find.

I have a text box where users can enter multiple words and I will
search the database for a regex made from those words (the underlying
databse record is from a CharField). My first try was this:

  regex=r'('+'|'.join(word_list)+')+'
  xQ = X.objects.filter(f__iregex=regex)

I entered "paper; select * from pkg_y" and got a screen dump (a text
traceback) going down to a line involving the database cursor (I have
a quite recent Django running from the svn, using Python 2.6 and
PostgreSQL, if that matters).  From this I understood that I have to
sanitize regex.

Is that right?  Is there a natural way to do that?  I have at the
moment got
  regex=r'('+"|".join([re.escape(t) for t in word_list])+')+'
but I am dubious about my ability to outsmart any bad guys.

Thank you for any help,
Jim
--~--~-~--~~~---~--~~
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: Auth permitions in templates

2009-04-15 Thread Gil Sousa

Thanks a lot :)

It works now :)

On 15 Abr, 13:58, Daniel Roseman 
wrote:
> On Apr 15, 11:56 am, Gil Sousa  wrote:
>
> > I am new with django, sorry about this kind of questions.
>
> > I don't know how to pass the 'user' variable into the template, how
> > can I do that?
>
> > Thanks for your help!
>
> The same way you pass all the other variables when you render the
> template.
>
> Or, as I said above, use the context processors - I meant to include
> the link:http://docs.djangoproject.com/en/dev/ref/templates/api/#id1
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Adding model instance attributes

2009-04-15 Thread Mitch Chapman

On Apr 14, 9:43 am, Alex Gaynor  wrote:
> On Tue, Apr 14, 2009 at 11:33 AM, Mitch Chapman 
> wrote:
> > Is it bad form in Django to add "transient" instance variables to
> > model instances?
>
> > I'm rendering a set of search results.  Each result record is a User
> > instance.  I want to show whether or not each record is a friend of
> > the user who is conducting the search.
>
> > Right now my view is annotating each search result record to indicate
> > whether or not it is a friend of the requesting user.  This works, but
> > I'm not sure what might break as a result of adding the instance
> > variable:
>
> >    matched_users = User.objects.filter(...)
> >    friends_set = set([...])
> >    for u in matched_users:
> >        u.is_my_friend = (u.username in friends_set)
>
> > I don't need to store this information permanently.  I just want to
> > use it to simplify template rendering, e.g.
>
> >    {% for user in matched_users %}
> >            ...
> >            {% if user.is_my_friend %}
> >                {{user.username}} is already your friend.
> >            {% endif %}
> >            ...
>
> > Is there a different, recommended way to do this?  Thanks for the help!
>
> In my view this is perfectly acceptable.  Django is just python and that's
> completely legal Python and even idiomatic.  Indeed just adding attribute is
> how annotations work in the development version.
>
> Alex

Thanks, Alex.

I guess ZODB made a strong impression on me :)

--
Mitch

>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: single queryset from multiple tables

2009-04-15 Thread veearrsix

Thanks guys that was perfect

On Apr 14, 3:53 pm, Alex Gaynor  wrote:
> On Tue, Apr 14, 2009 at 10:50 AM, veearrsix  wrote:
>
> > Thanks for the help so far guys, I've used that recipe suggested by
> > Malcolm, where by I pass a number of querysets into the method. It
> > works as expected I guess, BUT, I would like to be able to sort by the
> > datetime field from each queryset, however the fieldnames for each of
> > the date time fields from each queryset are different. Is there a way
> > around this, should I actually be looking at a custom sql query?
>
> > On Apr 11, 12:55 am, Alex Gaynor  wrote:
> > > On Fri, Apr 10, 2009 at 7:52 PM, Malcolm Tredinnick <
>
> > > malc...@pointy-stick.com> wrote:
>
> > > > On Fri, 2009-04-10 at 19:44 -0400, Alex Gaynor wrote:
>
> > > > > On Fri, Apr 10, 2009 at 7:40 PM, Malcolm Tredinnick
> > > > >  wrote:
> > > > [...]
>
> > > > >         Particularly with iterators, storing the (next head item,
> > rest
> > > > >         of
> > > > >         iterator) pair in a heap leads to a very neat and fast way to
> > > > >         create a
> > > > >         combined iterator. Here's one professional-quality
> > > > >         implementation that I
> > > > >         would recommend:http://code.activestate.com/recipes/491285/
>
> > > > > It has one unfortunate failing(which is the fault of the heapq
> > > > > library), it doesn't take a key/cmp function like sorted does.  It is
> > > > > otherwise completely excellent though.
>
> > > > It's Python and so is the heap module! Modifying things is easy. I've
> > > > used the same solution with custom comparison functions one a number of
> > > > occasions. Even writing a small heap implementaiton with a custom
> > > > comparison is only about two dozen lines. Come on, think a little bit
> > > > outside the box!
>
> > > I'm not!  A heap sort is a great solution to this problem(but you already
> > > knew that), it's just that the implementation in the python stdlib
> > doesn't
> > > work perfectly for this usecase(indeed I filed a ticket about this
> > upsteam
> > > several months ago, for reference it was rejected).  I did the same thing
> > > you suggested for a blog post on this topic a number of months ago,
> > however
> > > it wasn't nearly as optimial as this(I believe you even commented to that
> > > effect on the post).
>
> > > > Regards,
> > > > Malcolm
>
> > > Alex
>
> > > --
> > > "I disapprove of what you say, but I will defend to the death your right
> > to
> > > say it." --Voltaire
> > > "The people's good is the highest law."--Cicero
>
> Well, if you use some sorting mechanism that takes a key function(like the
> one sorted takes) you could write one up that's something like:
>
> DATE_FIELD_MAPPING = {
>     Model1: 'date',
>     Model2: 'pubdate',
>
> }
>
> def my_key_func(obj):
>     return getattr(obj, DATE_FIELD_MAPPING[type(obj)])
>
> And then sorted(chain(Model1.objects.all(), Model2.objects.all()),
> key=my_key_func)
>
> Or something similar using the heap sort method malcolm and I discussed.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Basic RSS in Django

2009-04-15 Thread Oto Brglez

Hi all you Django users and developers!

I have a question about RSS framework in Django. I want basic RSS.
Nothing custom nothing advanced. Just RSS from my model for last 10
imports in model. This is what i got:

# Model:

class Koda(models.Model):
naslov = models.CharField(max_length=50)
slug = models.SlugField(max_length=255,blank=True,null=True)
koda = models.TextField()
dodano = models.DateTimeField(default=datetime.datetime.now ,
blank=True)
avtor = models.ForeignKey(User)

@permalink
def get_absolute_url(self):
return ('koda_view', [self.slug])

def __unicode__(self):
return self.jezik.ime + ' / '+ self.naslov

#  RSS Model:

class SvezaKoda(Feed):
title = "Rss title..."
link = "/rss/"
description = "Description..."

def items(self):
return Koda.objects.order_by('-dodano')[:10]

def item_link(self,item):
return '/'+ item.jezik.slug + '/' + item.slug

def item_author_name(self,item):
return item.avtor

def item_pubdate(self,item):
return item.dodano

# URLs:

feeds = {
'koda': SvezaKoda,
}

urlpatterns = patterns('',
(r'^rss/(?P.*)/$', 'django.contrib.syndication.views.feed',
{'feed_dict': feeds}),
...

---

Now. This works. But in content field i don't get content that i want.
I want the field "koda" to be shown inside RSS content field. Insted
of the content inside rss item i get value of __unicode__

Can someone please help me.

Oto

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



Iterable blocks in templates

2009-04-15 Thread Daniel Isla

I'm trying to make our web designers will not see source code in
template files

is possible do this in django template system? there is something
similar?

Template - index.html


Test

News
{% block content %}
New number {{ number }}
{% endblock %}



Controller - test.py

def index(request):
news = {1,2,3}
t = loader.get_template('index.html')
content = t.get_block('content')
for n in news:
content.start() # start 'render' new block
content.set('number', n)
content.end()
return HttpResponse(t.render())


Regards,
Daniel


--~--~-~--~~~---~--~~
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: code from database in template -> br

2009-04-15 Thread google torp

Just wanted to add, the danger is not if the data is coming
from the db, as all the data, more or less will come from the db.
The problem is if the user has made the input that was saved
to the db, like the username. Marking such content with the
safe tag would make it possible for evil minded users to destroy
your site.

~Jakob

On 15 Apr., 14:29, mag_dex  wrote:
> sorry:
>
> Description:{{  script.desc | safe }}
> 
>
> no need to put   {% autoescape off %} in this second statement.
>
> On Apr 15, 3:28 pm, mag_dex  wrote:
>
> > Thanks. I've been on that page but I just found
>
> >       {% autoescape off %}
> >       Description:{{  script.desc }} > td>
> >       {% endautoescape %}
>
> > Using 'safe' it goes like:
>
> >       {% autoescape off %}
> >       Description:{{  script.desc |
> > safe }}
> >       {% endautoescape %}
>
> > Data goes from the db (by but some stuff) so there is not risk.
>
> > Thanks again.
>
> > Wishes,
>
> > M.
>
> > On Apr 15, 2:15 pm, google torp  wrote:
>
> > > Hi
> > > There is a page for all the django template 
> > > tags:http://docs.djangoproject.com/en/dev/ref/templates/builtins/
>
> > > Your problem is the auto escape, you can use "|safe" to mark something
> > > safe and it wont be escaped. Doing this for user submitted data is a
> > > bad idea though, so make sure you don't make your site vulnerable for
> > > attacks before use.
>
> > > ~Jakob
>
> > > On 15 Apr., 12:52, mag_dex  wrote:
>
> > > > Hey,
>
> > > > I've gotten a following problem. I have stored some pieces of html
> > > > code in the database.
> > > > If the django renders html code it  is changed to br  ;(
> > > > I guess there is easy one to change behaviour of rendering but I can't
> > > > find it.
>
> > > > Any ideas?
>
> > > > M.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: code from database in template -> br

2009-04-15 Thread mag_dex

sorry:

Description:{{  script.desc | safe }}


no need to put   {% autoescape off %} in this second statement.


On Apr 15, 3:28 pm, mag_dex  wrote:
> Thanks. I've been on that page but I just found
>
>       {% autoescape off %}
>       Description:{{  script.desc }} td>
>       {% endautoescape %}
>
> Using 'safe' it goes like:
>
>       {% autoescape off %}
>       Description:{{  script.desc |
> safe }}
>       {% endautoescape %}
>
> Data goes from the db (by but some stuff) so there is not risk.
>
> Thanks again.
>
> Wishes,
>
> M.
>
> On Apr 15, 2:15 pm, google torp  wrote:
>
> > Hi
> > There is a page for all the django template 
> > tags:http://docs.djangoproject.com/en/dev/ref/templates/builtins/
>
> > Your problem is the auto escape, you can use "|safe" to mark something
> > safe and it wont be escaped. Doing this for user submitted data is a
> > bad idea though, so make sure you don't make your site vulnerable for
> > attacks before use.
>
> > ~Jakob
>
> > On 15 Apr., 12:52, mag_dex  wrote:
>
> > > Hey,
>
> > > I've gotten a following problem. I have stored some pieces of html
> > > code in the database.
> > > If the django renders html code it  is changed to br  ;(
> > > I guess there is easy one to change behaviour of rendering but I can't
> > > find it.
>
> > > Any ideas?
>
> > > M.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: code from database in template -> br

2009-04-15 Thread mag_dex

Thanks. I've been on that page but I just found

  {% autoescape off %}
  Description:{{  script.desc }}
  {% endautoescape %}

Using 'safe' it goes like:

  {% autoescape off %}
  Description:{{  script.desc |
safe }}
  {% endautoescape %}

Data goes from the db (by but some stuff) so there is not risk.

Thanks again.

Wishes,

M.

On Apr 15, 2:15 pm, google torp  wrote:
> Hi
> There is a page for all the django template 
> tags:http://docs.djangoproject.com/en/dev/ref/templates/builtins/
>
> Your problem is the auto escape, you can use "|safe" to mark something
> safe and it wont be escaped. Doing this for user submitted data is a
> bad idea though, so make sure you don't make your site vulnerable for
> attacks before use.
>
> ~Jakob
>
> On 15 Apr., 12:52, mag_dex  wrote:
>
> > Hey,
>
> > I've gotten a following problem. I have stored some pieces of html
> > code in the database.
> > If the django renders html code it  is changed to br  ;(
> > I guess there is easy one to change behaviour of rendering but I can't
> > find it.
>
> > Any ideas?
>
> > M.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: save message text with registered character

2009-04-15 Thread CrabbyPete

Karen,

Sorry for the cryptic message.I just start using google groups and
django.  I was storing email that I received in a database. One of the
characters was a mark that could not be coverted for some reason. I
found the program decodeh.py and it fixed it for me.



On Apr 7, 1:40 pm, Karen Tracey  wrote:
> On Tue, Apr 7, 2009 at 1:29 PM, CrabbyPete  wrote:
>
> > I am trying to save a message that has  a registered trademark
> > character in it, like Coke is a registered trademark.
> > I get a DjangoDecodeError. How do I prevent this from happening?
>
> Wild guess: a decode error sounds like you are passing in a bytestring
> somewhere, and furthermore one that is not utf-8 encoded, as Django
> generally assumes utf-8 encoding for bytestrings. If you'd like a more
> educated guess you'll have to supply a few more details of what exactly it
> is your code is doing.
>
> 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: Error: no module named manager

2009-04-15 Thread Daniel Sisco

This problem was caused by the fact that my __init__.py file contained
two lines of "from django include ..." code. I must have copied these
from somewhere instead of creating them fresh. Removing these lines
fixes the problem.

> I don't understand this error, but I can tell you that you need a
> models.py for Django to recognise your application, even if it's
> blank. Try adding one and see if it solves your problem.

Hmm... I'm not sure this is correct because I have an app in my
project that consists of just templatetags with no models.py and it
works just fine. Applications are allowed to have no database content,
in which case it wouldn't make sense for them to require a models.py.

-dls

On Apr 15, 3:06 am, Daniel Roseman 
wrote:
> On Apr 15, 2:14 am, Daniel Sisco  wrote:
>
>
>
> > All:
>
> > I'm adding an app (from django snippits) that is just a template tag
> > for a calendar application in my blog. This is the new directory
> > structure:
>
> > /apps/postcal
> >               |
> >               --> __init__.py
> >               |
> >               --> /templatetags
> >                                         |
> >                                         --> __init__.py
> >                                         |
> >                                         --> calendar.py
>
> > settings.py has been modified to include postcal as such:
>
> > ADDITIONAL_APPS = (
> >     'recaptcha',
> >     'pingback',
> >     'watchlist',
> >     'blogroll',
> >     'robots',
> >     'django.contrib.admindocs',
> >     'gravatar',
> >     'userdata',
> >     'thumbnail',
> >     'postcal',
> >     )
>
> > Calls to manage.py that worked fine before, now throw the error:
> > "Error: no module named manager".
>
> I don't understand this error, but I can tell you that you need a
> models.py for Django to recognise your application, even if it's
> blank. Try adding one and see if it solves your problem.
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: code from database in template -> br

2009-04-15 Thread google torp

Hi
There is a page for all the django template tags:
http://docs.djangoproject.com/en/dev/ref/templates/builtins/

Your problem is the auto escape, you can use "|safe" to mark something
safe and it wont be escaped. Doing this for user submitted data is a
bad idea though, so make sure you don't make your site vulnerable for
attacks before use.

~Jakob

On 15 Apr., 12:52, mag_dex  wrote:
> Hey,
>
> I've gotten a following problem. I have stored some pieces of html
> code in the database.
> If the django renders html code it  is changed to br  ;(
> I guess there is easy one to change behaviour of rendering but I can't
> find it.
>
> Any ideas?
>
> M.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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 permitions in templates

2009-04-15 Thread Daniel Roseman

On Apr 15, 11:56 am, Gil Sousa  wrote:
> I am new with django, sorry about this kind of questions.
>
> I don't know how to pass the 'user' variable into the template, how
> can I do that?
>
> Thanks for your help!
>

The same way you pass all the other variables when you render the
template.

Or, as I said above, use the context processors - I meant to include
the link:
http://docs.djangoproject.com/en/dev/ref/templates/api/#id1
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Auth permitions in templates

2009-04-15 Thread Gil Sousa

I am new with django, sorry about this kind of questions.

I don't know how to pass the 'user' variable into the template, how
can I do that?

Thanks for your help!

On 15 Abr, 11:39, Daniel Roseman 
wrote:
> On Apr 15, 9:32 am, Gil Sousa  wrote:
>
>
>
> > Hi!
>
> > I have one menu that I use as a "base" template, this menu has some
> > entries which some of them should be restricted to logged users, but
> > even when I loggin I cannot see those entries.
>
> > This is my menu.html:
>
> >  > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;>
> > http://www.w3.org/1999/xhtml;>
> > 
> > 
> > {% block title %}{% endblock %}
> > 
> > 
> > 
> > 
> > 
> >         
> >                 Header
> >         
> >         
> >                 
> >                         Home
> >             {% if user.is_authenticated %}
> >             Profile
> >                         Community
> >             {% endif %}
> >                         Menu 3
> >                         Menu 4
> >                         Menu 5
> >                 
> >         
> >         {% block content %}{% endblock %}
> > 
> > 
>
> > What should I change?
>
> Are you sure you are passing a 'user' variable into the template? This
> only happens automatically if you are using the 'auth' context
> processor, and are using a RequestContext instance instead of Context
> to render your template.
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django request.POST is truncating data when 'Content-Encoding', 'gzip' is set in client request

2009-04-15 Thread Graham Dumpleton

Oh, reading past content length also will not necessarily work in
mod_python due to bugs it has:

  http://issues.apache.org/jira/browse/MODPYTHON-212

If you read in blocks may be okay, but not if you try and read all
data in one go.

Graham

On Apr 15, 8:44 pm, Graham Dumpleton 
wrote:
> On Apr 15, 7:44 pm, usaar33  wrote:
>
> > I just looked at the source code.  This is a django bug.
> > Ticket filed @http://code.djangoproject.com/ticket/10819
>
> When Apache is decompressing the content you run up against a
> limitation in way mutating input filters are dealt with.
>
> Namely, when request content is decompressed, the content length in
> the headers isn't updated to the actual final length of data. Thus, if
> an application only reads up to content length, rather than all
> available input, then it will truncate the data.
>
> The only problem is that WSGI specification, which I know you aren't
> using here, forbids you reading more than content length. Thus Django
> cannot be changed in the way that ticket suggests as by ignoring
> content length it would be in violation of WSGI specification and may
> not work on all WSGI hosting mechanisms.
>
> This is an issue which will hopefully be dealt with in WSGI 2.0
> specification.
>
> Graham
>
> > On Apr 15, 1:41 am, usaar33  wrote:
>
> > > Hello,
> > >   For my application, I am using using gzip content-encoding to
> > > compress POSTDATA that the client is giving to django.  The actual
> > > content-type is multipart/form-data (although django is screwing up on
> > > any content-type).  mod_deflate is used to decompress data coming in
> > > from the client.
> > >   I have verified that with mod_python that all postdata is there (it
> > > is even split correctly into req.form correctly).
>
> > >   Unfortunately, django appears to be truncating the data in its
> > > parsing.  Only a fixed amount (perhaps 200ish bytes?) are being placed
> > > into request.POST; some fields are missing and the last field in the
> > > dictionary is being truncated.
>
> > > Without ciient-side compression this does not occur.
>
> > > Has anyone seen this behavior? Does anyone know how to fix it?
>
> > > Best,
> > > Aaron Staley
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



code from database in template -> br

2009-04-15 Thread mag_dex

Hey,

I've gotten a following problem. I have stored some pieces of html
code in the database.
If the django renders html code it  is changed to br  ;(
I guess there is easy one to change behaviour of rendering but I can't
find it.

Any ideas?

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



Re: Django request.POST is truncating data when 'Content-Encoding', 'gzip' is set in client request

2009-04-15 Thread Graham Dumpleton



On Apr 15, 7:44 pm, usaar33  wrote:
> I just looked at the source code.  This is a django bug.
> Ticket filed @http://code.djangoproject.com/ticket/10819

When Apache is decompressing the content you run up against a
limitation in way mutating input filters are dealt with.

Namely, when request content is decompressed, the content length in
the headers isn't updated to the actual final length of data. Thus, if
an application only reads up to content length, rather than all
available input, then it will truncate the data.

The only problem is that WSGI specification, which I know you aren't
using here, forbids you reading more than content length. Thus Django
cannot be changed in the way that ticket suggests as by ignoring
content length it would be in violation of WSGI specification and may
not work on all WSGI hosting mechanisms.

This is an issue which will hopefully be dealt with in WSGI 2.0
specification.

Graham

> On Apr 15, 1:41 am, usaar33  wrote:
>
> > Hello,
> >   For my application, I am using using gzip content-encoding to
> > compress POSTDATA that the client is giving to django.  The actual
> > content-type is multipart/form-data (although django is screwing up on
> > any content-type).  mod_deflate is used to decompress data coming in
> > from the client.
> >   I have verified that with mod_python that all postdata is there (it
> > is even split correctly into req.form correctly).
>
> >   Unfortunately, django appears to be truncating the data in its
> > parsing.  Only a fixed amount (perhaps 200ish bytes?) are being placed
> > into request.POST; some fields are missing and the last field in the
> > dictionary is being truncated.
>
> > Without ciient-side compression this does not occur.
>
> > Has anyone seen this behavior? Does anyone know how to fix it?
>
> > Best,
> > Aaron Staley
--~--~-~--~~~---~--~~
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: Leopard deploy directory?

2009-04-15 Thread Graham Dumpleton



On Apr 15, 9:26 pm, Ayaz Ahmed Khan  wrote:
> On 14-Apr-09, at 4:12 AM, Shannon wrote:
>
>
>
> > Hi -- I am working on a django-powered site on Leopard server.  Where
> > is the recommended/conventional deployment directory?  Every example I
> > see uses a particular user's home directory, but that does not seem
> > appropriate for a production-level site.  I'm fairly new to the
> > Leopard environment and am curious what people typically use for their
> > production deployment directory.
>
> The default document root directory for Apache on 10.5.x is:
>      /Library/WebServer/Documents
>
> So, I should imagine that /Library/WebServer/, among other
> alternatives, may be a suitable place to deploy production-level
> sites.

Just don't stick source code in /Library/WebServer/Documents, or for
that matter any directory for which access has been enabled to Apache,
whether or not there is a current Alias setup such that that directory
is exposed via a URL.

Graham
--~--~-~--~~~---~--~~
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: Leopard deploy directory?

2009-04-15 Thread Ayaz Ahmed Khan


On 14-Apr-09, at 4:12 AM, Shannon wrote:

>
> Hi -- I am working on a django-powered site on Leopard server.  Where
> is the recommended/conventional deployment directory?  Every example I
> see uses a particular user's home directory, but that does not seem
> appropriate for a production-level site.  I'm fairly new to the
> Leopard environment and am curious what people typically use for their
> production deployment directory.
>

The default document root directory for Apache on 10.5.x is:
 /Library/WebServer/Documents

So, I should imagine that /Library/WebServer/, among other
alternatives, may be a suitable place to deploy production-level
sites.

-- 
Ayaz Ahmed Khan

An evil mind is a great comfort.


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



Re: Django request.POST is truncating data when 'Content-Encoding', 'gzip' is set in client request

2009-04-15 Thread usaar33

I just looked at the source code.  This is a django bug.
Ticket filed @ http://code.djangoproject.com/ticket/10819

On Apr 15, 1:41 am, usaar33  wrote:
> Hello,
>   For my application, I am using using gzip content-encoding to
> compress POSTDATA that the client is giving to django.  The actual
> content-type is multipart/form-data (although django is screwing up on
> any content-type).  mod_deflate is used to decompress data coming in
> from the client.
>   I have verified that with mod_python that all postdata is there (it
> is even split correctly into req.form correctly).
>
>   Unfortunately, django appears to be truncating the data in its
> parsing.  Only a fixed amount (perhaps 200ish bytes?) are being placed
> into request.POST; some fields are missing and the last field in the
> dictionary is being truncated.
>
> Without ciient-side compression this does not occur.
>
> Has anyone seen this behavior? Does anyone know how to fix it?
>
> Best,
> Aaron Staley
--~--~-~--~~~---~--~~
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 request.POST is truncating data when 'Content-Encoding', 'gzip' is set in client request

2009-04-15 Thread usaar33

Hello,
  For my application, I am using using gzip content-encoding to
compress POSTDATA that the client is giving to django.  The actual
content-type is multipart/form-data (although django is screwing up on
any content-type).  mod_deflate is used to decompress data coming in
from the client.
  I have verified that with mod_python that all postdata is there (it
is even split correctly into req.form correctly).

  Unfortunately, django appears to be truncating the data in its
parsing.  Only a fixed amount (perhaps 200ish bytes?) are being placed
into request.POST; some fields are missing and the last field in the
dictionary is being truncated.

Without ciient-side compression this does not occur.

Has anyone seen this behavior? Does anyone know how to fix it?

Best,
Aaron Staley

--~--~-~--~~~---~--~~
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: residual fields admin error

2009-04-15 Thread Daniel Roseman

On Apr 15, 4:24 am, CrabbyPete  wrote:
> I am just starting coding with django. So please bear with me.
>
> I made a change to my User model so the field email_addr is now email.
> I deleted the database, made new tables with manage.py, did a resync,
> and changed all the code that refered to email_addr to email.
> Everything looks fine, but I still get Ithe following error  when I
> looked at my database with the admin. Is there some
>

This is a FAQ:
http://docs.djangoproject.com/en/dev/faq/models/#if-i-make-changes-to-a-model-how-do-i-update-the-database
(the third option not mentioned there is to use one of the third-party
projects such as South, dmigrations or django-evolution to update your
database).
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Auth permitions in templates

2009-04-15 Thread Daniel Roseman

On Apr 15, 9:32 am, Gil Sousa  wrote:
> Hi!
>
> I have one menu that I use as a "base" template, this menu has some
> entries which some of them should be restricted to logged users, but
> even when I loggin I cannot see those entries.
>
> This is my menu.html:
>
>  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;>
> http://www.w3.org/1999/xhtml;>
> 
> 
> {% block title %}{% endblock %}
> 
> 
> 
> 
> 
>         
>                 Header
>         
>         
>                 
>                         Home
>             {% if user.is_authenticated %}
>             Profile
>                         Community
>             {% endif %}
>                         Menu 3
>                         Menu 4
>                         Menu 5
>                 
>         
>         {% block content %}{% endblock %}
> 
> 
>
> What should I change?

Are you sure you are passing a 'user' variable into the template? This
only happens automatically if you are using the 'auth' context
processor, and are using a RequestContext instance instead of Context
to render your template.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Auth permitions in templates

2009-04-15 Thread Gil Sousa

Hi!

I have one menu that I use as a "base" template, this menu has some
entries which some of them should be restricted to logged users, but
even when I loggin I cannot see those entries.

This is my menu.html:


http://www.w3.org/1999/xhtml;>


{% block title %}{% endblock %}






Header



Home
{% if user.is_authenticated %}
Profile
Community
{% endif %}
Menu 3
Menu 4
Menu 5


{% block content %}{% endblock %}



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



Re: django-grappelli setup problem

2009-04-15 Thread patrickk

in order to use the admin, just use /admin/ (grappelli doesn´t change
the admin-urls).

patrick


On 15 Apr., 10:06, Lars Stavholm  wrote:
> patrickk wrote:
> > which URL causes that error?
>
> http://localhost:8000/grappelli/admin/
>
> > please note that in order to use grappelli you have to setup the admin-
> > site before, 
> > seehttp://docs.djangoproject.com/en/dev/ref/contrib/admin/#ref-contrib-a
> > maybe this should be mentioned in the docs, but I guess it´s pretty
> > obvious.
>
> I guess it is, admin up and running nicely without grappelli.
>
> /L
>
> > On Apr 14, 8:36 pm, Lars Stavholm  wrote:
> >> Hi All,
>
> >> I'm trying to get django-grappelli running, but after following
> >> the installation instructions, I end up with a 404 and the following:
>
> >> Using the URLconf defined in bfact.urls, Django tried these URL
> >> patterns, in this order:
>
> >>    1. ^admin/(.*)
> >>    2. ^grappelli/ ^bookmark/add/$
> >>    3. ^grappelli/ ^bookmark/remove/$
> >>    4. ^grappelli/ ^help/(?P\d+)/$
> >>    5. ^grappelli/ ^help
> >>    6. ^grappelli/ ^obj_lookup/$
> >>    7. ^grappelli/ ^related_lookup/$
> >>    8. ^grappelli/ ^m2m_lookup/$
> >>    9. ^accounts/login/$
> >>   10. ^accounts/logout/$
>
> >> Notice the space after "grappelli/".
>
> >> Anyone else out there using django-grappelli?
> >> Any ideas as to what causes this?
>
> >> I'm using django-1.0.2 on Linux with latest grappelli from trunk.
>
> >> Any ideas appreciated
> >> /Lars
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django-grappelli setup problem

2009-04-15 Thread Lars Stavholm

patrickk wrote:
> which URL causes that error?

http://localhost:8000/grappelli/admin/

> please note that in order to use grappelli you have to setup the admin-
> site before, see 
> http://docs.djangoproject.com/en/dev/ref/contrib/admin/#ref-contrib-admin.
> maybe this should be mentioned in the docs, but I guess it´s pretty
> obvious.

I guess it is, admin up and running nicely without grappelli.

/L

> On Apr 14, 8:36 pm, Lars Stavholm  wrote:
>> Hi All,
>>
>> I'm trying to get django-grappelli running, but after following
>> the installation instructions, I end up with a 404 and the following:
>>
>> Using the URLconf defined in bfact.urls, Django tried these URL
>> patterns, in this order:
>>
>>1. ^admin/(.*)
>>2. ^grappelli/ ^bookmark/add/$
>>3. ^grappelli/ ^bookmark/remove/$
>>4. ^grappelli/ ^help/(?P\d+)/$
>>5. ^grappelli/ ^help
>>6. ^grappelli/ ^obj_lookup/$
>>7. ^grappelli/ ^related_lookup/$
>>8. ^grappelli/ ^m2m_lookup/$
>>9. ^accounts/login/$
>>   10. ^accounts/logout/$
>>
>> Notice the space after "grappelli/".
>>
>> Anyone else out there using django-grappelli?
>> Any ideas as to what causes this?
>>
>> I'm using django-1.0.2 on Linux with latest grappelli from trunk.
>>
>> Any ideas appreciated
>> /Lars
> > 
> 



--~--~-~--~~~---~--~~
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: Two projects, one admin, filebrowser

2009-04-15 Thread patrickk

although I don´t fully understand the problem, there seem to be
different solutions:

### when using the filebrowsefield, you could also write a custom
model method to get the different URLs.
### if your intranet-site and your public-site are on the same server
you could maybe use a symlink as well.
### you could also "hack" the upload-function. define a second upload-
directory/path in fb_settings and use the different directories/paths
based on uploads from the intranet-/public-site.

patrick


On 15 Apr., 04:45, Micah Ransdell  wrote:
> If you are just wanting to serve out the files on the public site then you
> can just copy them over from the media/uploads folder on the intranet site,
> to the media/uploads folder on the public site. You can setup an cron job or
> simple post_save signal on the private side that automatically copies the
> files over.
>
> Micah
>
> On Tue, Apr 14, 2009 at 5:56 PM, shacker  wrote:
>
> > We're building an intranet and a public site that share a lot of data
> > but without shared views. Therefore we're building them as two
> > distinct Django projects connecting to a single shared database, with
> > shared apps. To reduce confusion, the contrib.admin is only enabled on
> > the intranet side, not on the public side (one database, one admin
> > site seemed to make sense).
>
> > All is going well, but we just hit a puzzle:  After installing django-
> > filebrowser and integrating it into some admin views and flat pages,
> > we found that it (of course) only uploads media into media/uploads  on
> > the intranet side. If you create a flat page with uploaded media and
> > view it on the public site, images are broken because their URLs are /
> > media/uploads The path is technically correct, but points to the
> > file tree on the intranet side. There doesn't seem to be a way to tell
> > filebrowser which filesystem to upload into. Selecting a "Site" in the
> > flatpage editor doesn't communicate that info to filebrowser, of
> > course.
>
> > At this point I'm thinking the only way to resolve this is going to be
> > to have two /admin sites after all, rather than one. Or is there
> > another/better way to solve this?
>
> > Thanks,
> > Scot
>
>
--~--~-~--~~~---~--~~
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: Different approach?

2009-04-15 Thread google torp

Hi.

As I'm not sure exactly what your goals with this site is, I'll be
guessing a
bit here. Using the admin to create customers ect, can be a solution,
but
having access to the admin also means having access to a whole bunch
of
stuff that you can mess with. You could instead make some views that
will
display some modelforms that you can use to create what you need.
Maybe
you also some some views that will display customers based per city
postal code, city areas or whatever suits best. You could also add
order
tracking, so you can see what pizza's are selling most and see if
repeat
customers are buying the same (kind of) pizzas. All of these would
also
require views. There are lots of possibilities to extend. Also using
the admin
as the main part of the site should only be done, if the site is only
used by
very few trusted people.

~Jakob

On 15 Apr., 05:40, Mariano Sokal  wrote:
> Well, i'm also new :)
>
> I've been using django for a couple of days trying to learn while developing
> a Pizza Delivery Software... (yes, I got bored doing blogs) and since it is
> not a traditional website where one has an admin area and a
> regular-user-live-site area, I feel that almost every functionality that I
> want for my app can be accomplished just by using admin.
>
> Ok, as I told you, I am new... but I need to add customers, add addresses,
> add orders... and after doing all the models and registering the admin
> models I feel that I'm almost done with the application. Is that the way you
> do an application where there's no public website but is more like a
> point-of-sale?
>
> Regards,
> Mariano
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django-grappelli setup problem

2009-04-15 Thread patrickk

which URL causes that error?

please note that in order to use grappelli you have to setup the admin-
site before, see 
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#ref-contrib-admin.
maybe this should be mentioned in the docs, but I guess it´s pretty
obvious.

patrick.


On Apr 14, 8:36 pm, Lars Stavholm  wrote:
> Hi All,
>
> I'm trying to get django-grappelli running, but after following
> the installation instructions, I end up with a 404 and the following:
>
> Using the URLconf defined in bfact.urls, Django tried these URL
> patterns, in this order:
>
>    1. ^admin/(.*)
>    2. ^grappelli/ ^bookmark/add/$
>    3. ^grappelli/ ^bookmark/remove/$
>    4. ^grappelli/ ^help/(?P\d+)/$
>    5. ^grappelli/ ^help
>    6. ^grappelli/ ^obj_lookup/$
>    7. ^grappelli/ ^related_lookup/$
>    8. ^grappelli/ ^m2m_lookup/$
>    9. ^accounts/login/$
>   10. ^accounts/logout/$
>
> Notice the space after "grappelli/".
>
> Anyone else out there using django-grappelli?
> Any ideas as to what causes this?
>
> I'm using django-1.0.2 on Linux with latest grappelli from trunk.
>
> Any ideas appreciated
> /Lars
--~--~-~--~~~---~--~~
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: Error: no module named manager

2009-04-15 Thread Daniel Roseman

On Apr 15, 2:14 am, Daniel Sisco  wrote:
> All:
>
> I'm adding an app (from django snippits) that is just a template tag
> for a calendar application in my blog. This is the new directory
> structure:
>
> /apps/postcal
>               |
>               --> __init__.py
>               |
>               --> /templatetags
>                                         |
>                                         --> __init__.py
>                                         |
>                                         --> calendar.py
>
> settings.py has been modified to include postcal as such:
>
> ADDITIONAL_APPS = (
>     'recaptcha',
>     'pingback',
>     'watchlist',
>     'blogroll',
>     'robots',
>     'django.contrib.admindocs',
>     'gravatar',
>     'userdata',
>     'thumbnail',
>     'postcal',
>     )
>
> Calls to manage.py that worked fine before, now throw the error:
> "Error: no module named manager".

I don't understand this error, but I can tell you that you need a
models.py for Django to recognise your application, even if it's
blank. Try adding one and see if it solves your problem.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: RadioSelect widget not rendering

2009-04-15 Thread Daniel Roseman

On Apr 15, 7:10 am, Adam Yee  wrote:
> Can't get the forms.RadioSelect widget to render.  I'm using svn
> 10559, I've looked over forms/widgets.py, but I don't know...  I'm
> able to use forms.CheckboxSelect just fine.
>
> Is it Firefox giving me issues?  What's going on here?
>
> #forms.py
> class PollForm(forms.Form):
>     def make_fields(self, poll):
>         for c in poll.choice_set.iterator():
>             self.fields[c.choice] = forms.CharField
> (widget=forms.RadioSelect, label=c.choice)
>

What is this make_fields? Where did you get it from? What calls it?

If you want to create a dynamic field with choices from a queryset,
the usual way to do this is in the __init__ method.

And it won't work to declare a separate field for each choice. You
want a single field for 'polls', with the choices set to
poll.choice_set.all(). Even better, use a ModelChoiceField and use the
queryset argument.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



  1   2   >