RE: CSS and JS minification

2010-09-20 Thread Henrik Genssen
Hi,

use the minimizer from yahoo (yuicompressor) for js and css (yes, written in 
java).
But it does its job pretty well - and you won't reinvent the wheel...

regards

Henrik

>reply to message:
>date: 21.09.2010 07:53:33
>from: "Shamail Tayyab" 
>to: django-users@googlegroups.com
>subject: CSS and JS minification
>
>Hi,
>
>   I've a working setup of a Django site at production. Now I want to minify
>CSS and JS (in-place).
>
>To deploy I've a git's post-receive hook, that can call a script to do this.
>I've seen a minification tool, but thats in Java. Any python/django specific
>minification program? Does the framework has something for this?
>
>If simple enough, it can be coded as well?
>What all tasks are done in minification?
>
>* Remove comments
>* Remove white spaces
>* what else?
>
>Also, i've learnt that the CSS could be gzipped/zipped and transferred then?
>How can I configure that in apache?
>
>
>Thanks and regards
>
>-- 
>Shamail Tayyab
>Blog: http://shamail.in/blog
>
>-- 
>You received this message because you are subscribed to the Google Groups 
>"Django users" group.
>To post to this group, send email to django-us...@googlegroups.com.
>To unsubscribe from this group, send email to 
>django-users+unsubscr...@googlegroups.com.
>For more options, visit this group at 
>http://groups.google.com/group/django-users?hl=en.
>

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



CSS and JS minification

2010-09-20 Thread Shamail Tayyab
Hi,

   I've a working setup of a Django site at production. Now I want to minify
CSS and JS (in-place).

To deploy I've a git's post-receive hook, that can call a script to do this.
I've seen a minification tool, but thats in Java. Any python/django specific
minification program? Does the framework has something for this?

If simple enough, it can be coded as well?
What all tasks are done in minification?

* Remove comments
* Remove white spaces
* what else?

Also, i've learnt that the CSS could be gzipped/zipped and transferred then?
How can I configure that in apache?


Thanks and regards

-- 
Shamail Tayyab
Blog: http://shamail.in/blog

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



REST XML + HTML API suggestions

2010-09-20 Thread Brendon
Hi all,

I want to use DJango to implement an XML based RESTful API and a
website together using DJango. I am wondering if anyone here is aware
of any tutorials on ways of achieving this in DJango without
duplicating too much code?


Basically what I want to achieve is to use the same core logic for
both the website and the API and just have different presentation
layers for the two systems. I have not seen any tutorials or the like
on doing this sort of thing and was wondering if people here have
suggestions on best approaches or tutorials that might show good ways
to structure this.

The idea is that all interaction using the API uses XML. The POST data
sent to the server and responses from the server are all using an XML
schema that we have designed for our application. All interaction with
the website is the same but uses normal web forms etc for the
interface of the presentation layer.

Example API:
* GET   : https://mywebsite/api/rooms/ : List available rooms, returns
XML with a list of Room ID's
* POST : https://mywebsite/api/room/  : Create a new room, raw POST
data is XML with the parameters required to create a room, on success
returns a Room ID
* GET   : https://mywebsite/api/room// : Retrieves details
about an existing room
* POST : https://mywebsite/api/room// : Modifies details for
an existing room
* DELETE : https://mywebsite/api/room// : Delete a room

Now, on the website side of things I want to do exactly the same but
as part of a a nice HTML site (with menus for navigation, nice graphs
to display relevant data etc).

Example Web:
* GET   : https://mywebsite/web/rooms/ : Displays a page with a list
of links to available Rooms.
* GET   : https://mywebsite/web/room/   : Displays a page with a form
requesting input of all necessary data to create a new room.
* POST : https://mywebsite/web/room/   : Create a new room. POST data
comes from form displayed previously (on error redisplays form). On
success redirects the user to the details page for that room.
* GET   : https://mywebsite/web/room// : Displays details
about an existing room and provides it in a form that can be used to
change the data with a POST
* POST : https://mywebsite/web/room// : Modifies details for
an existing room
* DELETE : https://mywebsite/web/room// : Delete a room


Thanks,
Brendon.

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



Testing with a non-model database

2010-09-20 Thread andrew cooke

Hi,

I am using multiple databases.  My main database is working fine in
tests, but the database used by the standard Python OpenID library is
causing problems because it is not defined via a Django model.  The
OpenID library provides a way to generate the database at the command
line, but I cannot see how to either:
(1) Use an existing database in tests or
(2) Generate a fixture from the database that can be loaded in tests

I feel like I must be missing something really obvious, but there
doesn't seem to be a way to say to Django "use the database given by
TEST_NAME, but don't create it, just access it".  Nor does there seem
to be a way to generate fixtures from databases that are not
associated with Django models.

Any guidance would be appreciated - thanks!
Andrew

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



Re: multiple servers one database

2010-09-20 Thread Steve Holden
On 9/20/2010 11:11 AM, Tim Arnold wrote:
> hi, I have two machines for a Django-powered site and they are  setup
> to be duplicates to provide redundancy. Each one runs its own apache
> instance and accesses the same Django apps on a shared disk.
> 
> The problem I have is that I need a single database. The users should
> not need to know which machine they're actually connecting to. As I
> understand it, I can't do that with MySQL. I can make one a master and
> one a slave, but that's not duplication of machines. I tried making a
> symlink from /usr/local/mysql/var to a shared disk location for both
> MySQL servers, but that is a Bad Idea (from what I read this weekend).
> 
> So finally, my question is how to solve the problem and maybe whether
> SQLite would be a better database since AIUI, it is simply file-based.
> 
If the two web servers are sharing a disk they are presumably fairly
local to each other. Why not just a single database server with each
Django server connecting to it over a LAN? You may need to think more
deeply abut transaction isolation. Just an idea ...

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Subclassing User class or User class "profiles" recommended for extra attributes?

