Django Template Question

2009-04-05 Thread codingJoe

Up front, I'm not the most elegant coder, so please forgive.

  I have a page that is produced using django templates.   I used the
templates to do the header and footer, but now I'm down into the body
of the page.   Using the data from my template, I am able to fill the
first cell.

Is is possible to have the template do a request/response for other
data?  Or do I have to pass it all in when I build the page.   Analogy
would be an , but I don't want an image just
some text-based table data.   Or, a SharePoint WebPart that fits in a
table, but does its own thing.

{% block body %}
I am well within my body block...


  
 {{MyModel.A}}, {{MyModel.B}}   
   May Exist, May Not... Would like to pull data from another
request/response 
   May Exist, May Not... Would like to pull data from another
request/response  

{% end block %}

1.  If this is possible, how do I do it?   Simple example please.

2.  If this is poor coding, how is what I'm trying to do best
accomplished?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Best Convension for dealing with variables needed in every view.

2009-04-05 Thread Darryl Ross

Catching up on my mailing list folders.

On 30/03/2009 10:10 AM, IanR wrote:
> So if I created my own I could just add it to this list and it would
> do what I need.  Once my context_processor is made how would I add it
> to this list?  Something like
> settings.TEMPLATE_CONTEXT_PROCESSORS.append(my_processor)

I do something like this in my settings file:

from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS
TEMPLATE_CONTEXT_PROCESSORS += (
 'afoyi_com.modules.invoices.context_processors.invoice_details',
)

Regards
Darryl

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

2009-04-05 Thread alexarsh

Thanks for the fast reply.
And how can I find all python versions installed on a machine?

On Apr 5, 7:21 pm, Alex Gaynor  wrote:
> On Sun, Apr 5, 2009 at 12:16 PM, knight  wrote:
>
> > Hi,
>
> > I have 2 servers with my django app:
> > The first one has python2.5 as default python and the second don't (It
> > has python2.5 installed together with the older version).
> > I want to run dumpdata from my application and I have the following
> > problem:
> > If I call: "python manage.py dumpdata" the second server won't work.
> > If I call: "python2.5 manage.py dumpdata" the first server won't
> > work.
> > I mean, I will get the following error:
>
> > Traceback (most recent call last):
> >  File "manage.py", line 2, in 
> >    from django.core.management import execute_manager
> > ImportError: No module named django.core.management
>
> > How can I find the right python version to call? Maybe I can take it
> > from PYTHONPATH? If yes, where can I find it?
>
> > Thanks, Alex A.
>
> Getting errors like that means you have Django installed to the
> site-packages dir of that python version, to figure out which python version
> to run all you should need to do is go to each python interpretter and do
> import django, and whichever one doesn't give an error is the right one to
> use.
>
> 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 just put user id in session for authorization purpose?

2009-04-05 Thread Malcolm Tredinnick

On Sun, 2009-04-05 at 06:27 -0700, Zeal wrote:
> Django's auth is pretty good, however, I need some row-level
> authorziation mechnism, like in which department and function that the
> certain user could access, so my needs on authrization are pretty
> different than default auth model. Thanks!

I think you're misunderstanding something here, due to some lazy naming
practices in Django's past. The "auth" in django.contrib.auth is for
authentication, not authorization.

It has all the utility pieces needed to authenticate a user and store
any related user information in the session (the user object). It
doesn't handle anything to do with authorisation based on that user
object. So I was suggesting using the auth module to avoid needing to
manually store the user_id value in any session objects and to handle
the authentication portion in the natural flow of things.

Authorisation is a separate issue.

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: Pinax with django

2009-04-05 Thread atik

sorry i posted on wrong site.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Pinax with django

2009-04-05 Thread atik

The document doesn't make so much sense. Plz help me to how can i
start.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 get session data from template

2009-04-05 Thread Malcolm Tredinnick

On Sun, 2009-04-05 at 18:03 -0700, Joshua Partogi wrote:
> 
> 
> On Apr 6, 12:25 am, Antoni Aloy  wrote:
> > In your render_to_response don't forget to add
> > context_instance=RequestContext(request)
> 
> Thanks. So I have to add this everytime I return render_to_response? I
> thought I only add it on my login views.

if you're going to use it a lot, you could create a wrapper function
that you only have to pass "request" to. For example;

def render_with_request(request, *args, **kwargs):
   return render_to_response(
   context_instance=RequestContext(request),
   *args, **kwargs)

However you might find you also have more stuff you do at the end of
every view and it might make sense to have some common "finalise"
function you call each time, instead of render_to_response().
Circumstances vary.

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: Pinax with django

2009-04-05 Thread BraneSKS

atik:

You have just barely been waiting for 3 hours for the pinax-users list  
to respond. It's Saturday and a major release is coming out soon.  
Please be patient.

Someone responded 2 minutes before you posted this message: 
http://groups.google.com/group/pinax-users/browse_thread/thread/647444e431ad6cb2

If you have moved any of the files around you need to make sure that  
the paths in manage.py are set correctly.


On Apr 5, 2009, at 6:52 PM, atik wrote:

>
> I know this is for Pinax users group. But that group is not so active
> as this and i am not getting response.
> i have created a django project successfully and then create a
> directory within the project and put the files extracted from the
> pinax 0.5.1. When i have tried to run the command- python manage.py
> syncdb, it shows no module named notification.
> Was the process right? What to do?
> >


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



Re: How to get session data from template

2009-04-05 Thread Joshua Partogi



On Apr 6, 12:25 am, Antoni Aloy  wrote:
> In your render_to_response don't forget to add
> context_instance=RequestContext(request)

Thanks. So I have to add this everytime I return render_to_response? I
thought I only add it on my login views.

Many 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: django.contrib.auth user password decryption

2009-04-05 Thread Mike Ramirez
On Sunday 05 April 2009 05:39:37 pm Russell Keith-Magee wrote:
> On Sun, Apr 5, 2009 at 6:12 AM, Joshua Partogi  
wrote:
> > On Apr 4, 11:49 pm, Masklinn  wrote:
> >> On 4 Apr 2009, at 15:38 , Joshua Partogi wrote:
> >> > Dear all,
> >> >
> >> > I already take a look at the django.contrib.auth.models but could not
> >> > find any methods for decrypting the user password.
> >> >
> >> > Sometimes we need to get the real text password to be sent to user.
> >> >
> >> > What is the best way to do this? Anybody has got an idea?
> >> >
> >> > Thank you very much in advance!
> >>
> >> Django's passwords are salted[1] and hashed[2]. You cannot[3] retrieve
> >> them, and that's exactly the intent (well the intent is not that *you*
> >> cannot retrieve them, it's that nobody else can). If you need to send
> >> users their passwords, you have to generate new (random) passwords and
> >> send them that.
> >>
> >> Masklinn
> >
> > Thanks for the explanation Masklinn. :-)
> >
> > I'll find another way to send user their password.
>
> Don't. Ever. Do. This.
>
> You should _never_ store passwords in cleartext, and you should
> _never_ transmit passwords in cleartext. If you think I'm kidding,
> read up on what happened to Reddit.
>
> http://blog.moertel.com/articles/2006/12/15/never-store-passwords-in-a-data
>base
>
> Yours,
> Russ Magee %-)
>

I think that every web designer should read this,

 http://www.owasp.org/index.php/OWASP_AppSec_FAQ

and to address this question specifically:

http://www.owasp.org/index.php/OWASP_AppSec_FAQ#How_can_my_.22Forgot_Password.22_feature_be_exploited.3F

and the following four questions and answers.  

In the end, it also says the same things as Russ does.

Mike
-- 
Arcserve crashed the server again.


signature.asc
Description: This is a digitally signed message part.


Pinax with django

2009-04-05 Thread atik

I know this is for Pinax users group. But that group is not so active
as this and i am not getting response.
i have created a django project successfully and then create a
directory within the project and put the files extracted from the
pinax 0.5.1. When i have tried to run the command- python manage.py
syncdb, it shows no module named notification.
Was the process right? What to do?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django.contrib.auth user password decryption

2009-04-05 Thread Russell Keith-Magee

On Sun, Apr 5, 2009 at 6:12 AM, Joshua Partogi  wrote:
>
>
>
> On Apr 4, 11:49 pm, Masklinn  wrote:
>> On 4 Apr 2009, at 15:38 , Joshua Partogi wrote:
>>
>> > Dear all,
>>
>> > I already take a look at the django.contrib.auth.models but could not
>> > find any methods for decrypting the user password.
>>
>> > Sometimes we need to get the real text password to be sent to user.
>>
>> > What is the best way to do this? Anybody has got an idea?
>>
>> > Thank you very much in advance!
>>
>> Django's passwords are salted[1] and hashed[2]. You cannot[3] retrieve
>> them, and that's exactly the intent (well the intent is not that *you*
>> cannot retrieve them, it's that nobody else can). If you need to send
>> users their passwords, you have to generate new (random) passwords and
>> send them that.
>>
>> Masklinn
>
> Thanks for the explanation Masklinn. :-)
>
> I'll find another way to send user their password.

Don't. Ever. Do. This.

You should _never_ store passwords in cleartext, and you should
_never_ transmit passwords in cleartext. If you think I'm kidding,
read up on what happened to Reddit.

http://blog.moertel.com/articles/2006/12/15/never-store-passwords-in-a-database

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: Validate with PIL

2009-04-05 Thread Peter Douma
I can import from the shell.
  - Original Message - 
  From: Alex Gaynor 
  To: django-users@googlegroups.com 
  Sent: Sunday, April 05, 2009 6:47 PM
  Subject: Re: Validate with PIL





  On Sun, Apr 5, 2009 at 6:37 PM, CrabbyPete  wrote:


I installed the PIL Imaging library and when I validate my model I get
the error that I need the imaging library. I'm using Python 2.6.




  If you do import PIL at the python shell do you get an import error?  if so 
you're installation wasn't successful.

  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: Deploying django application

2009-04-05 Thread Daniel Roseman

On Apr 5, 10:04 pm, Oleg Oltar  wrote:
> Hi!
>
> I am trying to serve my project using server-spawned processes
>
> I created file .htaccess in my web_root directory which contains:
> AddHandler fastcgi-script .fcgi
> RewriteEngine On
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteRule ^(.*)$ mysite.fcgi/$1 [QSA,L]
>
> And also added file mysite.fcgi to same dir
> #!/usr/bin/python
> import sys, os
>
> # Add a custom Python path.
> sys.path.insert(0, "/home/user/python")
>
> # Switch to the directory of your project. (Optional.)
> # os.chdir("/home/user/myproject")
>
> # Set the DJANGO_SETTINGS_MODULE environment variable.
> os.environ['DJANGO_SETTINGS_MODULE'] = "myproject.settings"
>
> from django.core.servers.fastcgi import runfastcgi
> runfastcgi(method="threaded", daemonize="false")
>
> But when trying to go to my domainhttp://goclub.org.ua/I see the
> contents of mysite.fcgi instead of my site...
>
> Could you please help me to understand the problem

