Re: Categorize and List if Item Exists

2008-04-23 Thread andy baxter

andy baxter wrote:
> you want a tag that would let you write an include file like:
>
> {% for category in categorybranch %}
>   
sorry that should be {% for category in categorybranch.sub_cats %}
> (print category name here)
> {% include "self.html" with categorybranch=category %}
> {% for product in categorybranch.products %}
> (print product name here)
> {% endfor %}
> {% endfor %}
>   


--~--~-~--~~~---~--~~
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: Categorize and List if Item Exists

2008-04-22 Thread andy baxter

Michael Ellis wrote:
> Hello all,
>
> I have the following models:
>
> class Category(models.Model):
>   name = models.CharField(core=True, max_length=100)
>   parent = models.ForeignKey('self', blank=True, null=True,
> related_name='child')
>
> class Product(models.Model):
>   name = models.CharField('name', max_length=200)
>   category = models.ForeignKey(Category, blank=False, null=False)
>
> Some products belong to top-level categories and some belong to sub-
> categories. Some categories have no sub-categories.
>
> I want to create a list of all categories, sub-categories, and their
> related products ONLY IF a product exists in that category. If a
> category exists but there are no products in it, I don't want to list
> it. Something like this:
>
> Cat 1
>   Subcat 1
>   prod 1
>   prod 2
>   Subcat 2
>   prod 3
> Cat 2
>   prod 4
>   prod 5
>
> Any suggestions would be greatly appreciated.
>
>   
I've been thinking a bit about this. I thought I would leave it for it a 
bit to see if anyone else replied, as I'm no expert and pretty new to 
all this, but the way I was thinking about it is:

* one question is whether to try to do it all in a single database 
query, or to construct the table in memory using a series of queries, 
and create some kind of tree like data structure to represent the 
results, then pass this to the template.

I think the first would be quite difficult, though might somehow be 
possible in raw SQL, so you'll probably have to do the second.

* then the question is whether to start with the products and work 'up' 
to the top level category, or start with the top level category and work 
'down' to the products. The first way works best with standard ways of 
doing recursion, but would mean writing code to eliminate empty 
categories, whereas if you started with the products, you would 
automatically return only the results you want.

Having decided how to do this, you've then got the problem of:

* how to write a template that can render a tree data structure. I'm not 
sure that this is possible without writing a custom tag. One way of 
doing it would be to rewrite or subclass the 'include' tag to allow 
extra parameters to be passed into the include which would only be valid 
inside that specific include. I.e. if you had a data structure which 
used 'Cat' classes like this:

class Cat:
name="category name"
sub_cats=[...list of sub categories...]
products=[...list of products...]

you want a tag that would let you write an include file like:

{% for category in categorybranch %}
(print category name here)
{% include "self.html" with categorybranch=category %}
{% for product in categorybranch.products %}
(print product name here)
{% endfor %}
{% endfor %}

Then you could have a template which recursively included itself, and 
passed a parameter to say which branch of the tree to render next. But 
I'm not sure how this would work with django's way of rendering templates.

Just my thoughts,

andy.

--~--~-~--~~~---~--~~
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: A modeling/implementation quiz

2008-04-19 Thread andy baxter

Juanjo Conti wrote:
> Hi all,
>
> I am worried about how to model the next scene (this is an example, but 
> an appropriated one): In the model we have People, and there are 
> different kind of people, let's say: Professors, Students and Other. 
> Each People object has a 'type' attribute. Type can be P, S or O.
>
> So far, all right.
>
> Each people has an identifier that looks like: {LETTER}{NUMBER}. P1, P2, 
> P3 and S1 are examples of valid identifiers.
>
> When you instance a People object you know its type but not its number:
>
> p = People(type="S")
>
> The question is, how can I handle this numbers in my model? The count 
> should be dependent of the type.
>
> I am thinking about creating PostgreSQL sequences and use them to 
> retrieve the propitiated number each time a People is instanced:
>
> ...
> if type == "S":
>   self.number = seq_wrapper_s.next()
> elif typ == "P":
>   self.number = seq_wrapper_p.next()
> else:
>   self.number = seq_wrapper_o.next()
> ...
>
> But this will tie me to an specific data base engine. Is there a way of 
> doing this task in Django in a independent-db-engine way?
>
>   
Is there a strong reason why the count should depend on the type? Can't 
you have a more standard model with two fields - 'id' (which would be a 
normal auto-increment primary key field) and 'type' (which could be 'P', 
'S', or 'O', or else you could model it as a SmallIntegerField, with a 
set of valid choices)?

