Question from django beginner

2008-12-02 Thread Vince

Hi everyone,

I'm new to django so perhaps those are really simple questions so
sorry about that:

I had an php page already working (css formatted, imgs and
everything), it's a very simple page for uploading zip files to a
server. The server (system Apache 2.2.4 with django) has already the
main app powered with django, so Apache is configured to go through
django. I tried to do the fileupload through PHP, but couldn't figure
out how to make main django app and php fileupload page working
together. As soon as the \location tags of python,django were added to
httpd.conf, PHP page stopped working.


   SetHandler python-program
   PythonPath "['D:\MainwebServer'] + sys.path"
   PythonHandler django.core.handlers.modpython
   SetEnv DJANGO_SETTINGS_MODULE server.settings
   PythonDebug On


   SetHandler None


   SetHandler None



CARGAR MODULO PHP
#Loadfile "D:/PHP/php5ts.dll"
#PHPIniDir "D:/PHP/"
#AddHandler application/x-httpd-php .php
#AddHandler application/x-httpd-php-source .phps
#AddType application/x-httpd-php .html

So my first question goes here: Does anyone know how to share both PHP
and django pages in the same web project ?

Anyway, My 2nd move was to try to make the fileupload by using django
itself, so here I already have a rather simple upload page, it works
already but I want to add some more stuff:

1. As I had already the PHP page working I have all the design done
(css, img, etc) I don't know how to easily "move" the html design to
the django template (tried to point to MEDIA_ROOT but css doesn't
apply)

Here's my template



Analyst DEMO server



{% block body %}

Subir fichero ZIP a servidor DEMO

  

  
{{ form }}
  
  

  
  Resultados de subida.

  
{% endblock %}

and here's the old php page, it uses javascript to show/hide some
labels once the fileupload was performed and if it was success or not:


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

   
   Main DEMO server
   


<!--
function startUpload(){
  document.getElementById('upload_process').style.visibility =
'visible';
  document.getElementById('upload_form').style.visibility =
'hidden';
  return true;
}

function stopUpload(success){
  var result = '';
  if (success == 1){
 result = '<span class="msg">Fichero correctamente subido!<\/
span><br/><br/>';
  }
  else {
 result = '<span class="emsg">Error al subir el fichero!<\/
span><br/><br/>';
  }
  document.getElementById('upload_process').style.visibility =
'hidden';
  document.getElementById('upload_form').innerHTML = result +
'<label>File: <input name="myfile" type="file" size="30" /><\/
label><label><input type="submit" name="submitBtn" class="sbtn"
value="Enviar" /><\/label>';
  document.getElementById('upload_form').style.visibility =
'visible';
  return true;
}
//-->




   

Main DEMO server


 Subiendo fichero...
 
 Fichero (zip):
  
 
 
 
 
 

 
 


So:

2. Is there any built-in opton in Django (0.97 version) to unzip
files. I would need to unzip the file to a folder once the upload has
been done.

Thanks a lot in advance for the help

Vince


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



include

2008-12-11 Thread Vince

Hi guys,

I have a fileupload template and I would like to show a .gif picture
during the upload process once the user submits a file to upload, it's
working already but .gif is not animated while waiting for fileupload
completion. On the other hand, if I include a frame in the form action
call, the gif gets animated but it doesn't go further to the
upload_success template, I mean it stays showing the ...loading
withthe animated .gif forever.

here is the piece of the template (like this it stays showing the
animated .gif forever):


<!--
function startUpload(){
  document.getElementById('f1_upload_process').style.visibility =
'visible';
  document.getElementById('f1_upload_form').style.visibility =
'hidden';
  return true;
}
//-->


[...]



 {% if not is_ok %}
 {{ msg }} 
 {% else %}

 {% endif %}
 Cargando...
 

 
  {{ form }}
 
 
 
 
 


