regression: Custom Upload Fields

2007-09-14 Thread James Utter

The Custom Upload Fields and Filters at 
http://code.djangoproject.com/wiki/CustomUploadAndFilters/
 (currently version 8) is now broken in the django development
version.

When you upload an image to a new object in the AutoFileField or
AutoImageField, it gets saved with the filename as "None.jpg".  If you
re-save the object, the image gets renamed to the correct
"4.jpg" (where 4 is the primary key).

Does anyone know what is going on here, and how to fix it?

Cheers,
James


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

2007-09-14 Thread Peter Baumgartner

> Also, we're looking for a suitable application that can be used for file
> upload/download management. There appear to be a number of different
> candidates available, so I'd appreciate suggestions. The features we are
> looking for are
>

You may want to check out FileBrowser:
http://trac.dedhost-sil-076.sil.at/trac/filebrowser/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Setting "blank" to one Field?

2007-09-14 Thread r_f_d

I am not sure this is possible, null=True is for the database, while
blank=True is for form validation.  Also there is a datatype None,
there is no datatype blank.  If you tried to assign blank as apposed
to 'blank' to any variable within python it would complain. If there
were not a named variable called blank it would tell you that 'blank
is not defined', whilst it is easily accomplished to set something to
None.  Django is written in python and while it does some really cool
things easily, it has not implemented a class called blank, afaik.
-richard


On Sep 14, 1:41 pm, Xan <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Following the database API reference (http://www.djangoproject.com/
> documentation/db-api/):
>
>  If a ForeignKey field has null=True set (i.e., it allows
> NULL values), you can assign None to it. Example:
>
>  e = Entry.objects.get(id=2)
>  e.blog = None
>  e.save() # "UPDATE blog_entry SET blog_id = NULL ...;"
>
> I want to know what is equivalent to Blank? That is, how to set
> e.blog to blank if blank=True?
>
> Thanks,
> Xan.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Using a filter with many to many relationship

2007-09-14 Thread r_f_d

You are missing Q.

try
from django.db.models import Q (I think that is where it resides but
cannot verify right now, a quick check of the documentation should
confirm)

