pythonpath on Ubuntu 8.10

2009-03-06 Thread python_fan

Hey,

I have an application that I'm running using Django's built-in server
on both Windows XP and Ubuntu 8.10. While it is wokring perfectly fine
on XP, I get import errors in Ubuntu. When I tried printing pythonpath
on Ubuntu, I managed to locate the problem. It seems like if I start
the server with a python script it happens before the shell is updated
with correct pythonpath path from the .bashrc. However, if i do it
manually it starts perfectly fine (since it manages to update
pythonpath at the start).

So, the question is: Is it possible to do anything to make it to work
with automatic start-up? I.e. update Django's pythonpath somehow? Or
maybe put environment variables somewhere else than .bashrc? Anyone?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pythonpath on Ubuntu 8.10

2009-03-06 Thread python_fan

Seems like I found one solution to that: Add --
pythonpath="path_to_your_app" to the manage.py runserver call. Any
better 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
-~--~~~~--~~--~--~---



File upload with no database - Fantasy or reality?

2008-04-22 Thread python_fan

Hey!

Currently, I'm having a project where I use django to generate some
simple web pages. I don't want to use a database in this project since
it is really small and it suits me very well that way. However, as far
as I can see, it seems like file upload via django (using newforms &
FileField) requires a database.

So, my question is: Is it possible to add file upload functionality
(upload file from client to server -> save it on server somewhere ->
pass the path to python code on the server) without any underlying
databases?

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



Re: File upload with no database - Fantasy or reality?

2008-04-22 Thread python_fan

On Apr 22, 9:30 am, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 22-Apr-08, at 12:54 PM, Kenneth Gonsalves wrote:
>
> >> So, my question is: Is it possible to add file upload functionality
> >> (upload file from client to server -> save it on server somewhere ->
> >> pass the path to python code on the server) without any underlying
> >> databases?
>
> > yes - just get the filename and content from request.POST and save it
> > wherever you like using ordinary python
>
> oops - from request.FILES
>

Great! Thanks!

Can I see a working example? I tried various things, and it almost
worked (I got a widget on the page, got an upload button, etc), but
nothing happens when i press Upload/Submit.


python_fan

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



Re: File upload with no database - Fantasy or reality?

2008-04-22 Thread python_fan


On Apr 22, 9:41 am, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 22-Apr-08, at 1:00 PM, python_fan wrote:
>
> >>> yes - just get the filename and content from request.POST and
> >>> save it
> >>> wherever you like using ordinary python
>
> >> oops - from request.FILES
>
> > Great! Thanks!
>
> > Can I see a working example? I tried various things, and it almost
> > worked (I got a widget on the page, got an upload button, etc), but
> > nothing happens when i press Upload/Submit.
>
> paste your view and template please

I guess the problem lies mostly in FileUploadForm class. I should have
some kind of 'save' function there...
http://dpaste.com/46221/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: File upload with no database - Fantasy or reality?

2008-04-22 Thread python_fan


On Apr 22, 10:32 am, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 22-Apr-08, at 1:23 PM, python_fan wrote:
>
> >>> Can I see a working example? I tried various things, and it almost
> >>> worked (I got a widget on the page, got an upload button, etc), but
> >>> nothing happens when i press Upload/Submit.
>
> >> paste your view and template please
>
> > I guess the problem lies mostly in FileUploadForm class. I should have
> > some kind of 'save' function there...
>
> your code:
> if request.method == 'post':
>  upload_form = FileUploadForm(request.POST, request.FILES)
>
>  if not is_valid():
>  upload_result = "Invalid form!"
>  else:
>  upload_form = FileUploadForm()
>
> should be:
>
> if request.method == 'POST':
>  upload_form = FileUploadForm(request.POST, request.FILES)
>
>  if upload_form.is_valid():
>  file_name = request.FILES['txt_file']['filename']
> file_content=request.FILES['txt_file']['content']
>  # here use python to save the file
> else:
>  upload_form = FileUploadForm()
>

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



Re: File upload with no database - Fantasy or reality?

2008-04-25 Thread python_fan

Hm... I think I'm still missing something. All I get on the web page
is 'None'. Any ideas?