Directives are only allowed in .htaccess files if the main Apache
configuration has been set to allow them. It's possible that whoever
runs your server has not allowed the use of AddHandler in .htaccess,
so it is serving the file rather than running it.

Talk to your hosting company and see if this is the case, and if so
whether there are any alternatives that they support.
--
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
-~--~~~~--~~--~--~---



django forms - JSONRPC API - progress

2009-04-05 Thread lkcl

the basic plan is to provide a generic JSONRPC front-end to Django
forms which could conceivably become a de-facto interoperability
standard for web 2.0 applications to create, validate and store data
in "forms".

i've just added "describe" and "describe_errors".

http://pyjamas.svn.sourceforge.net/viewvc/pyjamas/trunk/pyjs/jsonrpc/django/jsonrpc.py?view=markup

the basic idea, as mentioned previously, is to allow an AJAX
application, using JSONRPC, to interact fully with Django Forms. i.e.
*without* forcing the server to generate some dumb bit of HTML which
you are forced to use, forced to perform HTTP POSTs on etc. etc.

now that "describe" has been added, the next step will be to create an
http://pyjs.org AJAX form "widget" that uses the "describe" command to
find out what fields to build into the form.

* CharField, FloatField, DecimalField etc. will result in a pyjamas
TextBox, with the option for a TextArea being a user-defined option.

* DateField, TimeField etc. will result in a calendar widget popping
up, there's one i've found at:
http://pyjamas-utils.googlecode.com/svn/trunk/examples/calendar/index.py

* FilePathField will be interesting because it implies a level of
interaction with the server: the most sensible widget to use here
would be a recursive / interactive Tree Widget that performs further
JSONRPC function calls to obtain subdirectory contents, on request.

exactly what these fields will go in to, and what CSS style names will
be attached to them, will be entirely up to the user, with sensible
defaults provided.  a Grid seems the most sensible, with the names on
the left, and fields on the right, springs to mind, resulting in the
construction of something similar to the "as_table" method of Django
Forms.  except pure AJAX. no HTML in sight.

interestingly, i can't find anything in Django Forms which tells you
how to specify "password" input boxes.  also, RegexField's design
destroys the possibility for finding out what the regex is (in string
form), thus making it very difficult to perform client-side validation
(using the ECMAScript Regex object).

so there are a few hurdles yet to be overcome.

the above can also be implemented in GWT, using exactly the same
JSONRPC service, which is why i describe the API as being a de-facto
standard.  in fact, if you were feeling particularly masochistic (i.e.
a PHP programmer) you could implement this in PHP, both client or
server.

anyone who would like to collaborate or contribute please do join the
pyjamas-dev list.

l.

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

2009-04-05 Thread eli

No, how to add  functionality to back to the previous step without
deleting current step's data.

regards.

On 5 Kwi, 22:39, codecowboy  wrote:
> Are you asking how to modify the html in the multi-step-form app to
> add a button?
>
> On Apr 5, 4:33 pm, eli  wrote:
>
> > No, I have one view.. My example is similar to that one from Django
> > tutorial:http://docs.djangoproject.com/en/dev/ref/contrib/formtools/form-wizar...
>
> > regards.
>
> > On 5 Kwi, 21:52, codecowboy  wrote:
>
> > > Do you have one view for each form or do you use one view with a large
> > > amount of conditional logic (e.g. if stepone then show this form
> > > elseif steptwo show this form)?
>
> > > On Apr 5, 1:14 pm, eli  wrote:
>
> > > > anybody ? :-)
>
> > > > regards.
>
> > > > On 4 Kwi, 11:17, eli  wrote:
> > > > I have no problem reading existing docs if you know that this is 
> > > > already answered elsewhere
> > > > > Hi,
>
> > > > > What is the best way to add button "previous step" to multi-steps
> > > > > form ?
>
> > > > > Thank You.
>
> > > > > 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
-~--~~~~--~~--~--~---



Deploying django application

2009-04-05 Thread Oleg Oltar

Hi!

I am trying to serve my project using server-spawned processes

I created file .htaccess in my web_root directory which contains:
AddHandler fastcgi-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ mysite.fcgi/$1 [QSA,L]

And also added file mysite.fcgi to same dir
#!/usr/bin/python
import sys, os

# Add a custom Python path.
sys.path.insert(0, "/home/user/python")

# Switch to the directory of your project. (Optional.)
# os.chdir("/home/user/myproject")

# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "myproject.settings"

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")


But when trying to go to my domain http://goclub.org.ua/ I see the
contents of mysite.fcgi instead of my site...


Could you please help me to understand the problem

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

2009-04-05 Thread codecowboy

Are you asking how to modify the html in the multi-step-form app to
add a button?

On Apr 5, 4:33 pm, eli  wrote:
> No, I have one view.. My example is similar to that one from Django
> tutorial:http://docs.djangoproject.com/en/dev/ref/contrib/formtools/form-wizar...
>
> regards.
>
> On 5 Kwi, 21:52, codecowboy  wrote:
>
> > Do you have one view for each form or do you use one view with a large
> > amount of conditional logic (e.g. if stepone then show this form
> > elseif steptwo show this form)?
>
> > On Apr 5, 1:14 pm, eli  wrote:
>
> > > anybody ? :-)
>
> > > regards.
>
> > > On 4 Kwi, 11:17, eli  wrote:
> > > I have no problem reading existing docs if you know that this is already 
> > > answered elsewhere
> > > > Hi,
>
> > > > What is the best way to add button "previous step" to multi-steps
> > > > form ?
>
> > > > Thank You.
>
> > > > 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: Form wizard - previous step

2009-04-05 Thread eli

No, I have one view.. My example is similar to that one from Django
tutorial: 
http://docs.djangoproject.com/en/dev/ref/contrib/formtools/form-wizard/?from=olddocs

regards.

On 5 Kwi, 21:52, codecowboy  wrote:
> Do you have one view for each form or do you use one view with a large
> amount of conditional logic (e.g. if stepone then show this form
> elseif steptwo show this form)?
>
> On Apr 5, 1:14 pm, eli  wrote:
>
> > anybody ? :-)
>
> > regards.
>
> > On 4 Kwi, 11:17, eli  wrote:
> > I have no problem reading existing docs if you know that this is already 
> > answered elsewhere
> > > Hi,
>
> > > What is the best way to add button "previous step" to multi-steps
> > > form ?
>
> > > Thank You.
>
> > > 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: Beginner's Help needed

2009-04-05 Thread Florian Strzelecki
Yes you can !

*WSGI :*

Alias /another /path/to/your/phpApplication
WSGIScriptAlias / /path/to/file.wsgi

*MOD_PYTHON :*

Use Location apache directive.
I don't remember what to do for php... sorry, but I know that on this way.


2009/4/5 Dougal Matthews 

> It depends how you mean combine really. You can have them both running on
> the same server, you can have them share the same database (then you can
> still manage it with django)
> Dougal
>
>
> ---
> Dougal Matthews - @d0ugal
> http://www.dougalmatthews.com/
>
>
>
> 2009/4/5 atik 
>
>
>> Ok. Again Thanks. I will do it.
>> Can i combine django application with PHP?
>>
>>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 can I filter query sets in a django template?

2009-04-05 Thread Daniel Roseman