Offer.objects.filter(Q(terms__exact = 'term1') & Q(terms__exact =
'term2') & Q(terms__exact = 'term3))



On Sep 14, 6:46 pm, Merric Mercer <[EMAIL PROTECTED]> wrote:
> I have a model "OFFER" that has has many to many relationship with a
> model  "TERMS".
>
> Class OFFER:
>terms=models.ManyToMany(Terms)
>
> Assuming I have the following value for 3 records in Term
> term1=2
> term2=5
> term3=8
>
> I want to return ONLY those offers which have ALL three of these terms .
> I've tried:
>
> qs=Offer.objects.all().filter(terms=term1).filter(terms=term2).filter(terms=term3)
> but this doesn't work - I always end up with an empty query set.
>
> What am I missing?
>
> Cheers


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



Using a filter with many to many relationship

2007-09-14 Thread Merric Mercer

I have a model "OFFER" that has has many to many relationship with a 
model  "TERMS".  

Class OFFER:
   terms=models.ManyToMany(Terms)


Assuming I have the following value for 3 records in Term
term1=2
term2=5
term3=8

I want to return ONLY those offers which have ALL three of these terms . 
I've tried:

qs=Offer.objects.all().filter(terms=term1).filter(terms=term2).filter(terms=term3)
but this doesn't work - I always end up with an empty query set.

What am I missing?

Cheers



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Reinstalled OS X... what do I need to reinstall?

2007-09-14 Thread Austin Govella

I've done more poking about.

Django is totally gone and MySQL isn't running. (May be gone, too.)

Is there a way to install django so it doesn't disappear when you
reinstall the os?



-- 
Austin Govella
Thinking & Making: http://thinkingandmaking.com
Thinking Links: http://thinkingandmaking.com/links

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Reinstalled OS X... what do I need to reinstall?

2007-09-14 Thread [EMAIL PROTECTED]

Austin,

Just make sure Django is in the site-packages directory of the Python
installation that is actually being used.

Regards,
-scott

On Sep 14, 5:06 pm, "Austin Govella" <[EMAIL PROTECTED]> wrote:
> They reinstalled OS X on my machine today.
>
> Runserver tells me "No module named django.core.management" and web
> research suggests that means I need to reinstall python 2.4.
>
> From your experience, is there anything else I need to reinstall?
>
> Should I reinstall django, too? (If I wanted to reinstall django
> anyway, should I just install over the current installation?)
>
> --
> Austin Govella
> Thinking & Making:http://thinkingandmaking.com
> Thinking Links:http://thinkingandmaking.com/links


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Using decoupled urls.py and generic views

2007-09-14 Thread Nathaniel Whiteinge

Whoops, mind the typo. Should be::

urlpatterns = patterns("xgm.AbbrDB.views",
(r"^$", "search"),
)
urlpatterns += patterns("django.views.generic.list_detail",
(r'^list/$', 'object_list', info_dict),
)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Using decoupled urls.py and generic views

2007-09-14 Thread Nathaniel Whiteinge

If you're only doing one or two, use callables [1]_ which will ignore
your view prefix::

from django.conf.urls.defaults import *
from models import Abbreviation
import django.views.generic.list_detail.object_list as object_list

info_dict = { "queryset": Abbreviation.objects.all(), }

urlpatterns = patterns("xgm.AbbrDB.views",
(r"^$", "search"),
(r'^list/$', object_list, info_dict),
)

Otherwise I'd recommend this syntax to join multiple urlpatterns
together::

urlpatterns = patterns("xgm.AbbrDB.views",
(r"^$", "search"),
(r'^list/$', object_list, info_dict),
)
urlpatterns += patterns("django.views.generic.list_detail",
(r'^list/$', 'object_list', info_dict),
)

.. [1] 
http://www.djangoproject.com/documentation/url_dispatch/#passing-callable-objects-instead-of-strings

Cheers!
- whiteinge


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



Reinstalled OS X... what do I need to reinstall?

2007-09-14 Thread Austin Govella

They reinstalled OS X on my machine today.

Runserver tells me "No module named django.core.management" and web
research suggests that means I need to reinstall python 2.4.

>From your experience, is there anything else I need to reinstall?

Should I reinstall django, too? (If I wanted to reinstall django
anyway, should I just install over the current installation?)




-- 
Austin Govella
Thinking & Making: http://thinkingandmaking.com
Thinking Links: http://thinkingandmaking.com/links

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Having Django iterate through JSON possible?

2007-09-14 Thread Richard Dahl
sure,
I am using the YUI tree to display a tree of assets and thier associated
children, i.e. the 'Devices' node of the tree has 'www.acme.com' and '
db1.acme.com' underneath it.  Clicking on the tree parent utilizes the
builtin YUI function to expand the tree which sends an async (Xml HTTP
Request aka AJAX) request to a view which returns the nodes and is
populated.  However, when the user clicks on a childless node such as '
www.acme.com'  an XHR request is sent to a view which, after verifying some
security parameters, creates a newform of the device, gets associated
history records, assessment records, and messages for the device and then
uses a number of render_to_response calls ala:

form = render_to_response('device_form_template.html', {'form': f})

The view then creates tables for the related records (history, assessments,
messages) ala:

a = obj.assessments.all()
assessment_table = render_to_response('assessment_table.html':
{'assessment': a})

This template formats the assessment, history, and message information into
3 raw html tables

the view then takes all of these components (the tables and the form) and
bundles it into a response dictionary

response_dict.update{'form': form._container, 'assessment_table':
assessment_table, messages, history... )

and returned: via
HttpResponse(simplejson.dumps(response_dict), mimetype =
'application/javascript')

My javascript callback function then unpacks the json object and puts the
forms and the three tables into one of four tabs on a tab panel on the right
2/3rd of the screen.  As I said I am using the YUI so I can easily transform
the three tables into Yahoo User Interface Datatables which allow sorting
and scrolling and all that stuff really easily.

I hope this explanation has been clear enough, but I can post a sample if
you would like, let me know which piece is most puzzling (view, template,
javascript)

-richard

On 9/14/07, robo <[EMAIL PROTECTED]> wrote:
>
>
> Hi Richard,
>
> Can you give an example of what you are suggesting?
>
> > One thing that you can do is to pass a
> > render_to_response call a template and the python dictionary you want
> > modified and let django work its majic on it before returning the
> > '._container' to the page via json.
>
> Thanks.
>
> To Olivier: Iterating through javascript like that is possible, but it
> poses a disadvantage in that I cannot access the data's related object
> (e.g. ForeignKey relationships).
> For example I can do data[0].fields.user and I'd get "3" as a
> response, but I cannot do data[0].fields.user.username, where user is
> a foreignkey. Whereas in Django I can do something like this:
> manager.user.username and I'd get the user name.
>
> Thanks for the responses, all.
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Having Django iterate through JSON possible?

2007-09-14 Thread olivier

> To Olivier: Iterating through javascript like that is possible, but it
> poses a disadvantage in that I cannot access the data's related object
> (e.g. ForeignKey relationships).
> For example I can do data[0].fields.user and I'd get "3" as a
> response, but I cannot do data[0].fields.user.username, where user is
> a foreignkey. Whereas in Django I can do something like this:
> manager.user.username and I'd get the user name.


That's the reason you may want to build a custom JSON dict and use
simplejson.dumps().
Something like:

orders_qs = Order.objects.all()
orders = []
for order in order_qs:
# stuff all the fields and foreign key fields you want to use
here.
item = [order.foo, order.spam, order.user.username]
orders.append(item)

output = {"orders" : orders}
return HTTPResponse(simplejson.dumps(output), mimetype = "application/
javascript")


and in javascript

var form_data = {
url: "/ajax_form_test/",
handleAs: "json",
load: function(data){
  for (i = 0, i < data.orders.length, i ++) {
  // Do something
  }
},


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Having Django iterate through JSON possible?

2007-09-14 Thread robo

Hi Richard,

Can you give an example of what you are suggesting?

> One thing that you can do is to pass a
> render_to_response call a template and the python dictionary you want
> modified and let django work its majic on it before returning the
> '._container' to the page via json.

Thanks.

To Olivier: Iterating through javascript like that is possible, but it
poses a disadvantage in that I cannot access the data's related object
(e.g. ForeignKey relationships).
For example I can do data[0].fields.user and I'd get "3" as a
response, but I cannot do data[0].fields.user.username, where user is
a foreignkey. Whereas in Django I can do something like this:
manager.user.username and I'd get the user name.

Thanks for the responses, all.


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



CREATIVE WRITING

2007-09-14 Thread shamsee26
*Creative Writing Skill is not heriditary. We may learn
it.
*



* *

*http://www.100stuff.com/sdk/creative-writing/*



*--*

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Having Django iterate through JSON possible?

2007-09-14 Thread r_f_d

The big issue here would be why to do that.  If you are doing this
synchronously, why put the data into a json object.  Just pass a
dictionary and do what yo will.  If you are doing this ansynchronously
(ala AJAX) then the page will not reload and the template will already
be compiled and unable to incorporate any new information passed
asynchronously.  One thing that you can do is to pass a
render_to_response call a template and the python dictionary you want
modified and let django work its majic on it before returning the
'._container' to the page via json.  You will still have to use some
javascript to display the new information.  I use this mechanism
extensively in an app I am currently writing, but am partial to the
YUI rather than dojo.
-richard


On Sep 14, 12:35 pm, robo <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am able to send JSON data from Django to my javascript function, but
> I would like to iterate JSON by using the Django template language. Is
> this possible at all?
>
> For example, my view passing JSON back:
> def ajax_form_test(request):
>   data = serializers.serialize("json", Order.objects.all())
>   if request.method == 'POST':
> return HttpResponse(data, mimetype="application/json")
>
> And my Javascript function that receives JSON:
>
>function hello() {
>  var form_data = {
> url: "/ajax_form_test/",
> handleAs: "json",
> load: function(data){
>   dojo.byId("myDiv1").innerHTML = data;
> },
> error: function(data){
> alert("Holy Bomb Box, Batman!  An error occurred: " +
> data);
> },
> timeout: 5000,
> form: "myForm"
> };
> dojo.xhrPost(form_data);
>}
>
> Right now the way my template displays JSON is by using innerHTML as
> above. But I would like to convert the data somehow so that Django can
> iterate in the {{...}} syntax.
>
> Thanks,
>
> robo


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



Best Download Softwares

2007-09-14 Thread shamsee26
*Disk Cloning Tools, Registry Cleaners, Graphic Design, Tweaking, Hard Disk
Tools and Registry Repair
Softwares:
** *

*http://www.gobsmack.info/software-download/cCleaner*

*-*

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



Setting "blank" to one Field?

2007-09-14 Thread Xan

Hi,

Following the database API reference (http://www.djangoproject.com/
documentation/db-api/):

 If a ForeignKey field has null=True set (i.e., it allows
NULL values), you can assign None to it. Example:

 e = Entry.objects.get(id=2)
 e.blog = None
 e.save() # "UPDATE blog_entry SET blog_id = NULL ...;"

I want to know what is equivalent to Blank? That is, how to set
e.blog to blank if blank=True?

Thanks,
Xan.


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



Taking data from and uploaded file and distributing it to the database

2007-09-14 Thread jacoberg2

I am relatively new to django nad i was wondeirng if anyone knew how
to open and read the files taht have been uploaded to the site. I have
tried the following code in the save method of my filefield model. The
problem is that you have to save the file to the system and then try
to manipulate it, but when i try to call the open function on the
parser i get an error stating that
'module' object cannot be called
 so i am stuck, here is the code and thanks to anyone who takes the
time to respond to me

def save(self):
super(BulkDataRegFiles, self).save()

import ConfigParser
config=ConfigParser.ConfigParser()
config.readfp(open('%s' % (self.bulk_file)))

sec=config.sections()
for i in sec:
set_name = i
it = config.items(i)
for k in it:
tag = k[0]
if tag == 'url':
url = k[1]
elif tag == 'type':
type1 = k[1]
elif tag == 'end_date':
end = k[1]
elif tag == 'start_date':
start = k[1]
elif tag == 'metadata':
meta = k[1]
   # else
   # raise validators.ValidationError('.INI file not
formatted
   # properly')
b=DataSetRegistration(data_set_type=type1,
  data_set_name=set_name,
  server_url=url,
  start_date=start,
  end_date=end,
  metadata=meta)
b.save()


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Having Django iterate through JSON possible?

2007-09-14 Thread olivier

Hi,


> I am able to send JSON data from Django to my javascript function, but
> I would like to iterate JSON by using the Django template language. Is
> this possible at all?

No, it's not. Javascript works on the client side and doesn't know
anything about the way the server did generate the response.

But nothing prevents you to iterate your data with regular javascript,
ie. stuff like :
for (i = 0; i < data.length; i++) {
   // do something.
}

In this case, you may want to build your json object by hand with
simplejson.dumps() instead of using serializers.serialize(), it will
give you more flexibility.

Regards,

 olivier


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



Having Django iterate through JSON possible?

2007-09-14 Thread robo

Hi,

I am able to send JSON data from Django to my javascript function, but
I would like to iterate JSON by using the Django template language. Is
this possible at all?

For example, my view passing JSON back:
def ajax_form_test(request):
  data = serializers.serialize("json", Order.objects.all())
  if request.method == 'POST':
return HttpResponse(data, mimetype="application/json")

And my Javascript function that receives JSON:

   function hello() {
 var form_data = {
url: "/ajax_form_test/",
handleAs: "json",
load: function(data){
  dojo.byId("myDiv1").innerHTML = data;
},
error: function(data){
alert("Holy Bomb Box, Batman!  An error occurred: " +
data);
},
timeout: 5000,
form: "myForm"
};
dojo.xhrPost(form_data);
   }

Right now the way my template displays JSON is by using innerHTML as
above. But I would like to convert the data somehow so that Django can
iterate in the {{...}} syntax.

Thanks,

robo


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Arithmetic operations in a templete

2007-09-14 Thread [EMAIL PROTECTED]

On Sep 14, 12:46 pm, "Jonathan Buchanan" <[EMAIL PROTECTED]>
wrote:
> I'd have to take a look at how that tag was implemented, but I'd
> likely start out with something horrific, like the attached patch :D

Tsk, tsk. Bending the rules of the game a bit now, aren't we? :-)

Again, yes, you could do all of that. I'd rather not have to patch/
decorate/modify existing Django code for a specific application to do
it, however.

Regards,
-scott


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Arithmetic operations in a templete

2007-09-14 Thread Jonathan Buchanan
On 9/14/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> On Sep 14, 11:29 am, "Jonathan Buchanan" <[EMAIL PROTECTED]>
> wrote:
> > Pesky kids these days, with your music and your anticipation...
>
> :-)
>
> > I agree that what you propose here would be useful in the scenario
> > you've described. *Personally*, if I wanted something like that, I'd
> > just write a function to do it and use it on my tag arguments.
> >
> > Quick and dirty implementation (assuming the template library will
> > allow you to pass your example tag arguments as-is):
> >
> > expression_re = re.compile(r'\$\{ *([a-z0-9\._]+) *\}')
> > expression_re.sub(resolve_variable(r'\1'), your_tag_argument)
>
> But if you wanted to use that logic in a tag defined by someone else,
> say, the url tag...
>
> Regards,
> -scott

I'd have to take a look at how that tag was implemented, but I'd
likely start out with something horrific, like the attached patch :D

Jonathan.

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



template-expressions.diff
Description: Binary data


file upload/download management in Django

2007-09-14 Thread Faheem Mitha


Dear Django Users,

I've been given the task of developing a web application at work. This is 
for uploading/downloading large data files, specifically microarray data 
files for bioinformatics work.

I've been looking at Django and managed to get some basic framework stuff 
working, using the 0.96 package on Debian etch. I've also put Django 
behind Apache.

I had some questions, which I hope are suitable for this mailing list.

1) I've noticed that the Django admin interface has the property that once 
a user has logged in, he can then connnect to the interface without 
logging in again if he (for example) closes the browser window. This may 
be a configuration error or something I have not enabled. In any case, 
this seems to me undesirable behaviour, so I would appreciate 
clarification.

2) How can one configure the login so that a user does not see the 
admin interface but goes directly to the application page? I am sure this 
is a straightfoward configuration.

3) Is it possible (with the admin interface) to have per folder 
permissions, so that only certain groups can access (read, write) a 
particular folder?