Then I have my view from what I'm calling the template, as I said
everything works (with unanimated loader.gif if I don't include the
target parameter inside the form action line. Without the target, as
soon as it finishes uploading goes to POST and executes the django
view.

I would like to know if this approach is valid, I mean if I can
combine calling a frametarget and going to my django view after the
process has been completed. if not How can I show the animated .gif ??

Thanks a lot in advance

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



redirect to results

2009-01-14 Thread Vince

Hi everyone,

I am a bit confused about how to do what follows, I would appreciate
any help.

My django project is very simple I have a upload zip page, this page
processes a zip file and it is being decompressed and stored in a
folder for further purposes.
After I check and unzip the file I call the return_to_render

return render_to_response('upload_OK.html', {'nombre': filename,
'size': filesize, 'type': filetype, 'msg': msg, 'is_ok': isOk,
'zip_list': zf.namelist(), 'item': file_inzip})

I have a link in the upload_ok.html that is supossed to show the files
inside the zip file (see below)

[...]

   

Analyst DEMO server


Subiendo...
 
 
  {% if is_ok %}
 {{ msg }} 
 {{ size|filesizeformat }}
 Tipo de archivo: {{ type}}

http://aux/
unzip_results/">Visualizar ficheros descomprimidos
[...]

The problem is that i have already the template that shows the results
and it works if I change the return render_to_response line by another
call to a different template. as the variables that I need are all in
the same function (check, unzip and store in a folder).

If I change the return render_to_response line by:

return render_to_response('unzip_OK.html', {'nombre':
filename,'zip_list': zf.namelist(), 'item': file_inzip, 'iNum':
iCount})

it works as it shows the results. The thing is that I would like to
only show the results if the user wants to, once he sees that the zip
has been correctly processed (by clicking at the link)

How am I supossed to implement this, Can i pass parameters to another
function that calls the second return render_to_response ?

Thanks in advance

Vince



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

2009-06-24 Thread vince


I saw the former question in stackoverflow "can i use a database view
as a model in django"[http://stackoverflow.com/questions/507795/can-i-
use-a-database-view-as-a-model-in-django] and try it in my app,but
that's not work.I create a view named "vi_topics" manually and it had
"id" column。But I always got the error about "no such column:
vi_topics.id",even I add "id" field explicitly.

here is my view models :

from django.db import models

class Vitopic(models.Model):
title = models.CharField(max_length=200)
content = models.TextField()
author_name = models.CharField(max_length=200)
author_email = models.CharField(max_length=200)
view_count = models.IntegerField(default=0)
replay_count = models.IntegerField(default=0)
tags = models.CharField(max_length=255)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

class Meta:
db_table = 'vi_topics'

btw: I use sqlite3.

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

2009-04-21 Thread Vince

In ubuntu, you'll need to install mysqldb package for python:

sudo apt-get install python-mysqldb

test by entering python interactive mode and importing the package
without errors:

$ python
$ import MySQLdb

case matters.

On Mar 10, 5:09 am, Karen Tracey  wrote:
> On Tue, Mar 10, 2009 at 1:54 AM, kk  wrote:
>
> > Hi Karen,
>
> >  I'm having the same problem as ches and brita had. I downloaded the
> > link that you have given, but I'm unable to run as it is an
> > application. If you can guide me where to store that application and
> > how to run that, I will be glad. Also, for the DATABASEHOST in
> > settings do we need to give the path of mysql in our computer or can
> > we just mention localhost. Please, reply.
>
> I'm not sure what exactly you downloaded that you cannot run as an
> application.  The page I pointed to has five files for download: two are
> .egg files, one tar.gz, and two .exe.  You want to download the .exe that
> matches the level of Python you are running, so if you are running Python
> 2.5 you want to get MySQL-python-1.2.2.win32-py2.5.exe, alternatively if you
> are running Python 2.4 you want to get the one with py2.4 in its name.  Once
> you download it (put it anywhere you like) you run it once to install and
> all the needed files are copied to the Python installation tree.  You can
> then delete the file you downloaded.
>
> As for the DATABASE_HOST setting, you can just leave it blank or set it to
> 'localhost'.
>
> 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
-~--~~~~--~~--~--~---