On Apr 5, 8:49 pm, codecowboy  wrote:
> I posted a question earlier today about circular imports (http://
> groups.google.com/group/django-users/t/6119e979131c8c25).  I now have
> a follow question to that.  I've got the following view logic.
>
> def portal(request):
>     scientist_id = 1
>     s = get_object_or_404(Scientist, pk=scientist_id)
>     return render_to_response('scientists/portal.html',
> {'scientist':s})
>
> Now, Scientists are related (many-to-many) to Conferences through
> ConferenceAttendee.  Both of these models are created in a different
> app.  I won't paste them in unless someone needs to see them in order
> to answer my question.
>
> I only want to loop through conferences that this scientist is
> presenting.  (ConferenceAttendee.presenter=True).  I have tried
> following the docs (http://docs.djangoproject.com/en/dev/topics/db/
> queries/#field-lookups-intro), but it seems that you can only call the
> filter method in python files like views.py or models.py.  I've tried
> replacing the loop code below with "for ...conference._set.filter(...)
> but python gives me errors when I do that.  Here is my template logic.
>
> Your Presentations
>
> 
>     {% for conference in scientist.conference_set.all %}
>         
> {{ conference.title }}
>     {% endfor %}
>
> 
>
> I've been stuck on this one for days now so any help would be greatly
> appreciated.  Please do point me to any articles that I may have
> missed that already answer this post.
>
> Thank you,
>
> Guy

The issue is that in a template, you can't call any method or function
that requires an argument. There are two ways of dealing with this:
create a custom template tag or filter, or create a method that
doesn't need arguments.

In this case, I'd go with the second option. Just create a method on
the Scientist model that returns a queryset of conferences at which
they are a presenter.

class Scientist(models.Model):
 blah 

def presenting_conferences(self):
return self.conferences_set.filter(presenter=True)
#or whatever the filter is

and in the template:

{% for conference in scientists.presenting_conferences %}
etc.
--
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: Best JS Library compatibility for Django

2009-04-05 Thread Florian Strzelecki
Hm... look at this :
http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.is_ajax

HttpRequest.is_ajax()¶
New
in Django 1.0: *Please, see the release
notes*

Returns True if the request was made via an XMLHttpRequest, by checking the
HTTP_X_REQUESTED_WITH header for the string 'XMLHttpRequest'. The following
major JavaScript libraries all send this header:

   - jQuery
   - Dojo
   - MochiKit
   - MooTools
   - Prototype
   - YUI

If you write your own XMLHttpRequest call (on the browser side), you'll have
to set this header manually if you want is_ajax() to work.


2009/4/5 Alex Gaynor 

>
>
> On Sun, Apr 5, 2009 at 4:02 PM, lodmod@gmail.com  > wrote:
>
>>
>> What are some JS libraries that people have had good experience with
>> using in conjunction with Django webapps?
>>
>>
>>
> Django will work perfectly fine with any javascript library you choose to
> use.  That being said I personally like jQuery because of its simple API.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
>
>
> >
>

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



Re: How can I filter query sets in a django template?

2009-04-05 Thread Florian Strzelecki
Did you try to look at Inclusion Tag ?
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#inclusion-tags

In template you are not allowed to use some python code... but with an
inclusion tag, you will be able to write this :

{% load related_conferences %}
{% related_conferences scientist %}

And your inclusion tag may be this :

@register.inclusion_tag('path/to/tag/related_conferences.html')
def related_conferences(scientist):
# define here list_of_conferences
return {'list': list_of_conferences}

The inclusion tag have been created for this : move python code into python
file ! Not into template files.

I hope this will help you.
And sorry for my English, I'm french. :)


2009/4/5 codecowboy 

>
> I posted a question earlier today about circular imports (http://
> groups.google.com/group/django-users/t/6119e979131c8c25).  I now have
> a follow question to that.  I've got the following view logic.
>
> def portal(request):
>scientist_id = 1
>s = get_object_or_404(Scientist, pk=scientist_id)
>return render_to_response('scientists/portal.html',
> {'scientist':s})
>
> Now, Scientists are related (many-to-many) to Conferences through
> ConferenceAttendee.  Both of these models are created in a different
> app.  I won't paste them in unless someone needs to see them in order
> to answer my question.
>
> I only want to loop through conferences that this scientist is
> presenting.  (ConferenceAttendee.presenter=True).  I have tried
> following the docs (http://docs.djangoproject.com/en/dev/topics/db/
> queries/#field-lookups-intro),
> but it seems that you can only call the
> filter method in python files like views.py or models.py.  I've tried
> replacing the loop code below with "for ...conference._set.filter(...)
> but python gives me errors when I do that.  Here is my template logic.
>
> Your Presentations
>
> 
>{% for conference in scientist.conference_set.all %}
>
> {{ conference.title }}
>{% endfor %}
>
> 
>
> I've been stuck on this one for days now so any help would be greatly
> appreciated.  Please do point me to any articles that I may have
> missed that already answer this post.
>
> Thank you,
>
> Guy
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Best JS Library compatibility for Django

2009-04-05 Thread Alex Gaynor
On Sun, Apr 5, 2009 at 4:02 PM, lodmod@gmail.com
wrote:

>
> What are some JS libraries that people have had good experience with
> using in conjunction with Django webapps?
>
> >
>
Django will work perfectly fine with any javascript library you choose to
use.  That being said I personally like jQuery because of its simple API.

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



Best JS Library compatibility for Django

2009-04-05 Thread lodmod....@gmail.com

What are some JS libraries that people have had good experience with
using in conjunction with Django webapps?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Beginner's Help needed

2009-04-05 Thread Dougal Matthews
It depends how you mean combine really. You can have them both running on
the same server, you can have them share the same database (then you can
still manage it with django)
Dougal


---
Dougal Matthews - @d0ugal
http://www.dougalmatthews.com/



2009/4/5 atik 

>
> Ok. Again Thanks. I will do it.
> Can i combine django application with PHP?
> >
>

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

2009-04-05 Thread codecowboy

Do you have one view for each form or do you use one view with a large
amount of conditional logic (e.g. if stepone then show this form
elseif steptwo show this form)?

On Apr 5, 1:14 pm, eli  wrote:
> anybody ? :-)
>
> regards.
>
> On 4 Kwi, 11:17, eli  wrote:
> I have no problem reading existing docs if you know that this is already 
> answered elsewhere
> > Hi,
>
> > What is the best way to add button "previous step" to multi-steps
> > form ?
>
> > Thank You.
>
> > 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
-~--~~~~--~~--~--~---



How can I filter query sets in a django template?

2009-04-05 Thread codecowboy

I posted a question earlier today about circular imports (http://
groups.google.com/group/django-users/t/6119e979131c8c25).  I now have
a follow question to that.  I've got the following view logic.

def portal(request):
scientist_id = 1
s = get_object_or_404(Scientist, pk=scientist_id)
return render_to_response('scientists/portal.html',
{'scientist':s})

Now, Scientists are related (many-to-many) to Conferences through
ConferenceAttendee.  Both of these models are created in a different
app.  I won't paste them in unless someone needs to see them in order
to answer my question.

I only want to loop through conferences that this scientist is
presenting.  (ConferenceAttendee.presenter=True).  I have tried
following the docs (http://docs.djangoproject.com/en/dev/topics/db/
queries/#field-lookups-intro), but it seems that you can only call the
filter method in python files like views.py or models.py.  I've tried
replacing the loop code below with "for ...conference._set.filter(...)
but python gives me errors when I do that.  Here is my template logic.

Your Presentations


{% for conference in scientist.conference_set.all %}

{{ conference.title }}
{% endfor %}



I've been stuck on this one for days now so any help would be greatly
appreciated.  Please do point me to any articles that I may have
missed that already answer this post.

Thank you,

Guy
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Beginner's Help needed

2009-04-05 Thread atik

Ok. Again Thanks. I will do it.
Can i combine django application with PHP?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: More beginner questions : model data in public view

2009-04-05 Thread zayatzz

ah.. figured it out already... its the 'lang'.. should be 'lpl'

Alan.

On Apr 5, 10:39 pm, zayatzz  wrote:
> Thanks again. Thats pretty much clear to every programmer i guess
> (which im not - im just trying to figure out wtf are the programmers
> at my work talking about).
>
> Can you clarify me why these do not work :
>
> def index(request):
>         lpl = lang.objects.get(id=1)
>         return render_to_response('front/index.html', {'lang': lpl })
>
> def index(request):
>         lpl = get_object_or_404(lang, id=1)
>         return render_to_response('front/index.html', {'lang': lpl})
>
> and this does
>
> def index(request):
>         lpl = lang.objects.get(id=1)
>         t = loader.get_template('front/index.html')
>         c = Context({
>                 'lpl': lpl
>         })
>         return HttpResponse(t.render(c))
>
> since i get crap in public view, it seems there is something wrong
> with getting the value of lpl..
>
> alan.
>
> On Apr 5, 10:32 pm, Alex Gaynor  wrote:
>
> > On Sun, Apr 5, 2009 at 3:30 PM, zayatzz  wrote:
>
> > > Okay.. the problem was what i suspected, but i thought, that if i
> > > filter the results and get object by its id, then it would be ok,
> > > since im getting single object.
>
> > > Alan.
>
> > > On Apr 5, 10:25 pm, Alex Gaynor  wrote:
> > > > On Sun, Apr 5, 2009 at 3:23 PM, zayatzz 
> > > wrote:
>
> > > > > Hello
>
> > > > > I have created app for public view or well.. the whole site actually,
> > > > > but its somehow not working.
>
> > > > > I have this in views.py
>
> > > > > def index(request):
> > > > >        lpl = lang.objects.filter(id=1)
> > > > >        t = loader.get_template('front/index.html')
> > > > >        c = Context({
> > > > >                'lpl': lpl
> > > > >        })
> > > > >        return HttpResponse(t.render(c))
>
> > > > > And this in index.html :
>
> > > > > {% if lpl %}
> > > > > 
> > > > > {{ lpl.title }}
> > > > > 
> > > > >        {{ lpl.name }}
> > > > > 
> > > > > 
> > > > > {% else %}
> > > > > crap
> > > > > {% endif %}
>
> > > > > For a while i was getting crap, until i copy pasted code from
> > > > > example... now im getting just this in browser:
>
> > > > > 
> > > > > 
> > > > > 
> > > > >        
> > > > > 
> > > > > 
>
> > > > > So obviously i dont know how to use the data from the model and
> > > > > perhaps im phrasing the question both wrong here and in my searches,
> > > > > because i have not been able to find answer in groups or web.
>
> > > > > Alan
>
> > > > Your issue here is `lpl` is a QuerySet, not a lang object, when you want
> > > > more than one object you use .filter and then iterate over it using the
> > > for
> > > > tag.  However, when you want a single item you should ues .get(), so
> > > > lang.objects.get(id=1).
>
> > > > 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
>
> > Django doesn't know you have a single object, all it sees is that you have a
> > queryset.  Just like if you have a list with only one object you can't
> > pretend that it's the same as the one object: [obj] != obj.
>
> > 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: More beginner questions : model data in public view

2009-04-05 Thread zayatzz

Thanks again. Thats pretty much clear to every programmer i guess
(which im not - im just trying to figure out wtf are the programmers
at my work talking about).

Can you clarify me why these do not work :

def index(request):
lpl = lang.objects.get(id=1)
return render_to_response('front/index.html', {'lang': lpl })

def index(request):
lpl = get_object_or_404(lang, id=1)
return render_to_response('front/index.html', {'lang': lpl})

and this does

def index(request):
lpl = lang.objects.get(id=1)
t = loader.get_template('front/index.html')
c = Context({
'lpl': lpl
})
return HttpResponse(t.render(c))

since i get crap in public view, it seems there is something wrong
with getting the value of lpl..

alan.

On Apr 5, 10:32 pm, Alex Gaynor  wrote:
> On Sun, Apr 5, 2009 at 3:30 PM, zayatzz  wrote:
>
> > Okay.. the problem was what i suspected, but i thought, that if i
> > filter the results and get object by its id, then it would be ok,
> > since im getting single object.
>
> > Alan.
>
> > On Apr 5, 10:25 pm, Alex Gaynor  wrote:
> > > On Sun, Apr 5, 2009 at 3:23 PM, zayatzz 
> > wrote:
>
> > > > Hello
>
> > > > I have created app for public view or well.. the whole site actually,
> > > > but its somehow not working.
>
> > > > I have this in views.py
>
> > > > def index(request):
> > > >        lpl = lang.objects.filter(id=1)
> > > >        t = loader.get_template('front/index.html')
> > > >        c = Context({
> > > >                'lpl': lpl
> > > >        })
> > > >        return HttpResponse(t.render(c))
>
> > > > And this in index.html :
>
> > > > {% if lpl %}
> > > > 
> > > > {{ lpl.title }}
> > > > 
> > > >        {{ lpl.name }}
> > > > 
> > > > 
> > > > {% else %}
> > > > crap
> > > > {% endif %}
>
> > > > For a while i was getting crap, until i copy pasted code from
> > > > example... now im getting just this in browser:
>
> > > > 
> > > > 
> > > > 
> > > >        
> > > > 
> > > > 
>
> > > > So obviously i dont know how to use the data from the model and
> > > > perhaps im phrasing the question both wrong here and in my searches,
> > > > because i have not been able to find answer in groups or web.
>
> > > > Alan
>
> > > Your issue here is `lpl` is a QuerySet, not a lang object, when you want
> > > more than one object you use .filter and then iterate over it using the
> > for
> > > tag.  However, when you want a single item you should ues .get(), so
> > > lang.objects.get(id=1).
>
> > > 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
>
> Django doesn't know you have a single object, all it sees is that you have a
> queryset.  Just like if you have a list with only one object you can't
> pretend that it's the same as the one object: [obj] != obj.
>
> 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: Beginner's Help needed

2009-04-05 Thread Alex Gaynor
On Sun, Apr 5, 2009 at 3:35 PM, atik  wrote:

>
> Thanks! That is solved. Another Question.
> I can only run project at development server. How to run on apache?
> >
>
You can run under Apache using either mod_python or mod_wsgi, start by
taking a look at their documentation:
http://docs.djangoproject.com/en/dev/howto/deployment/modpython/
http://docs.djangoproject.com/en/dev/howto/deployment/modwsgi/

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: Beginner's Help needed

2009-04-05 Thread atik

Thanks! That is solved. Another Question.
I can only run project at development server. How to run on apache?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Beginner's Help needed

2009-04-05 Thread Alex Gaynor
On Sun, Apr 5, 2009 at 3:28 PM, atik  wrote:

>
>
> here is my urls.py file-
>
> from django.conf.urls.defaults import *
>
> urlpatterns = patterns('',
>(r'^polls/$', 'mysite.polls.views.index'),
>(r'^polls/(?P\d+)/$', 'mysite.polls.views.detail'),
>(r'^polls/(?P\d+)/results/$',
> 'mysite.polls.views.results'),
>(r'^polls/(?P\d+)/vote/$', 'mysite.polls.views.vote'),
> )
>
>
> # Uncomment the next two lines to enable the admin:
> from django.contrib import admin
> admin.autodiscover()
>
> #urlpatterns = patterns('',
># Example:
># (r'^mysite/', include('mysite.foo.urls')),
>
># Uncomment the admin/doc line below and add
> 'django.contrib.admindocs'
># to INSTALLED_APPS to enable admin documentation:
># (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
># Uncomment the next line to enable the admin:
>(r'^admin/(.*)', admin.site.root),
> )
>
> >
>
What you want to do is combine these into one urlpattern:

from django.conf.urls.defaults import *

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
(r'^polls/$', 'mysite.polls.views.index'),
(r'^polls/(?P\d+)/$', 'mysite.polls.views.detail'),
(r'^polls/(?P\d+)/results/$', 'mysite.polls.views.results'),
(r'^polls/(?P\d+)/vote/$', 'mysite.polls.views.vote'),
(r'^admin/(.*)', admin.site.root),
)

