how to make a field uneditable in admin site

2009-02-16 Thread guptha

hi ,
i need to know how to create a non editable field in admin site .I
tried , one like  below

acct_number=models.CharField(max_lenght=100,editable=False)

but it doesn't work
please any other ideas,

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

2009-02-16 Thread stryderjzw

Ah yeah, of course I can put a print statement. Thanks Malcolm. Your
many posts have helped me greatly in the past.

Looks like it works with a new Django project. I am using Pinax and
they alter the manage.py file slightly.

Can't see why it's not working though. I guess I'll have to dig in
deeper into the Django code.



On Feb 16, 6:42 pm, Malcolm Tredinnick 
wrote:
> On Mon, 2009-02-16 at 18:36 -0800, stryderjzw wrote:
>
> [...]
>
> > However, I'm running into the problem that I have no clue if manage.py
> > ever read my settings file correctly.
>
> The settings file is executable (well, importable) Python code, so put a
> print statement in there that will display something when the file is
> imported. You could do something like printing the value of
> MIDDLEWARE_CLASSES.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to use post_save signals

2009-02-16 Thread Malcolm Tredinnick

On Mon, 2009-02-16 at 22:38 -0800, gganesh wrote:
> hi,
> i wrote
> def after_save(sender,instance,created,**kaw):
>   instance.acct_number ='RBSB' + str(instance.id)
>   instance.save()
> 
> 
> post_save.connect(after_save,sender=Selector)
> 
> 
> once when i save it gives out error like
> "maximum recursion depth exceeded in cmp "Exception

That's not surprising. When you see that error, it's usually a hint that
you've got an infinite loop (the other possibility is that you're doing
a really complex computation, but that's relatively rare, particularly
in web programming), so start looking for what it can be. In this case,

(1) Something calls Selector.save()
(2) save() finished and post_save signal handler is called.
(3) your signal handler calls Selector.save() again
(4) save() calls the post_save signal handler (again)
(5) Go back to step 3, repeat forever.

You're going to have to build something into your signal handler to
detect the loop. One idea might be to add an attribute indicating that
you are already updating it:

def after_save(sender,instance,created,**kaw):
   if hasattr(instance, '_already_saving):
  del instance._already_saving
  return
   instance._already_saving = True
   instance.acct_number ='RBSB' + str(instance.id)
   instance.save()

However, in this particular case, it seems like using a post_save signal
handler might be overkill. Can you override the Selector.save() method
instead?

Signals are useful, generally, when you want to do something to multiple
models. In this case, the behaviour seems very specific to one
particular model, so just doing it in the model's save method seems more
sensible.

The one exception to this guideline is if you don't "own" the Selector
source -- if it's a third-party model -- and so can't modify the save()
method. In that case, a post_save handler can be a way to add new
behaviour. But that's more of a last resort situation.

Regards,
Malcolm



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



Re: how to use post_save signals

2009-02-16 Thread gganesh

hi,
i wrote
def after_save(sender,instance,created,**kaw):
instance.acct_number ='RBSB' + str(instance.id)
instance.save()


post_save.connect(after_save,sender=Selector)


once when i save it gives out error like
  "maximum recursion depth exceeded in cmp "Exception

I 'm not aware how to save back to the database ,please help

Thanks
guptha

On Feb 14, 4:02 pm, Daniel Roseman 
wrote:
> On Feb 14, 6:28 am, guptha  wrote:
>
>
>
> > hi ,
> > In models.py i have
> >        class Customer(...)
> >              bill_no=models.CharFeild(...)
>
> > All i need to access the field 'bill_no' and assign a value, In
> > views.py i wrote
>
> >  from django.db.models.signals importpost_save
> >  from mypro.myapp import Customer
>
> >            def after_save(sender,instance,created,**kaw):
> >                      sender.bill_no='INV'+ str(sender.id)
>
> >            post_save.connect(after_save,sender=Customer)
>
> > i'm getting an exception as attribute bill_no and id is not found ,so
> > i checked the db tables ,they are present, I suppose  i misunderstood
> > the concept .Please help me to find the fault
>
> The object being saved is 'instance', not 'sender'.
> Also, don't forget to save the changes to the object after modifying
> it.
> --
> 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: template tag

2009-02-16 Thread xankya

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



Re: template tag

2009-02-16 Thread Malcolm Tredinnick

On Mon, 2009-02-16 at 21:49 -0800, xankya wrote:
> hi,
>i need to do the following kind of template logic. can i achieve
> this using built in tags or i need to create custom tags?
> 
> {% if user in voter_list %}
>  You have already voted.
> {% else %}
> Vote
> {% endif %}

You can't do this with any of the builtins. At least not that I can
figure out.

I would probably create a filter that acts on the list and takes "user"
as the argument and returns true or false, depending on whether the
argument is in the list. Then you can use that filter inside the
existing "if" template tag. Suppose the filter is called "contains", you
could write:

{% if voter_list|contains:user %}
   ...
{% endif %}

This might be a little easier than writing a full-on block-based
template tag. It also reads fairly naturally, to my eye.

Regards,
Malcolm



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



Re: Organizing multiple django projects/apps on 1 server

2009-02-16 Thread Malcolm Tredinnick

On Mon, 2009-02-16 at 21:35 -0800, bbeaudreault wrote:
> Hello all,
> 
> I am pretty new to Django, and coming from a fairly "protective"
> environment in terms of web development.  My only experience in webdev
> stems from my first job out of college, where I came into a very
> complex/robust system and did more tweaking/maintaining than creating.
> 
> I am trying to broaden my horizons, and feel that my background is
> sort of tainting my view of how to organize my own server, especially
> one in which the framework used is so much different (read: better ..
> DRY, MVC) than what I am used to.
> 
> So I created the stereotypical "blog" project, along with using
> pluggables such as tagging, django-syncr, etc. to further extend it.
> However, as I start to read around, I feel more and more that I really
> messed up the organization of that project.
> 
> How I have it set up is like this:
> 
> /mainproject (contains settings.py, etc).
> /mainproject/core/ (contains a bunch of core apps that are required
> throughout, i.e. I put the tagging and django-syncr apps here, as well
> as a people app for users)
> /mainproject/contrib/ (contains all the other apps, such as the blog
> app, a contact form app, etc)
> 
> This has caused me a good deal of stress, as you probably can
> imagine.  To start, I have clashing SVN repositories due to the svn
> checkout of tagging and django-syncr.

Isn't this just a case of setting of svn:externals correctly? You don't
explain how you have things set up, but you should be able to pull in
external svn-managed projects fairly easily using externals.

If you end up using projects that reside in other source control systems
as well, I'd recommend looking at a relatively new project called Pip,
which is available through PyPI. It handles similar work to
svn:external, but for multiple version control systems (svn, git,
mercurial, etc).

>   Also, I have to add 3 separate
> paths to my PYTHONPATH in order to get python to find everything.

That's a slight drawback, although it's not too unusual. One python path
addition for the settings module, one for external apps and one for
internal apps isn't a crazy situation to have. You only have to set up
the Python path once per webserver config, after all.

>   As
> I add more sites to this server, and continued the same directory
> structure, I would end up needing 3 new entries on the PYTHONPATH for
> each project.
> 
> I was thinking of changing this around, to better suit multiple django
> projects on one server, as well as simplify my pythonpath and
> repositories.
> 
> /home/django/pluggables/ (contains such things as tagging, django-
> syncr, any other future pluggables I download)
> /home/django/sitename/projectname/ (contains settings.py for that site-
> project, templates, apps for that project, etc)
> /home/django/sitename/static/ (contains all static content, css, js,
> etc)

This seems reasonable.

The only slight change I would make is to avoid using a directory named
django/. You will already have a module called "django" on your Python
path (Django's source), so it will avoid confusion when you're reading
exception tracebacks and logs to not have another directory with the
same name.

> How do you guys set up your directory structure, especially for
> servers that may host multiple websites using django?
> 
> Is it bad form to use such a directory structure as I have currently
> set up? (I am guessing it is, but looking for confirmation or
> otherwise)

I've seen it in use before. I may have even used it before, I can't
remember (I see a lot of different Django setups for various clients, so
they all start to blur together after a while).

> 
> Just trying to get some ideas on the most efficient, easily movable/
> extensible way of organizing my projects on a shared server (shared in
> the sense that I have multiple sites, not a shared hosting environment
> per se, and movable in that how easily I could take one project and
> move it to a separate server).

Another axis to consider here is the version control aspect. Typically,
your settings and Django applications you develop specifically for a
project will be version controlled by you. external apps might be pulled
from another site and thus use svn:external or some other system.
Keeping external versus internal apps clearly distinguishable at a
glance is worthwhile doing. It makes debugging a lot easier.

You might also want to have a look at the directory structure Pinax
uses. They have considered that issue. My personal opinion is that there
is a lot of path configuration going on in the various Pinax scripts,
which feels a bit uncomfortable, but is a consequence of having lots of
external dependencies. And, again, it's something that you mostly only
have to set up once (and then document). Worth making as simple as
possible, but don't try to go any simpler than that and waste time
looking for some non-existent nirvana.

Regards,
Malcolm




template tag

2009-02-16 Thread xankya

hi,
   i need to do the following kind of template logic. can i achieve
this using built in tags or i need to create custom tags?

{% if user in voter_list %}
 You have already voted.
{% else %}
Vote
{% endif %}
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Organizing multiple django projects/apps on 1 server

2009-02-16 Thread bbeaudreault

Hello all,

I am pretty new to Django, and coming from a fairly "protective"
environment in terms of web development.  My only experience in webdev
stems from my first job out of college, where I came into a very
complex/robust system and did more tweaking/maintaining than creating.

I am trying to broaden my horizons, and feel that my background is
sort of tainting my view of how to organize my own server, especially
one in which the framework used is so much different (read: better ..
DRY, MVC) than what I am used to.

So I created the stereotypical "blog" project, along with using
pluggables such as tagging, django-syncr, etc. to further extend it.
However, as I start to read around, I feel more and more that I really
messed up the organization of that project.

How I have it set up is like this:

/mainproject (contains settings.py, etc).
/mainproject/core/ (contains a bunch of core apps that are required
throughout, i.e. I put the tagging and django-syncr apps here, as well
as a people app for users)
/mainproject/contrib/ (contains all the other apps, such as the blog
app, a contact form app, etc)

This has caused me a good deal of stress, as you probably can
imagine.  To start, I have clashing SVN repositories due to the svn
checkout of tagging and django-syncr.  Also, I have to add 3 separate
paths to my PYTHONPATH in order to get python to find everything.  As
I add more sites to this server, and continued the same directory
structure, I would end up needing 3 new entries on the PYTHONPATH for
each project.

I was thinking of changing this around, to better suit multiple django
projects on one server, as well as simplify my pythonpath and
repositories.

/home/django/pluggables/ (contains such things as tagging, django-
syncr, any other future pluggables I download)
/home/django/sitename/projectname/ (contains settings.py for that site-
project, templates, apps for that project, etc)
/home/django/sitename/static/ (contains all static content, css, js,
etc)

How do you guys set up your directory structure, especially for
servers that may host multiple websites using django?

Is it bad form to use such a directory structure as I have currently
set up? (I am guessing it is, but looking for confirmation or
otherwise)

Just trying to get some ideas on the most efficient, easily movable/
extensible way of organizing my projects on a shared server (shared in
the sense that I have multiple sites, not a shared hosting environment
per se, and movable in that how easily I could take one project and
move it to a separate server).


Thanks for your insight.

Bryan
--~--~-~--~~~---~--~~
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: Changing an ImageField file without re-upload

2009-02-16 Thread Eric Abrahamsen


On Feb 17, 2009, at 5:17 AM, Carmelly wrote:

>
> My situation is this: I want to allow my users to upload multiple
> userpics and then choose between them. So I have a Profile model with
> an ImageField for the userpic. When users upload a file it is
> displayed around the site as usual. When they upload a new file, that
> file replaces their the "userpic" field in their Profile and is
> displayed all over the site, but the old userpic is not overwritten on
> disk. This is what we want.

Have you tried this out? So far as I can see, ImageField and FileField  
uploads don't overwrite old files, even if the filename is the same  
(underscores are appended to the filename). This much should be  
working already.

> Now, if I display a page for the user with all the userpics they ever
> uploaded and let them choose between them, how can I set the path in
> the ImageField to the file the chose? I know there is a userpic.save()
> method, but I'm not sure what to pass into it, or if this is even the
> correct way to go about it.

You could do something hacky where a view displays the contents of a  
directory and allows you to manipulate what you find there, but  
probably what you want is a separate UserPic model, with a M2M  
relation to your Profile. That way each user can have as many pics as  
they want, they can be accessible inline from their profile page, and  
you'll have the convenience of working with a proper django model  
instance. Put a datetime attribute on each photo, and you can use that  
to sort and display the most recently uploaded.

Hope that helps,
Eric

> >


--~--~-~--~~~---~--~~
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: Incompatibility with FreeTDS/ODBC and Unicode on a MSSQL server?

2009-02-16 Thread kgingeri

I should add a couple more things here that may have a bearing on my
problem...

a) I am running Ubuntu Linux and
b) I am accessing my data via a VPN connection
c) I have done most of my installs via Synaptics but will try to redo
some with compiling from source.

If I answer my own question, I will post back here.

Thx again for any ideas  :v)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Incompatibility with FreeTDS/ODBC and Unicode on a MSSQL server?

2009-02-16 Thread kgingeri

I am fairly new to Django and am working my way through the latest
tutorial and get the error below.  I have the latest dev for Django
installed (I know cuz I started out with 0.96), the most recent
FreeTDS, pyodbc and django-pyodbc.  My isql and running all the api
stuff works fine with my SQL Server database but, when I try to use
the admin app I get the traceback below

Calling up http://localhost:8000/admin/ in my browser, yeilds...

Traceback (most recent call last):

...several lines here - I cut them for brevity...