On Apr 22, 10:51 am, python_fan <[EMAIL PROTECTED]> wrote:
> On Apr 22, 10:32 am, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
>
>
>
> > On 22-Apr-08, at 1:23 PM, python_fan wrote:
>
> > >>> Can I see a working example? I tried various things, and it almost
> > >>> worked (I got a widget on the page, got an upload button, etc), but
> > >>> nothing happens when i press Upload/Submit.
>
> > >> paste your view and template please
>
> > > I guess the problem lies mostly in FileUploadForm class. I should have
> > > some kind of 'save' function there...
>
> > your code:
> > if request.method == 'post':
> >  upload_form = FileUploadForm(request.POST, request.FILES)
>
> >  if not is_valid():
> >  upload_result = "Invalid form!"
> >  else:
> >  upload_form = FileUploadForm()
>
> > should be:
>
> > if request.method == 'POST':
> >  upload_form = FileUploadForm(request.POST, request.FILES)
>
> >  if upload_form.is_valid():
> >  file_name = request.FILES['txt_file']['filename']
> > file_content=request.FILES['txt_file']['content']
> >  # here use python to save the file
> > else:
> >  upload_form = FileUploadForm()
>
> Great, thanks a lot! Will try to it that way now.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: File upload with no database - Fantasy or reality?

2008-04-25 Thread python_fan

Hm... seems like I'm still missing something. All I get on the web
page is 'None'. Any ideas?

Rustam

On Apr 22, 10:51 am, python_fan <[EMAIL PROTECTED]> wrote:
> On Apr 22, 10:32 am, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
>
>
>
> > On 22-Apr-08, at 1:23 PM, python_fan wrote:
>
> > >>> Can I see a working example? I tried various things, and it almost
> > >>> worked (I got a widget on the page, got an upload button, etc), but
> > >>> nothing happens when i press Upload/Submit.
>
> > >> paste your view and template please
>
> > > I guess the problem lies mostly in FileUploadForm class. I should have
> > > some kind of 'save' function there...
>
> > your code:
> > if request.method == 'post':
> >  upload_form = FileUploadForm(request.POST, request.FILES)
>
> >  if not is_valid():
> >  upload_result = "Invalid form!"
> >  else:
> >  upload_form = FileUploadForm()
>
> > should be:
>
> > if request.method == 'POST':
> >  upload_form = FileUploadForm(request.POST, request.FILES)
>
> >  if upload_form.is_valid():
> >  file_name = request.FILES['txt_file']['filename']
> > file_content=request.FILES['txt_file']['content']
> >  # here use python to save the file
> > else:
> >  upload_form = FileUploadForm()
>
> Great, thanks a lot! Will try to it that way now.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: File upload with no database - Fantasy or reality?

2008-04-26 Thread python_fan


On Apr 26, 3:54 am, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:

> or better still, please paste your full current view and template.
> Also it would be easier to handle the thread if you did not top post ;-)

Ok, will do. :)
Here is the code: http://dpaste.com/47029/

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



Re: File upload with no database - Fantasy or reality?

2008-04-26 Thread python_fan



On Apr 26, 8:13 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> upload_form = None
> upload_result = ''
>
> if request.method == 'POST':
> upload_form = FileUploadForm(request.POST, request.FILES)
>  if upload_form.is_valid():
> # get file name and contents from request:
> file_name = request.FILES['txt_file']['filename']
> file_content=request.FILES['txt_file']['content']
>  # save the file. something like:
> f=open("C:\\" + file_name, 'w')
> f.writelines(file_content)
> f.close()
> else:
> upload_form = FileUploadForm()
>
> You've got the creation of the blank FileUploadForm nested in the else for
> if upload_form.is_valid().  So it appears you do not create a FileUploadForm
> when request.method is anything other than POST (unless there is more
> relevant code that follows this snippet).  It looks like the else that you
> have should be un-dented one level, so that a blank FileUploadForm is
> generated for display when request.method is, say, GET.
>
> It's also normal to return an HttpResponseRedirect to a different page when
> is_valid() processing completes, which you don't seem to be doing.  Finally
> nowhere in here do you set upload_result, which seems to be expected by your
> template.  Your initial code seemed to be using that to display errors,
> which is not necessary if you go the normal route of re-displaying the
> invalid form (which will have error messages printed by each field that did
> not validate) when is_valid returns False.  So perhaps you just want to
> remove the upload_result reference from your template.
>
> Karen

Yes, of course! You were right!
Un-indenting the else fixed the problem. Thanks a lot! :-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---