Did the django tutorial change recently?

2009-10-04 Thread Vince

A couple months ago I was working through the django tutorials and
ended up having to take a break for a while.  I believe they were on
the djangoproject website.  However, I can't seem to find the tutorial
I was working on before, which started with pages that could display
the time based on what you entered in the address bar and led to using
books, authors, and publishers as an example to demonstrate database
functionality.  Does this ring a bell?  I'd really like to pick up
where I left off if possible, so please let me know.

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: How can I re-use the filtering and sorting from the admin pages in my view?

2007-07-31 Thread vince

I asked about this same issue a while back because this is a feature
that I think would be really handy. Not sure how feasible it would be
however.

I put something together after reviewing of the html source of the
admin pages. I did *not* look at the python source (too complicated
for me :). It worked but it is not exactly pretty :) I cut out a bunch
of stuff from my own application that you don't need. I left in the
qstring stuff which can be useful if you have links on your page and
you want to remember the sorting order and stuff when you return to
the page.

Best,

Vincent

= VIEW ===
def view_data(request):
# defining the fields you want to work with in a list of dictionaries
fields = [

{'field':'id','label':'ID','order':'asc','class':'','area':'All',},
{'field':'first_name','label':'First
name','order':'asc','class':'','area':'All',},
{'field':'last_name','label':'Last
name','order':'asc','class':'','area':'All',},
]

# fields for filters
filter_fields = [

{'field':'All','label':'All','sort_by':'','order':'asc','class':'',},

{'field':'type1','label':'type1','sort_by':'','order':'asc','class':'',},

{'field':'type2','label':'type2','sort_by':'','order':'asc','class':'',},
]

# fitering the area of interest
filter = request.GET.get('area__exact','All')
if filter == 'All':
applicants = Application.objects.all()
else:
applicants = Application.objects.filter(area=filter)
# adding the correct filter elements to each sort field
for i in fields:
i['area'] = filter
# adding the correct elements to each filter field
for i in filter_fields:
if i['field'] == filter:
i['class'] = 'class=\"selected\"'

# sorting the applicant dictionary
sort_by = int(request.GET.get('o','1'))
sort_asc = request.GET.get('ot','asc') == 'asc'
if sort_asc:
fields[sort_by]['order'] = 'desc'
fields[sort_by]['class'] = 'class=\"sorted ascending\"'
applicants = dictsort(applicants,fields[sort_by]['field'])
# adding the correct elements to each filter field
for i in filter_fields:
i['sort_by'] = sort_by
i['order'] = 'asc'
else:
fields[sort_by]['order'] = 'asc'
fields[sort_by]['class'] = 'class=\"sorted descending\"'
applicants = 
dictsortreversed(applicants,fields[sort_by]['field'])
# adding the correct elements to each filter field
for i in filter_fields:
i['sort_by'] = sort_by
i['order'] = 'desc'

return render_to_response('view/view.html',
{'applicants':applicants,'nr_applicants':len(applicants),'fields':fields,'filter_fields':filter_fields,'sort_by':fields[sort_by]
['field'],'sort_asc':sort_asc,'qstring':request.META["QUERY_STRING"],'eval_fn':request.user.first_name,'eval_ln':request.user.last_name,},)

 TEMPLATE ===
{% extends "admin/change_list.html" %}
{% block title %}List of Applicants{% endblock %}

{% block content %}

Number of Applicants: {{ nr_applicants }}



Filter by Area:
{% for i in filter_fields %}
{{ 
i.label }}
{% endfor %}






{% for i in fields %}
{{ 
i.label }}
{% endfor %}




{% for applicant in applicants %}

{% if qstring %}
Evaluate
{% else %}
Evaluate
{% endif %}
{{ applicant.id }}
{{ applicant.first_name }}
{{ applicant.last_name }}

{% endfor %}






{% endblock %}


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



include statements for non-dynamic pages

2007-05-28 Thread vince

I am trying to learn Django to convert a site where I use php + python
cgi scripts. For consistent layout i would use php's include statement
for headers and footers on the old site. It is mentioned the Django
book that something similar exists for Django. Suppose i want to
create a home page (index.html). What would i need to do exactly to
get the following to work?

{% include("design/index_nav.html") %}
Welcome to the home page
{% include("design/footer.html") %}

If you have suggestion for better solutions with templates i'd luv to
hear them.

Thanks,

Vincent


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



Any Django Developers in Santa Cruz, CA

2013-01-14 Thread vince
Looking to connect with individuals living "over the hill" who are 
interested in Django development.  I have some opportunities that require 
local talent.  Thanking you all in advance.

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



What's the best way to auto convert a model field values before it is rendered?

2016-04-26 Thread Vince
I need to store and retrieve temperatures in a model.  I'd like to store 
all the values in celsius.  However some users prefer to view the value in 
fahrenheit.
What is the recommended way to setup a model like this?  

Perhaps manually convert the values in the view and on save?
Or is it possible to use python properties in a model for saves, updates 
and gets? 
Or is some other practice preferred?

class Temp(models.Model):
user = models.ForeignKey(User, unique=False)
temperature = models.FloatField(null=True, blank=True)




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


Re: How to run cdn link in a local setup without screwed up hyperlink?

2013-04-13 Thread Vince Fulco
what is the advantage?  TIA, V.


On Sat, Apr 13, 2013 at 1:24 PM, Avraham Serour  wrote:

> Instead of http:// I recommend using just // , for example:
>  rel="stylesheet">
> 
>
>
> On Sat, Apr 13, 2013 at 6:29 PM, Vincent Fulco  wrote:
>
>> [SOLVED] Oddly, copied right from an online resource and colon was
>> missing in web address, accesses external site correctly now.
>>
>>
>> On Saturday, April 13, 2013 9:37:07 AM UTC-5, Vincent Fulco wrote:
>>>
>>> Attempting to use bootstrapcdn.com in a local bootstrap template on a
>>> VM (with 2nd IP address to outside world) before pushing to heroku.
>>> Standard code in the head:
>>>
>>> http://netdna.**bootstrapcdn.com/twitter-**
>>> bootstrap/2.3.1/css/bootstrap-**combined.min.css<http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css>"
>>> rel="stylesheet">
>>>
>>> http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js</a>>
>>> ">
>>>
>>> Static urls ref in other lines works fine--> >> href="{{STATIC_URL}}css/**custom.css" rel="stylesheet">
>>>
>>> Django base.py seems to be set up correctly but I get a mangled
>>> hyperlink and #404 error:
>>>
>>> /website/http//netdna.**bootstrapcdn.com/twitter-**
>>> bootstrap/2.3.1/js/bootstrap.**min.js<http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js>HTTP/1.1"
>>>  404
>>> 2915
>>>
>>>
>>> TIA, V.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>>
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/9G7j9fF-sVI/unsubscribe?hl=en
> .
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Vince Fulco, CFA, CAIA
612.424.5477 (universal)
vful...@gmail.com
twitter: vfulco
app.net: vfulco

--

Since too many in government have conveniently forgotten they've taken a
solemn oath to uphold the Constitution of the United States and not follow
their narrow self-interests, here is a reminder of the beginning of that
unassailable document from one of the citizens for whom they are expected
and supposed to serve, "We the People of the United States, in Order to
form a more perfect Union, establish Justice, insure domestic Tranquility,
provide for the common defence, promote the general Welfare, and secure the
Blessings of Liberty to ourselves and our Posterity, do ordain and
establish this Constitution for the United States of America."

For the balance, feel free to re-visit this site often:

http://www.archives.gov/exhibits/charters/constitution_transcript.html

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