ProgrammingError: ('42000', '[42000] [FreeTDS][SQL Server]Unicode data
in a Unicode-only collation or ntext data cannot be sent to clients
using DB-Library (such as ISQL) or ODBC version 3.7 or earlier. (4004)
(SQLExecDirectW)')

I reinstall several packages to be sure I have the latest, but still
no luck.
Any help is 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: Differen unicode behaviour between mac os x and linux

2009-02-16 Thread Malcolm Tredinnick

On Mon, 2009-02-16 at 19:03 -0800, Polat Tuzla wrote:
> Thanks a lot for your reply Malcolm.
> It's OK if I don't understand the reason of different behaviours, but
> I must find a proper way of writing log files on the linux server.

Aah, context certainly helps with understanding the broader issues.
There are other ways to solve your problem that might be more robust.

> 
> I think I should have clarified some more facts about my setup.
> 1- On mac, django is running on dev mode, so stdout is the console. On
> linux, it's mod_wsgi, so stdout is redirected to apache error log
> files, on which I'm issuing a "tail -f" thorough ssh.

I was a little surprised that stdout was redirected to the error logs in
mod_wsgi, but it seems that that is indeed the case. I don't know what
mod_wsgi might be doing to character encoding on output (maybe nothing,
but maybe that's playing a role). However, instead of using print, I
would recommend using Python's logging module and sending the results to
a dedicated logging file.

Apache error logs aren't a great place for audit-style logging, since
there's so much other (Apache-specific) stuff in there. if you use the
logging module, you'll have code the looks something like this to set
things up (maybe in your settings file):

LOGGER = logging.handlers.FileHandler(...)
LOGGER.setFormatter(logging.Formatter('%(asctime)-24s %(name)-18s 
%(levelname)-8s %(message)s'))
LOG_LEVEL = logging.DEBUG

and then you can use it in your code like so:

import logging

log = logging.getLogger()
log.log(logging.INFO, u"%s" % request.user)

A couple of tests I did here suggest that will work fine with non-ASCII
data, although I couldn't repeat your original problem initially here,
either (I don't have time to play around setting up a mod_wsgi test
project for this right now).



> 2- If I test the same code in the djang shell, the two boxes behave
> the same.
> 
> To sum up, my main problem is error raising print statements on
> production server, causing Http 500 responses, while they perfectly
> work on the local box. And I can't remove the print statements due to
> logging requirements.
> 
> What's the proper way of 'printing' a model object?
>  print u"%s" % request.user
> raises UnicodeEncodeError as I previously mentioned.

The problem with that line is the "print" and the output encoding. The
correct way to get a string form is definitely u"%s" % request.user (or
even unicode(request.user)). The difficulty here apparently comes from
using "print" to do logging in your particular setup. Consider switching
to the logging module.

Regards,
Malcolm


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



Re: Differen unicode behaviour between mac os x and linux

2009-02-16 Thread Polat Tuzla

Thanks a lot for your reply Malcolm.
It's OK if I don't understand the reason of different behaviours, but
I must find a proper way of writing log files on the linux server.

I think I should have clarified some more facts about my setup.
1- On mac, django is running on dev mode, so stdout is the console. On
linux, it's mod_wsgi, so stdout is redirected to apache error log
files, on which I'm issuing a "tail -f" thorough ssh.
2- If I test the same code in the djang shell, the two boxes behave
the same.

To sum up, my main problem is error raising print statements on
production server, causing Http 500 responses, while they perfectly
work on the local box. And I can't remove the print statements due to
logging requirements.

What's the proper way of 'printing' a model object?
 print u"%s" % request.user
raises UnicodeEncodeError as I previously mentioned.

Regards,
Polat Tuzla


On Feb 17, 4:15 am, Malcolm Tredinnick 
wrote:
> On Mon, 2009-02-16 at 17:55 -0800, Polat Tuzla wrote:
> > Hi,
> > I've the same django app deployed to my local mac os x and linux
> > server. I print the username in my view function to the standart
> > output:
> >     def my_view(request):
> >         print request.user
>
> > On mac it prints:
> >     İşÖ
>
> > which is what i expect. But on linux it prints:
> >     \xc4\xb0\xc5\x9f\xc3\x96
>
> I'm not quite sure why the Linux system doesn't display characters,
> although the data is correct. However, it's almost certainly terminal
> related: at some point Python has to format the result in a fashion that
> can be displayed on the terminal ("in the terminal application" would be
> a bit more appropriate to today's implementations, I guess) and your
> Linux and Mac systems don't necessarily coincide in their capabilities.
> Most Linux setups will be fine, but there are reasons why it might be
> restricted to something like, say, only ASCII (accessing via telnet or
> ssh with restricted negotiation, for example).
>
> You are asking Python to use the __str__ method on the model. Unless you
> somehow tell it that the result should be a unicode object, it will
> assume a str. Django uses the User.__unicode__ method and UTF-8 encodes
> it. The Linux output you're seeing is consistent with this: it's the
> UTF-8 encoding of the original string.
>
>
>
> > If I change my view code as:
> >     def my_view(request):
> >         print u"%s" % request.user
>
> > On mac it prints the same as before:
> >     İşÖ
>
> > But on linux it raises a UnicodeEncodeError:
> >     UnicodeEncodeError: 'ascii' codec can't encode characters in
> > position 0-2: ordinal not in range(128)
>
> This would be consistent with your terminal not supporting something
> like UTF_8 output -- or, rather, with Python thinking that the output
> has to be displayed in ASCII.
>
> Don't get too hung up on the results of print output (I realise it might
> hamper some debugging approaches, but it's the debugging approach that
> is causing the problem here, not some bigger issue). There's a big
> variable involved -- terminal encoding type -- that isn't present in
> normal code execution.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Disabling middleware for tests

2009-02-16 Thread Malcolm Tredinnick

On Mon, 2009-02-16 at 18:36 -0800, stryderjzw wrote:
[...]
> However, I'm running into the problem that I have no clue if manage.py
> ever read my settings file correctly.

The settings file is executable (well, importable) Python code, so put a
print statement in there that will display something when the file is
imported. You could do something like printing the value of
MIDDLEWARE_CLASSES.

Regards,
Malcolm



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



Re: Disabling middleware for tests

2009-02-16 Thread stryderjzw

Well, looking at Ticket 9172 (http://code.djangoproject.com/ticket/
9172), we're supposed to be turning off the CSRF middleware during
tests.

I believe we can do that by writing another settings file, disabling
the Csrf Middleware and using that settings file to run our tests, as
per this thread.

However, I'm running into the problem that I have no clue if manage.py
ever read my settings file correctly. I'm assuming it didn't because I
still get the Cross Site Request Forgery error. I can import my
test_settings fine in the shell, so it's not the file that is
incorrect.

I'll dig into this more tonight.

Cheers,
Justin


On Feb 16, 4:12 pm, felix  wrote:
> ah ha.
>
> yes, I've wasted several hours over this issue.  it took me a while to
> figure out that it was the CSRF middleware that was breaking the tests.
> both auth tests and actually every single one that tests the posting of
> forms.
>
> I didn't see it mention of this issue in either the CSRF docs or the unit
> test docs, but those are both places that we would first look to diagnose.
> a docs request ticket should be filed.  I couldn't find one existing.
>
> I thought it was something to do with self.client.login failing (because I
> would get 403)
>
> I couldn't figure this out: is there a way to tell that we are running as a
> test ?
>
>      felix :    crucial-systems.com
>
> On Mon, Feb 16, 2009 at 9:33 PM, stryderjzw  wrote:
>
> > > from settings import *
>
> > > #CSRFMiddleware breaks authtests
> > > MIDDLEWARE_CLASSES = list(MIDDLEWARE_CLASSES)
> > > MIDDLEWARE_CLASSES.remove
> > > ('django.contrib.csrf.middleware.CsrfMiddleware')
>
> > > # Turn this off to allowteststhat look at http status to pass
> > > PREPEND_WWW = False
>
> sorry, I don't get this.  what fails ?  response.status_code == 200 ?
>
>
>
> > > I then run the test suite using this command:
> > > python manage.py test --settings=mysite.settings-test.py
>
> > > Best,
> > > Dave
--~--~-~--~~~---~--~~
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 I overwrite the ModelAdmin for User

2009-02-16 Thread Karen Tracey
On Mon, Feb 16, 2009 at 8:19 PM, Kevin Audleman wrote:

>
> Alex,
>
> I managed to get it to work, and the column is even sortable! Thanks
> for your help.
>
> Here's my code for reference for anyone else who comes across this
> post:
>
> class UserAdmin(admin.ModelAdmin):
>

There are some extensions made to the default User ModelAdmin that you are
going to miss unless you base your customized class off of auth's provided
default UserAdmin.  See:

http://code.djangoproject.com/ticket/8916#comment:14

That ticket notes that change password, for example, won't work if you base
your customized class on admin.ModelAdmin, there may also be other such
things.

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: Differen unicode behaviour between mac os x and linux

2009-02-16 Thread Malcolm Tredinnick

On Mon, 2009-02-16 at 17:55 -0800, Polat Tuzla wrote:
> Hi,
> I've the same django app deployed to my local mac os x and linux
> server. I print the username in my view function to the standart
> output:
> def my_view(request):
> print request.user
> 
> On mac it prints:
> İşÖ
> 
> which is what i expect. But on linux it prints:
> \xc4\xb0\xc5\x9f\xc3\x96

I'm not quite sure why the Linux system doesn't display characters,
although the data is correct. However, it's almost certainly terminal
related: at some point Python has to format the result in a fashion that
can be displayed on the terminal ("in the terminal application" would be
a bit more appropriate to today's implementations, I guess) and your
Linux and Mac systems don't necessarily coincide in their capabilities.
Most Linux setups will be fine, but there are reasons why it might be
restricted to something like, say, only ASCII (accessing via telnet or
ssh with restricted negotiation, for example).

You are asking Python to use the __str__ method on the model. Unless you
somehow tell it that the result should be a unicode object, it will
assume a str. Django uses the User.__unicode__ method and UTF-8 encodes
it. The Linux output you're seeing is consistent with this: it's the
UTF-8 encoding of the original string.

> 
> 
> If I change my view code as:
> def my_view(request):
> print u"%s" % request.user
> 
> On mac it prints the same as before:
> İşÖ
> 
> But on linux it raises a UnicodeEncodeError:
> UnicodeEncodeError: 'ascii' codec can't encode characters in
> position 0-2: ordinal not in range(128)

This would be consistent with your terminal not supporting something
like UTF_8 output -- or, rather, with Python thinking that the output
has to be displayed in ASCII.

Don't get too hung up on the results of print output (I realise it might
hamper some debugging approaches, but it's the debugging approach that
is causing the problem here, not some bigger issue). There's a big
variable involved -- terminal encoding type -- that isn't present in
normal code execution.

Regards,
Malcolm


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



Differen unicode behaviour between mac os x and linux

2009-02-16 Thread Polat Tuzla

Hi,
I've the same django app deployed to my local mac os x and linux
server. I print the username in my view function to the standart
output:
def my_view(request):
print request.user

On mac it prints:
İşÖ

which is what i expect. But on linux it prints:
\xc4\xb0\xc5\x9f\xc3\x96


If I change my view code as:
def my_view(request):
print u"%s" % request.user

On mac it prints the same as before:
İşÖ

But on linux it raises a UnicodeEncodeError:
UnicodeEncodeError: 'ascii' codec can't encode characters in
position 0-2: ordinal not in range(128)

So, these are two cases of different behaviour. Databases in both of
the machines are mysql, and the auth_user tables in both machines have
a charset of utf8.

Could somebody tell what would be the reason?

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: Changing an ImageField file without re-upload

2009-02-16 Thread James Mowery

I don't really understand your question (perhaps English isn't your
first language), and I'm too tired to try to understand, but maybe one
of the following will help:

http://docs.djangoproject.com/en/dev/topics/db/models/#overriding-predefined-model-methods
http://docs.djangoproject.com/en/dev/ref/models/fields/#filepathfield

Perhaps if you attempt to explain your question more clearly, others
will have a better idea of what you need.

But hopefully one of the aforementioned links will help.

On Feb 16, 4:17 pm, Carmelly  wrote:
> My situation is this: I want to allow my users to upload multiple
> userpics and then choose between them. So I have a Profile model with
> an ImageField for the userpic. When users upload a file it is
> displayed around the site as usual. When they upload a new file, that
> file replaces their the "userpic" field in their Profile and is
> displayed all over the site, but the old userpic is not overwritten on
> disk. This is what we want.
>
> Now, if I display a page for the user with all the userpics they ever
> uploaded and let them choose between them, how can I set the path in
> the ImageField to the file the chose? I know there is a userpic.save()
> method, but I'm not sure what to pass into it, or if this is even the
> correct way to go about 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: Can I overwrite the ModelAdmin for User

2009-02-16 Thread Kevin Audleman

Alex,

I managed to get it to work, and the column is even sortable! Thanks
for your help.

Here's my code for reference for anyone else who comes across this
post:

class UserAdmin(admin.ModelAdmin):

def display_profile_status(self, obj):
profile = obj.myprofile_set.all()
if len(profile) > 0:
return "%s" % profile[0].get_status_display()
else:
return "Nada"
display_profile_status.short_description = 'Status'
display_profile_status.allow_tags = True
display_profile_status.admin_order_field = 'myprofile__status'

inlines = [MyProfileInline]
list_display = ('username',
'first_name',
'last_name',
'email',
'is_active',
'display_profile_status',
)


On Feb 16, 4:15 pm, Alex Gaynor  wrote:
> On Mon, Feb 16, 2009 at 7:13 PM, Kevin Audleman 
> wrote:
>
>
>
>
>
> > Alex,
>
> > I feel like I'm one step closer to getting this to work. From the
> > documentation you sent my way, it seems like what I would do would be
> > to create a method on the User object which will span the relationship
> > and grab the value:,
>
> > def get_payment_status(self):
> >    return self.myprofile_set.all()[0].payment_status
>
> > However I am working with the core User object which I didn't write.
> > Am I SOL, or is there some way I can do this.
>
> > Thanks,
> > Kevin
>
> > On Feb 16, 4:02 pm, Alex Gaynor  wrote:
> > > On Mon, Feb 16, 2009 at 6:59 PM, Kevin Audleman <
> > kevin.audle...@gmail.com>wrote:
>
> > > > Thanks!
>
> > > > I've got my new User display going and another question has come up.
> > > > In the related MyProfile object, I've got a field called
> > > > payment_status. It's important for my client to be able to quickly
> > > > view a list of users with a payment_status of 'Unpaid.' Is there a way
> > > > to add a related field to the list_display or list_filter sets for the
> > > > User object?
>
> > > > Cheers,
> > > > Kevin
>
> > > > On Feb 16, 3:45 pm, Alex Gaynor  wrote:
> > > > > On Mon, Feb 16, 2009 at 6:27 PM, Kevin Audleman <
> > > > kevin.audle...@gmail.com>wrote:
>
> > > > > > I've created a custom profile per the instructions in chapter 12 of
> > > > > > the book to give my user's fields like address1, address2, etc.
> > > > > > Currently when I log in to the admin and want to update a user, I
> > have
> > > > > > to go to two separate pages: the User page to update core user
> > fields,
> > > > > > and the Profile page to update fields in the profiles.
>
> > > > > > I would like to overwrite the ModelAdmin for the User object and
> > > > > > inline the Profile object so that all fields for a user can be
> > edited
> > > > > > from one page. However django is throwing an error when I try to do
> > > > > > so:
>
> > > > > > AlreadyRegistered at /admin/
> > > > > > The model User is already registered
>
> > > > > > Here's the code:
>
> > > > > > class ProfileInline(admin.TabularInline):
> > > > > >    model = MyProfile
>
> > > > > > class UserAdmin(admin.ModelAdmin):
> > > > > >    list_display = ('username', 'email', 'first_name', 'last_name',
> > > > > > 'is_staff')
> > > > > >    list_filter = ('is_staff', 'is_superuser')
> > > > > >    inlines = [ProfileInline]
>
> > > > > > admin.site.register(User, UserAdmin)
>
> > > > > > Is there a way to do this?
>
> > > > > > Thanks,
> > > > > > Kevin Audleman
>
> > > > > Yes just do admin.site.unregister(User) before registering yours.
>
> > > > > 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 can add it to the list_display by creating a method on the model for
> > it(http://docs.djangoproject.com/en/dev/ref/contrib/admin/#list-display)
> > and
> > > perhaps use the boolean option to make it more obvious.  Right now you
> > can't
> > > actually use related fields in list_filter:
> >http://code.djangoproject.com/ticket/3400
>
> > > 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 can also just write a method on the ModelAdmin itself, as the examples
> show.
>
> 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 

Re: Different ways of working against a SQLite3 dB

2009-02-16 Thread Karen Tracey
On Mon, Feb 16, 2009 at 3:53 PM, DaSa  wrote:

>
>
> Thx for your tips!
>
> I tried to update my Python version but it did not work.
>

Updating Python failed?  Or changing to 2.6 did not affect your problem?


>
> Today I have my data in an Excel document, and I have a script that
> parse the excel document and creates sql-commands that I paste in the
> SQL shell. But as you know I have the problem with swedish signs.


Well, you haven't actually said what the problems are, you just said "the
windows command prompt does not support swedish signs."  But then later you
said that you do use chcp to set the encoding in the command prompt and the
symbols appear properly, but aren't handled properly when you use "python
manage.py shell", specifically, which rather well matches my experience with
that Python issue.  Now you say "the SQL shell" and I'm not sure if you mean
the sqlite program or manage.py shell, so I'm a bit confused.  Perhaps if
you gave some specific details it would help.  What codepage do you use for
chcp, what exact commands are you issuing in the (and which) shell, what is
the result?  If the problem isn't fixed by that Python issue than perhaps
the problem is that your data is not encoded in the character set you think
it is encoded in.


>
>
> I shall try to use the admin interface instead, but today I can only
> add one item at the time. Do you know any example how to add several
> items at the same time?
>

If you've got a script that parses the Excel file I'm not sure why you have
a pasting via the shell part involved at all -- why not just change the
script to issue directly whatever commands you are pasting into the shell
instead?  Doing anything interactive, whether in the admin interface or
manage.py shell, is much more cumbersome than just having a script do the
bulk data importing.  You also then bypass any issues specific to the
Windows command prompt and its character set issues.  But if the root of the
problem is the source encoding for your data, then bypassing the shell isn't
going to help, so again more information about what exactly is going wrong
would help people help you.

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: Can I overwrite the ModelAdmin for User

2009-02-16 Thread Alex Gaynor
On Mon, Feb 16, 2009 at 7:13 PM, Kevin Audleman wrote:

>
> Alex,
>
> I feel like I'm one step closer to getting this to work. From the
> documentation you sent my way, it seems like what I would do would be
> to create a method on the User object which will span the relationship
> and grab the value:,
>
> def get_payment_status(self):
>return self.myprofile_set.all()[0].payment_status
>
> However I am working with the core User object which I didn't write.
> Am I SOL, or is there some way I can do this.
>
> Thanks,
> Kevin
>
>
> On Feb 16, 4:02 pm, Alex Gaynor  wrote:
> > On Mon, Feb 16, 2009 at 6:59 PM, Kevin Audleman <
> kevin.audle...@gmail.com>wrote:
> >
> >
> >
> >
> >
> > > Thanks!
> >
> > > I've got my new User display going and another question has come up.
> > > In the related MyProfile object, I've got a field called
> > > payment_status. It's important for my client to be able to quickly
> > > view a list of users with a payment_status of 'Unpaid.' Is there a way
> > > to add a related field to the list_display or list_filter sets for the
> > > User object?
> >
> > > Cheers,
> > > Kevin
> >
> > > On Feb 16, 3:45 pm, Alex Gaynor  wrote:
> > > > On Mon, Feb 16, 2009 at 6:27 PM, Kevin Audleman <
> > > kevin.audle...@gmail.com>wrote:
> >
> > > > > I've created a custom profile per the instructions in chapter 12 of
> > > > > the book to give my user's fields like address1, address2, etc.
> > > > > Currently when I log in to the admin and want to update a user, I
> have
> > > > > to go to two separate pages: the User page to update core user
> fields,
> > > > > and the Profile page to update fields in the profiles.
> >
> > > > > I would like to overwrite the ModelAdmin for the User object and
> > > > > inline the Profile object so that all fields for a user can be
> edited
> > > > > from one page. However django is throwing an error when I try to do
> > > > > so:
> >
> > > > > AlreadyRegistered at /admin/
> > > > > The model User is already registered
> >
> > > > > Here's the code:
> >
> > > > > class ProfileInline(admin.TabularInline):
> > > > >model = MyProfile
> >
> > > > > class UserAdmin(admin.ModelAdmin):
> > > > >list_display = ('username', 'email', 'first_name', 'last_name',
> > > > > 'is_staff')
> > > > >list_filter = ('is_staff', 'is_superuser')
> > > > >inlines = [ProfileInline]
> >
> > > > > admin.site.register(User, UserAdmin)
> >
> > > > > Is there a way to do this?
> >
> > > > > Thanks,
> > > > > Kevin Audleman
> >
> > > > Yes just do admin.site.unregister(User) before registering yours.
> >
> > > > 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 can add it to the list_display by creating a method on the model for
> it(http://docs.djangoproject.com/en/dev/ref/contrib/admin/#list-display)
> and
> > perhaps use the boolean option to make it more obvious.  Right now you
> can't
> > actually use related fields in list_filter:
> http://code.djangoproject.com/ticket/3400
> >
> > 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 can also just write a method on the ModelAdmin itself, as the examples
show.

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: Can I overwrite the ModelAdmin for User

2009-02-16 Thread Kevin Audleman

Alex,

I feel like I'm one step closer to getting this to work. From the
documentation you sent my way, it seems like what I would do would be
to create a method on the User object which will span the relationship
and grab the value:,

def get_payment_status(self):
return self.myprofile_set.all()[0].payment_status

However I am working with the core User object which I didn't write.
Am I SOL, or is there some way I can do this.

Thanks,
Kevin


On Feb 16, 4:02 pm, Alex Gaynor  wrote:
> On Mon, Feb 16, 2009 at 6:59 PM, Kevin Audleman 
> wrote:
>
>
>
>
>
> > Thanks!
>
> > I've got my new User display going and another question has come up.
> > In the related MyProfile object, I've got a field called
> > payment_status. It's important for my client to be able to quickly
> > view a list of users with a payment_status of 'Unpaid.' Is there a way
> > to add a related field to the list_display or list_filter sets for the
> > User object?
>
> > Cheers,
> > Kevin
>
> > On Feb 16, 3:45 pm, Alex Gaynor  wrote:
> > > On Mon, Feb 16, 2009 at 6:27 PM, Kevin Audleman <
> > kevin.audle...@gmail.com>wrote:
>
> > > > I've created a custom profile per the instructions in chapter 12 of
> > > > the book to give my user's fields like address1, address2, etc.
> > > > Currently when I log in to the admin and want to update a user, I have
> > > > to go to two separate pages: the User page to update core user fields,
> > > > and the Profile page to update fields in the profiles.
>
> > > > I would like to overwrite the ModelAdmin for the User object and
> > > > inline the Profile object so that all fields for a user can be edited
> > > > from one page. However django is throwing an error when I try to do
> > > > so:
>
> > > > AlreadyRegistered at /admin/
> > > > The model User is already registered
>
> > > > Here's the code:
>
> > > > class ProfileInline(admin.TabularInline):
> > > >    model = MyProfile
>
> > > > class UserAdmin(admin.ModelAdmin):
> > > >    list_display = ('username', 'email', 'first_name', 'last_name',
> > > > 'is_staff')
> > > >    list_filter = ('is_staff', 'is_superuser')
> > > >    inlines = [ProfileInline]
>
> > > > admin.site.register(User, UserAdmin)
>
> > > > Is there a way to do this?
>
> > > > Thanks,
> > > > Kevin Audleman
>
> > > Yes just do admin.site.unregister(User) before registering yours.
>
> > > 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 can add it to the list_display by creating a method on the model for 
> it(http://docs.djangoproject.com/en/dev/ref/contrib/admin/#list-display) and
> perhaps use the boolean option to make it more obvious.  Right now you can't
> actually use related fields in 
> list_filter:http://code.djangoproject.com/ticket/3400
>
> 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: Disabling middleware for tests

2009-02-16 Thread felix
ah ha.

yes, I've wasted several hours over this issue.  it took me a while to
figure out that it was the CSRF middleware that was breaking the tests.
both auth tests and actually every single one that tests the posting of
forms.

I didn't see it mention of this issue in either the CSRF docs or the unit
test docs, but those are both places that we would first look to diagnose.
a docs request ticket should be filed.  I couldn't find one existing.

I thought it was something to do with self.client.login failing (because I
would get 403)



I couldn't figure this out: is there a way to tell that we are running as a
test ?



 felix :crucial-systems.com




On Mon, Feb 16, 2009 at 9:33 PM, stryderjzw  wrote:

>
>
> > from settings import *
> >
> > #CSRFMiddleware breaks authtests
> > MIDDLEWARE_CLASSES = list(MIDDLEWARE_CLASSES)
> > MIDDLEWARE_CLASSES.remove
> > ('django.contrib.csrf.middleware.CsrfMiddleware')
> >
> > # Turn this off to allowteststhat look at http status to pass
> > PREPEND_WWW = False
>

sorry, I don't get this.  what fails ?  response.status_code == 200 ?





>
> >
> > I then run the test suite using this command:
> > python manage.py test --settings=mysite.settings-test.py
> >
> > Best,
> > Dave
> >
>
>

--~--~-~--~~~---~--~~
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 I overwrite the ModelAdmin for User

2009-02-16 Thread Alex Gaynor
On Mon, Feb 16, 2009 at 6:59 PM, Kevin Audleman wrote:

>
> Thanks!
>
> I've got my new User display going and another question has come up.
> In the related MyProfile object, I've got a field called
> payment_status. It's important for my client to be able to quickly
> view a list of users with a payment_status of 'Unpaid.' Is there a way
> to add a related field to the list_display or list_filter sets for the
> User object?
>
> Cheers,
> Kevin
>
> On Feb 16, 3:45 pm, Alex Gaynor  wrote:
> > On Mon, Feb 16, 2009 at 6:27 PM, Kevin Audleman <
> kevin.audle...@gmail.com>wrote:
> >
> >
> >
> >
> >
> > > I've created a custom profile per the instructions in chapter 12 of
> > > the book to give my user's fields like address1, address2, etc.
> > > Currently when I log in to the admin and want to update a user, I have
> > > to go to two separate pages: the User page to update core user fields,
> > > and the Profile page to update fields in the profiles.
> >
> > > I would like to overwrite the ModelAdmin for the User object and
> > > inline the Profile object so that all fields for a user can be edited
> > > from one page. However django is throwing an error when I try to do
> > > so:
> >
> > > AlreadyRegistered at /admin/
> > > The model User is already registered
> >
> > > Here's the code:
> >
> > > class ProfileInline(admin.TabularInline):
> > >model = MyProfile
> >
> > > class UserAdmin(admin.ModelAdmin):
> > >list_display = ('username', 'email', 'first_name', 'last_name',
> > > 'is_staff')
> > >list_filter = ('is_staff', 'is_superuser')
> > >inlines = [ProfileInline]
> >
> > > admin.site.register(User, UserAdmin)
> >
> > > Is there a way to do this?
> >
> > > Thanks,
> > > Kevin Audleman
> >
> > Yes just do admin.site.unregister(User) before registering yours.
> >
> > 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 can add it to the list_display by creating a method on the model for it(
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#list-display) and
perhaps use the boolean option to make it more obvious.  Right now you can't
actually use related fields in list_filter:
http://code.djangoproject.com/ticket/3400

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: Can I overwrite the ModelAdmin for User

2009-02-16 Thread Kevin Audleman

Thanks!

I've got my new User display going and another question has come up.
In the related MyProfile object, I've got a field called
payment_status. It's important for my client to be able to quickly
view a list of users with a payment_status of 'Unpaid.' Is there a way
to add a related field to the list_display or list_filter sets for the
User object?

Cheers,
Kevin

On Feb 16, 3:45 pm, Alex Gaynor  wrote:
> On Mon, Feb 16, 2009 at 6:27 PM, Kevin Audleman 
> wrote:
>
>
>
>
>
> > I've created a custom profile per the instructions in chapter 12 of
> > the book to give my user's fields like address1, address2, etc.
> > Currently when I log in to the admin and want to update a user, I have
> > to go to two separate pages: the User page to update core user fields,
> > and the Profile page to update fields in the profiles.
>
> > I would like to overwrite the ModelAdmin for the User object and
> > inline the Profile object so that all fields for a user can be edited
> > from one page. However django is throwing an error when I try to do
> > so:
>
> > AlreadyRegistered at /admin/
> > The model User is already registered
>
> > Here's the code:
>
> > class ProfileInline(admin.TabularInline):
> >    model = MyProfile
>
> > class UserAdmin(admin.ModelAdmin):
> >    list_display = ('username', 'email', 'first_name', 'last_name',
> > 'is_staff')
> >    list_filter = ('is_staff', 'is_superuser')
> >    inlines = [ProfileInline]
>
> > admin.site.register(User, UserAdmin)
>
> > Is there a way to do this?
>
> > Thanks,
> > Kevin Audleman
>
> Yes just do admin.site.unregister(User) before registering yours.
>
> 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: site.title does not show in child flatpages templates

2009-02-16 Thread Malcolm Tredinnick

On Mon, 2009-02-16 at 13:40 -0800, Manuel Ignacio wrote:
> Hi, when i load my site i have the next code in my view:
> 
> current_site = Site.objects.get_current()
> def default_index(request):
> return render_to_response('doorsFront/default_index.html',
> {'current_site':current_site})

This has nothing to do with the problem at hand, since flatpages don't
call your own views.

[...]
> and at the moment of viewing a flatpage, the title doesn't show, i
> think taht the reason is because i've passed de current_site object
> like a parameter in my view code, and the flatpages url doesn't know
> anyting about this parameter, but i don't know how to fix it.

Depends what you intend to have happen.

Flatpages do not receive any information about the current site id. So
you could either restructure your template to display the site id if
that variable is present or display something else by default. Or you
would need to write your own template tag to retrieve the site id.

Regards,
Malcolm



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



Re: Settings for an application - define as a model?

2009-02-16 Thread Alex Gaynor
On Mon, Feb 16, 2009 at 6:29 PM, Russell Keith-Magee  wrote:

>
> On Tue, Feb 17, 2009 at 6:24 AM, Rob  wrote:
> >
> > I'm writing a Django app to act as the front-end interface to a backup
> > application, using MySQL as the database. I need to store some
> > variables to act as the "global" settings specific to my app - like
> > UNIX backup location, etc.
> >
> > At present I have a model called Setting, with two fields - name and
> > value. The problem with this, however, is that if the project is reset
> > - as it often is at the moment as I am playing around with the models
> > a lot - all the rows in the settings table are lost, and therefore all
> > the values.
> >
> > Is there a commonly "accepted" way to achieve what I am doing here?
> > How does one store variables which don't really conform strictly to
> > the "model". I want these values to be changeable via views in the web
> > interface.
>
> There's really only two places you can store this sort of thing -
> settings files, or a model. If you put it in a settings file, it won't
> get lost in a reset, but users won't be able to change them; if you
> put them in a model, users will change them, but they will be
> susceptible to loss.
>
> If you need users to be able to change the values, then using the
> settings file obviously isn't an option. This just leaves using
> tables, and managing the reset process so you don't lose data.
>
> Django doesn't have anything built-in to make sure data isn't lost
> during a reset - mostly because the point of a reset is to lose data
> :-) However, you can use the dumpdata and loaddata management commands
> to make it easier to save and restore specific table data; you can
> also use the initial_data fixture to ensure than an application always
> has appropriate initial values.
>
> Also - I would be remiss if I didn't point you at a reusable app that
> was designed specifically for this problem:
>
> http://code.google.com/p/django-values/
>
> I haven't used it myself, but Marty is a well respected member of the
> Django community, so I'm fairly confident his code will be fairly
> usable.
>
> Yours,
> Russ Magee %-)
>
> >
>
I don't know how well Marty maintains it, but if it doesn't work out for you
the satchmo guys have a nice fork of it that's obviously actively worked on,
so you can always use it(with minimal other bits from stachmo) if it works
better for 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: Can I overwrite the ModelAdmin for User

2009-02-16 Thread Alex Gaynor
On Mon, Feb 16, 2009 at 6:27 PM, Kevin Audleman wrote:

>
> I've created a custom profile per the instructions in chapter 12 of
> the book to give my user's fields like address1, address2, etc.
> Currently when I log in to the admin and want to update a user, I have
> to go to two separate pages: the User page to update core user fields,
> and the Profile page to update fields in the profiles.
>
> I would like to overwrite the ModelAdmin for the User object and
> inline the Profile object so that all fields for a user can be edited
> from one page. However django is throwing an error when I try to do
> so:
>
> AlreadyRegistered at /admin/
> The model User is already registered
>
>
> Here's the code:
>
> class ProfileInline(admin.TabularInline):
>model = MyProfile
>
> class UserAdmin(admin.ModelAdmin):
>list_display = ('username', 'email', 'first_name', 'last_name',
> 'is_staff')
>list_filter = ('is_staff', 'is_superuser')
>inlines = [ProfileInline]
>
> admin.site.register(User, UserAdmin)
>
> Is there a way to do this?
>
> Thanks,
> Kevin Audleman
> >
>
Yes just do admin.site.unregister(User) before registering yours.

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: Settings for an application - define as a model?

2009-02-16 Thread Russell Keith-Magee

On Tue, Feb 17, 2009 at 6:24 AM, Rob  wrote:
>
> I'm writing a Django app to act as the front-end interface to a backup
> application, using MySQL as the database. I need to store some
> variables to act as the "global" settings specific to my app - like
> UNIX backup location, etc.
>
> At present I have a model called Setting, with two fields - name and
> value. The problem with this, however, is that if the project is reset
> - as it often is at the moment as I am playing around with the models
> a lot - all the rows in the settings table are lost, and therefore all
> the values.
>
> Is there a commonly "accepted" way to achieve what I am doing here?
> How does one store variables which don't really conform strictly to
> the "model". I want these values to be changeable via views in the web
> interface.

There's really only two places you can store this sort of thing -
settings files, or a model. If you put it in a settings file, it won't
get lost in a reset, but users won't be able to change them; if you
put them in a model, users will change them, but they will be
susceptible to loss.

If you need users to be able to change the values, then using the
settings file obviously isn't an option. This just leaves using
tables, and managing the reset process so you don't lose data.

Django doesn't have anything built-in to make sure data isn't lost
during a reset - mostly because the point of a reset is to lose data
:-) However, you can use the dumpdata and loaddata management commands
to make it easier to save and restore specific table data; you can
also use the initial_data fixture to ensure than an application always
has appropriate initial values.

Also - I would be remiss if I didn't point you at a reusable app that
was designed specifically for this problem:

http://code.google.com/p/django-values/

I haven't used it myself, but Marty is a well respected member of the
Django community, so I'm fairly confident his code will be fairly
usable.

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



Can I overwrite the ModelAdmin for User

2009-02-16 Thread Kevin Audleman

I've created a custom profile per the instructions in chapter 12 of
the book to give my user's fields like address1, address2, etc.
Currently when I log in to the admin and want to update a user, I have
to go to two separate pages: the User page to update core user fields,
and the Profile page to update fields in the profiles.

I would like to overwrite the ModelAdmin for the User object and
inline the Profile object so that all fields for a user can be edited
from one page. However django is throwing an error when I try to do
so:

AlreadyRegistered at /admin/
The model User is already registered


Here's the code:

class ProfileInline(admin.TabularInline):
model = MyProfile

class UserAdmin(admin.ModelAdmin):
list_display = ('username', 'email', 'first_name', 'last_name',
'is_staff')
list_filter = ('is_staff', 'is_superuser')
inlines = [ProfileInline]

admin.site.register(User, UserAdmin)

Is there a way to do this?

Thanks,
Kevin Audleman
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



site.title does not show in child flatpages templates

2009-02-16 Thread Manuel Ignacio

Hi, when i load my site i have the next code in my view:

current_site = Site.objects.get_current()
def default_index(request):
   return render_to_response('doorsFront/default_index.html',
{'current_site':current_site})

I load the site name in my template and i extend this template por
evereting at mi web site.
this is the template code:


 {% block title %}{{current_site.name}}{% endblock %}


When i have the defatul.htlm page for flatpages, i have this:

{% extends "doorsFront/default_index.html" %}
{% block title %}{{current_site.name}} My page{% endblock%}
{% block content %}
 {{ flatpage.title }}
   {{ flatpage.content }}
{% endblock %}


and at the moment of viewing a flatpage, the title doesn't show, i
think taht the reason is because i've passed de current_site object
like a parameter in my view code, and the flatpages url doesn't know
anyting about this parameter, but i don't know how to fix it.

Thanks very much
Best regards

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



site.title does not show in child flatpages templates

2009-02-16 Thread Manuel Ignacio

Hi, when i load my site i have the next code in my view:

current_site = Site.objects.get_current()
def default_index(request):
return render_to_response('doorsFront/default_index.html',
{'current_site':current_site})

I load the site name in my template and i extend this template por
evereting at mi web site.
this is the template code:


 {% block title %}{{current_site.name}}{% endblock %}


When i have the defatul.htlm page for flatpages, i have this:

{% extends "doorsFront/default_index.html" %}
{% block title %}{{current_site.name}} My page{% endblock%}
{% block content %}
  {{ flatpage.title }}
{{ flatpage.content }}
{% endblock %}


and at the moment of viewing a flatpage, the title doesn't show, i
think taht the reason is because i've passed de current_site object
like a parameter in my view code, and the flatpages url doesn't know
anyting about this parameter, but i don't know how to fix it.

Thanks very much
Best regards

--~--~-~--~~~---~--~~
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: mptt usage

2009-02-16 Thread Francis

Do you have any suggestion for a better alternative?



On Feb 3, 3:58 pm, adelevie  wrote:
> mptta is slow as hell
>
> On Feb 3, 4:50 am, vicalloy  wrote:
>
> > I thinkmptthave good doc.http://code.google.com/p/django-mptt/
> >mpttjust a set of function to build tree efficient.
>
> > 2009/2/3 Muslu Yüksektepe :
>
> > > i did try it too but i deleted.
>
> > > 2009/2/3 new_user 
>
> > >> Hi, everyone.
>
> > >> Recently I've installedmpttapp on my project. But I cannot find out
> > >> how to use it. Should I use it's functions manually, or could I use
> > >> admin interface to order my models in tree structure?
>
> > >> Thx in advance.
>
>
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Settings for an application - define as a model?

2009-02-16 Thread Rob

I'm writing a Django app to act as the front-end interface to a backup
application, using MySQL as the database. I need to store some
variables to act as the "global" settings specific to my app - like
UNIX backup location, etc.

At present I have a model called Setting, with two fields - name and
value. The problem with this, however, is that if the project is reset
- as it often is at the moment as I am playing around with the models
a lot - all the rows in the settings table are lost, and therefore all
the values.

Is there a commonly "accepted" way to achieve what I am doing here?
How does one store variables which don't really conform strictly to
the "model". I want these values to be changeable via views in the web
interface.

Thanks for any input,

Rob

--~--~-~--~~~---~--~~
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 an ImageField file without re-upload

2009-02-16 Thread Carmelly

My situation is this: I want to allow my users to upload multiple
userpics and then choose between them. So I have a Profile model with
an ImageField for the userpic. When users upload a file it is
displayed around the site as usual. When they upload a new file, that
file replaces their the "userpic" field in their Profile and is
displayed all over the site, but the old userpic is not overwritten on
disk. This is what we want.

Now, if I display a page for the user with all the userpics they ever
uploaded and let them choose between them, how can I set the path in
the ImageField to the file the chose? I know there is a userpic.save()
method, but I'm not sure what to pass into it, or if this is even the
correct way to go about 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: Signals getting sent twice

2009-02-16 Thread stevedegrace

Figured it out myself... you have to set dispatch_uid for the connect
methods. See modification below to the last three lines of my example
above. It's still annoying that the overhead of module import is
apparently being incurred twice, but at least things work the way you
expect. Aside from this bit of weirdness, the signalling framework is
awesome, but it does seem to reveal an unfortunate characteristic of
Django itself.

comment_will_be_posted.connect(pre_comment, Comment,
dispatch_uid='comments.pre_comment')
comment_was_posted.connect(post_comment, Comment,
dispatch_uid='comments.post_comment')
comment_was_flagged.connect(flag_comment, Comment,
dispatch_uid='comments.flag_comment')

On Feb 15, 8:46 pm, stevedegrace  wrote:
> I realise going through Google that this has been hashed over before,
> but nevertheless, I want to know if there is any new thought on this.
> Ever since I removed project references from imports in my code, I
> have noticed a new problem whereby many functions connected to signals
> are being called twice. I don't know if that caused the problem, but
> it seems likely because everything I've been reading tracks the
> problem down to imports.
>
> A good example is in my __init__.py for my comments application, which
> is basically just a bunch of customizations to the Django comments
> application. That one has no imports of any of my models in it. It is
> posted below.
>
> This is a real pain. Is there any way to make it not do this, short of
> going through my code and making all my imports through the project
> again? Maybe that wouldn't even help. I tried making selected imports,
> e.g., through the list of installed apps in settings.py import through
> the project name again but that didn't fix it, so I don't see an easy
> hack.
>
> The same thing is happening whether I'm using manage.py runserver at
> home or Apache2/mod_wsgi2 on Webfaction. On Webfaction I have no
> choice but to have both the project directory and the directory
> containing it on my path or I get Apache 500 errors, the only way I
> can make my application load is to have both on the path.
>
> This is really awful behaviour - it's probably the ugliest wart (maybe
> the only significant one, but still) I have ever found in Django, and
> it sucks because my applications are using signals a lot. I hope
> there's a way around it.
>
> Stephen
>
> from django.contrib.comments.signals import comment_will_be_posted,
> comment_was_posted, comment_was_flagged
> from django.contrib.comments.models import Comment
> from django.contrib.sites.models import Site
> from django.template import Context, loader
> from django.core.mail import send_mail
> from django.conf import settings
>
> def pre_comment(sender, comment, request, **kwargs):
>     if not request.user.is_authenticated:
>         comment.is_removed = True
>
> def post_comment(sender, comment, request, **kwargs):
>     if comment.is_removed:
>         comment.delete()
>     else:
>         request.session['flash'].append('Thank you for your
> comments.')
>         request.session.modified = True
>         site = Site.objects.get_current()
>         template = loader.get_template('comments/comment_email.html')
>         context = Context({
>                 'comment': comment,
>                 'protocol': 'https' if request.is_secure() else
> 'http',
>                 'site': site,
>             })
>         send_mail("A comment was posted at %s" % site.name,
>             template.render(context), getattr(settings,
> 'DEFAULT_FROM_EMAIL', None),
>             getattr(settings, 'MODERATOR_EMAILS', None))
>
> def flag_comment(sender, comment, flag, created, request, **kwargs):
>     site = Site.objects.get_current()
>     template = loader.get_template('comments/comment_flag_email.html')
>     context = Context({
>             'comment': comment,
>             'flagged_by': request.user,
>             'protocol': 'https' if request.is_secure() else 'http',
>             'site': site,
>         })
>     send_mail("A comment was flagged by %s" % request.user.username,
>         template.render(context), getattr(settings,
> 'DEFAULT_FROM_EMAIL', None),
>         getattr(settings, 'MODERATOR_EMAILS', None))
>
> comment_will_be_posted.connect(pre_comment, Comment)
> comment_was_posted.connect(post_comment, Comment)
> comment_was_flagged.connect(flag_comment, Comment)
--~--~-~--~~~---~--~~
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 views to admin interface

2009-02-16 Thread Robert

Well then, now I have added my custom view to admin interface by
altering the template index.html. I added the following:


Diagramm

Chart
 
 



wrote a view and put both together in url.py. The problem is, as
thought before, that I have no idea how to check if an user has the
permission to this view and if not he shouldn't see the above section.
Would it be best to write my own permission in the permission table in
mysql, so that I can give the permission to groups or users via the
admin interface? How do I check if a user has the permission for the
view?
What is the best solution to hide the above code if a user has no
permission for that view?
When I choose one of my application names, the django admin hides all
the other apps automatically. How can I add this behavior to my custom
view?
A lot of questions, I hope somebody can help me...

Thanks and greetz Robert


On 16 Feb., 10:45, Ales Zoulek  wrote:
> > Once you have added a new HTML link to the template that will trigger
> > your view, you have to write a view for it. You add something to one of
> > your URL Conf files to catch the URL (do this *before* any admin
> > patterns are processed, so that your pattern is handled first) and send
> > it off to the view you have written. That view will just be a normal
> > Django view, so you can use the normal permission decorators on the view
> > if you like.
>
> Or you can overload __call__ method of ModelAdmin class.
> class PersonAdmin(admin.ModelAdmin):
>   def __call__(self, request, url, *a, **k):
>     if url.startswith('mypath'):
>        return my_view(request)
>     return super(PersonAdmin, self).__call__(request, url, *a, **k)
>
> You still need to link it from custom admin template.
>
> A.
>
>
>
> > Regards,
> > Malcolm
>
> --
> --
> Ales Zoulek
> +420 604 332 515
> Jabber: ales.zou...@gmail.com
> --
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Different ways of working against a SQLite3 dB

2009-02-16 Thread DaSa


Thx for your tips!

I tried to update my Python version but it did not work.

Today I have my data in an Excel document, and I have a script that
parse the excel document and creates sql-commands that I paste in the
SQL shell. But as you know I have the problem with swedish signs.

I shall try to use the admin interface instead, but today I can only
add one item at the time. Do you know any example how to add several
items at the same time?


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



creating links from inline within admin

2009-02-16 Thread Mark (Nosrednakram)

Hello,

models
  person
  organization

fk relationship between person and organization, i.e. an organization
consists of people.

I would like to list the people using an inline form in admin with a
like back to the person and have the person added to the organization
in the person form.  The main reason the the overhead for drop down
boxes with thousands of people and hundreds of members.

I have created a template and assigned it using the inline.
Changed to using raw_id_fields to limit the amount of information to
process

I would like to do something like this in the inner loop in the
template by can't find a way to do it:

{{ person.first_name}}

Any help appreciated, I have searched the archives an am not finding
anything with the terms I am using.  I am no afraid to extend classes
is someone can advise me on where I might start on this.

Thank you,
Mark
--~--~-~--~~~---~--~~
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: Disabling middleware for tests

2009-02-16 Thread stryderjzw

This doesn't seem to be working for me.

I created my own test_settings.py in the project root directory.

I ran
python manage.py test --settings=test_settings

It runs as usual and CSRF still fails when I run tests.

Anyone know what I might be doing wrong here? How can I tell that
python manage.py has accepted my test_settings?

On Jan 26, 10:16 am, davenaff  wrote:
> Malcolm,
>
> Thanks a lot for the pointer.  For anyone else interested, here is
> what my settings-test.py looks like:
>
> from settings import *
>
> #CSRFMiddleware breaks authtests
> MIDDLEWARE_CLASSES = list(MIDDLEWARE_CLASSES)
> MIDDLEWARE_CLASSES.remove
> ('django.contrib.csrf.middleware.CsrfMiddleware')
>
> # Turn this off to allowteststhat look at http status to pass
> PREPEND_WWW = False
>
> I then run the test suite using this command:
> python manage.py test --settings=mysite.settings-test.py
>
> Best,
> Dave
>
> On Jan 22, 4:50 pm, Malcolm Tredinnick 
> wrote:
>
> > On Thu, 2009-01-22 at 15:17 -0800,davenaffwrote:
> > > What is the best way to disable a specific middleware when running
> > > djangotests?
>
> > > This ticket was designated wontfix, so I get test failures on the auth
> > >testsevery time I run our test suite:
> > >http://code.djangoproject.com/ticket/9172#comment:12
>
> > > I'd prefer not to have to edit settings.py every time I run ourtests,
> > > and of course I don't liketeststhat fail...
>
> > Create a settings file for your testing purposes. It imports your
> > standard settings file and then modifies any settings that are specific
> > for thetests(e.g. altering the MIDDLEWARE_CLASSES tuple).
>
> > Regards,
> > Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: cache.get_model() vs. models.get_model()

2009-02-16 Thread richleland

Ah I didn't realize - thanks for the quick response!

On Feb 16, 3:14 pm, Alex Gaynor  wrote:
> On Mon, Feb 16, 2009 at 3:10 PM, richleland  wrote:
>
> > Is there any advantage/disadvantage to using cache.get_model() vs.
> > models.get_model() in an admin.py file? I'm assuming that
> > cache.get_model() provides quicker access, but just wanted to see if
> > there were any drawbacks.
>
> > A simple example of each usage is below:
>
> > from django.contrib import admin
> > from django.db.models import get_model
>
> > ...
> > model admin code here
> > ...
>
> > admin.site.register(get_model('app', 'model), MyModelAdmin)
>
> > OR
>
> > from django.contrib import admin
> > from django.db.models.loading import cache
>
> > ...
> > model admin code here
> > ...
>
> > admin.site.register(cache.get_model('app', 'model), MyModelAdmin)
>
> > Thanks in advance!
> > Rich
>
> They are exactly the same as you can see from the 
> source:http://code.djangoproject.com/browser/django/trunk/django/db/models/l...
>
> access without the .cache. exists solely for backwards compatibility.
>
> 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
-~--~~~~--~~--~--~---



Date Formating

2009-02-16 Thread ReneMarxis

Hello

i am having some problems getting date-formating running ...

here is some code-snippet i use in my app
http://dpaste.com/121354/

The form shows up ok. If i enter valid data everything is ok. But if i
enter invalid data or none the form will be empty. There is no
validation error showing up, just nothing.
The validation rules are the once entered in DateFormattedTextInput
(format='d.m.Y'). I can check that by entering data only valid for
that formater.

So. Can anyone give me some hint where to look next? I am a little bit
lost.

Or even better: Is there one way to specify date/time/datetime formats
for the whole app? I thought of using technical message ids and
localization, but i was told that will also not work.

Many thanks in advance.


--~--~-~--~~~---~--~~
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 Template Hyphenated Keys

2009-02-16 Thread bfrederi

I have a dictionary of dictionaries that I want to use in a template.
Unfortunately some of the keys are hyphenated (I can't change it), so
when I try to call them in the template using {{ dictionary.key-
name }} it doesn't work:

Could not parse the remainder: '-qualifiers' from
'display.vocabularies.agent-qualifiers'

Is there a simple work around method for this in Django that I haven't
picked up yet? Or is this something that I will have to create a
special work around for? Any suggestions?
--~--~-~--~~~---~--~~
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: cache.get_model() vs. models.get_model()

2009-02-16 Thread Alex Gaynor
On Mon, Feb 16, 2009 at 3:10 PM, richleland  wrote:

>
> Is there any advantage/disadvantage to using cache.get_model() vs.
> models.get_model() in an admin.py file? I'm assuming that
> cache.get_model() provides quicker access, but just wanted to see if
> there were any drawbacks.
>
> A simple example of each usage is below:
>
> from django.contrib import admin
> from django.db.models import get_model
>
> ...
> model admin code here
> ...
>
> admin.site.register(get_model('app', 'model), MyModelAdmin)
>
> OR
>
> from django.contrib import admin
> from django.db.models.loading import cache
>
> ...
> model admin code here
> ...
>
> admin.site.register(cache.get_model('app', 'model), MyModelAdmin)
>
> Thanks in advance!
> Rich
>
> >
>
They are exactly the same as you can see from the source:
http://code.djangoproject.com/browser/django/trunk/django/db/models/loading.py#L178

access without the .cache. exists solely for backwards compatibility.

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



cache.get_model() vs. models.get_model()

2009-02-16 Thread richleland

Is there any advantage/disadvantage to using cache.get_model() vs.
models.get_model() in an admin.py file? I'm assuming that
cache.get_model() provides quicker access, but just wanted to see if
there were any drawbacks.

A simple example of each usage is below:

from django.contrib import admin
from django.db.models import get_model

...
model admin code here
...

admin.site.register(get_model('app', 'model), MyModelAdmin)

OR

from django.contrib import admin
from django.db.models.loading import cache

...
model admin code here
...

admin.site.register(cache.get_model('app', 'model), MyModelAdmin)

Thanks in advance!
Rich

--~--~-~--~~~---~--~~
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: Question about class variables

2009-02-16 Thread bruno desthuilliers

On 16 fév, 20:33, MV  wrote:
> Hi there,
>
> I have a question about class variables in Django.  If I create a
> custom field, e.g.
>
> class TinyMCEField(models.Field):
> superadmin = False
> def formfield(self, **kwargs):
> if superadmin:
>  defaults = {'widget':TinyMCE(... blah blah blah})}
> else:
>  defaults = {'widget':TinyMCE(... blah blah blah})}

Actually, this code will raise a NameError on the first line of the
formfield function.

> And if use middleware to change the value of TinyMCEField.superadmin
> to True or False depending on information in request.user, is the
> change to the class variable scoped only to that request?

Practically, the answer is a very clear "no".

> Or am I
> doing something dangerous?

You are.


--~--~-~--~~~---~--~~
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: Context processor or make custom tag

2009-02-16 Thread basoko

After read you I've decided to do a tag, I think that it's the best way to do 
it. About the calls to the database I can that it's no problem because in the 
future I could use cache system so it's no problem.

Thanks for your help and recommendations, it's been very good and I'm so happy 
with this group.

If my job give me some free time, I'll try to participate more.

>On Wednesday 11 February 2009 22:44:52 Michael Newman wrote:
> > Hi all,
> >
> > I'm new in this group and I have to say that my English is very poor
> > so sorry.
>
> Welcome to the group!
>
> > I've the follow problem, I want to put in one of my base templates
> > (that it's include in main base template) a list of one model, for
> > example a Category model that has a relationship with other model like
> > Post (this has a ForeignKey with Category).
> >
> > I can do it by two ways. I can create a context processor where I can
> > retrive all category's objects and put them in the context so I could
> > access them through all templates, or I can make a new tag where I can
> > do the same and use it in that template.
>
> As a general rule context processors are great when you need the
> information on any page at any given time. Template tags are good when
> you need information in certain places.
>
> > I don't know which is better and why, and if you've other ideas to do
> > it I'm very interested in know them.
>
> In reality they both do the same thing and it is up to you how they
> work. Think of it as over head. Without any caching in place a context
> processor will make a call to the database (or multiple calls) for
> every page that is loaded. A template tag will only be loaded on the
> pages you load it on and only call the database when you call the tag.
> it up to you if you need it that much.
>
> I recommend you use django-logging and view your SQL queries. It is
> always a good thing to see if your page loads are much heavier than
> you expect. Then you can decide on how you want to hit your db,
> whether it be with a selectively chosen template tag or a brute force
> context processor.
>
> > Thanks and sorry about my english.
>
> No problem and don't be sorry, your English is great,
>
> Michael
> 
-- 
David Basoko


--~--~-~--~~~---~--~~
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: Question about class variables

2009-02-16 Thread Alex Gaynor
On Mon, Feb 16, 2009 at 2:33 PM, MV  wrote:

>
> Hi there,
>
> I have a question about class variables in Django.  If I create a
> custom field, e.g.
>
> class TinyMCEField(models.Field):
>superadmin = False
>def formfield(self, **kwargs):
>if superadmin:
> defaults = {'widget':TinyMCE(... blah blah blah})}
>else:
> defaults = {'widget':TinyMCE(... blah blah blah})}
>
> And if use middleware to change the value of TinyMCEField.superadmin
> to True or False depending on information in request.user, is the
> change to the class variable scoped only to that request? Or am I
> doing something dangerous?
> >
>
Nope, that change will be to the entire python process, so that's not how
you want to handle it.

Alex

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

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



Question about class variables

2009-02-16 Thread MV

Hi there,

I have a question about class variables in Django.  If I create a
custom field, e.g.

class TinyMCEField(models.Field):
superadmin = False
def formfield(self, **kwargs):
if superadmin:
 defaults = {'widget':TinyMCE(... blah blah blah})}
else:
 defaults = {'widget':TinyMCE(... blah blah blah})}

And if use middleware to change the value of TinyMCEField.superadmin
to True or False depending on information in request.user, is the
change to the class variable scoped only to that request? Or am I
doing something dangerous?
--~--~-~--~~~---~--~~
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: BINARY columns

2009-02-16 Thread Alex Gaynor
On Mon, Feb 16, 2009 at 2:19 PM, Andy Dustman  wrote:

>
> I'm working on a custom field type for Django which depends on being
> able to save data in a BINARY column. (Not a big BLOB, just a couple
> of bytes.) Unfortunately Django (trunk and probably 1.0) keeps trying
> to turn it into unicode which fails. I'm now using patch.3.txt on
> http://code.djangoproject.com/ticket/2417 and that seems to be doing
> the job. What are the chances of something like this making it into
> Django-1.1?
> Looks like we might be past the feature freeze according to the 1.1
> roadmap.
> --
> Patriotism means to stand by the country. It does
> not mean to stand by the president. -- T. Roosevelt
>
> MANDATED GOVERNMENT HEALTH WARNING:
> Government mandates may be hazardous to your health.
>
> This message has been scanned for memes and
> dangerous content by MindScanner, and is
> believed to be unclean.
>
> >
>
While we are technically past the feature freeze now, as a practical matter
there are several features for 1.1 that I believe we still want to get in,
so even though we aren't implementing the feature freeze all the core
developers attention is really on these features, so I don't think any of
them will have the time to look at that, as it's something that can live
outside of Django I would suggset using it like that(or with the patch
applied to your Django install) until hopefully a developer has the chance
to review it.

Alex

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

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



BINARY columns

2009-02-16 Thread Andy Dustman

I'm working on a custom field type for Django which depends on being
able to save data in a BINARY column. (Not a big BLOB, just a couple
of bytes.) Unfortunately Django (trunk and probably 1.0) keeps trying
to turn it into unicode which fails. I'm now using patch.3.txt on
http://code.djangoproject.com/ticket/2417 and that seems to be doing
the job. What are the chances of something like this making it into
Django-1.1?
Looks like we might be past the feature freeze according to the 1.1 roadmap.
-- 
Patriotism means to stand by the country. It does
not mean to stand by the president. -- T. Roosevelt

MANDATED GOVERNMENT HEALTH WARNING:
Government mandates may be hazardous to your health.

This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

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



renaming file name after uploading at admin site

2009-02-16 Thread Mirat Can Bayrak

i wrote a save function like that

class ProductAdmin(admin.ModelAdmin):   
   
def save_model(self, request, obj, form, change):   
   
from os.path import dirname, join, splitext 
   
from shutil import move as rename   
   
extension = splitext(obj.image.path)[-1]
   
new_image_path = join(dirname(obj.image.path), obj.slug + extension)
   
rename(obj.image.path, new_image_path)  
 
obj.image = new_image_path  
   
obj.save()

it is working but, when i saving it from admin site, image urls are being wrong 
and being same as file path. see :

In [1]: from products.models import Product

In [2]: p = Product.objects.get(id=1)

In [3]: p.image.path
Out[3]: u'/home/horselogy/django/mmm/media/product_images/akatis.png'

In [4]: p.image.url
Out[4]: 
u'http://localhost:8000/home/horselogy/django/mmm/media/product_images/akatis.png'

why it is being like that? what am i doing wronG? Thanks for your response

-- 
Mirat Can Bayrak 

--~--~-~--~~~---~--~~
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: order_by foreign key

2009-02-16 Thread Alex Gaynor
On Mon, Feb 16, 2009 at 1:52 PM, jeffhg58  wrote:

>
> I have seen other posts on this topic but it seems that it was on the
> old trunk. I am using
> Django version 1.1 and I am unable to sort by foreign key
>
> When I try and execute the following query
>
> Result.objects.select_related().order_by('StatusId.Status')
>
>  I get 0 rows retrieved.
>
> Is that the correct way to order by foreign keys?
>
> Here are the models in question
>
> class Result( models.Model):
>TestName = models.CharField( max_length=100)
>TestVersion =  models.CharField( max_length=50,
>null=True)
>ExecutionStartDate =   models.DateTimeField( verbose_name = "Start
> Date",
>null=True)
>StatusId = models.ForeignKey( Status,
>verbose_name = "Status",
>db_column='StatusId',
>
> related_name="OverallStatus")
>AutoStatusId = models.ForeignKey( Status,
>verbose_name = "Status",
>db_column='AutoStatusId',
>related_name="AutoStatus")
>PrintVerifyStatusId =  models.ForeignKey( Status,
>verbose_name = "Status",
>
> db_column='PrintVerifyStatusId',
>
> related_name="PrintVerifyStatus")
>ImageVerifyStatusId =  models.ForeignKey( Status,
>verbose_name = "Status",
>
> db_column='ImageVerifyStatusId',
>
> related_name="ImageVerifyStatus")
>ExecutionTime =models.DecimalField( max_digits=10,
>decimal_places=4)
>StationId =models.ForeignKey( Station,
>verbose_name = "Station",
>db_column='StationId')
>SubmitDate =   models.DateTimeField( verbose_name="Submit
> Date",
>null=True)
>Owner =models.CharField( max_length=100)
>ProjectId =models.ForeignKey( Project,
>verbose_name = "Project",
>db_column='ProjectId')
>PhaseId =  models.ForeignKey( Phase,
>verbose_name = "Phase",
>db_column='PhaseId')
>TestTypeId =   models.ForeignKey( Type,
>verbose_name = "Test
> Type",
>db_column='TestTypeId')
>UserInterventionFlag = models.BooleanField( default=False)
>CurrentFlag =  models.BooleanField( default=True)
>ActiveFlag =   models.BooleanField( default=True)
>objects =  models.Manager() # The default manager.
>
>config_objects =   ResultManager()
>
>
> class Status( models.Model):
>Status =   models.CharField( max_length=100)
>AutoFlag = models.BooleanField()
>
> Thanks,
> Jeff
> >
>
http://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by-fieldstake
a look at the example of doing related filtering and note that it uses
the __ syntax.

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



order_by foreign key

2009-02-16 Thread jeffhg58

I have seen other posts on this topic but it seems that it was on the
old trunk. I am using
Django version 1.1 and I am unable to sort by foreign key

When I try and execute the following query

Result.objects.select_related().order_by('StatusId.Status')

 I get 0 rows retrieved.

Is that the correct way to order by foreign keys?

Here are the models in question

class Result( models.Model):
TestName = models.CharField( max_length=100)
TestVersion =  models.CharField( max_length=50,
null=True)
ExecutionStartDate =   models.DateTimeField( verbose_name = "Start
Date",
null=True)
StatusId = models.ForeignKey( Status,
verbose_name = "Status",
db_column='StatusId',
 
related_name="OverallStatus")
AutoStatusId = models.ForeignKey( Status,
verbose_name = "Status",
db_column='AutoStatusId',
related_name="AutoStatus")
PrintVerifyStatusId =  models.ForeignKey( Status,
verbose_name = "Status",
 
db_column='PrintVerifyStatusId',
 
related_name="PrintVerifyStatus")
ImageVerifyStatusId =  models.ForeignKey( Status,
verbose_name = "Status",
 
db_column='ImageVerifyStatusId',
 
related_name="ImageVerifyStatus")
ExecutionTime =models.DecimalField( max_digits=10,
decimal_places=4)
StationId =models.ForeignKey( Station,
verbose_name = "Station",
db_column='StationId')
SubmitDate =   models.DateTimeField( verbose_name="Submit
Date",
null=True)
Owner =models.CharField( max_length=100)
ProjectId =models.ForeignKey( Project,
verbose_name = "Project",
db_column='ProjectId')
PhaseId =  models.ForeignKey( Phase,
verbose_name = "Phase",
db_column='PhaseId')
TestTypeId =   models.ForeignKey( Type,
verbose_name = "Test
Type",
db_column='TestTypeId')
UserInterventionFlag = models.BooleanField( default=False)
CurrentFlag =  models.BooleanField( default=True)
ActiveFlag =   models.BooleanField( default=True)
objects =  models.Manager() # The default manager.

config_objects =   ResultManager()


class Status( models.Model):
Status =   models.CharField( max_length=100)
AutoFlag = models.BooleanField()

Thanks,
Jeff
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



regex query search with [\w]

2009-02-16 Thread Stephen Sundell

I'm trying to do a query filter with a regex expression where I want
to search for a word character.  I'm using postgresql and if I do
Blog.objects.filter(post__regex=r'[\w]'), django ends up using [\\w]
in the query.  I can't seem to get one backslash in the query.  Is
there some way to do this?  [\\w] is different from [\w] so this
really messes up my query.

Thanks in advance.
--~--~-~--~~~---~--~~
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: Mutli-Assignable Models

2009-02-16 Thread Justin Lilly

Hi Peter,

  While your proposed solution would work for the prototyping example
I've given, I have 3 more arching themes like Show and probably
another 4-5 content types like photo and articles. The main idea here
is to be able to select an arbitrary element, be it a photo, video,
article, etc. and display all of its related content, regardless of
content type, within the theme (aka Show). As an ancillary goal, I
need to ensure I'm not generating a ton of expensive queries for each
of these lookups as this site will be serving a large number of users.
 As far as I can tell, abstracting these relationships is the best way
to go about the problem, its just the method of abstraction that I'm
unsure on.

 -justin

On Sun, Feb 15, 2009 at 10:32 AM, Peter Herndon  wrote:
>
> Hi Justin,
>
> I can't view your code at the moment, but it seems to me you want a
> ForeignKey on Article to Show, another FK on Photo to Show, an M2M
> from Article to Photo, and a custom manager on Show, or some other
> custom method, that returns both Articles and Photos.  The latter
> might best be accomplished by having Articles and Photos inherit from
> some common model, and have Show pull from that common ancestor and
> then descend to the specific type as needed.  The common model would
> be where you'd have the FK to Show, thinking about it, and then you
> wouldn't need a custom method on Show, you could just use std methods.
>
> ---Peter
>
> On 2/12/09, Justin Lilly  wrote:
>>
>> Hi all.
>>
>>   I have a project where I need to assign multiple models to each
>>   other via some many to many relationship.
>>
>>   There are a few main players in my prototype: Articles, Photos and
>>   Shows. Shows has many Articles and Photos. Article has many Photos,
>>   but has one Show. Photos has one Show, but has many Articles. (Might
>>   make more sense below) There will be more models involved in this
>>   process when this app goes to production, but these 3 will do for
>>   prototyping.
>>
>>   My initial thought was to have an intermediate model with 2 generic
>>   relationships. I think this is going to be too costly in terms of
>>   performance as I'll need to run 2x the queries per lookup. One to
>>   check if my lookup object is referenced in the first generic
>>   relationship, then to see if its referenced in the 2nd one.
>>
>>   The next idea was to have a self-referential m2m field for my models
>>   to inherit from. The issue there is the lookup returns objects whose
>>   type is that of the parent model, not the child model.
>>
>>   I'm looking for a way to accomplish queries similar to this:
>>
>>   >>> myshow
>>   
>>   >>> myshow.related.all()
>>   [, , , , ]
>>   >>> photo1 = myshow.related.all()[0]
>>   >>> photo1.related.all()
>>   [, , , ]
>>
>>   The self referential model code I was using can be found at
>>   http://dpaste.com/119897/ and an ipython session at
>>   http://dpaste.com/119898/ . I feel as if I may be stretching what
>>   model inheritance was meant for or at least what its currently
>>   capable of.
>>
>>   Although everyone says it, the solution will need to scale to a
>>   large number of users as it will be used in a very large
>>   dynamic-content site. This is the core of the content plan (to
>>   present various content types based on a given "pivot point", in the
>>   illustrated case above, shows).
>>
>>   Looking for any advice or help you may be able to provide.
>>
>>  -justin
>>
>> >
>>
>
> >
>



-- 
Justin Lilly
Web Developer/Designer
http://justinlilly.com

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



Re: mod_wsgi+apache2.2+django1+WindowsXP: can't serve images

2009-02-16 Thread Angel Cruz
Thank you Graham!  All of my reference materials, including the Django book
I am currently reading (mod_wsgi was toward the end of the book and I should
have looked there first :>) ), has the "Alias" directive.  Why I typed Match
in there, I am now at a lost :>)
Off I gothank you again!

On Sun, Feb 15, 2009 at 4:11 PM, Graham Dumpleton <
graham.dumple...@gmail.com> wrote:

>
>
>
> On Feb 16, 10:19 am, MrBodjangles  wrote:
> > I am going thru the sample blog application introduced in the book
> > "Python Web Development with Django (covers Django 1.0)".
> >
> > Before getting too deep into the book, I decided I wanted to first
> > ensure that the application will render in apache since I want to
> > include an image at the bottom of the blog posts (I have been hacking
> > spaghetti code in php for a couple of years now, but now, am intent on
> > coding neatly with python).
> >
> > The blog application works partially in that apache renders the text
> > contents, but not the image.
> >
> > Note the access.log contents in the end ( "GET /media/img/
> > people_rose.jpg HTTP/1.1" 404 2001)
> >
> > I have read so much good stuff about Django that I want to dive into
> > it full speed ahead, but now I am stuck in serving a simple image.
> >
> > Help?
> >
> > --
> > httpd.conf:
> > ===
> > .
> > .
> > .
> > 
> > # I will put this later in a separe conf file
> > ###
> > # This did not work ==>>>  AliasMatch ^/([^/]+)/media/(.*) "c:/my_wsgi/
> > media"
> > #
> > # trying AliasMatch below...still does not work :>(
> > #
> >
> > AliasMatch ^media/(.*) "c:/my_wsgi/media/"
>
> Use Alias directive, not AliasMatch, as described in mod_wsgi
> documentation. See:
>
>  http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
>
> Perform direct URL accesses against stuff in media directory to
> ascertain if working or not.
>
> > 
> > Order allow,deny
> > Options Indexes
> > Allow from all
> > IndexOptions FancyIndexing
> > 
> >
> > WSGIScriptAliasMatch ^/([^/]+) "c:/my_wsgi/apache/django.wsgi"
>
> Again, read the documentation. Do not use WSGIScriptAliasMatch, use
> WSGIScriptAlias.
>
> Why are you using the Match variants? Where did you get the idea you
> had to do that?
>
> Try what is in the documentation instead.
>
> Graham
>
> > 
> > Order deny,allow
> > Allow from all
> > 
> > 
> >
> > #
> > # DirectoryIndex: sets the file that Apache will serve if a directory
> > # is requested.
> > .
> > .
> > .
> >
> > 
> > django.wsgi:
> > 
> > import os, sys
> >
> > #Calculate the path based on the location of the WSGI script.
> > apache_configuration= os.path.dirname(__file__)
> > project = os.path.dirname(apache_configuration)
> > workspace = os.path.dirname(project)
> >
> > sys.path.append(workspace)
> > sys.path.append('c:\\my_wsgi')
> >
> > os.environ['DJANGO_SETTINGS_MODULE'] = 'blog.settings'
> > import django.core.handlers.wsgi
> > application = django.core.handlers.wsgi.WSGIHandler()
> >
> > 
> > settings.py:
> > 
> > .
> > .
> > .
> > # Absolute path to the directory that holds media.
> > # Example: "/home/media/media.lawrence.com/"
> > MEDIA_ROOT = ''
> >
> > # URL that handles the media served from MEDIA_ROOT. Make sure to use
> > a
> > # trailing slash if there is a path component (optional in other
> > cases).
> > # Examples: "http://media.lawrence.com;, "http://example.com/media/;
> > MEDIA_URL = ''
> >
> > # URL prefix for admin media -- CSS, JavaScript and images. Make sure
> > to use a
> > # trailing slash.
> > # Examples: "http://foo.com/media/;, "/media/".
> > ADMIN_MEDIA_PREFIX = '/media/'
> > .
> > .
> > .
> >
> > 
> > base.html (lives in c:\my_wsgi\blog\templates):
> > ==
> > .
> > .
> > .
> > 
> > {%block content %}
> > {%endblock%}
> >
> >  
> >  > height="848"> 
> > .
> > .
> > .
> >
> > -
> > access.log:
> > =
> > 127.0.0.1 - - [15/Feb/2009:15:05:41 -0800] "GET /blog/v_blog/ HTTP/
> > 1.1" 200 565
> > 127.0.0.1 - - [15/Feb/2009:15:05:43 -0800] "GET /media/img/
> > people_rose.jpg HTTP/1.1" 404 2001
> > 127.0.0.1 - - [15/Feb/2009:15:05:44 -0800] "GET /favicon.ico HTTP/1.1"
> > 404 1944
> >
>

--~--~-~--~~~---~--~~
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: Admin Change List Page - Can I have anonymous users view this table?

2009-02-16 Thread Bfox

Hi Alex-

Thanks for the links.  I am trying out django-tables, and it seems
like it will work pretty good.  It seems a little disappointing that
there is the great admin table interface and someone has to build and
maintain a separate module to implement something similar.

I will also take a look at your filters module if it turns out that I
need to use the filters.

Thanks very much.

On Feb 11, 10:13 am, Alex Gaynor  wrote:
> On Wed, Feb 11, 2009 at 1:07 PM, Bfox  wrote:
>
> > I really like the admin pages.  I want to figure out how to show the
> > "list page" to all users (even when anonymous), but I don't want
> > anonymous users to be able to edit the data (obviously).  I looked at
> > databrowse, but as far as I can tell, it is not tabular.
>
> > The table I am referring to has the title "select xxx to change," is
> > called the "admin change list page" in the admin documentation and
> > usually has a path of:
> > /myproject/admin/myapp/myobject
>
> > I especially like the nice customization in admin.py:
> >   list_display
> >   list_filter
> >   list_per_page
> >   search_fields
> >http://docs.djangoproject.com/en/dev/ref/contrib/admin/#list-display
>
> > I am new to django, so I don't know if this is an easy thing to do or
> > not.  I suspect it might be hard.  Would this question be more
> > appropriate on the django-admin group?
>
> > Thanks very much.
>
> The django admin really isn't designed to be used like this, it's meant for
> trusted users only.  That being said once you learn django building a page
> like that for your specific data isn't terrible hard and there are a few
> cool projects like django-tables or django-filter(disclaimer, I wrote this)
> to help you in building such a page.
>
> 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: Any django users in Malaysia/Singapore

2009-02-16 Thread Azril Nazli

Any RoR die hard fan here :)

On Feb 7, 11:24 pm, cheeming  wrote:
> I am using Django as well, for my startup.
> Would be nice to have some get together or teh tarik sessions.
>
> On Jan 29, 1:45 pm, ycloh  wrote:
>
> > Yeah, would have been nice if there was some sharing, which is why i
> > wanted to know if there were users in KL or Sin. Would be nice to at
> > least arrange some sort of get together/ teh tarik session, if there
> > were enough developers around.
>
> > On Jan 29, 9:15 am, Bond Lim  wrote:
>
> > > Hi, I am from Malaysia and currently using django. Too bad is that in
> > > Malaysia, we do not have any python or django conference,
>
> > > On Wed, Jan 28, 2009 at 04:58:09PM -0800, ycloh wrote:
>
> > > > Hi all, just wondering if there are many django users in this part of
> > > > this world and how is django being used.

--~--~-~--~~~---~--~~
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: Geodjango GPolygon

2009-02-16 Thread Adonis

Justin,

So it would seem,
Thank you very much for this notice.
I reversed the Glatlng() and now it works just fine.

regards,

On Feb 16, 4:35 pm, Justin Bronn  wrote:
> > Im afraid that it does not change anything by leaving out the fromstr
> > and wkt.
> > It is a really weird problem reversing the lat and lng like that...
>
> It's probably because your GEOS polygon has the order wrong to begin
> with.  All spatial databases use (x, y) ordering -- in other words
> (lon, lat).  Thus, your GEOS geometry should have the coordinates in
> (lon, lat) order.  However, mapping APIs use (lat, lon) order
> instead.  This is why GPolygon switches the order, to be compatible
> with the GMaps API -- and you probably had the order wrong to begin
> with in your geometry.
>
> -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
-~--~~~~--~~--~--~---



change template code

2009-02-16 Thread Akhmat Safrudin

hello...
how changed template take effect after deployed with fastcgi ?

thank's


--~--~-~--~~~---~--~~
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: LaTeX custom Field, png url

2009-02-16 Thread Alex Gaynor
On Mon, Feb 16, 2009 at 12:05 PM, alain31  wrote:

>
> What I understood reading custom-model-fields.html is that Field class
> only handle one column in database
> (db_type method returns a database type...). I first thought to
> inherit from TextField and build the name of the png file using a hash
> from
> the LaTeX string (so no need to store it in the database), or store a
> string made of concatenation of LaTeX string + url
> but I imagine that there must be a cleaner way to do it no?
>
> >
> If you take a look at how Generic Foreign Key fields are used the user
defines 2 fields on the model, and then the generic foreign key acts as a
psuedofield(it exists in python, but not the DB) and combines the data from
both those fields.  That's how I would do it, take a look at
django.contrib.cotnenttypes.generic to see how that's implemented.

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: LaTeX custom Field, png url

2009-02-16 Thread alain31

What I understood reading custom-model-fields.html is that Field class
only handle one column in database
(db_type method returns a database type...). I first thought to
inherit from TextField and build the name of the png file using a hash
from
the LaTeX string (so no need to store it in the database), or store a
string made of concatenation of LaTeX string + url
but I imagine that there must be a cleaner way to do it no?

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



Re: Custom template tags in admin with hacking to source?

2009-02-16 Thread Karen Tracey
On Mon, Feb 16, 2009 at 11:49 AM, Daniel Roseman <
roseman.dan...@googlemail.com> wrote:

>
> On Feb 16, 4:23 pm, Ben Gerdemann  wrote:
> > Is it possible to add a custom template tag to the admin without
> > modifying the Django source? I'd like to add a tag to display a
> > different submit_line, but the only way I can figure out how to do
> > this is by either adding one of the existing template tags in django/
> > contrib/admin/templatetags or adding a new file in the directory. I
> > tried adding a templatetags directory to my app, but it doesn't work
> > because Django only searches for template tags in the templatetag
> > directory of the active app. Any ideas about how to do this without
> > hacking the source?
> >
> > Cheers,
> > Ben
>
> I don't know why you think that Django only searches in the 'active
> app', but it's not true. As long as the app is present in
> INSTALLED_APPS, Django will make its template tags available to any
> other application. So all you need to do in order to get your tag into
> the admin is to customise your admin template (instructions are in the
> docs) and refer to it there.


I'm not quite following the original problem description either, but this
ticket:

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

highlights that it is not at present very easy to override just the
submit_line, so perhaps that is coming into play.  If so, feedback in that
ticket as to whether the blocks defined there are helpful in solving
whatever problem is being encountered here would be useful.

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



Access extra parameters in forms.py

2009-02-16 Thread peterandall

Hi all,

I'm trying to access a list of users in forms.py I'm creating two
lists and merging them in my view (new_bug) then passing them through
when i create the form. I was going off answers on these two existing
topics: 
http://groups.google.com/group/django-users/browse_thread/thread/9dce5b8b0c1bfeb/b7f3e3753e1d8842
and 
http://groups.google.com/group/django-users/browse_thread/thread/809ec467d4a97386/8f7cddde9ff1ed19

You can see my current code here:
  http://dpaste.com/121276/

So i'm creating the list of users fine (all_users), passing them to
the __init__ method, I can access them and print them out fine.

My issue is where i'm trying to build the form and get it to display
in the template nothing appears, i.e none of the form fields appear,
but i don't get any error messages. If i move all of the fields out of
the __init__ method then they display in the template, but the
'assigned_to' field can't access the 'all_users' variable from the
__init__ method.

I guess it comes down to me not fully understanding how to access the
information in the __init__ method and still have the form be built
with all the fields.

Any advice would be great, or if you need me to clarify anything give
me a shout.

Cheers,

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



Re: Custom template tags in admin with hacking to source?

2009-02-16 Thread Daniel Roseman

On Feb 16, 4:23 pm, Ben Gerdemann  wrote:
> Is it possible to add a custom template tag to the admin without
> modifying the Django source? I'd like to add a tag to display a
> different submit_line, but the only way I can figure out how to do
> this is by either adding one of the existing template tags in django/
> contrib/admin/templatetags or adding a new file in the directory. I
> tried adding a templatetags directory to my app, but it doesn't work
> because Django only searches for template tags in the templatetag
> directory of the active app. Any ideas about how to do this without
> hacking the source?
>
> Cheers,
> Ben

I don't know why you think that Django only searches in the 'active
app', but it's not true. As long as the app is present in
INSTALLED_APPS, Django will make its template tags available to any
other application. So all you need to do in order to get your tag into
the admin is to customise your admin template (instructions are in the
docs) and refer to it there.
--
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: LaTeX custom Field, png url

2009-02-16 Thread Alex Gaynor
On Mon, Feb 16, 2009 at 10:40 AM, alain31  wrote:

>
> Hello,
> I plan to use django for some projects with heavy use of math formulas
> and I would like to create a reusable custom field to store LaTeX
> strings and to get a png image on disk  after compilation. The usage
> would go like this :
> model:
> formula = LatexField()
> template to get the png:
> {{model.formula.url}}
> Before saving the field, I compile the string on server with LaTeX and
> make a png stored in a local file.
>
> I have the following question : I need to store in the database the
> LaTeX string as well as the url of the
> png image and I wonder how to do it  (I looked at FileField,
> ImageField but only the url is saved in the database). Another point,
> it would be nice to create a specific form to see the errors during
> LaTeX compilation and to correct them before saving the field in the
> database.
>
> Any suggestions, starting point in docs ?
> Thanks.
>
> >
>
Here's a guide on writing a custom model field:
http://docs.jezdez.com/howto/custom-model-fields.html .  My guess is you'll
actually need 2 real fields in the DB, with one psuedofield similar to the
generic foreign key that actually handles combining those 2 into a real
item.

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: Geodjango GPolygon

2009-02-16 Thread Justin Bronn

> Im afraid that it does not change anything by leaving out the fromstr
> and wkt.
> It is a really weird problem reversing the lat and lng like that...

It's probably because your GEOS polygon has the order wrong to begin
with.  All spatial databases use (x, y) ordering -- in other words
(lon, lat).  Thus, your GEOS geometry should have the coordinates in
(lon, lat) order.  However, mapping APIs use (lat, lon) order
instead.  This is why GPolygon switches the order, to be compatible
with the GMaps API -- and you probably had the order wrong to begin
with in your geometry.

-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: HttpResponse post

2009-02-16 Thread Antoni Aloy

2009/2/16 Mike :
>
> Hi all,
>
> I m not familiar with django and I have found several problems trying
> to sent a httpresponse with post parameters. I would like to return an
> httpresponse (or httpredirect) to a new url with the request
> parameters via post.
>
> Could anybody help me?
> Thank you in advance,
> Miguel
>
> I have defined a new view:
>
> def prueba(request, seccion):
>  if request.POST:
>new_data = request.POST.copy()
>
> [get all the parameters]
> [send a mail if correct]
>
>
>response = HttpResponse ("newUrl")
>#¿POST?
>return HttpResponseRedirect(response)
>

After a post you should use a HttpResponseRedirect(url). If you need
to have access to the post parameters an option is to save them in a
session, or encode them in the url itslef.

Hope it helps!

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



LaTeX custom Field, png url

2009-02-16 Thread alain31

Hello,
I plan to use django for some projects with heavy use of math formulas
and I would like to create a reusable custom field to store LaTeX
strings and to get a png image on disk  after compilation. The usage
would go like this :
model:
formula = LatexField()
template to get the png:
{{model.formula.url}}
Before saving the field, I compile the string on server with LaTeX and
make a png stored in a local file.

I have the following question : I need to store in the database the
LaTeX string as well as the url of the
png image and I wonder how to do it  (I looked at FileField,
ImageField but only the url is saved in the database). Another point,
it would be nice to create a specific form to see the errors during
LaTeX compilation and to correct them before saving the field in the
database.

Any suggestions, starting point in docs ?
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
-~--~~~~--~~--~--~---



HttpResponse post

2009-02-16 Thread Mike

Hi all,

I m not familiar with django and I have found several problems trying
to sent a httpresponse with post parameters. I would like to return an
httpresponse (or httpredirect) to a new url with the request
parameters via post.

Could anybody help me?
Thank you in advance,
Miguel

I have defined a new view:

def prueba(request, seccion):
 if request.POST:
new_data = request.POST.copy()

[get all the parameters]
[send a mail if correct]


response = HttpResponse ("newUrl")
#¿POST?
return HttpResponseRedirect(response)

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



Re: Geodjango GPolygon

2009-02-16 Thread Adonis

thank you Adam,

Im afraid that it does not change anything by leaving out the fromstr
and wkt.
It is a really weird problem reversing the lat and lng like that...

cheers,

On Feb 16, 2:58 pm, Adam Fast  wrote:
> GPolygon is "designed" to take the geometry natively - no fromstr() or
> .wkt necessary.
>
> Try GPolygon(polycoords_from_database.geometry)
>
> Adam
>
> 2009/2/16 Adonis :
>
>
>
> > Hello,
>
> > -being facing a non-givin-back-errors problem...
>
> > view.py
>
> > poly = GPolygon(fromstr
> > (polycoords_from_database.geometry.wkt),"#f33f00",3,1,"#008000",1)
>
> > blah.html
>
> > map.addOverlay(new {%block poly%}{%endblock%})
>
> > -the page source shows that the new GPolygon has a proper syntax BUT
> > the new GLatLng arrays are given as if it was G-Lng-Lat ( the
> > longtitude first and the latitude second ). I suppose this is critical
> > because lat can only be between -90 and +90 etc.
>
> > Any suggestions?
> > Thanks in advance.
>
>
--~--~-~--~~~---~--~~
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: Keys composed of multiple fields

2009-02-16 Thread jfmxl

I see. Thank you.

Alex Koshelev wrote:
> Django doesn't suppurt multi-field PKs. Try to search this group for more
> diussion.
>
> On Mon, Feb 16, 2009 at 12:43 PM, jfmxl  wrote:
>
> >
> > Hi again,
> >
> > How do I handle multifield keys?
> >
> > I have multifield primary keys which are in turn used as foreign keys
> > in other tables.
> >
> > My database backend is MySQL if that makes a difference.
> > >
> >
--~--~-~--~~~---~--~~
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: Geodjango GPolygon

2009-02-16 Thread Adam Fast

GPolygon is "designed" to take the geometry natively - no fromstr() or
.wkt necessary.

Try GPolygon(polycoords_from_database.geometry)

Adam


2009/2/16 Adonis :
>
> Hello,
>
> -being facing a non-givin-back-errors problem...
>
> view.py
>
> poly = GPolygon(fromstr
> (polycoords_from_database.geometry.wkt),"#f33f00",3,1,"#008000",1)
>
> blah.html
>
> map.addOverlay(new {%block poly%}{%endblock%})
>
> -the page source shows that the new GPolygon has a proper syntax BUT
> the new GLatLng arrays are given as if it was G-Lng-Lat ( the
> longtitude first and the latitude second ). I suppose this is critical
> because lat can only be between -90 and +90 etc.
>
> Any suggestions?
> Thanks in advance.
> >
>

--~--~-~--~~~---~--~~
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 the reponse headers & Firefox

2009-02-16 Thread mermer

I am trying to change the Headers in the response.

My frustration, is that I can change the ETAG header and it is
returned by the browser at the next request but  I can't seem to get
the Cache Control or Expire header accepted by the browser

Does anybody have a clue why?  Is this a browser issue and if so does
anybody have a work around?   The Etag is very useful because it
reduces the work on the servers, but still requires the client
(browser) to connect to the server.  I want to add a Cache-Control
header which would remove the need for the client to connect to the
server at all, until the header had expired.

A snippet of code is below:-

response=HttpResponse(status=304)
response["Etag"] = "test Etag"  #  This works. It gets picked up and
returned in the next request by Firefox

response["Cache-Control"]="max-age=120"  #  This does not work.
Firefox keeps returning max-age=0

response["Expires"]= "Mon, 18 Feb 2009 13:36:08 GMT" # This does not
work. Firefox calls the server.

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



Re: Admin hangs while updating a modified, repopulated model [update]

2009-02-16 Thread Karen Tracey
2009/2/16 haestan none 

>  Sorry, it looks like I had a wrong assumption in my original question. The
> server seems to hang as soon as I try to update a model with an URLField
> that is set to 'http://localhost:8000' (this is where the built-in
> webserver is running).
>
> Is this a bug or can't Django validate an URLField to its own webserver?
>
> Please forget, what I've written in the original post.
>

The development server is single-threaded and thus unable to serve requests
that require talking to itself, essentially.  This is a conscious
limitation, if you need to do this kind of thing during development testing
there are ways to accomplish it.  See this thread:

http://groups.google.com/group/django-users/browse_thread/thread/eaf7949437f0b856/984ae12bfae2bb80
?

and the one it points to for more discussion.

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: Negative value in forms.Integerfield throws TypeError

2009-02-16 Thread Karen Tracey
On Mon, Feb 16, 2009 at 4:26 AM, coan  wrote:

>
> I'm validating a form, and use forms.IntegerField(min_value=0,).
>
> If I submit a -1 value in that field, it throws a TypeError: not all
> arguments converted during string formatting.
> How come it doesn't raise a forms.ValidationError, and how should I
> catch a negative value in this field?


I cannot recreate any error like what you describe with the information you
have provided:

Python 2.5.1 (r251:54863, Jul 31 2008, 23:17:40)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django import forms
>>> class IForm(forms.Form):
...   nzint = forms.IntegerField(min_value=0,)
...
>>> iform = IForm(data={'nzint': -1})
>>> iform.is_valid()
False
>>> iform.errors
{'nzint': [u'Ensure this value is greater than or equal to 0.']}
>>>

Repeating myself for about the bazillionth time: snippets of the actual code
in use use and the full traceback of the error seen are much more likely to
get useful replies than brief word sketches of the code and the barest bones
of the debug information from the error.  Alternatively, an attempt to
recreate the error with the minimal information you think is relevant might
reveal how the stripped-down case works and possibly provide a clue as to
what's different about the code exhibiting the error, allowing you to solve
the problem on your own.

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: Trying to get data from template to view...

2009-02-16 Thread arbi

In fact I may have answered a bit quick.
Your solution is great, BUT in my case, I have an additional pb : my
js function calls a "call-back" function. I show you :

function js_function(address){
geocoder.getLocations(address, js_function_call_back); //
"getLocations" is a Google Maps API function

function js_function_call_back(response){
   // many operations on the response
  // many operations on the response
  // etc.
  test=document.getElementById("test");
  test.value=1; // to change the value of my "hidden input" in my
template
  return true;
}

But this doesn't work. Any suggestions?
Thx a lot :)

On 16 fév, 14:18, arbi  wrote:
> Thx nivhab, that's great :)
>
> On 15 fév, 20:56, nivhab  wrote:
>
> > If you'd likeJavaScriptto calculate values before you submit the
> > form then do the following:
>
> > 1. Add a "onSubmit" attribute on your "form" tag which calls a JS
> > function like:
> > 
>
> > 2. In the implementation of that function calculate whatever you need
> > and plant the result into a hidden input field inside your form OR
> > change the value of an existing input field.
>
> > 3. When you're done, your function should return "true" so that the
> > form submits.
>
> > Now the form submits with the value you have calculated.
> > Good luck.
> > Yaniv
>
> > On Feb 15, 6:56 pm,arbi wrote:
>
> > > Hi all,
>
> > > In fact my pb is : I have a  that sends a DATA that the user
> > > writes (input), but I would like it to send javascript_function(DATA)
> > > instead. How to do it?
>
> > > This is my input. The DATA is a "departure"
> > > 
>
> > > What shoud I write instead of name or value to return the
> > > javascript_function(departure) instead of departure only? (my js
> > > function calculates the latitude in fact).
>
> > > In general, how to bring back to viewjavascriptresults?
>
> > > Thanks a lot!
> > >Arbi
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Geodjango GPolygon

2009-02-16 Thread Adonis

Hello,

-being facing a non-givin-back-errors problem...

view.py

poly = GPolygon(fromstr
(polycoords_from_database.geometry.wkt),"#f33f00",3,1,"#008000",1)

blah.html

map.addOverlay(new {%block poly%}{%endblock%})

-the page source shows that the new GPolygon has a proper syntax BUT
the new GLatLng arrays are given as if it was G-Lng-Lat ( the
longtitude first and the latitude second ). I suppose this is critical
because lat can only be between -90 and +90 etc.

Any suggestions?
Thanks in advance.
--~--~-~--~~~---~--~~
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: Form wizard back button

2009-02-16 Thread urukay


Maybe i don't have exact solution to your problem, because i've never user
form wizard so far. I always create my own forms. During user's registraton
process i save user.id in session and in every view i'm testing if this ID
is in session (it menas, register process has not been finished) and if so,
i initialize form with data for this new user (if he saves particular data
before, of course). It's good even if user returns back using browser's back
button and reloads whole page.
And finally after successfull registration process i delete this variable in
session.
As i said, it's probably not exactly what you need, but maybe it'll point
you to the right direction.


Radovan


alain D. wrote:
> 
> 
> anyone?
> > 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Form-wizard-back-button-tp21875858p22036986.html
Sent from the django-users mailing list archive at Nabble.com.


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

2009-02-16 Thread TimSSP

HI,

I'm looking into using Django to redevelop a website to handle dynamic
content and some social app functions. I am interested in knowing
whether django can work alongside php, we built a modest database to
work on news articles in php and are considering using facebook's api
for an application in the near future.

I'm wondering whether the facebook would be able to use django on its
frontend or whether it would have to be php coded into that part of
the site. Any help / advice would be a great help, thanks

Best wishes

Tim

email: tim.clar...@gmail.com

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



Re: Trying to get data from template to view...

2009-02-16 Thread arbi

Thx nivhab, that's great :)

On 15 fév, 20:56, nivhab  wrote:
> If you'd likeJavaScriptto calculate values before you submit the
> form then do the following:
>
> 1. Add a "onSubmit" attribute on your "form" tag which calls a JS
> function like:
> 
>
> 2. In the implementation of that function calculate whatever you need
> and plant the result into a hidden input field inside your form OR
> change the value of an existing input field.
>
> 3. When you're done, your function should return "true" so that the
> form submits.
>
> Now the form submits with the value you have calculated.
> Good luck.
> Yaniv
>
> On Feb 15, 6:56 pm,arbi wrote:
>
> > Hi all,
>
> > In fact my pb is : I have a  that sends a DATA that the user
> > writes (input), but I would like it to send javascript_function(DATA)
> > instead. How to do it?
>
> > This is my input. The DATA is a "departure"
> > 
>
> > What shoud I write instead of name or value to return the
> > javascript_function(departure) instead of departure only? (my js
> > function calculates the latitude in fact).
>
> > In general, how to bring back to viewjavascriptresults?
>
> > Thanks a lot!
> >Arbi
--~--~-~--~~~---~--~~
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: Keys composed of multiple fields

2009-02-16 Thread Alex Koshelev
Django doesn't suppurt multi-field PKs. Try to search this group for more
diussion.

On Mon, Feb 16, 2009 at 12:43 PM, jfmxl  wrote:

>
> Hi again,
>
> How do I handle multifield keys?
>
> I have multifield primary keys which are in turn used as foreign keys
> in other tables.
>
> My database backend is MySQL if that makes a difference.
> >
>

--~--~-~--~~~---~--~~
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: Form wizard back button

2009-02-16 Thread alain D.

anyone?
--~--~-~--~~~---~--~~
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: Automated Translation Management -- Surely someone has already done this?

2009-02-16 Thread ville

The django-rosetta app might help you: http://code.google.com/p/django-rosetta/
It allows easy online editing of the po/mo files.

-ville

On Feb 16, 9:47 am, DrMeers  wrote:
> I have developed a Django site for an open source project, with
> contributors around the globe.
>
> A brief aside/background: I have used django-cms to store the majority
> of the content for the site, but rather than adopting its usual tactic
> of translating a whole page at a time, have used {% trans %} and {%
> blocktrans %} tags within the content, and written a script to dump
> the database content into dummy HTML files so they get picked up by
> django-admin.py's makemessages utility. This way translators don't
> have to hunt for which line/paragraph within a large page has been
> changed, nor worry about messing up the layout of the page when
> translating.
>
> Back to the point: this website will be translated into over a dozen
> languages, and undergo regular content updates. I have written code
> that runs django-admin.py makemessages (via subprocess.Popen, though I
> suspect there is a better way to run it within python?) and allows the
> download of the latest .po file for any given language. I would also
> like registered/authenticated users to be able to easily upload their
> updated translation files and have them automatically update the
> website (using compilemessages). So when I make a change to the
> website, I'd like the registered translators to be automatically
> emailed, and asked to update their translations (again, simply
> download and upload the new .po file via the website). This is easy
> enough to do, and saves me a HUGE amount of work over the next few
> years.
>
> But the reason I am posting this: this is such a common procedure,
> surely someone has written this stuff before? But I cannot find it
> anywhere online. Isn't there a django-translation-management package
> already written? Or should I create it once I finish coding? How have
> other people streamlined this process?

--~--~-~--~~~---~--~~
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: Authentication/access check when serving static media thru Apache/nginx

2009-02-16 Thread Graham Dumpleton



On Feb 16, 9:53 pm, "proteus...@gmail.com" 
wrote:
> The way to do this is by utilizing nginx as a reverse proxy for your
> dynamic django (presumably apache) server and a peer media server
> (presumably another nginx setup). Nginx has a great feature (as does
> lighttpd) where you can have your page request come into django and
> perform all the authN/authZ checks needed for your static content but
> redirect the request to the static media server once approved.
>
> Let's say you have a user profile with pictures and want the user to
> have find grained privacy control on his pictures.
> 1. request for user profile comes into nginx proxy.
> 2. nginx proxy fwds request to django server which determines which
> pics are appropriate to view (authorized) of that profile for the
> logged in user.
> 3. the django server, rather than returning static links to the media
> server, populates a field X-Accel-Redirect that points to the static
> content on the media server.
> 4. nginx proxy sees the X-Accel-Redirect contents and resubmits the
> request to the media server and returns its content instead of the
> content from the django server.
> 5. user gets only the static content that the django server authorized
> yet the load for the transfer is moved to the media server.

Also look at nginx X-Sendfile header. This is possibly better as you
don't need to have a URL which maps to the file. The Django
application can just set X-Sendfile with location of file being where
ever it wants, which would include being outside of any directories
that nginx had been set up to otherwise serve.

Graham

> Good luck,
>
>   -- Ben
>
> On Feb 16, 4:44 pm, MrMuffin  wrote:
>
> > I`m using django to develop something similar to flickr, a site for
> > photo-sharing. Photos can be public, need authentication or be
> > personal and not available for anyone but the owner. Serving static
> > data using django is not optimal, but how can I control access like
> > this when serving static media using apache or nginx?
>
> > Thanks in advance.
--~--~-~--~~~---~--~~
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: load huge dataset through fixtures

2009-02-16 Thread Russell Keith-Magee

On Mon, Feb 16, 2009 at 7:42 PM, Konstantin S  wrote:
>
> Hello!
>
> I am trying to load really huge dataset (contains millions of records)
> into database through fixtures and it seems that django loads entire
> data into memory before commiting it into db so python process dies
> out of memory. Am I right that the only possible solution in my case
> is not to use fixtures at all and upload data by script ?

This is correct.

There are several reasons for this, most of which come back to the
fact that the serialization tools that form the basis of the fixture
loaders are primarily intended for use as test data, or for the
transfer of small amounts of data (such as records to service an AJAX
request). Serializing an entire multi-gigabyte database wasn't part of
the original design specification. The XML serializer is the only
serializer that uses an event-based API under the hood, but even the
XML serializer attempts to process the entire file before committing
to the database.

However, even if Django's serializers used an event-based API which
would allow for streamed loading, you would almost certainly find that
using an SQL script will be faster anyway. While the overhead imposed
by using the parsers and the Django ORM is not especially large, if
you are dealing with _huge_ datasets, even a small per-object overhead
will add up to a non-trivial difference in overall processing time.

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: Authentication/access check when serving static media thru Apache/nginx

2009-02-16 Thread proteus...@gmail.com

The way to do this is by utilizing nginx as a reverse proxy for your
dynamic django (presumably apache) server and a peer media server
(presumably another nginx setup). Nginx has a great feature (as does
lighttpd) where you can have your page request come into django and
perform all the authN/authZ checks needed for your static content but
redirect the request to the static media server once approved.

Let's say you have a user profile with pictures and want the user to
have find grained privacy control on his pictures.
1. request for user profile comes into nginx proxy.
2. nginx proxy fwds request to django server which determines which
pics are appropriate to view (authorized) of that profile for the
logged in user.
3. the django server, rather than returning static links to the media
server, populates a field X-Accel-Redirect that points to the static
content on the media server.
4. nginx proxy sees the X-Accel-Redirect contents and resubmits the
request to the media server and returns its content instead of the
content from the django server.
5. user gets only the static content that the django server authorized
yet the load for the transfer is moved to the media server.

Good luck,

  -- Ben

On Feb 16, 4:44 pm, MrMuffin  wrote:
> I`m using django to develop something similar to flickr, a site for
> photo-sharing. Photos can be public, need authentication or be
> personal and not available for anyone but the owner. Serving static
> data using django is not optimal, but how can I control access like
> this when serving static media using apache or nginx?
>
> Thanks in advance.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



load huge dataset through fixtures

2009-02-16 Thread Konstantin S

Hello!

I am trying to load really huge dataset (contains millions of records)
into database through fixtures and it seems that django loads entire
data into memory before commiting it into db so python process dies
out of memory. Am I right that the only possible solution in my case
is not to use fixtures at all and upload data by script ?

--~--~-~--~~~---~--~~
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: Admin hangs while updating a modified, repopulated model [update]

2009-02-16 Thread haestan none

Sorry, it looks like I had a wrong assumption in my original question. The 
server seems to hang as soon as I try to update a model with an URLField that 
is set to 'http://localhost:8000' (this is where the built-in webserver is 
running).

Is this a bug or can't Django validate an URLField to its own webserver?

Please forget, what I've written in the original post.

Cheers.


From: haes...@hotmail.com
To: django-users@googlegroups.com
Subject: Admin hangs while updating a modified, repopulated model
Date: Mon, 16 Feb 2009 09:54:31 +








Hi,

I have a strange problem while editing a modified model in the admin. Whenever 
I change my models I usually issue the following commands to change the model 
and repopulate my data:

# ./manage.py dumpdata --indent=4 redir > old_data.json
-> do the model changes
# ./manage.py reset redir
# ./manage.py syncdb
# ./manage.py loaddata  old_data.json

Then, when I try to edit a model that has been changed in this process (f.e. 
added a db field), the admin hangs as soon as I submit save and the whole 
Django builtin webserver becomes unresponsive. Even restarting the webserver 
does not resolve this problem. It's definitely no browser problem since I 
tested it with different browser types. It's no database problem since issuing 
the query in the db shell works without any problems.

Btw, I'm using Django 1.0.2 installed from macports (on Mac, obviously), the db 
backend is a PostgreSQL 8.2 database.

Anyone ever experienced a similar problem? Any hints what the problem could be 
(I'm quite clueless atm)?

Thanks for any hints/comments.

What can you do with the new Windows Live? Find out





_
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.

http://www.microsoft.com/windows/windowslive/products/photos.aspx
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Admin hangs while updating a modified, repopulated model

2009-02-16 Thread haestan none

Hi,

I have a strange problem while editing a modified model in the admin. Whenever 
I change my models I usually issue the following commands to change the model 
and repopulate my data:

# ./manage.py dumpdata --indent=4 redir > old_data.json
-> do the model changes
# ./manage.py reset redir
# ./manage.py syncdb
# ./manage.py loaddata  old_data.json

Then, when I try to edit a model that has been changed in this process (f.e. 
added a db field), the admin hangs as soon as I submit save and the whole 
Django builtin webserver becomes unresponsive. Even restarting the webserver 
does not resolve this problem. It's definitely no browser problem since I 
tested it with different browser types. It's no database problem since issuing 
the query in the db shell works without any problems.

Btw, I'm using Django 1.0.2 installed from macports (on Mac, obviously), the db 
backend is a PostgreSQL 8.2 database.

Anyone ever experienced a similar problem? Any hints what the problem could be 
(I'm quite clueless atm)?

Thanks for any hints/comments.

_
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.

http://www.microsoft.com/windows/windowslive/products/photos.aspx
--~--~-~--~~~---~--~~
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: Authentication/access check when serving static media thru Apache/nginx

2009-02-16 Thread Ales Zoulek

You can write apache auth module in python, which is calling your
external (django) code.

It's not exactly Django issue. Maybe this blog post could help you

http://www.thoughtspark.org/node/25


A.

On Mon, Feb 16, 2009 at 10:44 AM, MrMuffin  wrote:
>
> I`m using django to develop something similar to flickr, a site for
> photo-sharing. Photos can be public, need authentication or be
> personal and not available for anyone but the owner. Serving static
> data using django is not optimal, but how can I control access like
> this when serving static media using apache or nginx?
>
> Thanks in advance.
> >
>



-- 
--
Ales Zoulek
+420 604 332 515
Jabber: ales.zou...@gmail.com
--

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



Re: Add views to admin interface

2009-02-16 Thread Ales Zoulek

> Once you have added a new HTML link to the template that will trigger
> your view, you have to write a view for it. You add something to one of
> your URL Conf files to catch the URL (do this *before* any admin
> patterns are processed, so that your pattern is handled first) and send
> it off to the view you have written. That view will just be a normal
> Django view, so you can use the normal permission decorators on the view
> if you like.

Or you can overload __call__ method of ModelAdmin class.
class PersonAdmin(admin.ModelAdmin):
  def __call__(self, request, url, *a, **k):
if url.startswith('mypath'):
   return my_view(request)
return super(PersonAdmin, self).__call__(request, url, *a, **k)


You still need to link it from custom admin template.


A.

>
> Regards,
> Malcolm
>
>
> >
>



-- 
--
Ales Zoulek
+420 604 332 515
Jabber: ales.zou...@gmail.com
--

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



Authentication/access check when serving static media thru Apache/nginx

2009-02-16 Thread MrMuffin

I`m using django to develop something similar to flickr, a site for
photo-sharing. Photos can be public, need authentication or be
personal and not available for anyone but the owner. Serving static
data using django is not optimal, but how can I control access like
this when serving static media using apache or nginx?

Thanks in advance.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Keys composed of multiple fields

2009-02-16 Thread jfmxl

Hi again,

How do I handle multifield keys?

I have multifield primary keys which are in turn used as foreign keys
in other tables.

My database backend is MySQL if that makes a difference.
--~--~-~--~~~---~--~~
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: InnoDB tables for MySQL

2009-02-16 Thread jfmxl

On Feb 16, 2:24 pm, Alex Gaynor  wrote:
> On Mon, Feb 16, 2009 at 1:37 AM, jfmxl  wrote:
>
> > Hi,
>
> > I read through the tutorials and thank you very much! They are well
> > designed and very helpful.
>
> > I noticed that the models' database definitions created using MySQL
> > always create MyISAM tables, but to use functional constraints on
> > foreign keys one must use InnoDB tables in MySQL.
>
> > Is there someway to change the table type created from MyISAM to
> > MyInnoDB with MySQL?
>
> By adding:
>
> DATABASE_OPTIONS = {
>    "init_command": "SET storage_engine=INNODB",
>
> }
>
> you can get innodb tables by default.
>
> Alex

Thanks very much! Now for primary keys using multiple fields... but
I'll open another thread.
>
> --
> "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
-~--~~~~--~~--~--~---



Negative value in forms.Integerfield throws TypeError

2009-02-16 Thread coan

I'm validating a form, and use forms.IntegerField(min_value=0,).

If I submit a -1 value in that field, it throws a TypeError: not all
arguments converted during string formatting.
How come it doesn't raise a forms.ValidationError, and how should I
catch a negative value in this field?
--~--~-~--~~~---~--~~
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: Supported Django version of Googale app engine

2009-02-16 Thread nivhab

Thanks!

On Feb 16, 10:51 am, Jarek Zgoda  wrote:
> Wiadomość napisana w dniu 2009-02-16, o godz. 08:32, przez nivhab:
>
> > Does anyone know if Django 1.0 is already supported out-of-the-box on
> > the Google app engine?
>
> Yes. It is not included, though.
>
> Seehttp://code.google.com/appengine/articles/django.htmlin the  
> section "Installing Django Development Version".
>
> --
> We read Knuth so you don't have to. - Tim Peters
>
> Jarek Zgoda, R, Redefine
> jarek.zg...@redefine.pl
--~--~-~--~~~---~--~~
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   >