Would be the end result.

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: More beginner questions : model data in public view

2009-04-05 Thread zayatzz

Okay.. the problem was what i suspected, but i thought, that if i
filter the results and get object by its id, then it would be ok,
since im getting single object.

Alan.

On Apr 5, 10:25 pm, Alex Gaynor  wrote:
> On Sun, Apr 5, 2009 at 3:23 PM, zayatzz  wrote:
>
> > Hello
>
> > I have created app for public view or well.. the whole site actually,
> > but its somehow not working.
>
> > I have this in views.py
>
> > def index(request):
> >        lpl = lang.objects.filter(id=1)
> >        t = loader.get_template('front/index.html')
> >        c = Context({
> >                'lpl': lpl
> >        })
> >        return HttpResponse(t.render(c))
>
> > And this in index.html :
>
> > {% if lpl %}
> > 
> > {{ lpl.title }}
> > 
> >        {{ lpl.name }}
> > 
> > 
> > {% else %}
> > crap
> > {% endif %}
>
> > For a while i was getting crap, until i copy pasted code from
> > example... now im getting just this in browser:
>
> > 
> > 
> > 
> >        
> > 
> > 
>
> > So obviously i dont know how to use the data from the model and
> > perhaps im phrasing the question both wrong here and in my searches,
> > because i have not been able to find answer in groups or web.
>
> > Alan
>
> Your issue here is `lpl` is a QuerySet, not a lang object, when you want
> more than one object you use .filter and then iterate over it using the for
> tag.  However, when you want a single item you should ues .get(), so
> lang.objects.get(id=1).
>
> 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: Beginner's Help needed

2009-04-05 Thread atik


here is my urls.py file-

from django.conf.urls.defaults import *

urlpatterns = patterns('',
(r'^polls/$', 'mysite.polls.views.index'),
(r'^polls/(?P\d+)/$', 'mysite.polls.views.detail'),
(r'^polls/(?P\d+)/results/$',
'mysite.polls.views.results'),
(r'^polls/(?P\d+)/vote/$', 'mysite.polls.views.vote'),
)


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

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

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

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

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: More beginner questions : model data in public view

2009-04-05 Thread Alex Gaynor
On Sun, Apr 5, 2009 at 3:23 PM, zayatzz  wrote:

>
> Hello
>
> I have created app for public view or well.. the whole site actually,
> but its somehow not working.
>
> I have this in views.py
>
> def index(request):
>lpl = lang.objects.filter(id=1)
>t = loader.get_template('front/index.html')
>c = Context({
>'lpl': lpl
>})
>return HttpResponse(t.render(c))
>
> And this in index.html :
>
> {% if lpl %}
> 
> {{ lpl.title }}
> 
>{{ lpl.name }}
> 
> 
> {% else %}
> crap
> {% endif %}
>
> For a while i was getting crap, until i copy pasted code from
> example... now im getting just this in browser:
>
> 
> 
> 
>
> 
> 
>
> So obviously i dont know how to use the data from the model and
> perhaps im phrasing the question both wrong here and in my searches,
> because i have not been able to find answer in groups or web.
>
> Alan
> >
>
Your issue here is `lpl` is a QuerySet, not a lang object, when you want
more than one object you use .filter and then iterate over it using the for
tag.  However, when you want a single item you should ues .get(), so
lang.objects.get(id=1).

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



More beginner questions : model data in public view

2009-04-05 Thread zayatzz

Hello

I have created app for public view or well.. the whole site actually,
but its somehow not working.

I have this in views.py

def index(request):
lpl = lang.objects.filter(id=1)
t = loader.get_template('front/index.html')
c = Context({
'lpl': lpl
})
return HttpResponse(t.render(c))

And this in index.html :

{% if lpl %}

{{ lpl.title }}

{{ lpl.name }}


{% else %}
crap
{% endif %}

For a while i was getting crap, until i copy pasted code from
example... now im getting just this in browser:








So obviously i dont know how to use the data from the model and
perhaps im phrasing the question both wrong here and in my searches,
because i have not been able to find answer in groups or web.

Alan
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Beginner's Help needed

2009-04-05 Thread Alex Gaynor
On Sun, Apr 5, 2009 at 3:17 PM, atik  wrote:

>
> Hello!
> I am new to django and using version 1.0.1. I have done some basics
> shown on official  target='_blank'>tutorials. I have a question: Every
> thing is quite ok to me except that when i have come through part two
> of the tutorial (a admin site) it gives me admin interface. But after
> finishing part three and four i have only public site. How can i get
> both working?
> >
>
Absolutely.  Without seeing  your code I'd guess the problem is that you
only have the patterns from part 2 in your URLconf.  You need to make sure
you have the URLs from both parts in your URLconf.

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



Multiple Database in 1.0.2 with custom manager

2009-04-05 Thread Justin

I am trying to setup a custom manager to connect to another database
on the same server as my default mysql connection.  I have tried
following the examples here
http://groups.google.com/group/django-developers/browse_thread/thread/5d8c73eb483029af/19b19ed79bbbfa0d
and here 
http://www.djangrrl.com/view/multiple-database-connection-a-simple-use-case/
but have had no luck.  I get an empty tuple when returning
MyCustomModel.objects.all().

Here is what I have in manager.py
from django.db import models
from django.db.backends.mysql.base import DatabaseWrapper
from django.conf import settings

class CustomManager(models.Manager):
"""
This Manager lets you set the DATABASE_NAME on a per-model basis.
"""
def __init__(self, database_name, *args, **kwargs):
models.Manager.__init__(self, *args, **kwargs)
self.database_name = database_name

def get_query_set(self):
qs = models.Manager.get_query_set(self)
qs.query.connection = self.get_db_wrapper()
return qs

def get_db_wrapper(self):
# Monkeypatch the settings file. This is not thread-safe!
old_db_name = settings.DATABASE_NAME
settings.DATABASE_NAME = self.database_name
wrapper = DatabaseWrapper()
wrapper._cursor(settings)
settings.DATABASE_NAME = old_db_name
return wrapper

and here is what I have in models.py:

from django.db import models
from myproject.myapp.manager import CustomManager
class MyCustomModel(models.Model):
field1  = models.CharField(max_length=765)
attribute = models.CharField(max_length=765)

objects = CustomManager('custom_database_name')

class Meta:
abstract = True

But if I run MyCustomModel.objects.all() I get an empty list.

I am pretty new at this stuff so I am not sure if this works with
1.0.2, I am going to look into the Manager code to see if I can figure
it out but I am just wondering if I am doing something wrong here.

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



Beginner's Help needed

2009-04-05 Thread atik

Hello!
I am new to django and using version 1.0.1. I have done some basics
shown on official tutorials. I have a question: Every
thing is quite ok to me except that when i have come through part two
of the tutorial (a admin site) it gives me admin interface. But after
finishing part three and four i have only public site. How can i get
both working?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Model A imports Model B imports Model A - I'm completely lost as to how to get around circular imports

2009-04-05 Thread codecowboy

Doug,

Thank you so much.  I completely missed that detail while ripping
through the django docs.  I've got it all working now.  Ramiro, thanks
again for your help.

For anyone else who is trying to do this and stumbles upon this
thread, here is my full final solution.

--- Overview ---
I've got two applications within the scinet project.
scinet.conferences and scinet.scientists  There are 4 files in all
that I need for this to work.  scinet.conferences.models.py,
scinet.scientists.models.py, scinet.scientists.views.py and
scinet.templates.scientists.portal.html

--- scinet.conferences.models (DjangoProjects/scinet/conferences/
models.py) ---

I define the many-to-many relationship between conferences and
scientists here.  A conference can be attended by multiple scientists
and a scientist can attend multiple conferences.  Do note that I have
arbitrarily chosen to use the Conference model to specify the
relationship between Conferences and Scientists.  I could have done
this in my scientist model just as well.  It is important to not that
I had to import the Scientist model here since I must reference it in
order to specify the relationship in the following line: scientists =
models.ManyToManyField(Scientist, through='ConferenceAttendee').

from django.db import models
from scinet.scientists.models import Scientist

class Conference(models.Model):
title = models.CharField(max_length=200)
description = models.TextField()
date = models.DateTimeField()
scientists = models.ManyToManyField(Scientist,
through='ConferenceAttendee')
created = models.DateTimeField()
modified = models.DateTimeField()

def __unicode__(self):
return self.name

class ConferenceAttendee(models.Model):
conference = models.ForeignKey(Conference)
scientist = models.ForeignKey(Scientist)
rsvp_date = models.DateTimeField()
presenter = models.BooleanField()

--- scinet.scientists.models (DjangoProjects/scinet/scientists/
models.py) ---

Here is where I define my Scientist model.  The point to note here is
that I do NOT need to reference the conference model because in
Django, I only need to define a relationship between two models in one
of the two models.  In fact, you must ONLY define the relationship
between two models in ONE of the two models.  DO NOT SPECIFY A
RELATIONSHIP BETWEEN TWO MODELS IN BOTH MODELS.

from django.db import models

class Scientist(models.Model):
user = models.ForeignKey('auth.User')
summary = models.TextField()
undergrad = models.CharField(max_length=50)
graduate = models.CharField(max_length=50)
post_doctorate = models.CharField(max_length=50)
current_employer = models.CharField(max_length=50)
zipcode = models.CharField(max_length=5)
city = models.CharField(max_length=50)
state = models.CharField(max_length=2)
country = models.CharField(max_length=200, blank=False)
created = models.DateTimeField()
modified = models.DateTimeField()