Also, we're looking for a suitable application that can be used for file 
upload/download management. There appear to be a number of different 
candidates available, so I'd appreciate suggestions. The features we are 
looking for are

a) Multiple upload: Specifically, this means that one can select multiple 
files within a single browse window by dragging the mouse (or something 
similar).

b) A progress bar for uploads:

c) Works with large file uploads: I'm not sure if this is even an issue. 
Is the issue wrt large streaming uploads described in 
http://code.djangoproject.com/ticket/2070 only a problem if the system in 
question does not have enough memory to keep the file in memory while it 
is being uploaded?

Please cc me on any reply. I'll be checking via gmane in any case.

Thanks, Faheem.

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



Using decoupled urls.py and generic views

2007-09-14 Thread Florian Lindner

Hello,
part 3 of the tutorial introduced how to decouple URL configuration into the 
app dir.
At part 4 [1] generic views are introduced and the decoupled URL 
configuration:

from django.conf.urls.defaults import *

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

apparently is being changed back to a coupled using generic views.:

from django.conf.urls.defaults import *
from mysite.polls.models import Poll

info_dict = {
'queryset': Poll.objects.all(),
}

urlpatterns = patterns('',

(r'^$', 'django.views.generic.list_detail.object_list', info_dict),

(r'^(?P\d+)/$', 'django.views.generic.list_detail.object_detail', 
info_dict), 
url(r'^(?P\d+)/results/$', 
'django.views.generic.list_detail.object_detail', 
dict(info_dict, template_name='polls/results.html'), 'poll_results'),

(r'^(?P\d+)/vote/$', 'mysite.polls.views.vote'),

)

How can I use decoupled URL configuration AND generic views, like that:


from django.conf.urls.defaults import *
from models import Abbreviation

info_dict = { "queryset": Abbreviation.objects.all(), }

urlpatterns = patterns("xgm.AbbrDB.views",
(r"^$", "search"),
(r'^list/$', 'django.views.generic.list_detail.object_list', info_dict),
)

Thanks,

Florian


[1] http://www.djangoproject.com/documentation/tutorial04/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Arithmetic operations in a templete

2007-09-14 Thread [EMAIL PROTECTED]

On Sep 14, 11:29 am, "Jonathan Buchanan" <[EMAIL PROTECTED]>
wrote:
> Pesky kids these days, with your music and your anticipation...

:-)

> I agree that what you propose here would be useful in the scenario
> you've described. *Personally*, if I wanted something like that, I'd
> just write a function to do it and use it on my tag arguments.
>
> Quick and dirty implementation (assuming the template library will
> allow you to pass your example tag arguments as-is):
>
> expression_re = re.compile(r'\$\{ *([a-z0-9\._]+) *\}')
> expression_re.sub(resolve_variable(r'\1'), your_tag_argument)

But if you wanted to use that logic in a tag defined by someone else,
say, the url tag...

Regards,
-scott


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Arithmetic operations in a templete

2007-09-14 Thread Jonathan Buchanan

> Thanks for the response. But to be fair to you I must disclose that I
> anticipated that someone would present this as an answer. I would have
> added this discussion into the original but it was already a bit
> long... :-)

Pesky kids these days, with your music and your anticipation...

> Now when I say expressions, I believe that at least 80% (if not more)
> of my objections could be addressed by allowing the following sort
> construct in template tags only:
>
> {% mytag "${some.context.variable}-arbitrary-${other.variable}-text"
> "Choose ${ parrot.name }!" %}
>
> There... no dirty logic, no arithmetic, nothing really objectionable
> as far as I can see with regards to the stated philosophy, but it
> opens up a whole world of possibilities for the template designer that
> are currently rather difficult and unnecessarily time-consuming to
> accomplish. One could even place this in the split_contents function
> to get halfway there, but I still believe it is most useful when
> implemented by the template parsing system. I mean, even Velocity
> allows this, and they're a good deal more dogmatic about it than the
> Django folks seem to be.

I agree that what you propose here would be useful in the scenario
you've described. *Personally*, if I wanted something like that, I'd
just write a function to do it and use it on my tag arguments.

Quick and dirty implementation (assuming the template library will
allow you to pass your example tag arguments as-is):

expression_re = re.compile(r'\$\{ *([a-z0-9\._]+) *\}')
expression_re.sub(resolve_variable(r'\1'), your_tag_argument)

> Again, thank you for the response, and regards,
> -scott anderson

Thanks for the interesting discussion, I only wish I had time to
participate in it properly. 5pm approaches :)

Jonathan.

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

2007-09-14 Thread Russell Keith-Magee

On 9/14/07, Dushyant Sharma <[EMAIL PROTECTED]> wrote:
>
> def thing_add(request):
> if request.method == 'POST':
> new_data = request.POST.copy()
> new_data.update(request.FILES)

This example is incorrect for the current trunk version of Django. You
don't update the request.FILES into request.POST - you pass in the
FILES data as a second argument to the form.

This obviously needs to be documented better - please raise a ticket
so that it doesn't get forgotten.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Arithmetic operations in a templete

2007-09-14 Thread [EMAIL PROTECTED]