e.g.

PERSON_TYPE_CHOICES=((1,'Professor'),(2,'Student'),(3,'Other'))

class Person(models.Model)
# (no need to put in the id field explicitly as it will be generated 
by django.)
type=models.SmallIntegerField(choices=PERSON_TYPE_CHOICES)
... any other person fields.




--~--~-~--~~~---~--~~
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: users and profiles - model structure question

2008-04-18 Thread andy baxter

andy baxter wrote:
> Alex Koshelev wrote:
>   
>> I usually make link to User model not profile. And have no problems
>> with usage.
>>
>>   
>> 
> I just tried switching to this way of doing it, and have come up against 
> a problem with getting the profile data into the template. If I create a 
> list of all users in the view, then pass the list of users to the 
> template as user_list, I would like to be able to iterate over the list 
> using '{% for user in user_list %}', and then retrieve the data from the 
> profile inside the template. I tried doing {{ 
> user.get_profile.self_description }}, which is meant to retrieve the 
> self_description field from the Member object associated with the given 
> User. But this raises a template error: 'Too many values to unpack'
>
> Is it possible to refer to profile data in the template like this, or do 
> I need to find another way to do it?
>
>   
Sorry, forget that - I just had AUTH_PROFILE_MODULE set wrong. Now it's 
working OK.

andy.

--~--~-~--~~~---~--~~
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: users and profiles - model structure question

2008-04-18 Thread andy baxter

Alex Koshelev wrote:
> I usually make link to User model not profile. And have no problems
> with usage.
>
>   
I just tried switching to this way of doing it, and have come up against 
a problem with getting the profile data into the template. If I create a 
list of all users in the view, then pass the list of users to the 
template as user_list, I would like to be able to iterate over the list 
using '{% for user in user_list %}', and then retrieve the data from the 
profile inside the template. I tried doing {{ 
user.get_profile.self_description }}, which is meant to retrieve the 
self_description field from the Member object associated with the given 
User. But this raises a template error: 'Too many values to unpack'

Is it possible to refer to profile data in the template like this, or do 
I need to find another way to do it?

andy

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



users and profiles - model structure question

2008-04-18 Thread andy baxter

Hello,

I have built a data model for a virtual library, which contains the 
following classes (among others):

User - the built in user class from django.contrib.auth.
Member - a profile for each user, containing extra information about 
each member.
Item - a book, video, or music album
Iteminstance - a specific copy of an item.

I am thinking about what is the best way to structure this data - in 
particular if ForeignKey fields from other tables (like iteminstance) 
should refer to the Member table or the User table. At the moment I have 
it like this:

Member.user -> User
ItemInstance.owner -> Member
ItemInstance.item -> Item

But I'm not sure about the second of these - should it be 
ItemInstance.owner->User?

I'm getting the feeling as I'm starting to write the code dealing with 
Members and Users that making the right choice here could be important, 
so as not to have to end up writing unnecessarily tangled code as the 
model develops in the future (e.g. if I add 'Review' which refers to an 
Item and is made by a Member/User).

Has anyone dealt with this problem in practice, and do people have any 
thoughts about what is the best way of doing things here, from the point 
of view of keeping the code simple, and also minimising the time spent 
doing database lookups? (I'm guessing that looking up a User from a 
Member is slightly quicker than looking up a Member from a User).

andy

--~--~-~--~~~---~--~~
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: Protecting static files

2008-04-17 Thread andy baxter

Nate wrote:
> Hi all,
> I've been googling for days and haven't really found a good solution
> to my problem.
>
> I am building a site where a user can view photos and then choose
> which of the photos they want to purchase. (Weddings/parties/HS
> graduation etc...) My client doesn't want other users of the site to
> be able to access another user's event photos.
> So far the only way I can think to truly secure photos from another
> user is to serve the image up through Django, but the website says
> it's inefficient and insecure. Honestly, the inefficiency, I can
> probably deal with as this site will be for a local photographer who
> probably won't be getting millions of hits per day, but the insecurity
> is what I'm worried about.
>
> I read django's way of protecting static files, but that only limits
> it to a group of people and not an individual.
>
> Can anyone help me?
>
> Thanks!
>
>   
pure-ftpd might be worth looking at. It is an FTP server that lets you 
authenticate requests against a mysql database, and also write simple 
custom authentication backends.