--- scinet.scientists.views (DjangoProjects/scinet/scientists/
views.py) ---

There is nothing special to note here other than that I am simply
getting a scientist.  The following line grabs a scientist and all
related conferences.  s = get_object_or_404(Scientist,
pk=scientist_id).  In the template file which I will show next, you
will see how I access the conferences that are associated with this
particular scientist.  Do note once again that there is no need to
explicitly import the Conference model.  Django (or Python) does this
magically (which I am curious about if anyone is up for explaining
that to me).

from django.shortcuts import render_to_response, get_object_or_404
from django.template import Context, loader
from scinet.scientists.models import Scientist
from django.http import HttpResponse, HttpResponseRedirect

def portal(request):
scientist_id = 1
s = get_object_or_404(Scientist, pk=scientist_id)
return render_to_response('scientists/portal.html',
{'scientist':s})

--- scinet.templates.scientists.portal (DjangoProjects/scinet/
templates/scientists/portal.html) ---

The key here is to understand how to traverse related models in
reverse.  Check out the link that Doug posted above.  In short,
because I chose to indicate a relationship between Conferences and
Scientists in the Conference model, Scientist must access conferences
in reverse.  I used Django's default naming of a reverse model
reference in my loop below.  In case you don't know, here is the loop
for traversing scientists that belong to a conference.

{% for scientist in 
conference.scientists.all %}
{{ 
scientist.user.get_full_name }}
{% endfor %}

In order to traverse the conferences that a scientist will attend you
must use scientists.conference_set.all.  The key differnece being
"_set".  Anyways, the template code that I used is below.

{{ scientist.user.get_full_name }}
You are 

Re: cx_Oracle django and "dumb" connect

2009-04-05 Thread Mike RA9FTM

Thank you for your answer.
I think it will be a problem, beacuse I am already using postgresql
database in my django project.

On 5 апр, 17:02, Alex Gaynor  wrote:
>
> Instead of importing cx_oracle directly you should do `from django.db import
> connection` which gets you a normal PEP-249 database cursor, but Django
> wraps a few of the methods to make it play nice with Unicode and such.

But, how I tried to resolve my problem:

By googling found and added this one:
import os
os.environ["NLS_LANG"] = "Russian_Russia.UTF8"

So, there is no message about unicode decode problems, but I get
oracle error "ORA-12638".
Again, by googling I found how to resolve this:
comment out string SQLNET.AUTHENTICATION_SERVICES in file sqlnet.ora.

Now it is working, but I think it is bad way.
So, will try to learn this 
http://code.djangoproject.com/wiki/MultipleDatabaseSupport

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



Re: Model A imports Model B imports Model A - I'm completely lost as to how to get around circular imports

2009-04-05 Thread Doug B

Take a look at this part of the documentation:

http://docs.djangoproject.com/en/dev/topics/db/queries/#backwards-related-objects

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



Re: django.contrib.auth user password decryption

2009-04-05 Thread Adam N

A good solution is to reset the password through the screen.

1. Validate the user through some sort of test (secret question or
something).
2. Then send them to a screen where they can reset the password
themselves to whatever they want.
3. Initiate an email to the stored email address notifying of the
password reset (in case an imposter made the change).

It's a little less secure (because of social engineering attacks), but
it's fine for a low security site while still maintaining fundamental
security at the password data level.

Keep in mind the requirement to reset an unknown password really is
for your own good.  Two way encryption of passwords is unsafe both
because somebody can get and use them without the owner even knowing
that they've been compromised and because anybody with the decryption
key (often anybody with access to the codebase) can get passwords.

-Adam

On Apr 5, 4:51 am, soniiic  wrote:
> I hope that doesn't mean storing the real password in a table in the
> database :)
>
> On Apr 4, 11:12 pm, Joshua Partogi  wrote:
>
>
>
> > On Apr 4, 11:49 pm, Masklinn  wrote:
>
> > > On 4 Apr 2009, at 15:38 , Joshua Partogi wrote:
>
> > > > Dear all,
>
> > > > I already take a look at the django.contrib.auth.models but could not
> > > > find any methods for decrypting the user password.
>
> > > > Sometimes we need to get the real text password to be sent to user.
>
> > > > What is the best way to do this? Anybody has got an idea?
>
> > > > Thank you very much in advance!
>
> > > Django's passwords are salted[1] and hashed[2]. You cannot[3] retrieve  
> > > them, and that's exactly the intent (well the intent is not that *you*  
> > > cannot retrieve them, it's that nobody else can). If you need to send  
> > > users their passwords, you have to generate new (random) passwords and  
> > > send them that.
>
> > > Masklinn
>
> > Thanks for the explanation Masklinn. :-)
>
> > I'll find another way to send user their password.
>
> > Thank you very much.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: cx_Oracle django and "dumb" connect

2009-04-05 Thread Alex Gaynor
On Sun, Apr 5, 2009 at 12:59 PM, Mike RA9FTM  wrote:

>
> Hi. I need direct connection to oracle for import some information
> sometimes.
> Here is what I do for first test:
>
>
> def orcl_test(request):
>connstr='scott/ti...@orcl'
>conn = cx_Oracle.connect(connstr)
>curs = conn.cursor()
>curs.execute('select * from dept')
>rows = [row[2] for row in curs.fetchall()]
>conn.close()
>return render_to_response('DekanatImport/test.html', {'rows':
> rows})
>
>
> This django view work, when I first load it in browser. But after
> pressing F5 I have following error.
> By debugging it using PyDev, I found, that it appears after conn =
> cx_Oracle.connect(connstr) string.
>
> I am using Django 1.0, cx_Oracle-5.0.1-10g.win32-py2.6.msi.
>
> raceback (most recent call last):
>
>  File "I:\Python26\lib\site-packages\django\core\servers
> \basehttp.py", line 277, in run
>self.result = application(self.environ, self.start_response)
>
>  File "I:\Python26\lib\site-packages\django\core\servers
> \basehttp.py", line 634, in __call__
>return self.application(environ, start_response)
>
>  File "I:\Python26\lib\site-packages\django\core\handlers\wsgi.py",
> line 239, in __call__
>response = self.get_response(request)
>
>  File "I:\Python26\lib\site-packages\django\core\handlers\base.py",
> line 128, in get_response
>return self.handle_uncaught_exception(request, resolver, exc_info)
>
>  File "I:\Python26\lib\site-packages\django\core\handlers\base.py",
> line 148, in handle_uncaught_exception
>return debug.technical_500_response(request, *exc_info)
>
>  File "I:\Python26\lib\site-packages\django\views\debug.py", line 39,
> in technical_500_response
>html = reporter.get_traceback_html()
>
>  File "I:\Python26\lib\site-packages\django\views\debug.py", line 97,
> in get_traceback_html
>'exception_value': smart_unicode(self.exc_value,
> errors='replace'),
>
>  File "I:\Python26\lib\site-packages\django\utils\encoding.py", line
> 35, in smart_unicode
>return force_unicode(s, encoding, strings_only, errors)
>
>  File "I:\Python26\lib\site-packages\django\utils\encoding.py", line
> 70, in force_unicode
>raise DjangoUnicodeDecodeError(s, *e.args)
>
> DjangoUnicodeDecodeError: 'utf8' codec can't decode bytes in position
> 11-12: invalid data. You passed in DatabaseError( object at 0x00D48E60>,) ()
>
>
> >
>
Instead of importing cx_oracle directly you should do `from django.db import
connection` which gets you a normal PEP-249 database cursor, but Django
wraps a few of the methods to make it play nice with Unicode and such.

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



cx_Oracle django and "dumb" connect

2009-04-05 Thread Mike RA9FTM

Hi. I need direct connection to oracle for import some information
sometimes.
Here is what I do for first test:


def orcl_test(request):
connstr='scott/ti...@orcl'
conn = cx_Oracle.connect(connstr)
curs = conn.cursor()
curs.execute('select * from dept')
rows = [row[2] for row in curs.fetchall()]
conn.close()
return render_to_response('DekanatImport/test.html', {'rows':
rows})


This django view work, when I first load it in browser. But after
pressing F5 I have following error.
By debugging it using PyDev, I found, that it appears after conn =
cx_Oracle.connect(connstr) string.

I am using Django 1.0, cx_Oracle-5.0.1-10g.win32-py2.6.msi.

raceback (most recent call last):

  File "I:\Python26\lib\site-packages\django\core\servers
\basehttp.py", line 277, in run
self.result = application(self.environ, self.start_response)

  File "I:\Python26\lib\site-packages\django\core\servers
\basehttp.py", line 634, in __call__
return self.application(environ, start_response)

  File "I:\Python26\lib\site-packages\django\core\handlers\wsgi.py",
line 239, in __call__
response = self.get_response(request)

  File "I:\Python26\lib\site-packages\django\core\handlers\base.py",
line 128, in get_response
return self.handle_uncaught_exception(request, resolver, exc_info)

  File "I:\Python26\lib\site-packages\django\core\handlers\base.py",
line 148, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)

  File "I:\Python26\lib\site-packages\django\views\debug.py", line 39,
in technical_500_response
html = reporter.get_traceback_html()

  File "I:\Python26\lib\site-packages\django\views\debug.py", line 97,
in get_traceback_html
'exception_value': smart_unicode(self.exc_value,
errors='replace'),

  File "I:\Python26\lib\site-packages\django\utils\encoding.py", line
35, in smart_unicode
return force_unicode(s, encoding, strings_only, errors)

  File "I:\Python26\lib\site-packages\django\utils\encoding.py", line
70, in force_unicode
raise DjangoUnicodeDecodeError(s, *e.args)

DjangoUnicodeDecodeError: 'utf8' codec can't decode bytes in position
11-12: invalid data. You passed in DatabaseError(,) ()


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



Re: Using form validation to prevent deletion no longer works (after rev 10206/ticket #9587)

2009-04-05 Thread Dan Tallis

2009/4/5 Karen Tracey :
> Forgot the link to that other ticket [1]:
>
> http://code.djangoproject.com/ticket/10711

Thanks for the response, Karen.  I've posted to django-developers.  I
think ticket 10711 is only very loosely related.

Dan

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

2009-04-05 Thread Alex Gaynor
On Sun, Apr 5, 2009 at 12:16 PM, knight  wrote:

>
> Hi,
>
> I have 2 servers with my django app:
> The first one has python2.5 as default python and the second don't (It
> has python2.5 installed together with the older version).
> I want to run dumpdata from my application and I have the following
> problem:
> If I call: "python manage.py dumpdata" the second server won't work.
> If I call: "python2.5 manage.py dumpdata" the first server won't
> work.
> I mean, I will get the following error:
>
> Traceback (most recent call last):
>  File "manage.py", line 2, in 
>from django.core.management import execute_manager
> ImportError: No module named django.core.management
>
> How can I find the right python version to call? Maybe I can take it
> from PYTHONPATH? If yes, where can I find it?
>
> Thanks, Alex A.
>
> >
>
Getting errors like that means you have Django installed to the
site-packages dir of that python version, to figure out which python version
to run all you should need to do is go to each python interpretter and do
import django, and whichever one doesn't give an error is the right one to
use.

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