2010-09-20 Thread Chris Seberino
Adding extra attributes to User classes seems to be handled originally
by a "profiles".

A new way seems to be to subclass the User class.

One problem with the shiny new way is that lots of code is written to
handle User classes instead of subclasses.  The suggested way to fix
this is nontrivial.  You must write low level code to return a
subclass every time a User class is asked for.

Do most people still use profiles or is there an easier to to manage
sublassing User classes now?

Thanks!

cs

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



Re: process memory swelling during uploads

2010-09-20 Thread felix

I'm testing now with 6 WAV files (70M) all uploading at the same time
and its not causing any problems.  The process is up to 76M from its
usual 70M.

But this afternoon it gained about 1M a second up to 200M +

My next suspect is Mutagen, though I've looked through the code and it
appears to correctly only load the first 32768

Or MP3Info

Maybe a specific broken file caused it to trust the headers and read
it in

Still, any advice on nginx/apache cooperation greatly appreciated

On Sep 20, 10:10 pm, felix  wrote:
> I'm running Nginx front end proxying to Apache with mod_wsgi in Daemon
> mode.
>
> When uploading files the apache/django process is occasionally
> swelling up as though it were loading the whole file into memory.
>

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



process memory swelling during uploads

2010-09-20 Thread felix
I'm running Nginx front end proxying to Apache with mod_wsgi in Daemon
mode.

When uploading files the apache/django process is occasionally
swelling up as though it were loading the whole file into memory.

I've even removed the MemoryFileUploadHandler from the file upload
handlers just to be sure something didnt' go wrong there (that would
be very unlikely)

It might well be related to something the client is doing.

By client I am referring to the guy whose website it is, not the
browser thingy.
He says he isn't, but he might be uploading too much at the same time,
opening multiple browser windows.

I'm doing tests and not seeing it swell up like that, or at least it
wavers by 3-4 meg and the memory goes back down.
but he is consistently taking the server down every single day.

One thing I've thought of is that maybe its an issue with Nginx
passing the request on.

TemporaryFileUploadHandler works with a cache size of 65536 and Nginx
buffers it at 128k (see below)

I've tried it with 64k Nginx client_body_buffer_size
and with 640k client_body_buffer_size

no noticeable difference.

does anybody know or have experience with these settings and django
uploads ?
would 640k mean that nginx writes to file before passing initiating a
request to apache/django ?

location / {
# all else pass on to apache
proxy_pass  http://127.0.0.1:8085;

proxy_redirect  off;
proxy_set_headerHost $host;
proxy_set_headerX-Real-IP $remote_addr;
proxy_set_headerX-Forwarded-For
$proxy_add_x_forwarded_for;
client_max_body_size500m;
client_body_buffer_size 128k;
proxy_connect_timeout   90;
proxy_send_timeout  90;
proxy_read_timeout  90;
proxy_buffer_size   4k;
proxy_buffers   4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size  64k;
}

http://wiki.nginx.org/NginxHttpProxyModule

[With longer and larger files it usually ends with a 504 timeout
returned to the browser,
though the file did finish uploading ok.  changed proxy_read_timeout
to 900 and that fixed it]

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



Re: Automatically creating fields

2010-09-20 Thread pixelcowboy
I get what you are saying, you are right in that it might make more
sense to do it for every field that needs it. Thanks.


On Sep 20, 11:22 am, Shawn Milochik  wrote:
> There are always ways. You could subclass models.Model and add the behavior, 
> if you read enough to understand how Django's models work.
>
> However, since you're only going create a model once (except migrations 
> later), is it really going to save that much work?
>
> If you want to do it a quick & dirty way, you could write a Perl one-liner 
> (or a Python script) to read your models.py and automatically output the file 
> with additional lines after each models.*Field line.
>
> Shawn

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



Javascript error on multiple choice widgets

2010-09-20 Thread wchildsuk
Hi,

I'm trying to implement the same type of widget the admin interface
has for many-to-many fields where you select the field and it moves
across to the chosen list but on a non-admin page.

I've tried implementing two quite different solutions this afternoon
[1] but both have failed to work fully with the same javascript error
on page load...