http://www.pureftpd.org/project/pure-ftpd

One way to use it is when someone logs into the site, give them 
time-limited access from the IP address they are using, which is renewed 
every time they view a new page, say for five minutes. This isn't 
perfect security, but would prevent casual attempts to view someone 
else's pictures.

I was going to say that another way would be to embed ftp username / 
password info in the img tags of the pages django serves. I.e. instead of:

http://static.mysite.com/path/img1.jpg;>

you would have:

ftp://user1:[EMAIL PROTECTED]/path/img1.jpg">

However, microsoft have added a 'feature' to IE7 which prevents it from 
opening URLs of this sort, in order (they say) to prevent the risk of 
spoofing attacks like links with the form: 
http://[EMAIL PROTECTED]

see:
http://support.microsoft.com/kb/834489

andy.

--~--~-~--~~~---~--~~
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: python manage.py runserver

2008-04-16 Thread andy baxter

[EMAIL PROTECTED] wrote:
> when i run the command above it shows this message , what is the
> problem i have successful installed django and i want step to run the
> server and
> $ python manage.py runserver
> Validating models...
> Unhandled exception in thread started by  0xb7a7995c>
> Traceback (most recent call last):
>   File "/usr/lib/python2.5/site-packages/django/core/management/
> commands/runserver.py", line 47, in inner_run
> self.validate(display_num_errors=True)
>   File "/usr/lib/python2.5/site-packages/django/core/management/
> base.py", line 110, in validate
> num_errors = get_validation_errors(s, app)
>   File "/usr/lib/python2.5/site-packages/django/core/management/
> validation.py", line 28, in get_validation_errors
> for (app_name, error) in get_app_errors().items():
>   File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
> line 126, in get_app_errors
> self._populate()
>   File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
> line 55, in _populate
> self.load_app(app_name, True)
>   File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
> line 70, in load_app
> mod = __import__(app_name, {}, {}, ['models'])
>   File "/home/development/models.py", line 41
> department = models.CharField("Department Name", maxlength=50,
> primary_key=True)
>   
One problem here is that maxlength is now deprecated, and should be 
written max_length. But I don't think this would cause the error you've 
reported, so maybe it's something else as well.

--~--~-~--~~~---~--~~
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: Search Frameworks

2008-04-15 Thread andy baxter

brydon wrote:
> I'm curious what people are currently using for search frameworks on
> django based projects. I've done a fair bit of research here and
> elsewhere and I still haven't landed on a clear decision. What are
> people successfully using with django to get robust search
> capabilities a la lucene etc? Are pylucene, xapian working?
>
>   
I've written a fairly decent search function for my app just using Q 
objects and the icontains test (I'm thinking of updating it to use the 
new iregexp test, so as to search only whole words). I guess this 
wouldn't be so good if you're building a big site, but it works pretty 
well on mine. It takes a space separated string of keywords (which can 
include quoted phrases), and returns the items where each of the 
keywords is in at least one of the given fields.

The code I've written so far is pasted below. It isn't very tidy at the 
moment, but does work, and people are welcome to copy and adapt it if 
they like. I'm thinking at some point to generalise what I've written 
into a custom filter class which takes a list of fields and a string as 
an argument, and then post the code on the wiki, if people think that's 
worth doing?

import re
from django import newforms as forms
from django.http import Http404, HttpResponseRedirect
from django.shortcuts import render_to_response
from library.horace.models import Item, ItemInstance, Tag
from django.db.models import Q