python version

2009-04-05 Thread knight

Hi,

I have 2 servers with my django app:
The first one has python2.5 as default python and the second don't (It
has python2.5 installed together with the older version).
I want to run dumpdata from my application and I have the following
problem:
If I call: "python manage.py dumpdata" the second server won't work.
If I call: "python2.5 manage.py dumpdata" the first server won't
work.
I mean, I will get the following error:

Traceback (most recent call last):
  File "manage.py", line 2, in 
from django.core.management import execute_manager
ImportError: No module named django.core.management

How can I find the right python version to call? Maybe I can take it
from PYTHONPATH? If yes, where can I find it?

Thanks, Alex A.

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



Best way to add a custom Admin form inline

2009-04-05 Thread Oni

Hi all. After a lot of pondering and reading around, I am somewhat
stuck with this problem. I have a model that requires the creation of
both an image and an initial thumbnail. The thumbnail needs user
intervention as some images will require different approaches to get
the best result.

My aim was to create a default thumbnail and allow the user to edit it
later. I have found some AJAX code written for Django that allows the
user to drag around a box shape over the top of an image and create
the required co-ordinates for thumbnails.

Now, I have manged to create a custom admin view, complete with a
customform and widget to do this. However, getting this back into the
model proved tricky.

It seems that one can have the parent class in the admin site, and
have a set of subclasses as inlines. Added an inline to the default
admin seems a create idea. However, the default settings for the
inline dont include my fancy ajax. I need to get this included.

Istarted looking at the form and formset variables within the admin
form documentation. However, I came across this bug:
http://code.djangoproject.com/ticket/8071

This seems to limit inline overriding. Is there any other way to
attempt this? Does anyone have any suggestions?

Cheers :)
Ben
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Easy way to create pretty pages with nav?

2009-04-05 Thread Alex Gaynor
On Sun, Apr 5, 2009 at 11:38 AM, zayatzz  wrote:

>
> Im just as new and i ran into exactly the same problem.
>
> As it seems, some people suggest to create new app for just font page
> (or generic public view) and create index.html as this apps front page
> template.
>
> I think it is possible to create views.py and index.html for the
> project too.
>
> Im sure someone will clear all this for us soon enough :).
>
> For now i went for creating app for site. This app will hold stuff
> like website title, meta words, language parameters and website
> encoding - you'll declare them in your index html anyway, so why not
> store them in your database, so you can change them from admin,
> whenever  you want.
>
> Alan
>
> On Apr 5, 5:57 pm, dartdog1  wrote:
> > Ok I'm super new, skimmed the doc & tutorial but I just can't figure
> > out how to go about really building the Public view side? I don't see
> > how to apply simple css. how to set up simple stuff like navigation
> > tabs and links...
> >
> > I'm implementing on GAE with the AEP and have gotten the sample app up
> > and going, have more docs to read there. But it seems to me that I'm
> > missing something basic, and when I search for stuff like css and page
> > layout I don't get much help..
> >
> > For instance the sample AEP poll app has no style, I was trying to
> > figure out how to apply some,, but at a larger level how to do that
> > for a site, with navigation, and being able to take advantage of the
> > ability to add new apps later?
> >
> > I notice that I see a number of people raving about how much they love
> > Django on their WP or Blogger blogs,, Which tells me that even
> > designing a simple Bog is not that easy in Django. Yes I have seen a
> > few Django blogs, but not much discussion of how they did it, and how
> > they apply design. For some they seem to use a mix of other tools and
> > some undisclosed black magic?
> >
> > AEP has two sample blogs but truthfully they look pretty primitive.
> >
> > What am I missing?
> >
>
Yes, you can absolutely create a views.py that isn't in a application, views
are just python functions, so they can live wherever they want, likewise so
long as your index.html is in your TEMPLATE_DIRS folder then it can be used
from wherever you like.

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: Easy way to create pretty pages with nav?

2009-04-05 Thread zayatzz

Im just as new and i ran into exactly the same problem.

As it seems, some people suggest to create new app for just font page
(or generic public view) and create index.html as this apps front page
template.

I think it is possible to create views.py and index.html for the
project too.

Im sure someone will clear all this for us soon enough :).

For now i went for creating app for site. This app will hold stuff
like website title, meta words, language parameters and website
encoding - you'll declare them in your index html anyway, so why not
store them in your database, so you can change them from admin,
whenever  you want.

Alan