On Sep 14, 9:31 am, "Jonathan Buchanan" <[EMAIL PROTECTED]>
wrote:
>
> Template tags really are the best place to put display-specific logic
> like this. The original problem specified (a custom button and
> associated JavaScript for an object with the object's name in the
> button's id) could be solved using a template filter:
>
> BUTTON_TEMPLATE = u"""
> 
> Button.create("%(type)sButton-%(id)s", "%(text)s");
> """
>
> def button(obj, text):
> """
> Usage::
>
> {{ some_object|button:"Choose me!" }}
> """
> return BUTTON_TEMPLATE % {
> 'type': obj._meta.object_name.lower(),
> 'id': obj._get_pk_val(),
> 'text': ugettext(text),
> }
> button = register.filter(button)
>
> If you wanted to have the button rendered from a template file, that
> would be easy to add. Or if you wanted a different template file to be
> used depending on the type of object (say, with each specialised
> template inheriting from a generic button template), that would also
> be pretty easy.
>

Jonathan,

Thanks for the response. But to be fair to you I must disclose that I
anticipated that someone would present this as an answer. I would have
added this discussion into the original but it was already a bit
long... :-)

Here's the issue: while your solution works in this instance, it is
not a general solution to the problem.

So I have my Button template tag, and it allows both a type (or
discriminator, as I've been thinking of it) and an id, and it
arbitrarily mashes them together. So far, so good.

What if the next instance of a button needs an id that looks like
this?

parrotButton-{{ parrot.flock.id }}-{{ parrot.id }}

Or what if the text for the button is this?

Choose {{ parrot.name }}!

As you can see, the template tag code can quickly get arbitrarily
difficult and convoluted. Basically your solution requires that the
Button tag code anticipates every use to which it will ever be placed,
and this is one of the problems with this approach to which I object.
While you will always be able to present a specific solution to a
specific instance, your solution does not cover the general case which
leads to truly reusable template tag code.

Additionally, if we truly wish to allow the coding of templates by
people who are good at HTML, and leave the Python coding to the people
who are in turn good at Python, this sort of solultion requires the
template programmer to know Python in order to create tags that
reflect his or her needs. This is of course one of my main objections
to this approach: removing expressions from the template language
actually sabotages the main goal of separation of presentation and
logic.

> For the other options you went on to mention (including extra,
> optional arguments), a "full" template tag would probably be in order.
> You wouldn't have to place all the necessary data in the context first
> as you stated - e.g. if you wanted to be able to specify a class for
> the button, it wouldn't be too much work to implement a tag which can
> sort this out:
>
> {% button some_object "Choose me!" class=superButton %}

This solution generalizes to the case I mentioned in which the
template tags are responsible for parsing the expression language.
While it's possible to do this (and indeed I pointed this out in my
original post), it requires the template tag to be responsible for
anticipating how the tag will be used. While it is no doubt an
improvement, in the end the elegant solution is to allow the template
to responsible for this parsing so that even tags which do not
incorporate this special functionality can be used with expressions.

Now when I say expressions, I believe that at least 80% (if not more)
of my objections could be addressed by allowing the following sort
construct in template tags only:

{% mytag "${some.context.variable}-arbitrary-${other.variable}-text"
"Choose ${ parrot.name }!" %}

There... no dirty logic, no arithmetic, nothing really objectionable
as far as I can see with regards to the stated philosophy, but it
opens up a whole world of possibilities for the template designer that
are currently rather difficult and unnecessarily time-consuming to
accomplish. One could even place this in the split_contents function
to get halfway there, but I still believe it is most useful when
implemented by the template parsing system. I mean, even Velocity
allows this, and they're a good deal more dogmatic about it than the
Django folks seem to be.

> Jonathan.

Again, thank you for the response, and regards,
-scott anderson


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

concatenating querysets

2007-09-14 Thread hajo

I have a search function on my site.
A user needs to be able to input multiple words that are then searched
for in multiple text fields. My issue is the following: my function
works very well for a single word or for the last word of a search as
the queryset gets overwritten. I understand what is going on. What I
don't get is what to do about it. I can concatenate querysets by
casting them explicitly as lists; However I can't cast back to a
queryset so that I can use  generic list view. Any ideas? I know this
is such a common thing that it must have been done before by someone.

Appreciate any answers;

Hajo Smulders

Here is the view function:

def recipe_search(request, searchcriteria, sorter, page):
BASE_ROOT = determine_baseroot() # don't worry about this, this
sets the different environments I work in (IE: different URLs for
developemnt, QA and prod
searchcriteria = searchcriteria.split(" ") # This allows multiple
inputs
# I'm chceking one field (main_ingredients first; only if I don't get
any results do a do a full text search on the other fileds
for criterion in searchcriteria:
tempquery =
Recipe.objects.filter(main_ingredients__icontains=criterion)
if tempquery.count() < 1:
for criterion in searchcriteria:
tempquery =
Recipe.objects.filter(Q(ingredients__icontains=criterion) |
Q(description__icontains=criterion) |
Q(instructions__icontains=criterion))
recipequery = tempquery.order_by(sorter)
return list_detail.object_list(
request,
queryset = recipequery,
template_object_name = "recipe",
paginate_by = 20,
page=page,
allow_empty = True,
extra_context = {
"baseroot" : BASE_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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Validating dynamically generated fields (guess i'll need a metaclass)

2007-09-14 Thread JeffH

I agree with Doug B's advice - I've used that "list of forms with
different prefixes" technique and it works very well and the code
should be easy for others to follow down the road. You actually don't
need a prefix hidden field for each fieldset - one hidden field
containing the number of fieldsets is plenty if the prefixes follow a
sequence like 'room0','room1','room2' then loop as in the following
"notional code" (no validation, initialization, etc):

for i in range(int(request.POST['numberOfFieldSets'])):
roomshared.append(RoomShared(request.POST,prefix='room%d' % i))

If you are interested in generating the forms dynamically, one way
I've done it is to define the RoomShared class by building a
dictionary of fields and then creating the class using the built-in
type() rather than using a Class declaration:

RoomShared = type('RoomShared',(django.newforms.Form,),
{ 'field_name1':field_declaration1,'field_name2':...})

It's important to add the field declarations to the dictionary in the
order they will be displayed in the form if you want to use shortcuts
like as_p(). newforms assigns a creation counter to each field when
it's declaration is processed and orders fields by their creation
counters when displaying the form.

Using type() to create a class is discussed in the context of dynamic
model creation at http://code.djangoproject.com/wiki/DynamicModels

Cheers,
Jeff

On Sep 14, 9:16 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> On Sep 13, 11:06 pm, Doug B <[EMAIL PROTECTED]> wrote:
>
> > Could you just use a collection of forms with different prefixes...
>
> Hi Doug,
>
> that's a good idea... but i'm still following the meta-programming
> route... i tried with a form factory function which is conceptually
> closer to what i thought but still doesn't work.
>
> This is what i tried:
>
> def room_form_factory(new_data):
> room_type = IntegerField(widget=Select(choices=BEDROOM_TYPES))
> room_price = IntegerField()
> is_shared = BooleanField(required=False)
>
> class RoomShared(Form):
> pass
>
> for k in new_data:
> postfix = k[-3:]
>
> if k.startswith('room_type'):
> setattr(RoomShared, 'room_type_%s' % postfix, room_type)
> elif k.startswith('room_price'):
> setattr(RoomShared, 'room_price_%s' % postfix, room_price)
> elif k.startswith('is_shared'):
> setattr(RoomShared, 'is_shared_%s' % postfix, is_shared)
>
> return RoomShared(new_data)
>
> And this is my view code:
>
> def add_share_room_details(request, object_id):
>
> if request.method == 'POST':
> new_data = request.POST.copy()
> form = room_form_factory(new_data)
>
> d = vars(form)
> for kw in d:
> print "%s = %s" % (kw, d[kw])
>
> if form.is_valid():
> return HttpResponse("Form is valid")
> else:
> return HttpResponse("Form NOT valid")
> else:
> pass
>
> return render_to_response("house_share_room.html")
>
> Any other idea?
>
> Thanks,
> Lorenzo


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Arithmetic operations in a templete

2007-09-14 Thread Jonathan Buchanan

> However, simply dodging the question doesn't address the original point:
> why does Django adhere to such a nannyish philosophy, and how do you
> solve the problem I presented *within Django* in a reasonable way?
>
> Thanks and regards,
> -scott anderson

Template tags really are the best place to put display-specific logic
like this. The original problem specified (a custom button and
associated JavaScript for an object with the object's name in the
button's id) could be solved using a template filter:

BUTTON_TEMPLATE = u"""

Button.create("%(type)sButton-%(id)s", "%(text)s");
"""

def button(obj, text):
"""
Usage::

{{ some_object|button:"Choose me!" }}
"""
return BUTTON_TEMPLATE % {
'type': obj._meta.object_name.lower(),
'id': obj._get_pk_val(),
'text': ugettext(text),
}
button = register.filter(button)

If you wanted to have the button rendered from a template file, that
would be easy to add. Or if you wanted a different template file to be
used depending on the type of object (say, with each specialised
template inheriting from a generic button template), that would also
be pretty easy.

For the other options you went on to mention (including extra,
optional arguments), a "full" template tag would probably be in order.
You wouldn't have to place all the necessary data in the context first
as you stated - e.g. if you wanted to be able to specify a class for
the button, it wouldn't be too much work to implement a tag which can
sort this out:

{% button some_object "Choose me!" class=superButton %}

Jonathan.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Validating dynamically generated fields (guess i'll need a metaclass)

2007-09-14 Thread [EMAIL PROTECTED]

On Sep 13, 11:06 pm, Doug B <[EMAIL PROTECTED]> wrote:
> Could you just use a collection of forms with different prefixes...

Hi Doug,

that's a good idea... but i'm still following the meta-programming
route... i tried with a form factory function which is conceptually
closer to what i thought but still doesn't work.

This is what i tried:

def room_form_factory(new_data):
room_type = IntegerField(widget=Select(choices=BEDROOM_TYPES))
room_price = IntegerField()
is_shared = BooleanField(required=False)

class RoomShared(Form):
pass

for k in new_data:
postfix = k[-3:]

if k.startswith('room_type'):
setattr(RoomShared, 'room_type_%s' % postfix, room_type)
elif k.startswith('room_price'):
setattr(RoomShared, 'room_price_%s' % postfix, room_price)
elif k.startswith('is_shared'):
setattr(RoomShared, 'is_shared_%s' % postfix, is_shared)

return RoomShared(new_data)

And this is my view code:

def add_share_room_details(request, object_id):

if request.method == 'POST':
new_data = request.POST.copy()
form = room_form_factory(new_data)

d = vars(form)
for kw in d:
print "%s = %s" % (kw, d[kw])

if form.is_valid():
return HttpResponse("Form is valid")
else:
return HttpResponse("Form NOT valid")
else:
pass

return render_to_response("house_share_room.html")

Any other idea?

Thanks,
Lorenzo


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: ANN: Making some changes to djangoproject.com

2007-09-14 Thread Jarek Zgoda

Tim Chase napisał(a):

> - the addition of Cobol data-stores and hierarchical databases

- ability to write code in positional way, like in RPG/400

-- 
Jarek Zgoda
Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101

"We read Knuth so you don't have to." (Tim Peters)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: ANN: Making some changes to djangoproject.com

2007-09-14 Thread TheMaTrIx

Rewrote Django in PHP.
Rewrote Django in ASP.
Rewrote Django in Java.
Dropped Django development and defected to Ruby on Rails.
Rewrote Django to be the root of all online evil (but then again,
doing any of the above would qualify it for this by default :p)

If your server move messages have anything to do with it, I'm guessing
you changed something on the old server to check if it would run
better on up to date hardware and software on the new server.

On Sep 8, 12:51 am, Tim Chase <[EMAIL PROTECTED]> wrote:
> >> These changes are in preparation of some exciting news, but I'll leave
> >> y'all in suspense until next week.
>
> > You're rewriting Django in Java! Finally, enterprise capability!
>
> I thought it was one of the following:
>
> - adding "2.0" to the official name to make it a "Web 2.0"
> buzzword-compliant technology... "Django 2.0, now with more AJAXy
> goodness for your RESTful/SOAPy SaaS!  Paradigm!  Synergy!"
>
> - the addition of Cobol data-stores and hierarchical databases
>
> - support for SilverLight
>
> - Django has been ported from Python to PostScript and can now
> run on any PostScript compatible printer with minimal syntax changes
>
> - a complete reimplementation of Emacs in Django
>
> - a complete reimplementation of Django in Emacs
>
> - ability to use use Prolog as your backing fact database
>
> Any other guesses? :)
>
> TGIF...
>
> -tim


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



size of urls.py

2007-09-14 Thread Dushyant Sharma

is there any performance bottleneck when the size of urls.py goes
large.
if yes how to overcome that.
also if we use same url for a particular group, based on some hidden
action variable in htmls, would it improve performance. like i am
using

if request.method == 'POST':
action = request.POST['act']
if action == '0001':
 call some function based on action 0001


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: ATTN: (NOT) Moving djangoproject.com to a new server!

2007-09-14 Thread TheMaTrIx

Hrm, I ran Django on configs from old to bleeding edge python,
mod_python and apache and haven't had a problem with the auth layer
(aka apache 2.2, python 2.5.1, latest mod_python etc)

What trouble is it giving you?

On Sep 14, 8:32 am, "Jacob Kaplan-Moss" <[EMAIL PROTECTED]>
wrote:
> Hi all --
>
> OK, so I've run into some problems setting up the new box, so this
> isn't going to happen tonight. (If anyone can help me get Django's
> authentication handler working with Apache 2.2 / mod_python 3.3,
> please get in touch!)
>
> So chances are I'll put this off until after the sprint. Sorry for the
> false alarm :(
>
> Jacob


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

2007-09-14 Thread TheMaTrIx

I wish google would finaly start enabling their Gmail spam filters on
these frigin boards.
Spam is getting rediculous.

On Sep 14, 11:38 am, "Useful Database" <[EMAIL PROTECTED]>
wrote:
> Hello friends and group members,
>
> I recently happened to see the below information ... just thought that it
> could be useful to you people ...
>
> Thanks.
>
> --
>
> *Introducing for the first time in **India**, a Product that could be
> required for all types of Industries and Consultants in **India** and across
> the World.*
>
> *We have Quality Databases of all types of Doctors, Engineers and Graduates
> in **India**.*
>
> *Engineers*: Computer, Software, Electronics, Civil, Mechanical, Production,
> Chemical, Pharmacy, PhDs, etc.
>
> *Medical*:  Doctors, Surgeons, Physicians, PhDs, etc.
>
> *Graduates*: Physics, Chemistry, Biology, Agriculture, etc.
>
> The database is in the form of Excel Sheets and Word Documents. The word
> format document contains the resume of the concerned person.
>
> The database is divided into the following catagories:
>
>1. *By Functional Area*: Basically technical people working in
>projects, production, maintenance, software, quality control, research &
>development, etc. The number of resumes in each category, are around 
> 30,000.
>
>2. *By Industrial Segment*: Pharmaceutical, Drugs, Chemical, Marine,
>Electronics, Medical, Shipping, Construction, Automotives, Hotels,
>Computers, Rural Areas, and Government of India Companies (Railways,
>Municipality, Atomic Energy, Electricity, Power, Water Supply, etc.)  The
>number of resumes in each segment, are around 30,000.
>3. *Infotech & Software Personnel*: MCAs, BCAs, Computer/Electronics
>&Telecom Engineers, etc. Around 1,00,000 resumes.
>4. Company wise data are also available, around 50 reputed companies
>in India.
>
> *The basic purpose of this database is that the consumer can market his
> product/s sitting from his office, making cold calls or by mailing directly
> to the concerned personnel. *
>
> The Resume Database comprises of people who have maximum experience in their
> relevant field.
>
> The Resume Database does not contain personnel from the Accounts/Finance,
> Sales & Business Development department and the Banking Sector. The reason
> is that these people are comparatively easily accessible. Although Engineers
> (Technical personnel) working in sales, marketing and business development
> fields are available.
>
> *This Database is most suited and useful for Recruitment Consultants in **
> India** and Abroad. *If the consultant is not subscribed to the expensive
> portals then this data would be most useful to them.
>
> *This Data is also useful to small and medium sized companies who have
> limited resources, who cannot employ a battery of sales personnel.* Sales
> people who keep on moving around in the market are susceptible to change
> their job. They can spare some time to apply for other jobs and attend the
> interview, while on outdoor field. Hence sales and marketing people keep on
> changing their jobs after having short stints with companies. Once a
> Salesman leaves a company, he also takes away with him the market
> information and the intellectual database, sometimes.
>
> *Frequently Asked Questions*
>
> *Why Resumes as a database?*
>
> Resumes don't lie !
>
> A Resume gives the full detail of a person for example, the residential
> phone no. and address, the mobile/cell phone no., the email address, the job
> responsibilities, the references, etc. These details help to contact that
> key person with ease and perfection. Most importantly it saves time and
> money.
>
> *Money! How does it save money?*
>
> You save money on phone calls. For example you want to contact the
> Maintenance Manager of M/s.XYZ Corporation, you visit the companies website
> wherein you may not find the required details (like the plant address, the
> contact details, the contact person, the email address of that Manager,
> etc.). You hence call the telephone operator, who will give you the half
> information only (the telephone operator is normally not allowed to disclose
> the cell phone numbers, email IDs, etc. of key contact personnel).
>
> Ultimately to reach that department or that key man you spend some good
> amount of money on phone calls.
>
> *Is the database perfect and totally updated? *
>
> Honestly we believe that our database is nearly 94% correct. Because people
> change companies; they give the temporary home address in their resumes;
> sometimes email IDs  are also changed; etc. But in India normally people
> mention their permanent address in their resumes which rarely changes.
>
> *How do we search in this huge database ?   *
>
> By using the Microsoft search method, typing out the key words and selecting
> the particular folder in the options. The simplest method is to op

Re: Arithmetic operations in a templete

2007-09-14 Thread Scott Anderson

Yes, that's always the fall back, isn't it?

I'll look at Jinja, as I didn't realize there was such a fork.
Apparently I'm not the only one who thinks this way.

I'm concerned with how well a solution like this tracks the Django
release.

However, simply dodging the question doesn't address the original point:
why does Django adhere to such a nannyish philosophy, and how do you
solve the problem I presented *within Django* in a reasonable way?

Thanks and regards,
-scott anderson


On Thu, 2007-09-13 at 23:46 -0500, James Bennett wrote:
> On 9/13/07, Scott Anderson <[EMAIL PROTECTED]> wrote:
> > What I'm hoping, however, is that this missive was moot, because you'll
> > say, "no, Scott, you should just do *this*:", followed by an elegant and
> > reasonable solution that I, as a relative newcomer to Django, have not
> > yet considered. Here's to your reply, and cheers!
> 
> OK, here you go:
> 
> Use another template system, either site-wide or for the cases where
> the Django template system isn't doing what you need. It's not hard to
> do this, and it opens up the possibility of using any or all of the
> vast number of Python template systems available.
> 
> The Django template system, at this point, will almost certainly
> *never* include the type of functionality you're asking for, so use
> another template system that does or that's more willing to bend its
> philosophy to suit what you want. If you like the rest of the Django
> template system I'd suggest you try Jinja, which started as a fork of
> Django's template system and so is nearly feature-for-feature
> identical, but adds arbitrary Python expressions.
> 
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Arithmetic operations in a templete

2007-09-14 Thread Scott Anderson

Thank you, but that's exactly what I said I *didn't* want to do, because
it's silly. :-)

Why should my *data model* know *anything* about the presentation? And
what happens when I want a parrot row ID, or a parrot foo ID, or a
parrot cheese ID? Suddenly I have a proliferation of things in my data
model that have jack all to do with the data, and everything to do with
a particular implementation of a particular view.

And then don't forget the Sloth Button ID as well... so if I have two
different data objects with similar presentation needs (but no other
similarities beyond that), I have to either a) introduce an inheritance
dependency that really makes no sense or b) duplicate a lot of code.

And then there's the fact that I can't use my nice generic button tag
with anything other than data that understands how it's supposed to be
displayed by a particular tag.

Regards,
-scott anderson

On Fri, 2007-09-14 at 09:14 +, Samuel Adam wrote:
> no, Scott, you should just do *this*:
> 
> In your Parrot model, you could add a property that displays your DOM
> id.
> 
> class Parrot(models.Model):
> # fields
> 
> def _domid(self):
> return ''parrotButton-%s" % self.id
> domid = property(_domid)
> 
> and use parrot.domid in your templates.
> 
> On 14 sep, 06:46, "James Bennett" <[EMAIL PROTECTED]> wrote:
> > On 9/13/07, Scott Anderson <[EMAIL PROTECTED]> wrote:
> >
> > > What I'm hoping, however, is that this missive was moot, because you'll
> > > say, "no, Scott, you should just do *this*:", followed by an elegant and
> > > reasonable solution that I, as a relative newcomer to Django, have not
> > > yet considered. Here's to your reply, and cheers!
> >


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

2007-09-14 Thread Stewart

Excellent. A little bit of experimentation later and I see I can then
import core models into another app with "import sitename.core.models"

Many thanks.

On Sep 14, 11:35 am, Chris Hoeppner <[EMAIL PROTECTED]> wrote:
> I always have an app called "core" for that kind of stuff, like non-app
> related views, forms, middleware, models... etc.
>
> El vie, 14-09-2007 a las 03:09 -0700, Stewart escribi?:
>
> > Hi
>
> > I'm considering writing an web application in Django but I'm a little
> > confused about the Site-App model.
>
> > Say, for instance, I am writing a site that has both a blog and a
> > forum application. Each application has its own data models, but there
> > is also some data that is common between both. Is it possible to have
> > a site level models.py, is there a way for one application to
> > reference another's models, or do both forum and blog have to be part
> > of the same application in order to share data?
>
> > Thanks,
> > Stewart.


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

2007-09-14 Thread Chris Hoeppner

I always have an app called "core" for that kind of stuff, like non-app
related views, forms, middleware, models... etc.

El vie, 14-09-2007 a las 03:09 -0700, Stewart escribi�:
> Hi
> 
> I'm considering writing an web application in Django but I'm a little
> confused about the Site-App model.
> 
> Say, for instance, I am writing a site that has both a blog and a
> forum application. Each application has its own data models, but there
> is also some data that is common between both. Is it possible to have
> a site level models.py, is there a way for one application to
> reference another's models, or do both forum and blog have to be part
> of the same application in order to share data?
> 
> Thanks,
> Stewart.
> 
> 
> > 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: User session variable in view

2007-09-14 Thread Dushyant Sharma

use RequestContext
http://www.djangoproject.com/documentation/templates_python/#subclassing-context-requestcontext
pass request object to it
c= RequestContext(request, {other objects})
then you can use user.fieldname in your view


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



Site level data models

2007-09-14 Thread Stewart

Hi

I'm considering writing an web application in Django but I'm a little
confused about the Site-App model.

Say, for instance, I am writing a site that has both a blog and a
forum application. Each application has its own data models, but there
is also some data that is common between both. Is it possible to have
a site level models.py, is there a way for one application to
reference another's models, or do both forum and blog have to be part
of the same application in order to share data?

Thanks,
Stewart.


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



FREE PS3 or XBOX 360 ELITE or many more! As seen on BBC Newsnight!!

2007-09-14 Thread senjie49

As shown on BBC Newsnight, you can receive many free items! If you
don't believe me check out this video:
http://www.youtube.com/watch?v=JQao7pzpqm8
It has been proven to work!! I have already completed one of these and
received an iPod and a PS3, so I know it works! All you have to do is
follow these simple steps below:
STEP 1: Follow this link:

http://gameconsolegiveaway.co.uk/index.php?referral=74924
Here once you register (which is step 2) you will be able to select
from a multitude of free gifts. These are the following free gifts
available, and the number of referrals required:
·   Nintendo DS Lite - 6 referrals
·   Sony PSP - 9 referrals
·   Nintendo GameBoy Advance - 4 referrals
·   Xbox 360 - 10 referrals
·   Xbox 360 ELITE - 12 referrals
·   PS3 - 13 referrals

STEP 2: Register. This costs nothing and you don't even have to go on
with the offer after this if you don't want to.

STEP 3: Now you get to choose from a number of offers from different
companies (you don't get sent junk mail) - You need to complete one of
these offers. This will activate your account and give you a credit so
when you have enough referrals you can claim your item. Without
completing the offer you will not be able to receive it.
The current offers are ScreenSelect/LoveFilm, Coral, King Jackpot UK,
SmartStamp, Deal or No Deal, AOL, easyCinema Online DVD Rental,
Fasthosts, Green Flag, Jackpot Joy and TalkTalk. I would advise the
ScreenSelect/LoveFilm offer as it is a free trial, so as long as you
remember to cancel your free trial, you pay NOTHING! (NOTE: pick 10
DVD titles then wait for 1 DVD to be dispatched then cancel your
membership via the freephone number when you receive the DVD, just
simply posting it back in the pre-paid envelope. This will mean that
you will complete the offer. This method worked for me and also for my
friends that signed up. So you will get up to a max of 3 DVD's at a
time to watch free only by filling in a small form.) Alternatively,
the Coral deal is one that also comes highly recommended only needing
£5 deposit, and you get a £5 free bid!
STEP 4: Refer people. You only need 13 referrals for a PS3. Lets all
enjoy getting free Playstations whilst the offer lasts! JUST CHECK OUT
THE LINK FOR YOURSELF!

http://gameconsolegiveaway.co.uk/index.php?referral=74924
If you have any questions just send me a message :-)
ENJOY!!!


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: User session variable in view

2007-09-14 Thread Jarek Zgoda

Rufman napisał(a):

> in temlates user information is stored in the variable user. how can i
> access this data in a view. (im guessing it must be a session
> variable, but i haven't found any precise information)

Check the user attribute of request object.

-- 
Jarek Zgoda
Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101

"We read Knuth so you don't have to." (Tim Peters)

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



User session variable in view

2007-09-14 Thread Rufman

in temlates user information is stored in the variable user. how can i
access this data in a view. (im guessing it must be a session
variable, but i haven't found any precise information)

thx for the help
stephane


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: about get_cfg_var () function

2007-09-14 Thread Horst Gutmann

bjlinwu wrote:
>  echo  get_cfg_var("register_globals");
> Why it doesn't output anything?
> 

O_o ... and you're completely sure that you wrote this to the right
mailing list? ;-)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: ifequal function not working?

2007-09-14 Thread Nis Jørgensen

John M skrev:
> the ID is the primary key ID generated by django on models.
>
> basically, it's not the syntax im having issue with, i think the
> selected_id is being passed / parsed as a string not an intenger like
> ID is.
>   
So where do you get the selected_id from? GET/POST variables are always
strings.

Could you try converting it to an int before you pass it to the template?

Nis

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



Forms and unique fields

2007-09-14 Thread Thijs Thiessens

Hi!

I have a model which contains among others a unique email field. However this 
field has no corresponding form validating field. Is that correct? I have seen 
that I can make a custom validating field which probably should query the 
database to see if the email exists but having seen the clean library it looks 
a bit overdone.

Is their a common django way of doing this?


Thanx,

Thijs Thiessens

-- 
Thijs Thiessens <[EMAIL PROTECTED]>

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



[no subject]

2007-09-14 Thread Useful Database
Hello friends and group members,

I recently happened to see the below information ... just thought that it
could be useful to you people ...

Thanks.

--

*Introducing for the first time in **India**, a Product that could be
required for all types of Industries and Consultants in **India** and across
the World.*



*We have Quality Databases of all types of Doctors, Engineers and Graduates
in **India**.*

*Engineers*: Computer, Software, Electronics, Civil, Mechanical, Production,
Chemical, Pharmacy, PhDs, etc.

*Medical*:  Doctors, Surgeons, Physicians, PhDs, etc.

*Graduates*: Physics, Chemistry, Biology, Agriculture, etc.

The database is in the form of Excel Sheets and Word Documents. The word
format document contains the resume of the concerned person.



The database is divided into the following catagories:

   1. *By Functional Area*: Basically technical people working in
   projects, production, maintenance, software, quality control, research &
   development, etc. The number of resumes in each category, are around 30,000.

   2. *By Industrial Segment*: Pharmaceutical, Drugs, Chemical, Marine,
   Electronics, Medical, Shipping, Construction, Automotives, Hotels,
   Computers, Rural Areas, and Government of India Companies (Railways,
   Municipality, Atomic Energy, Electricity, Power, Water Supply, etc.)  The
   number of resumes in each segment, are around 30,000.
   3. *Infotech & Software Personnel*: MCAs, BCAs, Computer/Electronics
   &Telecom Engineers, etc. Around 1,00,000 resumes.
   4. Company wise data are also available, around 50 reputed companies
   in India.



*The basic purpose of this database is that the consumer can market his
product/s sitting from his office, making cold calls or by mailing directly
to the concerned personnel. *



The Resume Database comprises of people who have maximum experience in their
relevant field.



The Resume Database does not contain personnel from the Accounts/Finance,
Sales & Business Development department and the Banking Sector. The reason
is that these people are comparatively easily accessible. Although Engineers
(Technical personnel) working in sales, marketing and business development
fields are available.



*This Database is most suited and useful for Recruitment Consultants in **
India** and Abroad. *If the consultant is not subscribed to the expensive
portals then this data would be most useful to them.



*This Data is also useful to small and medium sized companies who have
limited resources, who cannot employ a battery of sales personnel.* Sales
people who keep on moving around in the market are susceptible to change
their job. They can spare some time to apply for other jobs and attend the
interview, while on outdoor field. Hence sales and marketing people keep on
changing their jobs after having short stints with companies. Once a
Salesman leaves a company, he also takes away with him the market
information and the intellectual database, sometimes.



*Frequently Asked Questions*



*Why Resumes as a database?*

Resumes don't lie !

A Resume gives the full detail of a person for example, the residential
phone no. and address, the mobile/cell phone no., the email address, the job
responsibilities, the references, etc. These details help to contact that
key person with ease and perfection. Most importantly it saves time and
money.



*Money! How does it save money?*

You save money on phone calls. For example you want to contact the
Maintenance Manager of M/s.XYZ Corporation, you visit the companies website
wherein you may not find the required details (like the plant address, the
contact details, the contact person, the email address of that Manager,
etc.). You hence call the telephone operator, who will give you the half
information only (the telephone operator is normally not allowed to disclose
the cell phone numbers, email IDs, etc. of key contact personnel).

Ultimately to reach that department or that key man you spend some good
amount of money on phone calls.



*Is the database perfect and totally updated? *

Honestly we believe that our database is nearly 94% correct. Because people
change companies; they give the temporary home address in their resumes;
sometimes email IDs  are also changed; etc. But in India normally people
mention their permanent address in their resumes which rarely changes.



*How do we search in this huge database ?   *

By using the Microsoft search method, typing out the key words and selecting
the particular folder in the options. The simplest method is to open each
resume.



*How is the supply of the database done?*

We shall courier you the CD/DVD containing the database to your said
address.



*Still Confused? A typical example is given below *

A Company manufacturing Medicines (tablets, syrups, injections, etc).
Normally, the method of sales is that the company employs MRs (Medical
Represent

Re: Uploading files

2007-09-14 Thread Dushyant Sharma


class ThingForm(forms.Form):
name = forms.CharField(max_length=30, required=True, label=_('Name
of the thing'))
photo = forms.Field(widget=forms.FileInput, required=False,
label=_('Photo'), help_text=_('Upload an image (max %s kilobytes)' %
settings.MAX_PHOTO_UPLOAD_SIZE))

def thing_add(request):
if request.method == 'POST':
new_data = request.POST.copy()
new_data.update(request.FILES)
form = ThingForm(new_data)
if form.is_valid():
clean_data = form.clean_data
t = Thing()
t.name = clean_data['name']
if clean_data['photo']:
photo = clean_data['photo']
t.save_photo_file(photo['filename'], photo['content'])

please also read
http://www.djangoproject.com/documentation/model-api/#filefield
and
http://batiste.dosimple.ch/blog/2007-05-13-1/

new forms have changed this binding and made things easy so you can
also check
http://www.djangoproject.com/documentation/newforms/#binding-uploaded-files-to-a-form


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Arithmetic operations in a templete

2007-09-14 Thread Samuel Adam

no, Scott, you should just do *this*:

In your Parrot model, you could add a property that displays your DOM
id.

class Parrot(models.Model):
# fields

def _domid(self):
return ''parrotButton-%s" % self.id
domid = property(_domid)

and use parrot.domid in your templates.

On 14 sep, 06:46, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 9/13/07, Scott Anderson <[EMAIL PROTECTED]> wrote:
>
> > What I'm hoping, however, is that this missive was moot, because you'll
> > say, "no, Scott, you should just do *this*:", followed by an elegant and
> > reasonable solution that I, as a relative newcomer to Django, have not
> > yet considered. Here's to your reply, and cheers!
>
> OK, here you go:
>
> Use another template system, either site-wide or for the cases where
> the Django template system isn't doing what you need. It's not hard to
> do this, and it opens up the possibility of using any or all of the
> vast number of Python template systems available.
>
> The Django template system, at this point, will almost certainly
> *never* include the type of functionality you're asking for, so use
> another template system that does or that's more willing to bend its
> philosophy to suit what you want. If you like the rest of the Django
> template system I'd suggest you try Jinja, which started as a fork of
> Django's template system and so is nearly feature-for-feature
> identical, but adds arbitrary Python expressions.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."


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



about get_cfg_var () function

2007-09-14 Thread bjlinwu

 echo  get_cfg_var("register_globals");
Why it doesn't output anything?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Deleting the relations and not the objects?

2007-09-14 Thread Nis Jørgensen

Xan skrev:
> class Aclass(models.Model):
>   be = models.ForeignKey('B')
>   ce = models.ManytoManyfield('C')
>
> class B(models.Model):
>[...]
>
> class C(models.Model):
>   [...]
>
> Suppose that with admin interface, I put:
> be = b1 (b1 is B)
> ce has c1, c2, c3 objects (c1, c2 and c3 are in C)
>
> in an object p (p in Aclass)
>
> I want to delete the relation that ce has c1 without deleting c1.
> How can I do that with shell?
>
> Do you understand that I want? If I run:
> p = Aclass.objects.get(pk=1) # p is the object I have
> p.be.all()
>b1
> p.ce.all()
>c1, c2, c3
>
> I want that p.ce.all() will be empty set, but c1, c2 and c3 exits as
> intances of class C
>   
Use

p.ce.clear()

or

p.ce = []

or

p.ce.remove(c1)
p.ce.remove(c2)
p.ce.remove(c3)

All found in the documentation at
http://www.djangoproject.com/documentation/models/many_to_many/ , not tested

This should work as well:

p.ce.remove(c1,c2,c3)

Found in http://www.djangoproject.com/documentation/db-api/

Nis

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

2007-09-14 Thread Jarek Zgoda

Jarek Zgoda napisał(a):

>>  I am using Django 0.97 pre in winxp. database is mysql. Please
>> forgive any errors or if I am not clear with some aspects as I am a
>> beginner trying to learn django. I am trying to upload a file: an
>> image. I am not worried about validation now. I want to know how to do
>> this.
>> I tried to do this But my data base shows only the name of the file
>> uploaded (I think it should store the path to the file).
>>   In my view I have
>>
>> def save_data(request):
>>
>> ed_user=getfrmdb(uid)
>> new_data=request.POST.copy()   #this accounts for uploading the
>> image too with other data.
>> print new_data
>> addata=User(id=uid,name=ed_user.name, email=new_data['u_email'],
>>  
>> address=new_data['u_add'],phone=new_data['u_ph'],date=datetime.date.today(),
>> comments=new_data['u_comm'], image=  __)
>> addata.save()
>>
>> I saw some codes (with new_data.update(request.FILES) )but I have a
>> hard time in understanding it completely.
>>I would also like to know important tips to retrieve this uploaded
>> image. Thanking you ..
> 
> It would be great if somebody wrote a quick introduction to handling
> file/image uploads in Django using both newforms and oldforms. I barely
> understand how it works, so I will not even try now...

Also, I found some related (but unanswered) question asked on this group
long time ago, which touches the topic of some importance if somebody
wants to store uploaded files outside MEDIA_ROOT. I think it's a common
case to not store user-submitted content along with static site content,
but in current state I just don't know how to achieve this...

http://groups.google.com/group/django-users/msg/f518a9e7579bf47e

-- 
Jarek Zgoda
Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101

"We read Knuth so you don't have to." (Tim Peters)

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

2007-09-14 Thread Jarek Zgoda

AniNair napisał(a):

>  I am using Django 0.97 pre in winxp. database is mysql. Please
> forgive any errors or if I am not clear with some aspects as I am a
> beginner trying to learn django. I am trying to upload a file: an
> image. I am not worried about validation now. I want to know how to do
> this.
> I tried to do this But my data base shows only the name of the file
> uploaded (I think it should store the path to the file).
>   In my view I have
> 
> def save_data(request):
> 
> ed_user=getfrmdb(uid)
> new_data=request.POST.copy()   #this accounts for uploading the
> image too with other data.
> print new_data
> addata=User(id=uid,name=ed_user.name, email=new_data['u_email'],
>  
> address=new_data['u_add'],phone=new_data['u_ph'],date=datetime.date.today(),
> comments=new_data['u_comm'], image=  __)
> addata.save()
> 
> I saw some codes (with new_data.update(request.FILES) )but I have a
> hard time in understanding it completely.
>I would also like to know important tips to retrieve this uploaded
> image. Thanking you ..

It would be great if somebody wrote a quick introduction to handling
file/image uploads in Django using both newforms and oldforms. I barely
understand how it works, so I will not even try now...

-- 
Jarek Zgoda
Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101

"We read Knuth so you don't have to." (Tim Peters)

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



Uploading files

2007-09-14 Thread AniNair

Hello,
 I am using Django 0.97 pre in winxp. database is mysql. Please
forgive any errors or if I am not clear with some aspects as I am a
beginner trying to learn django. I am trying to upload a file: an
image. I am not worried about validation now. I want to know how to do
this.
I tried to do this But my data base shows only the name of the file
uploaded (I think it should store the path to the file).
  In my view I have

def save_data(request):

ed_user=getfrmdb(uid)
new_data=request.POST.copy()   #this accounts for uploading the
image too with other data.
print new_data
addata=User(id=uid,name=ed_user.name, email=new_data['u_email'],
 
address=new_data['u_add'],phone=new_data['u_ph'],date=datetime.date.today(),
comments=new_data['u_comm'], image=  __)
addata.save()

I saw some codes (with new_data.update(request.FILES) )but I have a
hard time in understanding it completely.
   I would also like to know important tips to retrieve this uploaded
image. Thanking you ..


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



Managers and indirection

2007-09-14 Thread Scott Kilpatrick

Been thinking about how I could do this for a while now to no avail,
so maybe one of you can help me out.  I have a m2m with intermediate
model like so:

class Venue(models.Model):
...

class Artist(models.Model):
...

class Event(models.Model):
venue = models.PrimaryKey(Venue)
...

class Performance(models.Model):
event = models.PrimaryKey(Event)
artist = models.PrimaryKey(Artist)
...

I would like the functionality to get a queryset of Venues from a
Performance manager.  For instance, so I can do something like:

>>> beatles.performance_set.get_venues().exclude(name='Crappy Venue')

Anyone have any suggestions?
Scott


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