class SimpleSearchForm(forms.Form):
string = forms.CharField(label='Text to search for',max_length=100)
fields = forms.ChoiceField([(1,'Author, Title or 
Description'),(2,'Title or Description'),(3,'Title'),(4,'Author')], 
label='Where to search')
type = forms.ChoiceField([(1,'Any 
item'),(2,'Books'),(3,'Magazines'),(4,'Films'),(5,'Music')], label='What 
kind of item to search')

def simple_search(request):
"""Displays a simple search form and processes it.
Each word or phrase (marked by double quotes) has to be in at least 
one of the fields indicated"""
if request.method == 'POST':
form = SimpleSearchForm(request.POST)
if form.is_valid():
item_list=Item.objects.all()
string=request.POST.get('string','')
fields=request.POST.get('fields',1)
type=request.POST.get('type',1)
# first split the input string into seperate words or phrases.
# I.e. the string '"mandrake linux" compiler c' becomes:
#('mandrake linux','compiler','c')
# begin by taking out the double-quoted phrases.
reqt=re.compile(r'["\'](.*?)["\']')
phrases=reqt.findall(string)
#print "phrases: %s" % phrases
string=reqt.sub('',string) # remove the phrases
#print "string: %s" % string
rewd=re.compile(r'(\w+)( |$)')
resp=re.compile(r' ') # TODO - work out why there's an extra 
space at the end of words in the first place.
for pair in rewd.finditer(string):
wd=resp.sub('',pair.group())
#print "wd: -%s-" % wd
phrases.append(wd)
#print "phrases: %s" % phrases
# now phrases contains a list of terms to search for.
# next thing is to find which items contain all of the terms 
in at least one of the given fields.
# for each term, make a Q object which selects if it is in 
at least one of the given fields...
qand=None # TODO -find out if there is a null Q object you 
can start with without having to check if it's None later.
for phrase in phrases:
qor=None # a 'Q object' which can be combined with other 
Q objects to represent a complex query. see django documentation.
if (fields=='1') or (fields=='2') or (fields=='3'):
qor=Q(title__icontains=phrase)
if fields=='1' or fields=='4':
if qor==None:
qor=Q(creator__icontains=phrase)
else:
qor=qor | Q(creator__icontains=phrase)
if fields=='1' or fields=='2':
qor=qor | Q(description__icontains=phrase)
# now qor must contain something, so 'and' it with the 
rest if there are any yet
if qand != None:
qand=qand & qor
else:
qand=qor
if qand != None:
item_list=item_list.filter(qand)
# now process the 'type' field.
mapping={'2': 1, '3': 2, '4': 3, '5': 4}
if type in mapping.keys():
item_list=item_list.filter(item_type=mapping[type])
#print "item_list: %s" % item_list
#print "item_list._filters %s" % item_list._filters
length=item_list.count()
return render_to_response('simple-search.html',{'item_list': 
item_list,
#'search_string': "containing '%s'" 

Re: Application Concepts

2008-04-15 Thread andy baxter

James Bennett wrote:
> On Fri, Apr 11, 2008 at 1:09 PM, andy baxter
> <[EMAIL PROTECTED]> wrote:
>   
>>  What /should/ be inside the project folder?
>> 
>
> I often get severely flamed for saying this, but:
>
> I very rarely have a "project folder". All it is is a place to stick a
> settings file and a root URLConf module, both of which are just plain
> old Python files which can live anywhere you can import from. So most
> of the time I don't bother creating a folder just to do that; I only
> do so when I have groups of configuration files that I want to
> organize.
>   
Is there any strong reason why you /shouldn't/ do it the way in the 
tutorial - e.g. security? Or is this just your preference?

--~--~-~--~~~---~--~~
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: can i join your group

2008-04-13 Thread andy baxter

a.f wrote:
> am intersting in web desgining & puplishing
> e books & soft wear
> seo & ather stuff
>   
If you can read this, you're already subscribed to the group.

--~--~-~--~~~---~--~~
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: Images and Stylesheets

2008-04-12 Thread andy baxter

Greg Lindstrom wrote:
> Hello Everyone-
>
> I started learning Django at PyCon in Chicago and have worked most of 
> the way through the "Django Book" and Sams "Teach Yourself Django", as 
> well as "Head First HTML with CSS and XHTML".  It's been quite a lot 
> for this old dog, but I'd like to take a crack a writing my own web 
> site using Django.  I have two problems, and I think they are 
> related.  The first is how to get images in my site and the next is 
> how to use css.
>
> I wrote Jacob about images and he was kind enough to point me to 
> documentation on how to get the web server to "serve" the images.  I 
> hate to put it this bluntly, but I don't know what that means (I've 
> been programming database applications for 20 years and all this web 
> stuff is still pretty new to me).  Is there something that explains to 
> someone like me how to get images into the site?  Though I'm running 
> Django on my Ubuntu laptop, I would like to eventually have it 
> hosted.  I would like to know how to "do" images locally, then what I 
> need to do when I host my site.
>
> The other problem is getting css to work with my site.  I have set up 
> a base.html template (I love the templates, thank-you) and extend it 
> with other templates, call one greg.html.  The html generates just as 
> I expect it to (overriding blocks just as it should), but it doesn't 
> "see" the style sheet.  One it gets "in" the template I'm OK; the 
> "Head First" book did a pretty good job explaining it.  I even put a 
> syntax error in my view  so Django would list out the settings, but 
> couldn't find where Django is looking for the css file.  I suspect it 
> is a similar problem to the images, but I just don't know.
The basic point here is that while django is good for generating dynamic 
pages which are created in code from a database, it's not so good (quick 
/ reliable / secure) for just serving static pages that don't change. So 
the preferred solution is to have django do the bit it's good at, and 
use a standard webserver to do the static pages (including images and 
css). There is a django module for serving static content, but the docs 
say this should only be used during development, not in your final site.

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



Re: Django on plesk - Virtual Host

2008-04-11 Thread andy baxter

Tim wrote:
> I've got a couple Django apps running on Plesk. It's not the greatest
> but it works.
>
> First, after you set up your subdomain, you'll need to create the
> file:
> /var/www/vhosts/ domain.fr/subdomains/django/conf/vhost.conf
>
> Here's the contents of mine:
> --
> DocumentRoot /var/www/django_projects/myproject
>
> 
> SetHandler python-program
> PythonHandler django.core.handlers.modpython
> SetEnv DJANGO_SETTINGS_MODULE myproject.settings
> PythonPath "['/var/www/django_projects'] + sys.path"
> PythonDebug On
> 
>
> 
>   Options +Indexes
>   SetHandler none
> 
> --
>   
It's a bit of a more general question really, but does this sort of set 
up work OK, where you send '/' to django but have a sub-path of that 
served straight from the disk? I need to do something like this to serve 
my media files when I take my project live, but I was worried it would 
mean at some point having to create a separate IP address and virtual 
host to run a server on, rather than just serving everything from the 
same path.

--~--~-~--~~~---~--~~
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: Application Concepts

2008-04-11 Thread andy baxter

James Bennett wrote:
> On Tue, Apr 8, 2008 at 1:38 AM, jurian <[EMAIL PROTECTED]> wrote:
>   
>>  Are django applications meant to be implemented in such a manner as to
>>  allow the entire application directory to be copied into another
>>  project and used without having to alter any of the code?
>> 
>
> Though I often get flamed for saying this:
>
> Django applications should be implemented as Python modules that live
> standalone directly on the import path. If you have an application
> directly inside a project folder and it's not the poll app from the
> tutorial, something is wrong.
>   
What /should/ be inside the project folder?

--~--~-~--~~~---~--~~
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: unknown encoding: utf-8 error

2008-04-11 Thread andy baxter

Cephire wrote:
> Thanks Karen. It helped. But I got another error.
>
> AttributeError: 'module' object has no attribute 'admin'. Searching
> through the net, I found that __init.py__ should be present in the
> directory. It does have __init.py__.
>
> Should all directories (like media, templates) have __init.py__?
>
> As I said before, this works fine in development (using the django
> server) and production server too(apache+mod_python).
>
> Thank you,
> Joseph
>   
I think the rule is that every directory including and above the one you 
are referring to up to the point where the directory tree is added to 
the python path should have a __init.py__

As far as I know this doesn't apply to templates, just to .py modules - 
it's a python language thing not a django thing.

--~--~-~--~~~---~--~~
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: middleware that works with Ajax

2008-04-10 Thread andy baxter

Jarek Zgoda wrote:
> Chris Hoeppner napisaƂ(a):
>
>   
>> This is new to me. Dojo will be the official js toolkit for django?
>> Above jQuery? How come?
>> 
>
> No. It was stated many times: Django would not have any "official js
> toolkit" and will not "be bound to" or "embrace" any single toolkit. You
> are free to use the toolkit of your choice.
>   
OK, sorry. it was something I read a few months ago and must have 
misunderstood.

--~--~-~--~~~---~--~~
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: middleware that works with Ajax

2008-04-08 Thread andy baxter

Claudio Escudero wrote:
> Hi,
>
> Someone knows there is any middleware that works with Ajax, similar to 
> RJS of Ruby on Rails?
>
Do you mean middleware specifically written for django? If so not sure, 
but it might be worth looking at dojo (http://www.dojotoolkit.org/). It 
is a javascript toolkit which provides an API to make cross platform 
programming easier, and also supports ajax and a variety of widgets. I 
think it will be the official javascript toolkit of django at some point 
as well.

--~--~-~--~~~---~--~~
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: Whats wrong

2008-04-08 Thread andy baxter

Sarah Johns wrote:
> Hello, im a newbie so sorry to bother anyone, but i have problems with
> my site, i cant see the videos that i attached. whats wrong? Thanks
> for the help, the site adress is this: http://www.videoriporter.hu
>   
To be honest I thought your message was cleverly targetted spam, but 
after the first reply I decided to have a look. I agree it looks really 
good, but it's impossibly slow on my machine (an athlon 1400 with 384M 
ram). Have you considered showing a few less of the scrolling photos at 
one time, just so people with slower machines can use your site. I could 
barely get mozilla to scroll because the processor was so overloaded.

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



django security

2008-04-03 Thread andy baxter

hello,

Is there any documentation online about security issues when using 
django? I'm assuming when writing code for my django app that I don't 
have to worry about things like quoting strings sent to the database 
because the django db api will already do that, but other things I'm not 
so sure about, such as whether to check strings that will go into html 
for unwanted tags.

How much of this kind of stuff is done automatically and how much do you 
have to think about yourself? It would be nice to have a summary of 
security issues in the documentation somewhere.

andy

--~--~-~--~~~---~--~~
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: Best practice for databases and distributed development with Django

2008-04-03 Thread andy baxter

andy baxter wrote:
>
> Not sure if it's quite an answer to your question, but I've been dealing 
> with a similar problem which is how to keep the test data I've added to 
> the system between (mostly minor) changes to the database. The approach 
> I've taken is as follows:
>
> - before making any changes use 'mysqldump -c -n -t databasename -p > 
> dumpfile.sql' to dump the data only from the database, with column names 
> included.
> - then clear the database using ./manage.py sqlclear
> - then change the model in models.py
> - then recreate the database structure using ./manage.py syncdb
> - then re-import the data using 'mysql -p -f databasename < 
> dumpfile.sql' (try first without -f to check for errors).
>
> This seems to work pretty well for minor changes - e.g. making a field 
> allow nulls, or adding a new non-relational field.
>
> andy.
>
>   
Since writing the above, I've realised manage.py has a dumpdata command, 
which would probably be better for doing this.

--~--~-~--~~~---~--~~
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: Best practice for databases and distributed development with Django

2008-04-03 Thread andy baxter

Julien wrote:
> Hi,
>
> We're using SVN between several developers to work on the same project
> and it's working quite well. But it's not as simple concerning the
> database.
>
> Each of us has a local database to muck around with, and if one of us
> makes a change in the models that implies modifying the database
> manually (e.g. renaming a field, changing the type or the field, etc.)
> that developer has to inform all others of the changes so they all
> make the change manually on their own local database.
>
> Having a common database would avoid that, but that's not ideal since
> an online database would be slower to access, and it could quickly go
> out of control if many people add records or change the database
> structure at the same time.
>
> So, I just wanted to get some advice from you as to what is the best
> approach to go?
>   
Not sure if it's quite an answer to your question, but I've been dealing 
with a similar problem which is how to keep the test data I've added to 
the system between (mostly minor) changes to the database. The approach 
I've taken is as follows:

- before making any changes use 'mysqldump -c -n -t databasename -p > 
dumpfile.sql' to dump the data only from the database, with column names 
included.
- then clear the database using ./manage.py sqlclear
- then change the model in models.py
- then recreate the database structure using ./manage.py syncdb
- then re-import the data using 'mysql -p -f databasename < 
dumpfile.sql' (try first without -f to check for errors).

This seems to work pretty well for minor changes - e.g. making a field 
allow nulls, or adding a new non-relational field.

andy.

--~--~-~--~~~---~--~~
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: compiling files when installing to a web server

2008-03-29 Thread andy baxter

Michael Wieher wrote:
> I had an intermittent error when using just apache/mod_python, but 
> haven't had it happen since i started w/django
>
It looks like the speed issue is to do with memory - with just apache2, 
mysqld and django running, it was 72M into swap. So I guess I need to 
get a faster machine. It's not too much of a problem at the moment 
though because this machine is just for running a demo - I'm not 
planning to use it for the live site.

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



Re: compiling files when installing to a web server

2008-03-29 Thread andy baxter

andy baxter wrote:
> andy baxter wrote:
>   
>> hello,
>>
>> I have just installed a demo of an app I'm writing to a web server. 
>> There seems to be an intermittent error, and I'm wondering if this is to 
>> do with the permissions on the directories - I've tried to set the 
>> permissions so it can create .pyc files, but this doesn't seem to be 
>> working. What is the right way to set this up? for example is there a 
>> python command you can run to force all the modules in a given path to 
>> compile?
>>
>> andy baxter.
>>
>> -
>> 
> I just found out how to do this:
>
> http://docs.python.org/lib/module-compileall.html
>
> andy.
>   
Incidentally, I am running the demo on an old pentium II with 32M of 
memory, and it's a bit slow - 3-4 seconds page load times. Is this to be 
expected, or am I doing something wrong? What would people say are the 
recommended specs for a machine running a django app (assuming fairly 
light load where what matters is the response times for single requests, 
not having to deal with many concurrent requests)?

andy.

--~--~-~--~~~---~--~~
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: compiling files when installing to a web server

2008-03-29 Thread andy baxter

andy baxter wrote:
> hello,
>
> I have just installed a demo of an app I'm writing to a web server. 
> There seems to be an intermittent error, and I'm wondering if this is to 
> do with the permissions on the directories - I've tried to set the 
> permissions so it can create .pyc files, but this doesn't seem to be 
> working. What is the right way to set this up? for example is there a 
> python command you can run to force all the modules in a given path to 
> compile?
>
> andy baxter.
>
> -
I just found out how to do this:

http://docs.python.org/lib/module-compileall.html

andy.

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



compiling files when installing to a web server

2008-03-29 Thread andy baxter

hello,

I have just installed a demo of an app I'm writing to a web server. 
There seems to be an intermittent error, and I'm wondering if this is to 
do with the permissions on the directories - I've tried to set the 
permissions so it can create .pyc files, but this doesn't seem to be 
working. What is the right way to set this up? for example is there a 
python command you can run to force all the modules in a given path to 
compile?

andy baxter.

--~--~-~--~~~---~--~~
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: Do I need two classes that are identical because I want to use two database tables?

2008-03-28 Thread andy baxter

Peter Rowell wrote:
>> So should I just create two classes that are identical but name one
>> CurrentElectionResults and the other PastElectionResults?
>> 
Can't you just have a single class 'ElectionResults' and add a field 
called 'current'?

I'm planning on doing something similar with my app.

andy.

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



not receiving email from the list

2008-03-28 Thread andy baxter

hello,

I have subscribed successfully to the group, and can read it online,
but I'm not receiving emails sent from the group, even though I have
asked to when subscribing. Is this a known issue? Can any of you do
anything about it or should I contact google?

thanks,

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



ImportError: No module named urls

2008-03-25 Thread andy baxter

hello,

I am just starting out with django (and python). I have already worked
through the tutorial successfully; now I am going through it again
adapting the examples to suit the web app I want to build (a local
book sharing scheme). What I have done so far is to define the models,
create the database and tables, and add the admin app to
INSTALLED_APPS. I have uncommmented the line in urls.py so that it now
looks like this:

from django.conf.urls.defaults import *

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

# Uncomment this for admin:
 (r'^admin/', include('django.contrib.admin.urls')),
)

when I start the test server with 'python manage.py runserver', and
try to look at the admin page at:
http://127.0.0.1:8000/admin/
it comes up with a page saying:

ImportError at /admin/
No module named urls
Request Method: GET
Request URL:http://127.0.0.1:8000/admin/
Exception Type: ImportError
Exception Value:No module named urls
Exception Location: /var/lib/python-support/python2.5/django/core/
urlresolvers.py in _get_urlconf_module, line 161

I have checked that the django tutorial app still works, so the
problem seems to be with what I've done rather than the django
installation.

any help appreciated. thanks,

andy baxter.
--~--~-~--~~~---~--~~
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: dynamically assigning a field value

2008-01-08 Thread andy baxter

pinco wrote:
> Hi,
>
> I'm trying to figure out how to solve the following issue without
> succeed.
>
> I have a model like this:
>
> class Product(models.Model):
>...
>measure_cm = models.FloatField(...)
>measure_in = models.FloatField(...)
>   ...
>
> The fields contain the same information (a relevant dimension of a
> product) expressed in centimeter and in inches respectively.
>
>   
Why have two separate fields? Why not have one field - e.g. 'measure_mm' 
and convert to either inches or centimetres according to the user's choice?
> I would able, in the view and in the template, to do something like
> this:
>
> ...
> this_product = Product.objects.get(pk=product_id)
> this_product_measure = this_product.measure
>
> and dynamically assigning to this_product_measure the value of
> this_product.measure_cm or this_product.measure_in based on a variable
> stored in the session, representing a user preference.
>
> Actually I manage this with an "if request.session['user_preference']"
> statement, but it would be nice to catch the right value on every view
> without repeating the if statement.
>
> How can I do this?
>
> Thank you in advance
>
>
>
> >
>
>   


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



Re: static on separate what?

2007-12-09 Thread andy baxter

James Bennett wrote:
> On Dec 8, 2007 10:57 PM, Carl Karsten <[EMAIL PROTECTED]> wrote:
>   
>> I this text, does "separate Web server" contingent on a 2nd box?  If it is 
>> only
>> one box, the same Apache instance would be preferred, right?
>> 
>
> No, and no.
>
> You don't have to have separate physical machines, but the recommended
> setup is to have separate instances of whatever HTTP daemon you
> prefer. The reason for this is that it's a gross waste of resources in
> many cases to have a server process loaded up to serve requests
> through Django, and then use that process for nothing more than
> reading a file off disk and sending it down the wire -- you're tying
> up a valuable and limited resource when you do this. Running a
> separate instance of the HTTP daemon whose sole job is serving files
> off disk (and possibly a different HTTP daemon, as not all such
> daemons are created alike or optimized for the same use patterns)
> frees up that valuable resource to do nothing but serve requests
> through Django.
>   
Does this mean running the django server on a different port to the 
static files, or is there a way to do it through virtual hosts?

--~--~-~--~~~---~--~~
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: Problem with the django tutorial

2007-12-05 Thread andy baxter

I thought I had - in fact I'm pretty sure I remember doing it, but when 
I looked it wasn't there, so thanks for this. It's now working OK.

andy

ChaosKCW wrote:
> Hi
>
> It works for me,
>
> Did you add your application to the settings.py as per a previous
> step ?
>
> On Dec 5, 3:36 pm, andy baxter <[EMAIL PROTECTED]>
> wrote:
>   
>> Hello,
>>
>> I've been working my way through the django tutorial. I'm really
>> impressed with what django can do, but I've hit a problem - I'm now on
>> the part of part 2 of the tutorial where it says to add the following
>> lines to your mysite/polls/models.py:
>>
>> class Poll(models.Model):
>> # ...
>> class Admin:
>> pass
>>
>> This is supposed to bring the Poll class into the admin interface, but
>> on my system it isn't working - nothing changes on the admin page, even
>> when I refresh the page or restart the server.
>>
>> Can anyone help with this?
>>
>> andy baxter.
>> 
> >
>
>   


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



Problem with the django tutorial

2007-12-05 Thread andy baxter

Hello,

I've been working my way through the django tutorial. I'm really 
impressed with what django can do, but I've hit a problem - I'm now on 
the part of part 2 of the tutorial where it says to add the following 
lines to your mysite/polls/models.py:

class Poll(models.Model):
# ...
class Admin:
pass


This is supposed to bring the Poll class into the admin interface, but 
on my system it isn't working - nothing changes on the admin page, even 
when I refresh the page or restart the server.

Can anyone help with this?

andy baxter.


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