On Apr 5, 5:57 pm, dartdog1  wrote:
> Ok I'm super new, skimmed the doc & tutorial but I just can't figure
> out how to go about really building the Public view side? I don't see
> how to apply simple css. how to set up simple stuff like navigation
> tabs and links...
>
> I'm implementing on GAE with the AEP and have gotten the sample app up
> and going, have more docs to read there. But it seems to me that I'm
> missing something basic, and when I search for stuff like css and page
> layout I don't get much help..
>
> For instance the sample AEP poll app has no style, I was trying to
> figure out how to apply some,, but at a larger level how to do that
> for a site, with navigation, and being able to take advantage of the
> ability to add new apps later?
>
> I notice that I see a number of people raving about how much they love
> Django on their WP or Blogger blogs,, Which tells me that even
> designing a simple Bog is not that easy in Django. Yes I have seen a
> few Django blogs, but not much discussion of how they did it, and how
> they apply design. For some they seem to use a mix of other tools and
> some undisclosed black magic?
>
> AEP has two sample blogs but truthfully they look pretty primitive.
>
> What am I missing?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using form validation to prevent deletion no longer works (after rev 10206/ticket #9587)

2009-04-05 Thread Karen Tracey
Forgot the link to that other ticket [1]:

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

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: Using form validation to prevent deletion no longer works (after rev 10206/ticket #9587)

2009-04-05 Thread Karen Tracey
On Sun, Apr 5, 2009 at 9:40 AM, Dan Tallis  wrote:

>
> In my application I have a formset with can_delete.  Some custom
> validation is performed on submit, to determine whether the forms
> selected by the user for deletion can be deleted -- i.e. I have a
> custom clean() method on the form to decide whether deletion is
> permitted (based on various bits of dynamic state), which may raise a
> ValidationError to prevent it.
>
[snip remainder]

Not sure I fully understand your use case, but it sounds like this change
may have introduced an unanticipated backwards incompatibility, and one that
could lead to unexpected data deletion, which seems bad.  I suggest you
re-post this on django-developers to make all the right people see it.  It's
appropriate for there since you're discussing the effects of some recent dev
changes.  Also you might want to take a look at ticket #10711 [1] and see if
what's being proposed there would be of any use to 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: Model A imports Model B imports Model A - I'm completely lost as to how to get around circular imports

2009-04-05 Thread Ramiro Morales

On Sun, Apr 5, 2009 at 11:43 AM, codecowboy  wrote:
>
> Hi Everyone,
>
> I'm new to the Django community and I am having trouble with circular
> imports.  I've read every article that I can find about the issue
> including posts on this group.  I'm going to paste my model files and
> the stack trace.  I'm sure that this must be an issue that has come up
> before.  Thank you in advance for any help.  If you know of an article
> that explains the problem then point me to it.  Thanks again.
>
> [snip]

Do you need to have two, parallel, many to many relationships between Scientist
and Conference?. If the answer is no then yo don't need to define that
relationship in both models. This alone almost solves your circular reference
problem.

The technique of using a string with the name of the model instead of tthe Model
class onject iself to indicate the target of a relationship is only needed (and
accepted) when:

* The target model hasn't yet been defined (It comes after in the same
  application models.py file).

* or when you have two mutually referencing relationships between
  two models located in diferent applications (actually, this second use case
  isn't clearly explained in our documentation)

Using these guidelines and simplifying you example to the relevant bits,
something like this could be a start of a solution to your problem:

-- scinet.scientists.models ---
from django.db import models

class Scientist(models.Model):
# ...
# no many to many field needed here

-- scinet.conferences.models ---
from django.db import models
from scinet.scientists.models import Scientist

class ConferenceAttendee(models.Model):
# ...
conference = models.ForeignKey('Conference')
scientist = models.ForeignKey(Scientist)

class Conference(models.Model):
# ...
scientists = models.ManyToManyField(Scientist, through=ConferenceAttendee)


Relevant documentation links worth reading:

http://docs.djangoproject.com/en/dev/topics/db/models/#many-to-many-relationships
http://docs.djangoproject.com/en/dev/topics/db/models/#models-across-files
http://docs.djangoproject.com/en/dev/ref/models/fields/#lazy-relationships

HTH

--
Ramiro Morales
http://rmorales.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
-~--~~~~--~~--~--~---



Easy way to create pretty pages with nav?

2009-04-05 Thread dartdog1

Ok I'm super new, skimmed the doc & tutorial but I just can't figure
out how to go about really building the Public view side? I don't see
how to apply simple css. how to set up simple stuff like navigation
tabs and links...

I'm implementing on GAE with the AEP and have gotten the sample app up
and going, have more docs to read there. But it seems to me that I'm
missing something basic, and when I search for stuff like css and page
layout I don't get much help..

For instance the sample AEP poll app has no style, I was trying to
figure out how to apply some,, but at a larger level how to do that
for a site, with navigation, and being able to take advantage of the
ability to add new apps later?

I notice that I see a number of people raving about how much they love
Django on their WP or Blogger blogs,, Which tells me that even
designing a simple Bog is not that easy in Django. Yes I have seen a
few Django blogs, but not much discussion of how they did it, and how
they apply design. For some they seem to use a mix of other tools and
some undisclosed black magic?

AEP has two sample blogs but truthfully they look pretty primitive.

What am I missing?

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



Model A imports Model B imports Model A - I'm completely lost as to how to get around circular imports

2009-04-05 Thread codecowboy

Hi Everyone,

I'm new to the Django community and I am having trouble with circular
imports.  I've read every article that I can find about the issue
including posts on this group.  I'm going to paste my model files and
the stack trace.  I'm sure that this must be an issue that has come up
before.  Thank you in advance for any help.  If you know of an article
that explains the problem then point me to it.  Thanks again.

-- Model A ---

from django.db import models
from scinet.conferences.models import ConferenceAttendee
class Scientist(models.Model):
user = models.ForeignKey('auth.User')
summary = models.TextField()
undergrad = models.CharField(max_length=50)
graduate = models.CharField(max_length=50)
post_doctorate = models.CharField(max_length=50)
current_employer = models.CharField(max_length=50)
zipcode = models.CharField(max_length=5)
city = models.CharField(max_length=50)
state = models.CharField(max_length=2)
country = models.CharField(max_length=200, blank=False)
created = models.DateTimeField()
modified = models.DateTimeField()
conferences = models.ManyToManyField(Conference,
through='ConferenceAttendee')

-- Model B ---

from django.db import models
from scinet.scientists.models import Scientist
class Conference(models.Model):
title = models.CharField(max_length=200)
description = models.TextField()
date = models.DateTimeField()
scientists = models.ManyToManyField(Scientist,
through='ConferenceAttendee')
created = models.DateTimeField()
modified = models.DateTimeField()

def __unicode__(self):
return self.name

class ConferenceAttendee(models.Model):
conference = models.ForeignKey(Conference)
scientist = models.ForeignKey(Scientist)
rsvp_date = models.DateTimeField()
presenter = models.BooleanField()

-- Stack Trace 

Validating models...
Unhandled exception in thread started by 
Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/django/core/management/
commands/runserver.py", line 48, in inner_run
self.validate(display_num_errors=True)
  File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 246, in validate
num_errors = get_validation_errors(s, app)
  File "/usr/lib/python2.5/site-packages/django/core/management/
validation.py", line 28, in get_validation_errors
for (app_name, error) in get_app_errors().items():
  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 128, in get_app_errors
self._populate()
  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 57, in _populate
self.load_app(app_name, True)
  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 72, in load_app
mod = __import__(app_name, {}, {}, ['models'])
  File "/home/guy/DjangoApps/scinet/../scinet/scientists/models.py",
line 2, in 
from scinet.conferences.models import ConferenceAttendee
  File "/home/guy/DjangoApps/scinet/../scinet/conferences/models.py",
line 2, in 
from scinet.scientists.models import Scientist
ImportError: cannot import name Scientist

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 get session data from template

2009-04-05 Thread Antoni Aloy

2009/4/5 Joshua Partogi :
>
> Dear all,
>
> I'd like to get session object because I would like to figure out
> whether a user is still logged in or not. I tried searching the
> documents but could not find a way to do it.
> Using {% if user.is_authenticated %}, the user object is only
> available in one request but will be dissapeared in the next request.

In your render_to_response don't forget to add
context_instance=RequestContext(request)

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



How to get session data from template

2009-04-05 Thread Joshua Partogi

Dear all,

I'd like to get session object because I would like to figure out
whether a user is still logged in or not. I tried searching the
documents but could not find a way to do it.
Using {% if user.is_authenticated %}, the user object is only
available in one request but will be dissapeared in the next request.

Does anyone has any suggestion on how to get the auth info from the template?

Thank you in advance.

-- 
If you can't believe in God the chances are your God is too small.

Read my blog: http://joshuajava.wordpress.com/
Follow me on twitter: http://twitter.com/jpartogi

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



Using form validation to prevent deletion no longer works (after rev 10206/ticket #9587)

2009-04-05 Thread Dan Tallis

In my application I have a formset with can_delete.  Some custom
validation is performed on submit, to determine whether the forms
selected by the user for deletion can be deleted -- i.e. I have a
custom clean() method on the form to decide whether deletion is
permitted (based on various bits of dynamic state), which may raise a
ValidationError to prevent it.

Up to rev 10206 (which relates to ticket #9587), this worked nicely,
giving me exactly the user interface I want.  But rev 10206 has
changed things: the formset is_valid now returns True for deleted
forms even if they have validation errors, on the grounds that (to
quote) "formset with can_delete shouldn't require deleted forms to
validate".

This means that the formset is treated as valid by my view code, so it
goes ahead and tries to save the formset, whereas what I want (and
what happened prior to rev 10206) was that the form was re-displayed
to the user with a nice error message.

I understand the thinking behind #9587, but I wonder whether this
consequence -- that it's no longer (straightforwardly) possible to use
the validation mechanism to prevent deletion -- was intended.  (There
isn't much discussion in #9587 for me to tell.)

If it was intended, any suggestions on how I can best alter my
application to achieve what I want?

Regards

Dan

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 just put user id in session for authorization purpose?

2009-04-05 Thread Zeal

Django's auth is pretty good, however, I need some row-level
authorziation mechnism, like in which department and function that the
certain user could access, so my needs on authrization are pretty
different than default auth model. 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: Novice. - _unicode_(self) not working. :(

2009-04-05 Thread Antoni Aloy

2009/4/5 Nandha :
>
> Hi,
>
> I just started trying out Django. I am new to python too.!!
>
> I started with poll app in the tutorial.
>
> Adding _unicode_(self):  does not seem to change anything. I saw that
> it could be because i am using older version so i followed the
> installation guide and installed the development version.
>
> Did not help!!
>
> This is the models.py
> class Poll(models.Model):
>        question = models.CharField(max_length=200)
>        pub_date = models.DateTimeField('date_published')
>        def  _unicode_(self):

__unicode__(self)

with two underscores

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



Novice. - _unicode_(self) not working. :(

2009-04-05 Thread Nandha

Hi,

I just started trying out Django. I am new to python too.!!

I started with poll app in the tutorial.

Adding _unicode_(self):  does not seem to change anything. I saw that
it could be because i am using older version so i followed the
installation guide and installed the development version.

Did not help!!

This is the models.py
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date_published')
def  _unicode_(self):
return self.question
def was_published_today(self):
return self.pub_date.date() == datetime.date.today()


The Poll.objects.all()
gives

>>> Poll.objects.all()
[]

What am i missing??

Nandha




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 view: History log

2009-04-05 Thread Karen Tracey
On Sun, Apr 5, 2009 at 4:08 AM, EagerToUnderstand  wrote:

>
> With regards to the history log on models in the admin view.
>
> I am adding instances of models via the db api  (model.save())
> method.  When such a model is opened (but not edited) and then saved
> for the first time in the admin model view a history log entry is
> created showing ALL elements of the model has changed.  After this you
> can open and save the model and the history log behaves as expected.
>
> I looked into the code and see the has_changed and changed_data dict
> is created by calling methods on widgets which takes the
> responsibility to compare "new" data with "initial" data.  Unless I am
> mistaken these widgets think the initial data differs from the
> committed (but unchanged) data.  I now need to look deeper but hoped
> somebody stumbled across something similar that would be willing to
> offer help?
>
> Expected behavior would be that the history log on first model save
> (from the admin model view) only show model elements that actually
> changed.
>
>
I cannot recreate what you are describing.  My own DB is similar to what you
describe -- model instances are added not via admin but but by other code
that uses the ORM directly.  I just tried, and when I went to the change
page for one of these model instances in admin and selected "Change History"
I first got a note that the object did not have a change history, which
makes sense because it had never been changed in admin.  I then went back,
made no change to the model fields, and selected "Save and continue
editing".  When I now check the change history it has one item, with an
"Action" of "No fields changed."

So in general the admin behaves as you are asking it to.  Since you've
gotten as far as finding the code where this is done, it might be simplest
to start printing some initial/submitted values for what it is listing as
changed, then perhaps you can spot what the differences it is seeing are.

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: Problem with adding new columns to existing model.

2009-04-05 Thread zayatzz

Thanks to both of you. Yeah i noticed the part about alter table and
doing it manually. I just hoped there is some kind of command to
update the model. Just python manage.py sql appname did not work - it
showed the new additions i did to model, but they did not end up in
database after syncdb.

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



Re: Why is mod_python the preferred setup for Django?

2009-04-05 Thread Daniel Roseman

On Apr 5, 12:22 pm, Continuation  wrote:
> According to 
> thishttp://docs.djangoproject.com/en/1.0/howto/deployment/modpython/
> "Apache with mod_python currently is the preferred setup for using
> Django on a production server."
>
> What is the advantage of mod_python over mod_wsgi and mod_fcgi?
>
> Wouldn't WSGI, as something designed specifically for python, be a
> better choice?
> Also, wouldn't FCGI consume less memory than mod_python, which embeds
> Python within Apache?
>
> I'm looking for a way to deploy django that is the least resource
> intensive. My original plan was to use Nginx + FCGI. Now after reading
> the doc I'm not so sure.
>
> How does Nginx + FCGI compare to Apache + mod_python?
>
> Would love to hear your thoughts and experiences.

Actually, that doc is now contradicted by the new mod_wsgi
documentation, which says WSGI is the recommended setup:
http://docs.djangoproject.com/en/dev/howto/deployment/modwsgi/

Personally, I'd go with WSGI every time - easier to set up and
configure, less memory-hungry, and more well-supported.
--
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: Problem with adding new columns to existing model.

2009-04-05 Thread Daniel Roseman

On Apr 5, 11:26 am, zayatzz  wrote:
> Hello
>
> After finishing tutorial im trying to do something for myself. I
> created one model and proceeded to create another ones, but then i
> realised that i could just add few additional columns to existing
> model, but for some reason they dont end up in database table when i
> run python manage.py.
>
> I found this bit of help 
> -http://docs.djangoproject.com/en/dev/faq/models/#if-i-make-changes-to...
>
> But thats not exactly what i want, since it also empties the tables.

But that same FAQ gives you the alternative solution - run ALTER TABLE
statements on your database manually. Or you can investigate one of
the existing projects that help with this - django-evolution, south,
or dmigrations.

> Another one about django and databases. When i add the fields in admin
> i cant leave them empty... why not? what do i have to do in model or
> admin, so i could heave fields empty?

http://docs.djangoproject.com/en/dev/topics/db/models/#field-options

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



Why is mod_python the preferred setup for Django?

2009-04-05 Thread Continuation

According to this 
http://docs.djangoproject.com/en/1.0/howto/deployment/modpython/
"Apache with mod_python currently is the preferred setup for using
Django on a production server."

What is the advantage of mod_python over mod_wsgi and mod_fcgi?

Wouldn't WSGI, as something designed specifically for python, be a
better choice?
Also, wouldn't FCGI consume less memory than mod_python, which embeds
Python within Apache?

I'm looking for a way to deploy django that is the least resource
intensive. My original plan was to use Nginx + FCGI. Now after reading
the doc I'm not so sure.

How does Nginx + FCGI compare to Apache + mod_python?

Would love to hear your thoughts and experiences.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: http 404 is replaced by http 500----------Django-1.0.2-final

2009-04-05 Thread Coonay



On Mar 14, 12:30 pm, Malcolm Tredinnick 
wrote:
> On Fri, 2009-03-13 at 21:27 -0700, Flank wrote:
> > in order to use django/conf/urls/defaults.py, handler404, i did 2
> > things:
> > 1:change DEBUG = False in settings.py
> > 2:create a 404.html template in the root of the template directory
>
> > when i request a page that won't find ,such 
> > ashttp://localhost/page_don_exist.html.a
> > http 500 error is reported,
>

expected:404 error
but a 500 error returned

INFO 2009-04-05 10:44:55,687 mail_stub.py]
MailService.SendToAdmins
INFO 2009-04-05 10:44:55,687 mail_stub.py]   From: r...@localhost
INFO 2009-04-05 10:44:55,687 mail_stub.py]   Subject: [Django]
Error (EXTER
AL IP): /dud8djdd7udududdu
INFO 2009-04-05 10:44:55,687 mail_stub.py]   Body:
INFO 2009-04-05 10:44:55,687 mail_stub.py] Content-type: text/
plain
INFO 2009-04-05 10:44:55,687 mail_stub.py] Data length: 2080
ERROR2009-04-05 10:44:55,687 main.py] Exception in request:
ImportError: No
module named auth.models
Traceback (most recent call last):
  File "D:\workspace\coonay\django\core\handlers\base.py", line 113,