node.tagName is undefined
[Break on this error] if (node.tagName.toLowerCase() != 'form') {
   * SelectFilter2.js (line 11)

Then when I try to select a field I get this error (assuming this is a
symptom of the above);

SelectBox.cache[id] is undefined
[Break on this error] for (var i = 0; (node = SelectBox.cache[id][i]);
i++) {
   * SelectBox.js (line 58)

Django: 1.1
Template Code: http://dpaste.com/246432/
Form Code: http://dpaste.com/246435/
Other Info: I'm not getting an 404s on page load.

I was wondering if anyone can point me in the right direction to
resolve the issue.

Many thanks in advance

Wes

[1] 
http://www.hoboes.com/Mimsy/hacks/replicating-djangos-admin/reusing-djangos-filter_horizontal/
[2] http://code.google.com/p/django-ajax-filtered-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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Emergency: Critical form error on medium-volume site

2010-09-20 Thread intrepidweb
Thank you so much, Xavier. I think that's it. A while ago I checked my
template tags for thread safety, but somehow I missed one of them that
deals with form formatting. I will let you know if the problems
reappears.

All the best,
Leif


On Sep 20, 10:09 am, Xavier Ordoquy  wrote:
> Hi,
>
> Are you sure you don't get a thread safety issue ?
> Do you have your own template tags for those forms ?
>
> Regards,
> Xavier.
>
> Le 20 sept. 2010 à 18:42, intrepidweb a écrit :
>
>
>
> > Hi all,
>
> > Last week I ported a site that gets 50k+ pageviews/day from a PHP/
> > mySQL stack to Django/Postgresql. It has gone mostly smoothly, all
> > things considered. However, I have encountered a VERY troubling bug
> > involving the forms module, and I can't figure it out.
>
> > The form in question allows users to edit their profile. We have
> > several types of users, and each user type has a core set of fields,
> > as well as a few unique ones. Rather than write each profile edit form
> > from scratch, they inherit from parent classes.
>
> > The profile edit form accepts a User instance in its __init__ method,
> > and uses that object to populate the initial data, and also to save
> > the cleaned data to the appropriate User and UserProfile instances.
>
> > The problem is in about 20% of the time, the form, when displayed on a
> > page, is displaying OTHER users' information as the initial data. I
> > have determined that this is not a page caching issue. Additionally, I
> > confirmed that the correct user object is being passed to the form
> > class. So the form instance itself is switching the user object. My
> > guess is that somehow the user object is being assigned as a class
> > attribute, not an instance attribute. But otherwise I am stumped.
>
> > Here are snippets of the code. I know the inheritance scheme seems a
> > bit convoluted, but it was written this way in the name of DRY. Any
> > help would be greatly appreciated.
>
> > Leif
>
> > #
>
> > class PostalCodeForm (forms.Form):
> >    country = forms.ChoiceField(choices=[(c.country_code,c.en_name) for c
> > in Country.objects.all()],required=True, label='Country')
> >    postal_code = forms.CharField(required=True, label="ZIP/postal code")
>
> >    def clean_country (self):
> >            ...
>
> >    def clean_postal_code (self):
> >            ...
> > 
>
> > class UserProfileEditFormBase (forms.Form):
> >    first_name = custom_fields.NoProfanitiesCharField(max_length=150,
> > help_text = 'Your real first name. We will keep it private.')
> >    last_name = custom_fields.NoProfanitiesCharField(max_length=150,
> > required=False, help_text = 'Your real last name. We will keep it
> > private.')
> >    display_name = custom_fields.NoProfanitiesCharField(max_length=40,
> > help_text="Your public screenname. Will be shown on reviews that you
> > write, comments, etc.", label="Display name")
> >    email = custom_fields.EmailField()
> >    gender = forms.models.ModelChoiceField(queryset=Gender.objects.all(),
> > empty_label=None)
>
> >    def __init__ (self, user, *args, **kwargs):
> >            kwargs.setdefault('initial',{})
> >            kwargs['initial'] = self.get_initial(user,kwargs['initial'])
> >            super(UserProfileEditFormBase,self).__init__(*args, **kwargs)
> >            self.user = user
>
> >    def get_initial (self, user, initial={}):
> >            for k in self.base_fields.keys():
> >                    if k=='country':
> >                            initial[k] = getattr(profile,k).country_code
> >                    elif k=='postal_code' and getattr(profile,k,None):
> >                            initial[k] = getattr(profile,k).postal_code
> >                    elif getattr(user,k,None):
> >                            initial[k] = getattr(user,k)
> >                    elif getattr(profile, k, None):
> >                            a = getattr(profile, k)
> >                            if hasattr(a,'id'):
> >                                    initial[k] = a.id
> >                            else:
> >                                    initial[k] = a
> >            return initial
>
> >    def save (self):
> >            # uses self.user to save the cleaned_data
> >            ...
>
> > ##
>
> > class UserProfileEditForm (UserProfileEditFormBase, PostalCodeForm):
>
> >    about_you = forms.CharField(help_text="Description of yourself that
> > will appear with reviews and comments that you write.",
> > widget=forms.widgets.Textarea, required=False )
>
> >    def get_initial (self, user, initial={}):
>
> >            initial = super(UserProfileEditForm,self).get_initial(user, 
> > initial)
> >            bios = user.reviewerbio_set.filter(is_primary=True)
> >            if bios:
> >                    initial['about_you'] = bios[0].text
>
> >            return initial
>
> >    def save (self, user):
> >            
>
> > ###
>
> > --
> > You received this message because you are subscribed 

Re: Automatically creating fields

2010-09-20 Thread Shawn Milochik
There are always ways. You could subclass models.Model and add the behavior, if 
you read enough to understand how Django's models work.

However, since you're only going create a model once (except migrations later), 
is it really going to save that much work?

If you want to do it a quick & dirty way, you could write a Perl one-liner (or 
a Python script) to read your models.py and automatically output the file with 
additional lines after each models.*Field line.

Shawn


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



Re: Proto-newbie needs Django for running an app, not for dev work

2010-09-20 Thread Tiger Technologies
Hi, I'm with Tiger Technologies (we saw this post -- a little late --
via a Google Alert).

We are a shared hosting company, and that's why "sudo" didn't work.

However, as Shawn mentioned, it is possible to use virtualenv to
install a private copy of Django and other Python modules (we do have
the necessary dependencies). To make sure, I just followed Shawn's
instructions to the letter on a test account, and it works.

That said, if you're going to be using Django for anything other than
experimentation, Clifford's point is probably valid, too -- it might
be easier to use a company that has Django preinstalled and considers
themselves experts on it in case you run into trouble. I wouldn't say
we're Django experts... and while we'll probably eventually offer it
preinstalled to all customers, we're waiting for the next Debian Linux
release to get a reasonably current version with updates managed by
the Debian security team. So we'd certainly understand someone
switching elsewhere based on needing better Django support (and we
don't have evil fixed-term no-refund contracts, so you don't lose
money by switching).

Anyway, just wanted to confirm that Django certainly *should be*
possible if you're feeling adventurous, Thomas, though perhaps
adventure isn't what you're looking for.

--
Robert L Mathews, Tiger Technologies, http://www.tigertech.net/

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



Re: RSS Questions

2010-09-20 Thread Joel Davis
Thanks for trying it. And it works for me now. I guess google had to
index it or something... I gave it 24 hours but I guess it needed more
time.

I thought the description had to be text. I'll try stuffing the html
into there and see if it works.

Thanks for your help!
Joel

On Sep 20, 8:17 am, Nuno Maltez  wrote:
> Hi,
>
> I didn't have any problems subscribing to your blog with google reader
> fromhttp://www.tapnik.com/
>
>
>
> > Secondly, I'd like to include the entire post in the RSS feed, not
> > just the description. Looking at other feeds, it looks like these are
> > stuffed into a "content:encoded" tag? Is that right? How to I get the
> > RSS feed to generate that?
>
> What's wrong with including the post's html in the description field?
>
> http://djangogigs.com/feeds/gigs/
>
> hth,
> Nuno
>
> On Fri, Sep 17, 2010 at 6:52 PM, Joel Davis  wrote:
> > Hello,
>
> > I am trying to set up a blog on my django-based website. I followed
> > the examples here:
>
> >http://docs.djangoproject.com/en/1.1/ref/contrib/syndication/
>
> > The docs are great, and it was pretty easy to set up. And it sort-of
> > works. But there are a couple of problems I can't figure out.
>
> > First: Autodiscovery in google reader (and others). When I put most
> > websites with a link rel="alternate" type="application/rss+xml" tag
> > into Google Reader, the reader can find the RSS feed and subscribe.
> > However, when I try this with my site, i get "This site doesn't have a
> > feed, google can auto-generate one for you.." As far as I can tell
> > I've followed everything that google suggests for autodiscovery, I
> > can't tell what's different about my setup vs. others.  I'm sure I'm
> > doing something basic and stupid but I can't spot it.
> > The website is athttp://www.tapnik.com/and the feed is
> >http://www.tapnik.com/feeds/blog
>
> > I did notice that this was all refactored in django 1.2, I'd rather
> > stick with 1.1 if I can, but if this might be a lot easier in 1.2 then
> > I'll consider that.
>
> > Thanks for any advice!
> > Joel
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.

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



Re: Emergency: Critical form error on medium-volume site

2010-09-20 Thread Xavier Ordoquy
Hi,

Are you sure you don't get a thread safety issue ?
Do you have your own template tags for those forms ?

Regards,
Xavier.

Le 20 sept. 2010 à 18:42, intrepidweb a écrit :

> Hi all,
> 
> Last week I ported a site that gets 50k+ pageviews/day from a PHP/
> mySQL stack to Django/Postgresql. It has gone mostly smoothly, all
> things considered. However, I have encountered a VERY troubling bug
> involving the forms module, and I can't figure it out.
> 
> The form in question allows users to edit their profile. We have
> several types of users, and each user type has a core set of fields,
> as well as a few unique ones. Rather than write each profile edit form
> from scratch, they inherit from parent classes.
> 
> The profile edit form accepts a User instance in its __init__ method,
> and uses that object to populate the initial data, and also to save
> the cleaned data to the appropriate User and UserProfile instances.
> 
> The problem is in about 20% of the time, the form, when displayed on a
> page, is displaying OTHER users' information as the initial data. I
> have determined that this is not a page caching issue. Additionally, I
> confirmed that the correct user object is being passed to the form
> class. So the form instance itself is switching the user object. My
> guess is that somehow the user object is being assigned as a class
> attribute, not an instance attribute. But otherwise I am stumped.
> 
> Here are snippets of the code. I know the inheritance scheme seems a
> bit convoluted, but it was written this way in the name of DRY. Any
> help would be greatly appreciated.
> 
> Leif
> 
> #
> 
> class PostalCodeForm (forms.Form):
>   country = forms.ChoiceField(choices=[(c.country_code,c.en_name) for c
> in Country.objects.all()],required=True, label='Country')
>   postal_code = forms.CharField(required=True, label="ZIP/postal code")
> 
>   def clean_country (self):
>   ...
> 
>   def clean_postal_code (self):
>   ...
> 
> 
> class UserProfileEditFormBase (forms.Form):
>   first_name = custom_fields.NoProfanitiesCharField(max_length=150,
> help_text = 'Your real first name. We will keep it private.')
>   last_name = custom_fields.NoProfanitiesCharField(max_length=150,
> required=False, help_text = 'Your real last name. We will keep it
> private.')
>   display_name = custom_fields.NoProfanitiesCharField(max_length=40,
> help_text="Your public screenname. Will be shown on reviews that you
> write, comments, etc.", label="Display name")
>   email = custom_fields.EmailField()
>   gender = forms.models.ModelChoiceField(queryset=Gender.objects.all(),
> empty_label=None)
> 
>   def __init__ (self, user, *args, **kwargs):
>   kwargs.setdefault('initial',{})
>   kwargs['initial'] = self.get_initial(user,kwargs['initial'])
>   super(UserProfileEditFormBase,self).__init__(*args, **kwargs)
>   self.user = user
> 
>   def get_initial (self, user, initial={}):
>   for k in self.base_fields.keys():
>   if k=='country':
>   initial[k] = getattr(profile,k).country_code
>   elif k=='postal_code' and getattr(profile,k,None):
>   initial[k] = getattr(profile,k).postal_code
>   elif getattr(user,k,None):
>   initial[k] = getattr(user,k)
>   elif getattr(profile, k, None):
>   a = getattr(profile, k)
>   if hasattr(a,'id'):
>   initial[k] = a.id
>   else:
>   initial[k] = a
>   return initial
> 
>   def save (self):
>   # uses self.user to save the cleaned_data
>   ...
> 
> ##
> 
> class UserProfileEditForm (UserProfileEditFormBase, PostalCodeForm):
> 
>   about_you = forms.CharField(help_text="Description of yourself that
> will appear with reviews and comments that you write.",
> widget=forms.widgets.Textarea, required=False )
> 
>   def get_initial (self, user, initial={}):
> 
>   initial = super(UserProfileEditForm,self).get_initial(user, 
> initial)
>   bios = user.reviewerbio_set.filter(is_primary=True)
>   if bios:
>   initial['about_you'] = bios[0].text
> 
>   return initial
> 
>   def save (self, user):
>   
> 
> ###
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

-- 
You r

Emergency: Critical form error on medium-volume site

2010-09-20 Thread intrepidweb
Hi all,

Last week I ported a site that gets 50k+ pageviews/day from a PHP/
mySQL stack to Django/Postgresql. It has gone mostly smoothly, all
things considered. However, I have encountered a VERY troubling bug
involving the forms module, and I can't figure it out.

The form in question allows users to edit their profile. We have
several types of users, and each user type has a core set of fields,
as well as a few unique ones. Rather than write each profile edit form
from scratch, they inherit from parent classes.

The profile edit form accepts a User instance in its __init__ method,
and uses that object to populate the initial data, and also to save
the cleaned data to the appropriate User and UserProfile instances.

The problem is in about 20% of the time, the form, when displayed on a
page, is displaying OTHER users' information as the initial data. I
have determined that this is not a page caching issue. Additionally, I
confirmed that the correct user object is being passed to the form
class. So the form instance itself is switching the user object. My
guess is that somehow the user object is being assigned as a class
attribute, not an instance attribute. But otherwise I am stumped.

Here are snippets of the code. I know the inheritance scheme seems a
bit convoluted, but it was written this way in the name of DRY. Any
help would be greatly appreciated.

Leif

#

class PostalCodeForm (forms.Form):
country = forms.ChoiceField(choices=[(c.country_code,c.en_name) for c
in Country.objects.all()],required=True, label='Country')
postal_code = forms.CharField(required=True, label="ZIP/postal code")

def clean_country (self):
...

def clean_postal_code (self):
...


class UserProfileEditFormBase (forms.Form):
first_name = custom_fields.NoProfanitiesCharField(max_length=150,
help_text = 'Your real first name. We will keep it private.')
last_name = custom_fields.NoProfanitiesCharField(max_length=150,
required=False, help_text = 'Your real last name. We will keep it
private.')
display_name = custom_fields.NoProfanitiesCharField(max_length=40,
help_text="Your public screenname. Will be shown on reviews that you
write, comments, etc.", label="Display name")
email = custom_fields.EmailField()
gender = forms.models.ModelChoiceField(queryset=Gender.objects.all(),
empty_label=None)

def __init__ (self, user, *args, **kwargs):
kwargs.setdefault('initial',{})
kwargs['initial'] = self.get_initial(user,kwargs['initial'])
super(UserProfileEditFormBase,self).__init__(*args, **kwargs)
self.user = user

def get_initial (self, user, initial={}):
for k in self.base_fields.keys():
if k=='country':
initial[k] = getattr(profile,k).country_code
elif k=='postal_code' and getattr(profile,k,None):
initial[k] = getattr(profile,k).postal_code
elif getattr(user,k,None):
initial[k] = getattr(user,k)
elif getattr(profile, k, None):
a = getattr(profile, k)
if hasattr(a,'id'):
initial[k] = a.id
else:
initial[k] = a
return initial

def save (self):
# uses self.user to save the cleaned_data
...

##

class UserProfileEditForm (UserProfileEditFormBase, PostalCodeForm):

about_you = forms.CharField(help_text="Description of yourself that
will appear with reviews and comments that you write.",
widget=forms.widgets.Textarea, required=False )

def get_initial (self, user, initial={}):

initial = super(UserProfileEditForm,self).get_initial(user, 
initial)
bios = user.reviewerbio_set.filter(is_primary=True)
if bios:
initial['about_you'] = bios[0].text

return initial

def save (self, user):


###


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



Automatically creating fields

2010-09-20 Thread pixelcowboy
Hi, for every field in a model that I have created, I want to create a
releated boolean field. Is there any way to do this automatically?

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



Re: IE9 and dev server errors

2010-09-20 Thread TheIvIaxx
The server will hang once this occurs.  Seems to only happen with ajax
requests though.  Also, when it occurs, if I go into Internet Options
> Connection > LAN settings and simply hit Ok, then it finishes the
request.  I dont change anything, just open the settings and hit ok.
No proxy stuff in there.

Chrome uses the same network stack as IE, i thought, so i'm not sure
what the deal is.

IE's even more painful to develop for :)

On Sep 18, 5:02 am, Ramiro Morales  wrote:
> On Fri, Sep 17, 2010 at 8:11 PM, TheIvIaxx  wrote:
> > Hello all, I just downloaded the IE9 beta to see if everything worked
> > as expected.  However when going to 127.0.0.1 with IE9 using the
> > django dev server, i get:
>
> > [Errno 10054] An existing connection was forcibly closed by the remote
> > host
>
> > Not sure what is going on.  Any ideas?
>
> Does this cause any functional problem at all? Or simply.
> is that error message printed to the console?
>
> --
> Ramiro Morales  | http://rmorales.net

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



Re: RSS Questions

2010-09-20 Thread Nuno Maltez
Hi,

I didn't have any problems subscribing to your blog with google reader
from http://www.tapnik.com/

>
> Secondly, I'd like to include the entire post in the RSS feed, not
> just the description. Looking at other feeds, it looks like these are
> stuffed into a "content:encoded" tag? Is that right? How to I get the
> RSS feed to generate that?

What's wrong with including the post's html in the description field?

http://djangogigs.com/feeds/gigs/

hth,
Nuno

On Fri, Sep 17, 2010 at 6:52 PM, Joel Davis  wrote:
> Hello,
>
> I am trying to set up a blog on my django-based website. I followed
> the examples here:
>
> http://docs.djangoproject.com/en/1.1/ref/contrib/syndication/
>
> The docs are great, and it was pretty easy to set up. And it sort-of
> works. But there are a couple of problems I can't figure out.
>
> First: Autodiscovery in google reader (and others). When I put most
> websites with a link rel="alternate" type="application/rss+xml" tag
> into Google Reader, the reader can find the RSS feed and subscribe.
> However, when I try this with my site, i get "This site doesn't have a
> feed, google can auto-generate one for you.." As far as I can tell
> I've followed everything that google suggests for autodiscovery, I
> can't tell what's different about my setup vs. others.  I'm sure I'm
> doing something basic and stupid but I can't spot it.

> The website is at http://www.tapnik.com/ and the feed is
> http://www.tapnik.com/feeds/blog
>
> I did notice that this was all refactored in django 1.2, I'd rather
> stick with 1.1 if I can, but if this might be a lot easier in 1.2 then
> I'll consider that.
>
> Thanks for any advice!
> Joel
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: IPAddressField inserted as empty string although null=True

2010-09-20 Thread rihad


On Sep 20, 8:02 pm, Bill Freeman  wrote:
> I believe that this is documented.

Yes, the docs do mention that string types like Char or Textarea
should be using '' instead of NULL as a no-value option. But there
really isn't such a value for Postgres' inet database type. Given that
under MySQL this code probably wouldn't throw any exceptions due to
the absence of a native "inet" field type and due to simply storing
the value as a varchar, I propose this as a bug: Django shouldn't be
disregarding null=true for IPAddressField when dealing with Postgres.

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



multiple servers one database

2010-09-20 Thread Tim Arnold
hi, I have two machines for a Django-powered site and they are  setup
to be duplicates to provide redundancy. Each one runs its own apache
instance and accesses the same Django apps on a shared disk.

The problem I have is that I need a single database. The users should
not need to know which machine they're actually connecting to. As I
understand it, I can't do that with MySQL. I can make one a master and
one a slave, but that's not duplication of machines. I tried making a
symlink from /usr/local/mysql/var to a shared disk location for both
MySQL servers, but that is a Bad Idea (from what I read this weekend).

So finally, my question is how to solve the problem and maybe whether
SQLite would be a better database since AIUI, it is simply file-based.

thanks,
--Tim Arnold

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



Re: IPAddressField inserted as empty string although null=True

2010-09-20 Thread Bill Freeman
I believe that this is documented.  I think that it's a limitation of
forms that character fields store an empty result as a null string.
All the null=True means is that the model field (not the model form
field) is willing to send the database a null, should it find None in
the instance attribute, and that the database column has been created
such that the database won't complain either.  If you really need a
null stored there, you will need to override form field validation or
model field db preparation.

Are you sure that you need this?

On Mon, Sep 20, 2010 at 10:36 AM, rihad  wrote:
> I have these fields in a model:
>        ipaddr1 = models.IPAddressField()
>        ipaddr2 = models.IPAddressField(blank=True, null=True)
>
> When I "wrap" this model in a ModelForm, fill the form, and call
> form.save(), empty ipaddr2 gets inserted as '', causing database
> errors for Postgres' inet type.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: list out of range error

2010-09-20 Thread Xavier Ordoquy

Hi,

You are catching a KeyError while it throws and IndexError ;)

Regards,
Xavier.

Le 20 sept. 2010 à 17:04, grimmus a écrit :

> Hi,
> 
> On the homepage of my website i list 1 random ad in the right column.
> In my view i retrieve it like so:
> 
> side_ad = SideAd.objects.filter(active=1).order_by("?")[0]
> 
> If all ad's are inactive no object's will be returned thus creating an
> IndexError : list out of range
> 
> I tried to wrap the above in a try/except block but it's still the
> same error:
> 
> try:
> side_ad = SideAd.objects.filter(active=1).order_by("?")[0]
> except (KeyError,SideAd.DoesNotExist):
> side_ad = None
> 
> I still pass side_ad back in the context.
> 
> Could someone tell me what I'm doing wrong ?
> 
> Thanks.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



list out of range error

2010-09-20 Thread grimmus
Hi,

On the homepage of my website i list 1 random ad in the right column.
In my view i retrieve it like so:

side_ad = SideAd.objects.filter(active=1).order_by("?")[0]

If all ad's are inactive no object's will be returned thus creating an
IndexError : list out of range

I tried to wrap the above in a try/except block but it's still the
same error:

try:
 side_ad = SideAd.objects.filter(active=1).order_by("?")[0]
except (KeyError,SideAd.DoesNotExist):
 side_ad = None

I still pass side_ad back in the context.

Could someone tell me what I'm doing wrong ?

Thanks.

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



django.db.utils.DatabaseError: value too long for type character varying(50)

2010-09-20 Thread Valentin Golev
Hello,

I'm trying to deploy my Django application with PostgreSQL. While
trying to insert an object to the database, I'm getting the following
error:


django.db.utils.DatabaseError: value too long for type character
varying(50)


My application were working fine on SQLite. I guess it has something
to do with encoding (my data in in Cyrillic). I thought Django should
truncate in on the application level, but it obviously doesn't. What
can I do (except for truncating data by myself every time)?

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



TypeError: instancemethod expected at least 2 arguments, got 0

2010-09-20 Thread svintus
Django 1.1.2 & Python 2.6.5

I keep getting this error when executing a seemingly innocent
queryset. Looks exactly like the issue described in
http://code.djangoproject.com/ticket/7204 However, I'm running Django
1.1.2, which is supposed to have the fix for this bug. Has anybody
dealt with something similar before? For backtrace and code that
triggers the error, please see my post here

http://stackoverflow.com/questions/3736112/typeerror-instancemethod-expected-at-least-2-arguments-got-0


Thanks,
Ivan

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



IPAddressField inserted as empty string although null=True

2010-09-20 Thread rihad
I have these fields in a model:
ipaddr1 = models.IPAddressField()
ipaddr2 = models.IPAddressField(blank=True, null=True)

When I "wrap" this model in a ModelForm, fill the form, and call
form.save(), empty ipaddr2 gets inserted as '', causing database
errors for Postgres' inet type.

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



serialize dictionary problem

2010-09-20 Thread ashy
Hi All,

I am having problem retrieving object in javascript.

django function:

def function
  cursor = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
  sql = "select * from .."
  dict = cursor.fetchall()
  return HttpResponse(simplejson.dumps(dict), mimetype='application/
json')

javacript code:
function getuserinfo()
{
$.getJSON("/path", function(data) {
alert(data['location']);
});
}

the object is getting serialized properly, but in javascript
alert(data['location']);
always returns "undefined". Any ideas?

thanks
ashy

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



Re: Possible to have dynamic drop down list in ModelForm?

2010-09-20 Thread Scott Gould
Two ways, both requiring javascript:

1. Populate the city dropdown via ajax on country change.
2. Have your template write javascript to do country->city lookups and
alter the contents of the city dropdown on country change.

On Sep 19, 2:42 am, Andy  wrote:
> I have a model FieldReport that has, among other fields, these two
> fields:
>
> -country
> -city
>
> Both "country" and "city" are lists of choices.
>
> I want to have a form FieldReportForm as a ModelfForm based on the
> model FieldReport. I want to have "country" and "city" represented as
> drop down lists. Moreover, "city" should be a dynamic list based on
> the selected value of "country".
>
> For example, if someone selects the value "US" for "country", then
> "city" should be a list of US cities only, all cities in other
> countries shouldn't be loaded onto that list.
>
> Is this something that would work with Django's ModelForm? How would
> you implement something like this?
>
> Thanks.

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



What's the best way to develop an app that is similar the django admin?

2010-09-20 Thread Federico Capoano
Hi all,

I try to explain it clearly.

I have to develop an application that will implement similar
functionality and look of the django admin, but in the frontend.

So this application will have files management, clients management,
and much more similar stuff, with add new, edit, delete, file upload
and so on.

Is there a way you would advice to do this?

Thanks a lot.
Federico

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



Re: overriding the admin's template sucks

2010-09-20 Thread Julian
thanks for that simple solution, but I'm very reluctant to do this,
because putting template-logic in python-files reminds me of my PHP-
days. nevertheless, it's a quick way to solve my problem.

another problem will be to remove the admin-action-checkbox, because
it's displayed even though I'm not displaying the admin-action-
selectboxes.

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



Re: overriding the admin's template sucks

2010-09-20 Thread Daniel Roseman
On Sep 20, 11:54 am, Julian  wrote:
> Hi,
>
> I want to display a customized table for a model in the admin. I've
> just written a customized filter, which works very well.
>
> The problem: My model has a field 'timestamp' which is a
> datetimefield. It may be null, so in the admin it's displayed as
> '(None)'. I want to replace '(None)' with 'All'. The problems:
>
> - In change_list.html the table is not generated. It's generated in
> change_list_results.html. Well, the first one may be put in myapp/
> templates/myapp/mymodel/ and overwrites the default one. The latter
> one not.
> - So I have to write a custom template tag, which uses 'admin/
> templatetags/admin_list/result_list', just to tell it which custom
> template to use.
> - Then I realize that the whole
>
> (None)
>
> is NOT generated in a template but anywhere deep down in some python
> code. It's not that there's a
>
> {% if not result.value %}
> (None)
> {% endif %}
>
> which I could replace with
>
> {% if not result.value %}
> All
> {% endif %}
>
> (or similar), but it seems I have to write my own customized
> items_for_result-function, which just replaces with the
> EMPTY_CHANGELIST_VALUE (it's '(None)') with 'All'.
>
> so now my final question: Isn't there an easy, not-hurting way to
> solve my problem?

Instead of specifying the field name in `list_display`, specify the
name of a custom method on your ModelAdmin subclass. Then define that
method to return the format you want:

list_display = ('name', 'my_custom_timestamp')

def my_custom_timestamp(self, obj):
if obj.timestamp is None:
return 'All'
else:
return obj.timestamp

--
DR.

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



overriding the admin's template sucks

2010-09-20 Thread Julian
Hi,

I want to display a customized table for a model in the admin. I've
just written a customized filter, which works very well.

The problem: My model has a field 'timestamp' which is a
datetimefield. It may be null, so in the admin it's displayed as
'(None)'. I want to replace '(None)' with 'All'. The problems:

- In change_list.html the table is not generated. It's generated in
change_list_results.html. Well, the first one may be put in myapp/
templates/myapp/mymodel/ and overwrites the default one. The latter
one not.
- So I have to write a custom template tag, which uses 'admin/
templatetags/admin_list/result_list', just to tell it which custom
template to use.
- Then I realize that the whole

(None)

is NOT generated in a template but anywhere deep down in some python
code. It's not that there's a

{% if not result.value %}
(None)
{% endif %}

which I could replace with

{% if not result.value %}
All
{% endif %}

(or similar), but it seems I have to write my own customized
items_for_result-function, which just replaces with the
EMPTY_CHANGELIST_VALUE (it's '(None)') with 'All'.

so now my final question: Isn't there an easy, not-hurting way to
solve my problem?

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



Re: Django Chat App?

2010-09-20 Thread Sithembewena Lloyd Dube
Thanks Rod. Been away from office for a bit, but this is a good find indeed.
Many thanks, once again.

On Thu, Sep 16, 2010 at 11:05 PM, Rod Hamby  wrote:

>  Linux opensource with many add ons. I have seen/done many things with this
> setup althought not with Django.
> Rod
>
> > This might not be any help since I know nothing of VOIP, but for the
> > chat portion take a look in to Ape ( a comet server written in C ).
> >
> > On Sep 16, 9:41 am, Sithembewena Lloyd Dube  wrote:
> >> Indeed it is, but the media server isn't :).
> >>
> >> On Thu, Sep 16, 2010 at 5:35 PM, esatterwh...@wi.rr.com <
> >>
> >>
> >>
> >> esatterwh...@wi.rr.com> wrote:
> >> > The Flex Framework is open source.
> >>
> >> > On Sep 16, 6:19 am, Sithembewena Lloyd Dube 
> wrote:
> >> > > Thanks Shamail! I should have mentioned that I actually need
> >> something
> >> > > open-source :)
> >>
> >> > > On Thu, Sep 16, 2010 at 12:16 PM, Shamail Tayyab
> >>  >> > >wrote:
> >>
> >> > > > On Thursday 16 September 2010 03:40 PM, Sithembewena Lloyd Dube
> >> wrote:
> >>
> >> > > >> Hi all,
> >>
> >> > > >> I will soon be working on a Django site that will incorporate a
> >> > heavily
> >> > > >> customised chat app. The client wants voip capability.
> >>
> >> > > >> I've had a look at the Twisted framework, but I need to know
> >> whether
> >> > or
> >> > > >> not there is anything else out there - perhaps tailored for use
> >> with
> >> > Django?
> >>
> >> > > >> --
> >> > > >> Regards,
> >> > > >> Sithembewena Lloyd Dube
> >> > > >>http://www.lloyddube.com
> >> > > >> --
> >> > > >> You received this message because you are subscribed to the
> >> Google
> >> > Groups
> >> > > >> "Django users" group.
> >> > > >> To post to this group, send email to
> >> django-us...@googlegroups.com.
> >> > > >> To unsubscribe from this group, send email to
> >> > > >> django-users+unsubscr...@googlegroups.com
> 
> >
> >> > 
> >> > > >> .
> >> > > >> For more options, visit this group at
> >> > > >>http://groups.google.com/group/django-users?hl=en.
> >>
> >> > > > If its VoIP, your best bet would be to use flash, accompanied
> >> along
> >> > with a
> >> > > > media server, your chat can also work.
> >> > > > Reason: You need live streaming.
> >> > > > Wowza media server/Adobe FMS is what you should consider once.
> >>
> >> > > > Regards
> >>
> >> > > > --
> >> > > > Shamail Tayyab
> >> > > > Blog:http://shamail.in/blog
> >>
> >> > > > --
> >> > > > You received this message because you are subscribed to the Google
> >> > Groups
> >> > > > "Django users" group.
> >> > > > To post to this group, send email to
> >> django-us...@googlegroups.com.
> >> > > > To unsubscribe from this group, send email to
> >> > > > django-users+unsubscr...@googlegroups.com
> 
> >
> >> > 
> >> > > > .
> >> > > > For more options, visit this group at
> >> > > >http://groups.google.com/group/django-users?hl=en.
> >>
> >> > > --
> >> > > Regards,
> >> > > Sithembewena Lloyd Dubehttp://www.lloyddube.com
> >>
> >> > --
> >> > You received this message because you are subscribed to the Google
> >> Groups
> >> > "Django users" group.
> >> > To post to this group, send email to django-us...@googlegroups.com.
> >> > To unsubscribe from this group, send email to
> >> > django-users+unsubscr...@googlegroups.com
> 
> >
> >> > .
> >> > For more options, visit this group at
> >> >http://groups.google.com/group/django-users?hl=en.
> >>
> >> --
> >> Regards,
> >> Sithembewena Lloyd Dubehttp://www.lloyddube.com
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com
> .
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
> >
> >
>
>
> Rod Hamby  Sales Analyst
> p:619 573 4231 X100
> c:619 922 8895
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

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



how should models be semi-related

2010-09-20 Thread Mike Dewhirst
I have an address model with a 'country' field and a phone model with a 
'country_code' field.


I would guess the right approach is to use choices for both fields so 
the user can always select or change country in an address AND 
country_code in a phone number.


However, I would like the selection of at least one to be automatic. If 
an address record exists when creating a phone record the relevant 
country_code should be inserted as a default.


Is there a way to sensibly do this with code in a model?

A related question - if django signals are a reasonable way to tackle 
this, might it be better to write database triggers?


Thanks

Mike

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



Re: {% url %} template and javascript Get with callback

2010-09-20 Thread bruno desthuilliers
On 19 sep, 18:52, Ben Kraft  wrote:
> I'm trying to do a javascript post to an internal api and use a
> callback to process the JSON result.  I'm referencing the api using,
>
> {% url %},
>
> which returns a path url relative to my domain ( /api/... instead 
> ofhttp://localhost/api/... for the dev site).
>
> The problem is js does not recognize that the relative / path url
> returned by {% url %} is on the same domain current page,

A "path only" url should work too - when the domain is not specified,
it is assumed to the the same as the current page's. Please check the
generated HTML source and make sure the urls for your js libs are
using the same domain OR no domain at 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Mutli-column composite keys

2010-09-20 Thread Danny Adair
On Mon, Sep 20, 2010 at 08:50, J. P. Smyth
 wrote:
>[...]
> Does anyone have a suggestion how I can achieve this unique primary
> key in Django without resorting to creating another column with the
> company name plus the product id?

Unfortunately
http://code.djangoproject.com/ticket/373#comment:24
is probably as close as you'll get

Cheers,
Danny

-- 
Kind regards,

Danny W. Adair
Director
Unfold Limited
New Zealand

Talk:       +64 - 9 - 9555 101
Fax:        +64 - 9 - 9555 111
Write:      danny.ad...@unfold.co.nz
Browse:     www.unfold.co.nz
Visit/Post: 253 Paihia Road, RD 2, Kawakawa 0282, New Zealand

"We are what we repeatedly do. Excellence, then, is not an act but a habit."

==
Caution
The contents of this email and any attachments contain information
which is CONFIDENTIAL to the recipient. If you are not the intended
recipient, you must not read, use, distribute, copy or retain this
email or its attachments. If you have received this email in error,
please notify us immediately by return email or collect telephone call
and delete this email.  Thank you.  We do not accept any
responsibility for any changes made to this email or any attachment
after transmission from us.
==

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