in get_res
onse
return callback(request, **param_dict)
  File "D:\python\coonay\src\django\views\defaults.py", line 79, in
page_not_fo
nd
return http.HttpResponseNotFound(t.render(RequestContext(request,
{'request
path': request.path})))
  File "D:\workspace\coonay\django\template\context.py", line 105, in
__init__
self.update(processor(request))
  File "D:\python\coonay\src\django\core\context_processors.py", line
23, in au
h
from django.contrib.auth.models import AnonymousUser
ImportError: No module named auth.models
INFO 2009-04-05 10:44:55,703 dev_appserver.py] "GET /
dud8djdd7udududdu HTTP
1.1" 500 -

> What does the traceback say? It will provide the clues as to what is
> going wrong.
>
> 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: http 404 is replaced by http 500----------Django-1.0.2-final

2009-04-05 Thread Coonay

sory, there is a miss of the contrib.auth in my enviroment,which is
deleted by me when i setup,
now ,404 error can be return normally.

thank you all

On Mar 15, 8:21 am, Fergus  wrote:
> On 14 Mar, 04:30, Malcolm Tredinnick  wrote:
>
> > On Fri, 2009-03-13 at 21:27 -0700, Flank wrote:
> > > in order to use django/conf/urls/defaults.py, handler404, i did 2
> > > things:
> > > 1:change DEBUG = False in settings.py
> > > 2:create a 404.html template in the root of the template directory
>
> > > when i request a page that won't find ,such 
> > > ashttp://localhost/page_don_exist.html.a
> > > http 500 error is reported,
>
> As you've got DEBUG off, you won't see the traceback on screen. You
> need to make sure you've set ADMINS correctly, as in this case you
> normally get sent an email detailing what went wrong - as you'd see on-
> screen if DEBUG were True.
> 
>
> You might also want to check Django can send email successfully. There
> are a few settings you might need to tweak.
> 

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: http 404 is replaced by http 500----------Django-1.0.2-final

2009-04-05 Thread Coonay



On Mar 15, 8:21 am, Fergus  wrote:
> On 14 Mar, 04:30, Malcolm Tredinnick  wrote:
>
> > On Fri, 2009-03-13 at 21:27 -0700, Flank wrote:
> > > in order to use django/conf/urls/defaults.py, handler404, i did 2
> > > things:
> > > 1:change DEBUG = False in settings.py
> > > 2:create a 404.html template in the root of the template directory
>
> > > when i request a page that won't find ,such 
> > > ashttp://localhost/page_don_exist.html.a
> > > http 500 error is reported,
>

Yes ,i cann't see the debug on screen, but in the console
> As you've got DEBUG off, you won't see the traceback on screen. You

the expected error should be page-not-found error/404,not 500 error,
a 500 eroor will trig django send a mail to the admin,
> need to make sure you've set ADMINS correctly, as in this case you
> normally get sent an email detailing what went wrong - as you'd see on-
> screen if DEBUG were True.
> 
>
> You might also want to check Django can send email successfully. There
> are a few settings you might need to tweak.
> 

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Getting id of item before it recorded (or something else to solve my problem)

2009-04-05 Thread Daniel Roseman

On Apr 5, 11:38 am, MiratCanBayrak  wrote:
> here, i have a function that used as a upload_to parameter in my
> model. But i records my pic as screenshot_None.gif. Becouse id is
> appearing when it is recorded. How can i record my images as
> screenshot_id.gif ?? thanks for your response
>
> from os.path import join, exists
> from os import remove
>
> def screenshot_path(instance = None, filename = None):
>     filepath = join("products",  "images", instance.product.type,
> instance.product.slug, "screenshot_" + str(instance.id) + ".gif")
>     if exists(join(MEDIA_ROOT,filepath)):
>         remove(join(MEDIA_ROOT, filepath))
>     return filepath

There's no way to do this, because the model hasn't been saved yet, so
it doesn't have an ID. You will have to think of a different naming
scheme for your images, that doesn't depend on the autogenerated ID.

--
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: Getting id of item before it recorded (or something else to solve my problem)

2009-04-05 Thread MiratCanBayrak

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



Getting id of item before it recorded (or something else to solve my problem)

2009-04-05 Thread MiratCanBayrak

here, i have a function that used as a upload_to parameter in my
model. But i records my pic as screenshot_None.gif. Becouse id is
appearing when it is recorded. How can i record my images as
screenshot_id.gif ?? thanks for your response

from os.path import join, exists
from os import remove

def screenshot_path(instance = None, filename = None):
filepath = join("products",  "images", instance.product.type,
instance.product.slug, "screenshot_" + str(instance.id) + ".gif")
if exists(join(MEDIA_ROOT,filepath)):
remove(join(MEDIA_ROOT, filepath))
return filepath

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



Problem with adding new columns to existing model.

2009-04-05 Thread zayatzz

Hello

After finishing tutorial im trying to do something for myself. I
created one model and proceeded to create another ones, but then i
realised that i could just add few additional columns to existing
model, but for some reason they dont end up in database table when i
run python manage.py.

I found this bit of help -
http://docs.djangoproject.com/en/dev/faq/models/#if-i-make-changes-to-a-model-how-do-i-update-the-database

But thats not exactly what i want, since it also empties the tables.

Another one about django and databases. When i add the fields in admin
i cant leave them empty... why not? what do i have to do in model or
admin, so i could heave fields empty?

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



Upload from client machine to server in Django 0.95

2009-04-05 Thread Mike

Hello,

I am using Django 0.95 and need to upload from from client machine to
server. I wonder if anyone can point me to sample implementation or
any pointer that may help me to implement it.

I know file upload is there in Django 1.0 but its not possible for me
to move the project to Django 1.0.

Any help will be appreciated.

Regards,
Mike

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



Re: django.contrib.auth user password decryption

2009-04-05 Thread soniiic

I hope that doesn't mean storing the real password in a table in the
database :)

On Apr 4, 11:12 pm, Joshua Partogi  wrote:
> On Apr 4, 11:49 pm, Masklinn  wrote:
>
>
>
>
>
>
>
> > On 4 Apr 2009, at 15:38 , Joshua Partogi wrote:
>
> > > Dear all,
>
> > > I already take a look at the django.contrib.auth.models but could not
> > > find any methods for decrypting the user password.
>
> > > Sometimes we need to get the real text password to be sent to user.
>
> > > What is the best way to do this? Anybody has got an idea?
>
> > > Thank you very much in advance!
>
> > Django's passwords are salted[1] and hashed[2]. You cannot[3] retrieve  
> > them, and that's exactly the intent (well the intent is not that *you*  
> > cannot retrieve them, it's that nobody else can). If you need to send  
> > users their passwords, you have to generate new (random) passwords and  
> > send them that.
>
> > Masklinn
>
> Thanks for the explanation Masklinn. :-)
>
> I'll find another way to send user their password.
>
> Thank you very much.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 view: History log

2009-04-05 Thread EagerToUnderstand

With regards to the history log on models in the admin view.

I am adding instances of models via the db api  (model.save())
method.  When such a model is opened (but not edited) and then saved
for the first time in the admin model view a history log entry is
created showing ALL elements of the model has changed.  After this you
can open and save the model and the history log behaves as expected.

I looked into the code and see the has_changed and changed_data dict
is created by calling methods on widgets which takes the
responsibility to compare "new" data with "initial" data.  Unless I am
mistaken these widgets think the initial data differs from the
committed (but unchanged) data.  I now need to look deeper but hoped
somebody stumbled across something similar that would be willing to
offer help?

Expected behavior would be that the history log on first model save
(from the admin model view) only show model elements that actually
changed.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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: Cannot reverse inside urls.py

2009-04-05 Thread robin

Thank you all for your suggestions.
I did not explain clearly what I was trying to do.
So here's another eg. (with simpler unworkable syntax)

url(add/complete, direct_to_template, template=message.html,
name=add_complete,
  extra_context={
title:Add Complete,
url:[reverse(add_item), reverse(view_item), reverse(edit_item)]
}),

url(remove/complete, direct_to_template, template=message.html,
name=remove_complete,
  extra_context={
title:Remove Complete,
url:[reverse(remove_item), reverse(list_items)]
}),

So these are pages where you get redirected to, when adding is
complete, removing is complete, etc. and they all look pretty much the
same except with different title and different amount/types of links.

This way there's no need for a new view and a new template. Just
changing a couple of lines in urls.py

But I do realise that reverse(edit_item) and reverse(view_item) won't
work, because there's no ID specified and even so, direct_to_template
won't know what to do with it.

So I ended up creating my own custom view which has reverse,
direct_to_template, and even return json, in it to do what kinda
wanted to do but unfortunately has made many of my apps less portable.
I still need to account for reverse(edit_item) if i wish to have that
in the add complete page.

Anyway that's what I'm trying to do, making coding lazier.

Further suggestions or no, thank you.
Robin

On Apr 3, 10:04 pm, Reiner  wrote:
> I'm not sure if reversing inside theurlpatterns is possible (but I
> kinda doubt it), but maybe I can help out with a different, and
> probably better, solution. It seems you only want to use theURLto
> your add_item_wizard function inside your message.html template. Then
> you could use the builtinurltemplate tag to do the same thing.
>
> For example:
> Link
>
> Look here for more information on this 
> tag:http://docs.djangoproject.com/en/dev/ref/templates/builtins/#url
>
> If you need theURLmultiple times in your template, you can use this
> (as mentioned in the docs):
>
> {%urladd_item_wizard as the_url %}
> I'm linking to {{ the_url }}
>
> This way you don't need to pass theURLin your extra_context.
>
> Regards,
> Reiner
>
> On Apr 3, 10:24 am, robin  wrote:
>
>
>
> > It seems like you cannot usereversewithin urls.py
>
> >  url(r'^add/$','items.views.add_item_wizard',name='add_item_wizard'),
>
> >  url(r'^add/complete/
> > $','django.views.generic.simple.direct_to_template',{
> >       'template':'message.html',
> >       'extra_context':{
> >           'title': 'Add Item Complete',
> >           'url':reverse('add_item_wizard'),
> >       }
> >   }, name='add_item_complete'),
>
> > Is there no way?
>
> > Thanks in advance,
> > Robin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---