Re: Ignoring empty forms in a formset

2012-04-25 Thread Tom Evans
On Sun, Apr 22, 2012 at 5:44 PM, Martin Tiršel  wrote:
> Hello,
>
> I have a formset and some JavaScript to add more forms into this formset. In
> a view, I iterate through the formset saving (not a ModelForm just Form with
> save method) each form:
>
> for form in formset:
>     form.save()
>
> But I want to ignore empty forms that were added by JavasScript and not
> removed. How can I do this?
>
> Thanks,
> Martin
>

You don't show much of your code, but I presume you have called
formset.is_valid() at this point?

If so, this pattern is pretty canonical:

if formset.is_valid():
for form in formset:
if form.is_valid() and not form.empty_permitted:
form.save()

Extra forms in a formset are all instantiated with empty_permitted=True.

There are other things to be aware of though. This logic will not take
into account deleted forms etc, which is why there is a
BaseModelFormSet with the right behaviour baked into it's save()
method.

Cheers

Tom

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



Re: form doing a query for each element of foreign key in select

2012-04-25 Thread Tom Evans
On Wed, Apr 25, 2012 at 5:58 AM, Lee Hinde  wrote:
> I have a table with four or five foreign keys. Using the default form
> widgets, a foreign key is represented by a single value select.
>
> I noticed, with debug_tool_bar, that a query is being made for each
> element of each foreign key select option. Seems like it ought not
>
> I am using
>
>     classes = get_object_or_404(Classes, pk=pk)
>
> to load the record. I tried
> Classes.on_site.select_related().get(pk=pk) without any change.
>
> The question is, is this to be expected?
>

Yes. How else would it get the potential values that can be selected?

If you want to load all in one query, you can use select_related(). If
select_related() doesn't help, then your foreign keys are probably
nullable, which are not automatically loaded with select_related().

FYI, having each foreign key lookup as a separate query may not be a bad thing.
If the cardinality of the foreign keys doesn't change much (you don't
add frequently add potential new values for that foreign key), then it
is highly likely that those queries would be served from the query
cache.

If you are displaying 1 million different forms, but all their foreign
key lookups can be served from cache, do you think it would be quicker
to do 1 million queries with 5 joins in each query, with none of the
queries cached, or 5 million queries, 1 million with no joins and 4
million served from the query cache?

Cheers

Tom

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



buildout development vs. deployment

2012-04-25 Thread Reikje
Hi, I am looking into buildout to deploy a django webapp and all it's 
dependencies. I find it quite useful even during development because it 
forces you to keep track of your dependencies. A question regarding some 
best practices. Lets say I have buildout.cfg and setup.py in my project 
root and checked in into SCM. My webapp is listed under develop in 
buildout.cfg. While this is great, during deployment this is probably not 
what you want because you wanna lock the version of your source code. I 
want to do a git revision checkout to archive this. So i guess I need to 
maintain two different buildout.cfg files, one for development and one for 
deployment. How can this be organized to avoid DRY?

On a side note, what are the alternatives to buildout. Maybe there is 
something even better :)

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



Re: Where are the women?

2012-04-25 Thread Hanne Moa
On 24 April 2012 16:14, Daniele Procida  wrote:
> I was looking at  again with excited 
> anticipation, and reading through the talk summaries.
>
>  - and 
> then I had a closer look at the names of this year's speakers.
>
> There are *two* women out of the 24 or so speakers listed, and only one is 
> doing a solo talk.

More generally, I would have liked to go to EuroPythonCon both this
year and last year but from experience I don't deal with hot and humid
weather very well so it's out of the question.

More specifically, when the base percentage of programmers vs.
non-programmers being different in the two sexes (this is also depends
on class and culture) is multiplied with the base percentage of
open-source programmers vs. non-open source programmers you will end
up with four different groups generally in four different sizes (Bayes
theorem!). We know that male programmers outnumber female programmers.
If non-open-source programmers outnumber open source programmers then
the group "female open-source programmer" is likely to be the smallest
group.

You can then set up a new test with "female programmers" vs. "male
programmers" and "programmers that visit techie cons" vs. "programmers
not visiting techie cons". The group "female open-source programmer
that visit techie cons" will have fewer members than "female
open-source programmers".

You get the idea. It might be that running those numbers will explain
the low number of "female open-source programmer that visit techie
cons that also are of interest to you" all by itself, no conspiracy
required.

You get more women in by changing the weights in *any* of the tests:
more programmers, more female programmers, more open source
programmers, more programmers visiting techie cons etc. It adds up.

So: you have this wee group of potential "female open-source
programmer that visit techie cons that also are of interest to you".
Then, and only then can you start to look at con-specific or
language-specific tests that the community can directly do something
with: "bro"grammers, strip shows, excessive drinking and pressure to
drink (rumored to be a problem at Java Script venues), rock star
behavior (ruby?), specific idiots that should never have been left out
of the asylum and ruins it for everyone etc.

I haven't heard any rumors of stupid behavior among pythoneers or at
python cons though so it might just be that "female open-source
(python and django) programmer that visit techie cons that also are of
interest to you" is a very small group.


HM, member of "open source programmers that don't get a paid trip to
visit techie cons that often and can't function very well in hot
climates"

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



generic view 'create_object' inssue

2012-04-25 Thread Carlos Aboim
 

I fellows
I am getting a strange behavior from a simple generic view

The problem is that I can not pass the data in the form to introducing a 
new object in the database.
Then the urls.py file > http://dpaste.com/hold/732643/
The html form is this > http://dpaste.com/hold/732646/

when I submit the form the page redirects to somewhere but the data doesn't 
get into the database.

What am I doing wrong?
I thank you for your help!
hugs

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



Re: buildout development vs. deployment

2012-04-25 Thread Tom Evans
On Wed, Apr 25, 2012 at 11:21 AM, Reikje  wrote:
> Hi, I am looking into buildout to deploy a django webapp and all it's
> dependencies. I find it quite useful even during development because it
> forces you to keep track of your dependencies. A question regarding some
> best practices. Lets say I have buildout.cfg and setup.py in my project root
> and checked in into SCM. My webapp is listed under develop in buildout.cfg.
> While this is great, during deployment this is probably not what you want
> because you wanna lock the version of your source code. I want to do a git
> revision checkout to archive this. So i guess I need to maintain two
> different buildout.cfg files, one for development and one for deployment.
> How can this be organized to avoid DRY?
>
> On a side note, what are the alternatives to buildout. Maybe there is
> something even better :)
>

I have no experience of buildout, but I have spent a lot of time
working on SCM for my django sites, so I'll describe what I do.

Everything here is built around subversion, we don't use git. If you
haven't used subversion, 'svn:externals' check out another repository
in the specified location. It's a way of composing disparate bits of
versioned repositories.

The first thing to discuss is the project source code. This lives in
svn/projectname/trunk, with release branches in
svn/projectname/releases. Minor work happens on trunk, and is merged
to release branch(es). Major work happens on feature branches, which
is then merged to trunk and then to release branches.

Of course, project source code in itself is not enough to run a site.
The project must be deployed and configured for a specific host. We do
this with 'deployments'. Each deployment corresponds to an instance of
a project running on a specific server, and lives in
svn/projectname/deployments/servername, and consists of a skeleton
directory structure (derived from a base version), and lots of
'svn:externals' links.

So the deployment contains the structure of the project, and links to
check out the project code and other required files, like scripts for
starting/stopping the project, a bootstrap script for creating the
virtualenv environment, the settings files, etc, which are also all
stored in subversion.

The next stage is libraries. For this, we use virtualenv and pip. We
have a bootstrap script which creates the virtualenv if it is not
present, and a requirements.pip file, which lists the libraries and
specific versions to install.
All of our libraries are installed via pip, and we have a process
which checks out both our own libraries and patched vendor libraries
(eg, like django-debug-toolbar), builds packages from them, and pushes
them to our own pypi site¹. All our packages are then installed from
this pypi site.
The requirements.pip is another 'svn:externals' file, checked out from
svn/projectname/configurations/. All the production sites share one
requirements.pip.

The project has a default_settings.py file, and each deployment also
checks out a deployment specific settings.py, which imports from
default_settings.py and adds the host-specific settings for that site.

Every check-in on the project results in a buildbot updating a
buildbot specific deployment and running tests. There is a buildbot
for trunk and for each active release branch.

All schema migrations are taken care of by south.

Finally, all the production deployments are managed by a Fabric
fabfile. This contains programmatic instructions for doing various
tasks, eg update app servers to latest version, which:
  takes one set of backend servers out of the rotation
  stops DB replication from that deployment
  updates that deployment
  installs/uninstalls libraries as indicated in (updated) requirements.pip
  runs south sschema migrations
  marks that backend as the only active backend
  restarts DB replication
  updates all other servers.

If you're not using fabric, or some other automated rollout tool, to
manage your services, you should be!

For our 'bulletproof' sites, we have an exact replica of a production
stack in test. We never update the live site until we've updated this
test replica successfully.

Creating a new backend deployment is as simple as copying the stock
deployment, creating the site specific settings.py, checking it out on
a host and running the bootstrap script. In fact, it's slightly easier
than that, its 'fab new_prod_site hostname'.

Since everything is in subversion, we can easily re-constitute a site
as it was, or reproduce the exact same configuration in development as
we have in production. This aids debugging and increases confidence in
the system.

Cheers

Tom

Tools:

virtualenv: http://www.virtualenv.org/en/latest/index.html
pip: http://www.pip-installer.org/en/latest/index.html
south: http://south.aeracode.org/
fabric: http://fabfile.org/
buildbot: http://trac.buildbot.net/


¹ It's not as good as the real pypi site, its really just a big folder
served over http with all the packa

Re: Ignoring empty forms in a formset

2012-04-25 Thread Martin Tiršel
I am using class based views and my code is:

class PayOrdersView(AdminFormSetView):
form_class = PayOrderForm
template_name = 'internal/orders/pay_orders_form.html'
active_item = 'order_pay_orders'
context_formset_name = 'pay_orders_formset'
extra = 2

def formset_valid(self, formset):
logger.debug('Executing formset_valid')
for form in formset:
logger.debug('Is empty: %s' % form.empty_permitted)
form.save()
return super(PayOrdersView, self).formset_valid(formset)


formset_valid method is called after formset.is_valid(). I start with 2 
empty forms, I insert into first form order number and the second form 
stays empty. After I submit, I get:

[2012-04-25 13:42:07,776] DEBUG [31099 140249342375680] 
[project.internal.mixins:304] Processing POSTed form
[2012-04-25 13:42:07,778] DEBUG [31099 140249342375680] 
[project.internal.forms:29] Cleaning order_number
[2012-04-25 13:42:07,837] DEBUG [31099 140249342375680] 
[project.internal.mixins:307] Formset is valid
[2012-04-25 13:42:07,842] DEBUG [31099 140249342375680] 
[project.internal.views:93] Executing formset_valid
[2012-04-25 13:42:07,843] DEBUG [31099 140249342375680] 
[project.internal.views:95] Is empty: True
[2012-04-25 13:42:07,843] DEBUG [31099 140249342375680] 
[project.internal.forms:54] Saving PayOrderForm
[2012-04-25 13:42:09,914] DEBUG [31099 140249342375680] 
[project.internal.views:95] Is empty: True
[2012-04-25 13:42:09,914] DEBUG [31099 140249342375680] 
[project.internal.forms:54] Saving PayOrderForm

So both forms have empty_permitted == True. Management form in time of 
submit looks so:





Thanks, Martin

On Wednesday, April 25, 2012 11:03:49 AM UTC+2, Tom Evans wrote:
>
> On Sun, Apr 22, 2012 at 5:44 PM, Martin Tiršel  
> wrote:
> > Hello,
> >
> > I have a formset and some JavaScript to add more forms into this 
> formset. In
> > a view, I iterate through the formset saving (not a ModelForm just Form 
> with
> > save method) each form:
> >
> > for form in formset:
> > form.save()
> >
> > But I want to ignore empty forms that were added by JavasScript and not
> > removed. How can I do this?
> >
> > Thanks,
> > Martin
> >
>
> You don't show much of your code, but I presume you have called
> formset.is_valid() at this point?
>
> If so, this pattern is pretty canonical:
>
> if formset.is_valid():
> for form in formset:
> if form.is_valid() and not form.empty_permitted:
> form.save()
>
> Extra forms in a formset are all instantiated with empty_permitted=True.
>
> There are other things to be aware of though. This logic will not take
> into account deleted forms etc, which is why there is a
> BaseModelFormSet with the right behaviour baked into it's save()
> method.
>
> Cheers
>
> Tom
>

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



Soap web services with Soaplib in Django

2012-04-25 Thread Meenakshi Ithape
I used the Soap web services with Soaplib in Django, for that i take
the help from below link
http://djangosnippets.org/snippets/979/
When i run this code  through command prompt it runs properly, but
when i run it on browser it shows nothing,
Can anybody please help me, what should i done wrong?

Thanks for any suggestions

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



Re: Ignoring empty forms in a formset

2012-04-25 Thread Tom Evans
Hmm. Internally, model formsets do this differently - they are aware
of which forms are extra forms, and which forms are existing forms.

New forms will have form.empty_permitted=True, unmodified forms will
return True from form.has_changed(). This should be enough to skip
over blank new forms.

Cheers

Tom

On Wed, Apr 25, 2012 at 12:55 PM, Martin Tiršel  wrote:
> I am using class based views and my code is:
>
> class PayOrdersView(AdminFormSetView):
>     form_class = PayOrderForm
>     template_name = 'internal/orders/pay_orders_form.html'
>     active_item = 'order_pay_orders'
>     context_formset_name = 'pay_orders_formset'
>     extra = 2
>
>     def formset_valid(self, formset):
>         logger.debug('Executing formset_valid')
>         for form in formset:
>             logger.debug('Is empty: %s' % form.empty_permitted)
>             form.save()
>         return super(PayOrdersView, self).formset_valid(formset)
>
>
> formset_valid method is called after formset.is_valid(). I start with 2
> empty forms, I insert into first form order number and the second form stays
> empty. After I submit, I get:
>
> [2012-04-25 13:42:07,776] DEBUG [31099 140249342375680]
> [project.internal.mixins:304] Processing POSTed form
> [2012-04-25 13:42:07,778] DEBUG [31099 140249342375680]
> [project.internal.forms:29] Cleaning order_number
> [2012-04-25 13:42:07,837] DEBUG [31099 140249342375680]
> [project.internal.mixins:307] Formset is valid
> [2012-04-25 13:42:07,842] DEBUG [31099 140249342375680]
> [project.internal.views:93] Executing formset_valid
> [2012-04-25 13:42:07,843] DEBUG [31099 140249342375680]
> [project.internal.views:95] Is empty: True
> [2012-04-25 13:42:07,843] DEBUG [31099 140249342375680]
> [project.internal.forms:54] Saving PayOrderForm
> [2012-04-25 13:42:09,914] DEBUG [31099 140249342375680]
> [project.internal.views:95] Is empty: True
> [2012-04-25 13:42:09,914] DEBUG [31099 140249342375680]
> [project.internal.forms:54] Saving PayOrderForm
>
> So both forms have empty_permitted == True. Management form in time of
> submit looks so:
>
>  name="form-TOTAL_FORMS">
>  name="form-INITIAL_FORMS">
> 
>
> Thanks, Martin
>
> On Wednesday, April 25, 2012 11:03:49 AM UTC+2, Tom Evans wrote:
>>
>> On Sun, Apr 22, 2012 at 5:44 PM, Martin Tiršel 
>> wrote:
>> > Hello,
>> >
>> > I have a formset and some JavaScript to add more forms into this
>> > formset. In
>> > a view, I iterate through the formset saving (not a ModelForm just Form
>> > with
>> > save method) each form:
>> >
>> > for form in formset:
>> >     form.save()
>> >
>> > But I want to ignore empty forms that were added by JavasScript and not
>> > removed. How can I do this?
>> >
>> > Thanks,
>> > Martin
>> >
>>
>> You don't show much of your code, but I presume you have called
>> formset.is_valid() at this point?
>>
>> If so, this pattern is pretty canonical:
>>
>> if formset.is_valid():
>>     for form in formset:
>>         if form.is_valid() and not form.empty_permitted:
>>             form.save()
>>
>> Extra forms in a formset are all instantiated with empty_permitted=True.
>>
>> There are other things to be aware of though. This logic will not take
>> into account deleted forms etc, which is why there is a
>> BaseModelFormSet with the right behaviour baked into it's save()
>> method.
>>
>> Cheers
>>
>> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/aKliGdMNqGwJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Slow page in admin

2012-04-25 Thread Jonas Ghyllebert
I'm new to Django and I would like to apologize if it's been asked before.

I have two models *Region *and *Zip*. In the admin system, Zip is an inline 
model in Region

Whenever i want to add a Region it shows directly 25 listboxes with zips. 
This however takes a long time to load the page and results in an internal 
error.
There are 2,774 records in the zip table.
I suspect the cause of this error is that for each list, Django connects to 
the database to fetch those records.
Is there a way to solve this?

Thanks in advance

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



Re: Slow page in admin

2012-04-25 Thread akaariai
On Apr 25, 3:35 pm, Jonas Ghyllebert  wrote:
> I'm new to Django and I would like to apologize if it's been asked before.
>
> I have two models *Region *and *Zip*. In the admin system, Zip is an inline
> model in Region
>
> Whenever i want to add a Region it shows directly 25 listboxes with zips.
> This however takes a long time to load the page and results in an internal
> error.
> There are 2,774 records in the zip table.
> I suspect the cause of this error is that for each list, Django connects to
> the database to fetch those records.
> Is there a way to solve this?

Your question is a little hard to answer - it is always a good idea to
include the full error message, and preferably the model definitions
etc in your post. You leave all who try to help guessing what the
problem might be...

Without knowing more about the situation I suggest you check the
queries the page loading generates (using logging, django-debug-
toolbar or your database's query logging utilities). Then check if
there is a possibility to use select_related or prefetch_related to
ease the situation.

The internal error seems a little strange. Can you share more details
about that?

 - Anssi

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



Re: Slow page in admin

2012-04-25 Thread Jonas Ghyllebert
Hi,

Thanks for the quick reply.

when we test the application local, it works like a charm.
But when we deployed it on Google App engine using Cloud SQL, the 
application works now and then and this particular page is much slower than 
the others.
When there's an error, Django shows the 500 - internal server error.

These are my models:
*Zip*

class Zip(models.Model):

zip_code = models.IntegerField()

zip_name = models.CharField(max_length=75)

zip_lang = models.CharField(max_length=2)

province = models.ForeignKey(Province)



class Meta:

ordering = ["zip_name"]

verbose_name = "postcode"

verbose_name_plural = "postcodes"



def __unicode__(self):
return self.zip_name + ' (' + unicode(self.zip_code) +')'

*
*
*Region*

class Region(models.Model):

region_name = models.CharField(max_length=75)

office = models.ForeignKey(Office)

region_primary = models.BooleanField()

def __unicode__(self):

return self.region_name



class Meta:

verbose_name = "regio"

verbose_name_plural = "regio's"


There is an extra table which stores which zips are included in one Region:
*Zip_per_region*

class Zip_per_region(models.Model):

region = models.ForeignKey(Region)

zip = models.ForeignKey(Zip)



class Meta:

verbose_name = "postcode"

*
*

how can i use the select_related method?


On Wednesday, April 25, 2012 2:52:13 PM UTC+2, akaariai wrote:
>
> On Apr 25, 3:35 pm, Jonas Ghyllebert  wrote: 
> > I'm new to Django and I would like to apologize if it's been asked 
> before. 
> > 
> > I have two models *Region *and *Zip*. In the admin system, Zip is an 
> inline 
> > model in Region 
> > 
> > Whenever i want to add a Region it shows directly 25 listboxes with 
> zips. 
> > This however takes a long time to load the page and results in an 
> internal 
> > error. 
> > There are 2,774 records in the zip table. 
> > I suspect the cause of this error is that for each list, Django connects 
> to 
> > the database to fetch those records. 
> > Is there a way to solve this? 
>
> Your question is a little hard to answer - it is always a good idea to 
> include the full error message, and preferably the model definitions 
> etc in your post. You leave all who try to help guessing what the 
> problem might be... 
>
> Without knowing more about the situation I suggest you check the 
> queries the page loading generates (using logging, django-debug- 
> toolbar or your database's query logging utilities). Then check if 
> there is a possibility to use select_related or prefetch_related to 
> ease the situation. 
>
> The internal error seems a little strange. Can you share more details 
> about that? 
>
>  - Anssi

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



Re: buildout development vs. deployment

2012-04-25 Thread Reik Schatz
Hi Tom,

great answer, thanks. A lot of other sites mentioned Fabric. I'll
definitely check it out.

/Reik

On Wed, Apr 25, 2012 at 1:22 PM, Tom Evans  wrote:

> On Wed, Apr 25, 2012 at 11:21 AM, Reikje  wrote:
> > Hi, I am looking into buildout to deploy a django webapp and all it's
> > dependencies. I find it quite useful even during development because it
> > forces you to keep track of your dependencies. A question regarding some
> > best practices. Lets say I have buildout.cfg and setup.py in my project
> root
> > and checked in into SCM. My webapp is listed under develop in
> buildout.cfg.
> > While this is great, during deployment this is probably not what you want
> > because you wanna lock the version of your source code. I want to do a
> git
> > revision checkout to archive this. So i guess I need to maintain two
> > different buildout.cfg files, one for development and one for deployment.
> > How can this be organized to avoid DRY?
> >
> > On a side note, what are the alternatives to buildout. Maybe there is
> > something even better :)
> >
>
> I have no experience of buildout, but I have spent a lot of time
> working on SCM for my django sites, so I'll describe what I do.
>
> Everything here is built around subversion, we don't use git. If you
> haven't used subversion, 'svn:externals' check out another repository
> in the specified location. It's a way of composing disparate bits of
> versioned repositories.
>
> The first thing to discuss is the project source code. This lives in
> svn/projectname/trunk, with release branches in
> svn/projectname/releases. Minor work happens on trunk, and is merged
> to release branch(es). Major work happens on feature branches, which
> is then merged to trunk and then to release branches.
>
> Of course, project source code in itself is not enough to run a site.
> The project must be deployed and configured for a specific host. We do
> this with 'deployments'. Each deployment corresponds to an instance of
> a project running on a specific server, and lives in
> svn/projectname/deployments/servername, and consists of a skeleton
> directory structure (derived from a base version), and lots of
> 'svn:externals' links.
>
> So the deployment contains the structure of the project, and links to
> check out the project code and other required files, like scripts for
> starting/stopping the project, a bootstrap script for creating the
> virtualenv environment, the settings files, etc, which are also all
> stored in subversion.
>
> The next stage is libraries. For this, we use virtualenv and pip. We
> have a bootstrap script which creates the virtualenv if it is not
> present, and a requirements.pip file, which lists the libraries and
> specific versions to install.
> All of our libraries are installed via pip, and we have a process
> which checks out both our own libraries and patched vendor libraries
> (eg, like django-debug-toolbar), builds packages from them, and pushes
> them to our own pypi site¹. All our packages are then installed from
> this pypi site.
> The requirements.pip is another 'svn:externals' file, checked out from
> svn/projectname/configurations/. All the production sites share one
> requirements.pip.
>
> The project has a default_settings.py file, and each deployment also
> checks out a deployment specific settings.py, which imports from
> default_settings.py and adds the host-specific settings for that site.
>
> Every check-in on the project results in a buildbot updating a
> buildbot specific deployment and running tests. There is a buildbot
> for trunk and for each active release branch.
>
> All schema migrations are taken care of by south.
>
> Finally, all the production deployments are managed by a Fabric
> fabfile. This contains programmatic instructions for doing various
> tasks, eg update app servers to latest version, which:
>  takes one set of backend servers out of the rotation
>  stops DB replication from that deployment
>  updates that deployment
>  installs/uninstalls libraries as indicated in (updated) requirements.pip
>  runs south sschema migrations
>  marks that backend as the only active backend
>  restarts DB replication
>  updates all other servers.
>
> If you're not using fabric, or some other automated rollout tool, to
> manage your services, you should be!
>
> For our 'bulletproof' sites, we have an exact replica of a production
> stack in test. We never update the live site until we've updated this
> test replica successfully.
>
> Creating a new backend deployment is as simple as copying the stock
> deployment, creating the site specific settings.py, checking it out on
> a host and running the bootstrap script. In fact, it's slightly easier
> than that, its 'fab new_prod_site hostname'.
>
> Since everything is in subversion, we can easily re-constitute a site
> as it was, or reproduce the exact same configuration in development as
> we have in production. This aids debugging and increases confidence in
> the system.
>
> Chee

Canadian Django Meetings?

2012-04-25 Thread Daniel Sokolowski
Does anyone know of any upcoming Django meet ups in Canada? Has there
been any? Would you come?

I am living in Ontario, so Toronto being the venue would seem like a
logical choice.

Thoughts?

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



Django questions.

2012-04-25 Thread jacob
Hello everybody.

I am a newbie in django development and need your help for some
questions.

1. Under what circumstances would you avoid using the Django platform?
2. How do you describe the data layer in Django? Where would you place
additional functionality to the domain objects? And where would you
put behavior that is related to the entire table?
3. What would be the syntax to place a Python code block in a Django
template?
4. Choose one NoSQL product, describe what it is supposed to be used
for, and under which circumstances you would choose an RDBMS and not
this NoSQL.

If anybody answer for even a question on detail, I will appreciate it.

Looking forward to hearing soon.

Thanks & best regards

- Jacob

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



Re: Django questions.

2012-04-25 Thread Marcin Tustin
These are plainly your homework questions. I suggest that you undertake
your own research.

On Wed, Apr 25, 2012 at 15:20, jacob  wrote:

> Hello everybody.
>
> I am a newbie in django development and need your help for some
> questions.
>
> 1. Under what circumstances would you avoid using the Django platform?
> 2. How do you describe the data layer in Django? Where would you place
> additional functionality to the domain objects? And where would you
> put behavior that is related to the entire table?
> 3. What would be the syntax to place a Python code block in a Django
> template?
> 4. Choose one NoSQL product, describe what it is supposed to be used
> for, and under which circumstances you would choose an RDBMS and not
> this NoSQL.
>
> If anybody answer for even a question on detail, I will appreciate it.
>
> Looking forward to hearing soon.
>
> Thanks & best regards
>
> - Jacob
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Marcin Tustin
Tel: 07773 787 105

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



Re: Django questions.

2012-04-25 Thread Marcin Tustin
Apologies, these are job application questions:
https://www.odesk.com/jobs/Programmers-Python-Django-and-client-side-programming-MySQL_~~c7db577bb2246e77?tot=5000&pos=4&_redirected


On Wed, Apr 25, 2012 at 15:37, Marcin Tustin wrote:

> These are plainly your homework questions. I suggest that you undertake
> your own research.
>
>
> On Wed, Apr 25, 2012 at 15:20, jacob  wrote:
>
>> Hello everybody.
>>
>> I am a newbie in django development and need your help for some
>> questions.
>>
>> 1. Under what circumstances would you avoid using the Django platform?
>> 2. How do you describe the data layer in Django? Where would you place
>> additional functionality to the domain objects? And where would you
>> put behavior that is related to the entire table?
>> 3. What would be the syntax to place a Python code block in a Django
>> template?
>> 4. Choose one NoSQL product, describe what it is supposed to be used
>> for, and under which circumstances you would choose an RDBMS and not
>> this NoSQL.
>>
>> If anybody answer for even a question on detail, I will appreciate it.
>>
>> Looking forward to hearing soon.
>>
>> Thanks & best regards
>>
>> - Jacob
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>
>
> --
> Marcin Tustin
> Tel: 07773 787 105
>
>


-- 
Marcin Tustin
Tel: 07773 787 105

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



deploying django - including third party apps

2012-04-25 Thread luke lukes
hi everyone. i'm developing a simple CRUD django app and my idea is to host 
it on a free web hosting site that supports django (e.g. alwaysdata.com or 
heliohost.org). I havent tried locally to deploy it on a web server such as 
Apache, i've alway used the development server by manage.py runserver. Now 
i'm using third application on it: reportlab (for pdf generation), 
django-evolution (for models changes). well these apps are installed via 
apt-get (i'm using ubuntu as host system) or by getting the packages from 
their own sites and installing them by setup.py install. Now i've checked 
on alwaysdata.com and reportlab is installed, but seems there's no 
django_evolution. what i have to do to include it in my app and to get it 
working?

thanx
LuKe

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



Re: Django questions.

2012-04-25 Thread Shawn Milochik

On 04/25/2012 11:04 AM, Marcin Tustin wrote:
Apologies, these are job application questions: 
https://www.odesk.com/jobs/Programmers-Python-Django-and-client-side-programming-MySQL_~~c7db577bb2246e77?tot=5000&pos=4&_redirected 
 





Ha ha ha ha ha. This thread is awesome. Nice detective work, Marcin.

Hopefully the hiring company does a Google search on applicants and 
finds this. Ha!



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



Django CRUD questions

2012-04-25 Thread drewyan
Hi all,

I'm relatively new at designing web apps and I've been using Django to 
set-up a CRUD type application. I recently figured out how perform POST 
requests from the forms I set-up. I noticed that the data can be 
changed/updated through the Django admin site or through the Django API 
using SQL; I'm sure there's a way for non-admins who don't know SQL to 
retrieve and change/update the data they input through the web app, but 
it's not clear to me how to accomplish that (or even where to start 
looking). It looks like "
django.views.generic.create_update.create_object" might do the trick, but 
I'm not using generic views. Are there other options for retrieving form 
data and then updating it? If you'd like further information, I'd be happy 
to provide it.

Many thanks.

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



Re: Slow page in admin

2012-04-25 Thread akaariai
On Apr 25, 4:22 pm, Jonas Ghyllebert  wrote:
> Hi,
>
> Thanks for the quick reply.
>
> when we test the application local, it works like a charm.
> But when we deployed it on Google App engine using Cloud SQL, the
> application works now and then and this particular page is much slower than
> the others.
> When there's an error, Django shows the 500 - internal server error.
>
> These are my models:
> *Zip*
>
> class Zip(models.Model):
>
>     zip_code = models.IntegerField()
>
>     zip_name = models.CharField(max_length=75)
>
>     zip_lang = models.CharField(max_length=2)
>
>     province = models.ForeignKey(Province)
>
>     class Meta:
>
>         ordering = ["zip_name"]
>
>         verbose_name = "postcode"
>
>         verbose_name_plural = "postcodes"
>
>     def __unicode__(self):
>         return self.zip_name + ' (' + unicode(self.zip_code) +')'
>
> *
> *
> *Region*
>
> class Region(models.Model):
>
>     region_name = models.CharField(max_length=75)
>
>     office = models.ForeignKey(Office)
>
>     region_primary = models.BooleanField()
>
>     def __unicode__(self):
>
>         return self.region_name
>
>     class Meta:
>
>         verbose_name = "regio"
>
>         verbose_name_plural = "regio's"
>
> There is an extra table which stores which zips are included in one Region:
> *Zip_per_region*
>
> class Zip_per_region(models.Model):
>
>     region = models.ForeignKey(Region)
>
>     zip = models.ForeignKey(Zip)
>
>     class Meta:
>
>         verbose_name = "postcode"

I am afraid I can't help you. It seems the issue is related to Google
App Engine and Django interactions, and I know nothing about GAE. I
hope somebody else is able to help you out.

 - Anssi

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



Re: Django questions.

2012-04-25 Thread Kurtis Mullins
Man, I think if you don't know the answers to these questions -- you may
not want to apply for that job. Go research and play with NoSQL. Read the
documentation on Template Tags -- and realistically, the point of the
Templating engine in general. If you don't know about the Data Layer then
read the source code, research ORM, and read up on MVC. Good luck!

On Wed, Apr 25, 2012 at 11:04 AM, Marcin Tustin wrote:

> Apologies, these are job application questions:
> https://www.odesk.com/jobs/Programmers-Python-Django-and-client-side-programming-MySQL_~~c7db577bb2246e77?tot=5000&pos=4&_redirected
>
>
>
> On Wed, Apr 25, 2012 at 15:37, Marcin Tustin wrote:
>
>> These are plainly your homework questions. I suggest that you undertake
>> your own research.
>>
>>
>> On Wed, Apr 25, 2012 at 15:20, jacob  wrote:
>>
>>> Hello everybody.
>>>
>>> I am a newbie in django development and need your help for some
>>> questions.
>>>
>>> 1. Under what circumstances would you avoid using the Django platform?
>>> 2. How do you describe the data layer in Django? Where would you place
>>> additional functionality to the domain objects? And where would you
>>> put behavior that is related to the entire table?
>>> 3. What would be the syntax to place a Python code block in a Django
>>> template?
>>> 4. Choose one NoSQL product, describe what it is supposed to be used
>>> for, and under which circumstances you would choose an RDBMS and not
>>> this NoSQL.
>>>
>>> If anybody answer for even a question on detail, I will appreciate it.
>>>
>>> Looking forward to hearing soon.
>>>
>>> Thanks & best regards
>>>
>>> - Jacob
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>>
>>
>>
>> --
>> Marcin Tustin
>> Tel: 07773 787 105
>>
>>
>
>
> --
> Marcin Tustin
> Tel: 07773 787 105
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Django CRUD questions

2012-04-25 Thread drewyan
Any useful resources or examples you can suggest would very much 
appreciated as well.

On Wednesday, April 25, 2012 10:18:45 AM UTC-5, drewyan wrote:
>
> Hi all,
>
> I'm relatively new at designing web apps and I've been using Django to 
> set-up a CRUD type application. I recently figured out how perform POST 
> requests from the forms I set-up. I noticed that the data can be 
> changed/updated through the Django admin site or through the Django API 
> using SQL; I'm sure there's a way for non-admins who don't know SQL to 
> retrieve and change/update the data they input through the web app, but 
> it's not clear to me how to accomplish that (or even where to start 
> looking). It looks like "
> django.views.generic.create_update.create_object" might do the trick, but 
> I'm not using generic views. Are there other options for retrieving form 
> data and then updating it? If you'd like further information, I'd be 
> happy to provide it.
>
> Many thanks.
>

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



Re: Django CRUD questions

2012-04-25 Thread Kurtis Mullins
Check out ModelForms:
https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#django.forms.ModelForm
Note: I'm not sure which version of Django you are using but you may want
to choose a different document-version respectively.

Also, check out CreateView, UpdateView, and DeleteView for your Views:
https://docs.djangoproject.com/en/dev/ref/class-based-views/
An example that I came across from a quick search:
http://stackoverflow.com/questions/5773724/how-do-i-use-createview-with-a-modelform


Good luck!

On Wed, Apr 25, 2012 at 11:31 AM, drewyan  wrote:

> Any useful resources or examples you can suggest would very much
> appreciated as well.
>
>
> On Wednesday, April 25, 2012 10:18:45 AM UTC-5, drewyan wrote:
>>
>> Hi all,
>>
>> I'm relatively new at designing web apps and I've been using Django to
>> set-up a CRUD type application. I recently figured out how perform POST
>> requests from the forms I set-up. I noticed that the data can be
>> changed/updated through the Django admin site or through the Django API
>> using SQL; I'm sure there's a way for non-admins who don't know SQL to
>> retrieve and change/update the data they input through the web app, but
>> it's not clear to me how to accomplish that (or even where to start
>> looking). It looks like "
>> django.views.generic.create_**update.create_object" might do the trick,
>> but I'm not using generic views. Are there other options for retrieving
>> form data and then updating it? If you'd like further information, I'd
>> be happy to provide it.
>>
>> Many thanks.
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/sKakMf6m_k4J.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: form doing a query for each element of foreign key in select

2012-04-25 Thread Lee Hinde

On Apr 25, 2012, at 2:16 AM, Tom Evans wrote:

> On Wed, Apr 25, 2012 at 5:58 AM, Lee Hinde  wrote:
>> I have a table with four or five foreign keys. Using the default form
>> widgets, a foreign key is represented by a single value select.
>> 
>> I noticed, with debug_tool_bar, that a query is being made for each
>> element of each foreign key select option. Seems like it ought not
>> 
>> I am using
>> 
>> classes = get_object_or_404(Classes, pk=pk)
>> 
>> to load the record. I tried
>> Classes.on_site.select_related().get(pk=pk) without any change.
>> 
>> The question is, is this to be expected?
>> 
> 
> Yes. How else would it get the potential values that can be selected?
> 
> If you want to load all in one query, you can use select_related(). If
> select_related() doesn't help, then your foreign keys are probably
> nullable, which are not automatically loaded with select_related().
> 
> FYI, having each foreign key lookup as a separate query may not be a bad 
> thing.
> If the cardinality of the foreign keys doesn't change much (you don't
> add frequently add potential new values for that foreign key), then it
> is highly likely that those queries would be served from the query
> cache.
> 
> If you are displaying 1 million different forms, but all their foreign
> key lookups can be served from cache, do you think it would be quicker
> to do 1 million queries with 5 joins in each query, with none of the
> queries cached, or 5 million queries, 1 million with no joins and 4
> million served from the query cache?
> 
> Cheers
> 
> Tom
> 


Thanks Tom; I may have been unclear. I would expect at least one query per 
foreign key to load the potential values, but there is a query for each 
potential value. i.e.., one of the foreign keys is to an instructor table. 
There's that query, then there's a query for each instructor as part of the 
class page load.

And yes, I have a lot of nullable foreign keys. In this example, I can have a 
class but not know yet who the instructor will be. I suppose an alternative to 
a nullable key would be to have a default, 'no decision made yet' option. 
Thanks also for the reminder about select_related not following a nullable fk.

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



Re: Canadian Django Meetings?

2012-04-25 Thread Gab
On Wed, Apr 25, 2012 at 10:25 AM, Daniel Sokolowski <
daniel.sokolow...@klinsight.com> wrote:

> Does anyone know of any upcoming Django meet ups in Canada? Has there
> been any? Would you come?
>
> I am living in Ontario, so Toronto being the venue would seem like a
> logical choice.
>
> Thoughts?


Toronto would be a little bit far for me, but I'd go to one in Montréal for
sure.

--
Gab

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



Re: form doing a query for each element of foreign key in select

2012-04-25 Thread Tom Evans
On Wed, Apr 25, 2012 at 4:43 PM, Lee Hinde  wrote:
>
> On Apr 25, 2012, at 2:16 AM, Tom Evans wrote:
>
>> On Wed, Apr 25, 2012 at 5:58 AM, Lee Hinde  wrote:
>>> I have a table with four or five foreign keys. Using the default form
>>> widgets, a foreign key is represented by a single value select.
>>>
>>> I noticed, with debug_tool_bar, that a query is being made for each
>>> element of each foreign key select option. Seems like it ought not
>>>
>>> I am using
>>>
>>>     classes = get_object_or_404(Classes, pk=pk)
>>>
>>> to load the record. I tried
>>> Classes.on_site.select_related().get(pk=pk) without any change.
>>>
>>> The question is, is this to be expected?
>>>
>>
>> Yes. How else would it get the potential values that can be selected?
>>
>> If you want to load all in one query, you can use select_related(). If
>> select_related() doesn't help, then your foreign keys are probably
>> nullable, which are not automatically loaded with select_related().
>>
>> FYI, having each foreign key lookup as a separate query may not be a bad 
>> thing.
>> If the cardinality of the foreign keys doesn't change much (you don't
>> add frequently add potential new values for that foreign key), then it
>> is highly likely that those queries would be served from the query
>> cache.
>>
>> If you are displaying 1 million different forms, but all their foreign
>> key lookups can be served from cache, do you think it would be quicker
>> to do 1 million queries with 5 joins in each query, with none of the
>> queries cached, or 5 million queries, 1 million with no joins and 4
>> million served from the query cache?
>>
>> Cheers
>>
>> Tom
>>
>
>
> Thanks Tom; I may have been unclear. I would expect at least one query per 
> foreign key to load the potential values, but there is a query for each 
> potential value. i.e.., one of the foreign keys is to an instructor table. 
> There's that query, then there's a query for each instructor as part of the 
> class page load.
>
> And yes, I have a lot of nullable foreign keys. In this example, I can have a 
> class but not know yet who the instructor will be. I suppose an alternative 
> to a nullable key would be to have a default, 'no decision made yet' option. 
> Thanks also for the reminder about select_related not following a nullable fk.
>

When turning an instance of an object into a  element, Django
calls the unicode function on that instance. If your __unicode__
method for that object references related objects, then Django will
have to issue a query for each instance.

Eg, if you had a models like this:

class Store(Model):
  name = CharField()
  region = ForeignKey('Region')

class Region(Model):
  name = CharField()
  country = ForeignKey('Country')
  def __unicode__(self):
return u'%s (%s)' % (self.name, self.country.name)

class Country(Model):
  name = CharField()

and you were displaying a form for a Store instance, it would do one
query to look up all the related regions, but when it comes to render
the region options, it will issue an extra query per region in order
to look up the country name.

Remember that select_related() will happily follow nullable foreign
keys, you just have to explicitly ask for it by specifying the
relations you want loaded.

Cheers

Tom

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



Just sharing my Skype username

2012-04-25 Thread Kurtis
Hey guys/girls,

I want to share my Skype username in case anyone needs help in real-time. I 
am typically working when I'm online, so* please don't burden me with 
beginner-level questions* -- the Django Docs, Google, Stackoverflow, IRC 
and this mailing list are a great place for that. Also, if any experienced 
developers just want to extend their networking, feel free to contact me as 
well. 

Without trying to sound prejudice, *please only contact me with questions 
if you have excellent English-speaking skills* because I can't burn a lot 
of time trying to communicate with those who don't. As the case with many 
Americans, I only speak English.

My Skype username: kurtis.mullins

Hopefully I didn't just open myself up to a huge influx of craziness :)

Thanks
- Kurtis Mullins

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



Re: Just sharing my Skype username

2012-04-25 Thread Ahmad Abd Arrahman
Thanks Kurtis for sharing your account I have added you to my contacts :)

On Wed, Apr 25, 2012 at 5:56 PM, Kurtis  wrote:

> Hey guys/girls,
>
> I want to share my Skype username in case anyone needs help in real-time.
> I am typically working when I'm online, so* please don't burden me with
> beginner-level questions* -- the Django Docs, Google, Stackoverflow, IRC
> and this mailing list are a great place for that. Also, if any experienced
> developers just want to extend their networking, feel free to contact me as
> well.
>
> Without trying to sound prejudice, *please only contact me with questions
> if you have excellent English-speaking skills* because I can't burn a lot
> of time trying to communicate with those who don't. As the case with many
> Americans, I only speak English.
>
> My Skype username: kurtis.mullins
>
> Hopefully I didn't just open myself up to a huge influx of craziness :)
>
> Thanks
> - Kurtis Mullins
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/cxb1CEkgcMUJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Where are the women?

2012-04-25 Thread Daniele Procida
On Wed, Apr 25, 2012, Hanne Moa  wrote:

>On 24 April 2012 16:14, Daniele Procida  wrote:
>> I was looking at  again with
>excited anticipation, and reading through the talk summaries.

>> There are *two* women out of the 24 or so speakers listed, and only
>one is doing a solo talk.

>You get more women in by changing the weights in *any* of the tests:
>more programmers, more female programmers, more open source
>programmers, more programmers visiting techie cons etc. It adds up.
>
>So: you have this wee group of potential "female open-source
>programmer that visit techie cons that also are of interest to you".
>Then, and only then can you start to look at con-specific or
>language-specific tests that the community can directly do something
>with: "bro"grammers, strip shows, excessive drinking and pressure to
>drink (rumored to be a problem at Java Script venues), rock star
>behavior (ruby?), specific idiots that should never have been left out
>of the asylum and ruins it for everyone etc.

The Python/Django culture just isn't like that. The days and evenings I spent 
at DjangoCon in Amsterdam last year were in the company of pleasant, courteous 
and friendly people.

I wasn't entirely sure what to expect before I went, but I didn't imagine 
there'd be strippers and heavy drinking - is that usual? Or what people expect, 
and are put off by?

>I haven't heard any rumors of stupid behavior among pythoneers or at
>python cons though so it might just be that "female open-source
>(python and django) programmer that visit techie cons that also are of
>interest to you" is a very small group.

It clearly is a very small group. The question is, why so small, and what, if 
anything, to do to address it.

Daniele

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



Re: Just sharing my Skype username

2012-04-25 Thread Kurtis
No problem at all :)

On Wednesday, April 25, 2012 12:04:30 PM UTC-4, Ahmad wrote:
>
> Thanks Kurtis for sharing your account I have added you to my contacts :)
>
> On Wed, Apr 25, 2012 at 5:56 PM, Kurtis  wrote:
>
>> Hey guys/girls,
>>
>> I want to share my Skype username in case anyone needs help in real-time. 
>> I am typically working when I'm online, so* please don't burden me with 
>> beginner-level questions* -- the Django Docs, Google, Stackoverflow, IRC 
>> and this mailing list are a great place for that. Also, if any experienced 
>> developers just want to extend their networking, feel free to contact me as 
>> well. 
>>
>> Without trying to sound prejudice, *please only contact me with 
>> questions if you have excellent English-speaking skills* because I can't 
>> burn a lot of time trying to communicate with those who don't. As the case 
>> with many Americans, I only speak English.
>>
>> My Skype username: kurtis.mullins
>>
>> Hopefully I didn't just open myself up to a huge influx of craziness :)
>>
>> Thanks
>> - Kurtis Mullins
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/cxb1CEkgcMUJ.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>

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



Confused about GeoDjango and PostGIS

2012-04-25 Thread vishy
Hi,

I need to do spatial queries like find places within 5 miles of a
location given in latitude and longitude. So, I am thinking of
exploring PostGIS and GeoDjango. I have installed both. Now, I already
have a database which has a table for places with latitude and
longitude. Can I enable this db to use postgis and add column to this
table? Or, do I have to create a separate spatial db, create a table
with a column of geometry type and import data into that table (from
places table).? If I can use the existing database, how do I enable it
to use PostGIS?

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



Re: Confused about GeoDjango and PostGIS

2012-04-25 Thread Jeff Heard
Create a new spatial database and import the data.  That's by far your
easiest option.  You'll need to create a POINT column (look at the PostGIS
doc on how to add spatial columns) and then add rows either using the ORM
or with a spatial query including something like this as part of the insert:

GeomFromText('POINT(' + x + ' ' + y + ')', 4326)

where 4326 is the spatial reference system for longitude/latitude.



On Wed, Apr 25, 2012 at 11:17 AM, vishy  wrote:

> Hi,
>
> I need to do spatial queries like find places within 5 miles of a
> location given in latitude and longitude. So, I am thinking of
> exploring PostGIS and GeoDjango. I have installed both. Now, I already
> have a database which has a table for places with latitude and
> longitude. Can I enable this db to use postgis and add column to this
> table? Or, do I have to create a separate spatial db, create a table
> with a column of geometry type and import data into that table (from
> places table).? If I can use the existing database, how do I enable it
> to use PostGIS?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Just sharing my Skype username

2012-04-25 Thread Daniel Sokolowski
On related note: for quick and dirty screen sharing there is join.me; works 
amazingly with an IRC chat. 


From: Kurtis 
Sent: Wednesday, April 25, 2012 11:56 AM
To: django-users@googlegroups.com 
Subject: Just sharing my Skype username

Hey guys/girls, 

I want to share my Skype username in case anyone needs help in real-time. I am 
typically working when I'm online, so please don't burden me with 
beginner-level questions -- the Django Docs, Google, Stackoverflow, IRC and 
this mailing list are a great place for that. Also, if any experienced 
developers just want to extend their networking, feel free to contact me as 
well. 

Without trying to sound prejudice, please only contact me with questions if you 
have excellent English-speaking skills because I can't burn a lot of time 
trying to communicate with those who don't. As the case with many Americans, I 
only speak English.

My Skype username: kurtis.mullins

Hopefully I didn't just open myself up to a huge influx of craziness :)

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

Daniel Sokolowski
Web Engineer
KL Insight
http://klinsight.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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



why django document does not specify how to use non-global middleware

2012-04-25 Thread DanYun Liu
I am new to django, before django I used struts2 to build web application.
It is common that we need to apply some middleware to a part of views and
others not. I didn't find any userful information on the django site, so I
searched the stackoverflow and got the right answer.

http://stackoverflow.com/questions/2916966/non-global-middleware-in-django

I will be useful to people who is familiar struts but new to django  to
include how to user non-global middleware when introuduce the midlleware.


-- 
Pursuit the freedom of the soul.

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



Re: why django document does not specify how to use non-global middleware

2012-04-25 Thread Marcin Tustin
Just because you used to do it in Struts, it does not mean that it is the
best, or even a good, way to do it in django.

On Wed, Apr 25, 2012 at 17:26, DanYun Liu  wrote:

> I am new to django, before django I used struts2 to build web application.
> It is common that we need to apply some middleware to a part of views and
> others not. I didn't find any userful information on the django site, so I
> searched the stackoverflow and got the right answer.
>
> http://stackoverflow.com/questions/2916966/non-global-middleware-in-django
>
>
> I will be useful to people who is familiar struts but new to django  to
> include how to user non-global middleware when introuduce the midlleware.
>
>
> --
> Pursuit the freedom of the soul.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Marcin Tustin
Tel: 07773 787 105

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



Overriding an admin widget?

2012-04-25 Thread Roy Smith
I'm trying to get the admin to give me a thumbnail for an ImageForm.  Following 
the suggestion at http://djangosnippets.org/snippets/1580/, I've got the 
following code:

from django import forms
from django.contrib import admin
from django.db import models
from django.utils.safestring import mark_safe

class AdminImageWidget(forms.FileInput):
def __init__(self, attrs={}):
assert 0
super(AdminImageWidget, self).__init__(attrs)

def render(self, name, value, attrs=None):
output = []
if value and hasattr(value, "url"):
output.append((''
   ' '
   % (value.url, value.url)))
output.append(super(AdminImageWidget, self).render(name, value, attrs))
return mark_safe(u''.join(output))

class ImageVersionAdmin(admin.ModelAdmin):
readonly_fields = ('image',
   'data')
formfield_overrides = {
models.ImageField: {'widget': AdminImageWidget,
'label': 'My Label',},
}

admin.site.register(ImageVersion, ImageVersionAdmin)

The problem is, I'm still getting the standard admin display.  I stuck the 
"assert 0" in AdminImageWidget.__init__() just to prove that it's never being 
called.  What magic am I missing?

My model looks like:

class ImageVersion(Model):
image = ForeignKey(Image)
data = ImageField(upload_to="images/foo")

---
Roy Smith
r...@panix.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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Canadian Django Meetings?

2012-04-25 Thread Kurtis
If I have enough notice to get a Passport and it landed on a weekend where 
I was free -- I wouldn't mind taking that trip. I've always wanted to see 
Toronto anyways :P

On Wednesday, April 25, 2012 10:25:53 AM UTC-4, Daniel Sokolowski wrote:
>
> Does anyone know of any upcoming Django meet ups in Canada? Has there 
> been any? Would you come? 
>
> I am living in Ontario, so Toronto being the venue would seem like a 
> logical choice. 
>
> Thoughts?

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



Re: Overriding an admin widget?

2012-04-25 Thread Roy Smith
Ooops, forgot to mention, I'm using django 1.4.


On Apr 25, 2012, at 12:51 PM, Roy Smith wrote:

> I'm trying to get the admin to give me a thumbnail for an ImageForm.  
> Following the suggestion at http://djangosnippets.org/snippets/1580/, I've 
> got the following code:
> 
> from django import forms
> from django.contrib import admin
> from django.db import models
> from django.utils.safestring import mark_safe
> 
> class AdminImageWidget(forms.FileInput):
> def __init__(self, attrs={}):
> assert 0
> super(AdminImageWidget, self).__init__(attrs)
> 
> def render(self, name, value, attrs=None):
> output = []
> if value and hasattr(value, "url"):
> output.append((''
>' '
>% (value.url, value.url)))
> output.append(super(AdminImageWidget, self).render(name, value, 
> attrs))
> return mark_safe(u''.join(output))
> 
> class ImageVersionAdmin(admin.ModelAdmin):
> readonly_fields = ('image',
>'data')
> formfield_overrides = {
> models.ImageField: {'widget': AdminImageWidget,
> 'label': 'My Label',},
> }
> 
> admin.site.register(ImageVersion, ImageVersionAdmin)
> 
> The problem is, I'm still getting the standard admin display.  I stuck the 
> "assert 0" in AdminImageWidget.__init__() just to prove that it's never being 
> called.  What magic am I missing?
> 
> My model looks like:
> 
> class ImageVersion(Model):
> image = ForeignKey(Image)
> data = ImageField(upload_to="images/foo")
> 
> ---
> Roy Smith
> r...@panix.com
> 
> 
> 


---
Roy Smith
r...@panix.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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Confused about GeoDjango and PostGIS

2012-04-25 Thread vishy
So, the existing database cannot be used as a postgis db?

On Apr 25, 9:21 pm, Jeff Heard  wrote:
> Create a new spatial database and import the data.  That's by far your
> easiest option.  You'll need to create a POINT column (look at the PostGIS
> doc on how to add spatial columns) and then add rows either using the ORM
> or with a spatial query including something like this as part of the insert:
>
> GeomFromText('POINT(' + x + ' ' + y + ')', 4326)
>
> where 4326 is the spatial reference system for longitude/latitude.
>
>
>
>
>
>
>
> On Wed, Apr 25, 2012 at 11:17 AM, vishy  wrote:
> > Hi,
>
> > I need to do spatial queries like find places within 5 miles of a
> > location given in latitude and longitude. So, I am thinking of
> > exploring PostGIS and GeoDjango. I have installed both. Now, I already
> > have a database which has a table for places with latitude and
> > longitude. Can I enable this db to use postgis and add column to this
> > table? Or, do I have to create a separate spatial db, create a table
> > with a column of geometry type and import data into that table (from
> > places table).? If I can use the existing database, how do I enable it
> > to use PostGIS?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: Overriding an admin widget?

2012-04-25 Thread Roy Smith
Oh, I see what's going on.  I marked the field as readonly.  Apparently the 
widget only gets created if the field is editable (I guess that makes sense).



On Apr 25, 2012, at 1:28 PM, Roy Smith wrote:

> Ooops, forgot to mention, I'm using django 1.4.
> 
> 
> On Apr 25, 2012, at 12:51 PM, Roy Smith wrote:
> 
>> I'm trying to get the admin to give me a thumbnail for an ImageForm.  
>> Following the suggestion at http://djangosnippets.org/snippets/1580/, I've 
>> got the following code:
>> 
>> from django import forms
>> from django.contrib import admin
>> from django.db import models
>> from django.utils.safestring import mark_safe
>> 
>> class AdminImageWidget(forms.FileInput):
>> def __init__(self, attrs={}):
>> assert 0
>> super(AdminImageWidget, self).__init__(attrs)
>> 
>> def render(self, name, value, attrs=None):
>> output = []
>> if value and hasattr(value, "url"):
>> output.append((''
>>' '
>>% (value.url, value.url)))
>> output.append(super(AdminImageWidget, self).render(name, value, 
>> attrs))
>> return mark_safe(u''.join(output))
>> 
>> class ImageVersionAdmin(admin.ModelAdmin):
>> readonly_fields = ('image',
>>'data')
>> formfield_overrides = {
>> models.ImageField: {'widget': AdminImageWidget,
>> 'label': 'My Label',},
>> }
>> 
>> admin.site.register(ImageVersion, ImageVersionAdmin)
>> 
>> The problem is, I'm still getting the standard admin display.  I stuck the 
>> "assert 0" in AdminImageWidget.__init__() just to prove that it's never 
>> being called.  What magic am I missing?
>> 
>> My model looks like:
>> 
>> class ImageVersion(Model):
>> image = ForeignKey(Image)
>> data = ImageField(upload_to="images/foo")
>> 
>> ---
>> Roy Smith
>> r...@panix.com
>> 
>> 
>> 
> 
> 
> ---
> Roy Smith
> r...@panix.com
> 
> 
> 


---
Roy Smith
r...@panix.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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Canadian Django Meetings?

2012-04-25 Thread CLIFFORD ILKAY

On 04/25/2012 10:25 AM, Daniel Sokolowski wrote:

Does anyone know of any upcoming Django meet ups in Canada? Has there
been any? Would you come?

I am living in Ontario, so Toronto being the venue would seem like a
logical choice.


There are monthly Django Toronto meetings. To be informed of upcoming 
meetings, join the mailing list . The 
next one is May 17.

--
Regards,

Clifford Ilkay
Dinamis
1419-3230 Yonge St.
Toronto, ON
Canada  M4N 3P6


+1 416-410-3326

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



Re: Confused about GeoDjango and PostGIS

2012-04-25 Thread George Silva
Yes it can, as long PostGIS is installed.

On Wed, Apr 25, 2012 at 2:37 PM, vishy  wrote:

> So, the existing database cannot be used as a postgis db?
>
> On Apr 25, 9:21 pm, Jeff Heard  wrote:
> > Create a new spatial database and import the data.  That's by far your
> > easiest option.  You'll need to create a POINT column (look at the
> PostGIS
> > doc on how to add spatial columns) and then add rows either using the ORM
> > or with a spatial query including something like this as part of the
> insert:
> >
> > GeomFromText('POINT(' + x + ' ' + y + ')', 4326)
> >
> > where 4326 is the spatial reference system for longitude/latitude.
> >
> >
> >
> >
> >
> >
> >
> > On Wed, Apr 25, 2012 at 11:17 AM, vishy  wrote:
> > > Hi,
> >
> > > I need to do spatial queries like find places within 5 miles of a
> > > location given in latitude and longitude. So, I am thinking of
> > > exploring PostGIS and GeoDjango. I have installed both. Now, I already
> > > have a database which has a table for places with latitude and
> > > longitude. Can I enable this db to use postgis and add column to this
> > > table? Or, do I have to create a separate spatial db, create a table
> > > with a column of geometry type and import data into that table (from
> > > places table).? If I can use the existing database, how do I enable it
> > > to use PostGIS?
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Django users" group.
> > > To post to this group, send email to django-users@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
George R. C. Silva

Desenvolvimento em GIS
http://geoprocessamento.net
http://blog.geoprocessamento.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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Confused about GeoDjango and PostGIS

2012-04-25 Thread Jeff Heard
It can. I just usually consider it easier to create a new one
On Apr 25, 2012 1:38 PM, "vishy"  wrote:

> So, the existing database cannot be used as a postgis db?
>
> On Apr 25, 9:21 pm, Jeff Heard  wrote:
> > Create a new spatial database and import the data.  That's by far your
> > easiest option.  You'll need to create a POINT column (look at the
> PostGIS
> > doc on how to add spatial columns) and then add rows either using the ORM
> > or with a spatial query including something like this as part of the
> insert:
> >
> > GeomFromText('POINT(' + x + ' ' + y + ')', 4326)
> >
> > where 4326 is the spatial reference system for longitude/latitude.
> >
> >
> >
> >
> >
> >
> >
> > On Wed, Apr 25, 2012 at 11:17 AM, vishy  wrote:
> > > Hi,
> >
> > > I need to do spatial queries like find places within 5 miles of a
> > > location given in latitude and longitude. So, I am thinking of
> > > exploring PostGIS and GeoDjango. I have installed both. Now, I already
> > > have a database which has a table for places with latitude and
> > > longitude. Can I enable this db to use postgis and add column to this
> > > table? Or, do I have to create a separate spatial db, create a table
> > > with a column of geometry type and import data into that table (from
> > > places table).? If I can use the existing database, how do I enable it
> > > to use PostGIS?
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Django users" group.
> > > To post to this group, send email to django-users@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Confused about GeoDjango and PostGIS

2012-04-25 Thread vishy
Thanks.

On Apr 25, 11:07 pm, Jeff Heard  wrote:
> It can. I just usually consider it easier to create a new one
> On Apr 25, 2012 1:38 PM, "vishy"  wrote:
>
>
>
>
>
>
>
> > So, the existing database cannot be used as a postgis db?
>
> > On Apr 25, 9:21 pm, Jeff Heard  wrote:
> > > Create a new spatial database and import the data.  That's by far your
> > > easiest option.  You'll need to create a POINT column (look at the
> > PostGIS
> > > doc on how to add spatial columns) and then add rows either using the ORM
> > > or with a spatial query including something like this as part of the
> > insert:
>
> > > GeomFromText('POINT(' + x + ' ' + y + ')', 4326)
>
> > > where 4326 is the spatial reference system for longitude/latitude.
>
> > > On Wed, Apr 25, 2012 at 11:17 AM, vishy  wrote:
> > > > Hi,
>
> > > > I need to do spatial queries like find places within 5 miles of a
> > > > location given in latitude and longitude. So, I am thinking of
> > > > exploring PostGIS and GeoDjango. I have installed both. Now, I already
> > > > have a database which has a table for places with latitude and
> > > > longitude. Can I enable this db to use postgis and add column to this
> > > > table? Or, do I have to create a separate spatial db, create a table
> > > > with a column of geometry type and import data into that table (from
> > > > places table).? If I can use the existing database, how do I enable it
> > > > to use PostGIS?
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Django users" group.
> > > > To post to this group, send email to django-users@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > django-users+unsubscr...@googlegroups.com.
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/django-users?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: Confused about GeoDjango and PostGIS

2012-04-25 Thread vishy
thanks

On Apr 25, 11:07 pm, Jeff Heard  wrote:
> It can. I just usually consider it easier to create a new one
> On Apr 25, 2012 1:38 PM, "vishy"  wrote:
>
>
>
>
>
>
>
> > So, the existing database cannot be used as a postgis db?
>
> > On Apr 25, 9:21 pm, Jeff Heard  wrote:
> > > Create a new spatial database and import the data.  That's by far your
> > > easiest option.  You'll need to create a POINT column (look at the
> > PostGIS
> > > doc on how to add spatial columns) and then add rows either using the ORM
> > > or with a spatial query including something like this as part of the
> > insert:
>
> > > GeomFromText('POINT(' + x + ' ' + y + ')', 4326)
>
> > > where 4326 is the spatial reference system for longitude/latitude.
>
> > > On Wed, Apr 25, 2012 at 11:17 AM, vishy  wrote:
> > > > Hi,
>
> > > > I need to do spatial queries like find places within 5 miles of a
> > > > location given in latitude and longitude. So, I am thinking of
> > > > exploring PostGIS and GeoDjango. I have installed both. Now, I already
> > > > have a database which has a table for places with latitude and
> > > > longitude. Can I enable this db to use postgis and add column to this
> > > > table? Or, do I have to create a separate spatial db, create a table
> > > > with a column of geometry type and import data into that table (from
> > > > places table).? If I can use the existing database, how do I enable it
> > > > to use PostGIS?
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Django users" group.
> > > > To post to this group, send email to django-users@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > django-users+unsubscr...@googlegroups.com.
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/django-users?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: Confused about GeoDjango and PostGIS

2012-04-25 Thread vishy
Yes, I just ran  the 2 scripts  in my current database -
spatial_ref_sys.sql and postgis.sql. Seems to work. I am able to
define a geometry column in my current existing table.

On Apr 25, 11:03 pm, George Silva  wrote:
> Yes it can, as long PostGIS is installed.
>
>
>
>
>
>
>
>
>
> On Wed, Apr 25, 2012 at 2:37 PM, vishy  wrote:
> > So, the existing database cannot be used as a postgis db?
>
> > On Apr 25, 9:21 pm, Jeff Heard  wrote:
> > > Create a new spatial database and import the data.  That's by far your
> > > easiest option.  You'll need to create a POINT column (look at the
> > PostGIS
> > > doc on how to add spatial columns) and then add rows either using the ORM
> > > or with a spatial query including something like this as part of the
> > insert:
>
> > > GeomFromText('POINT(' + x + ' ' + y + ')', 4326)
>
> > > where 4326 is the spatial reference system for longitude/latitude.
>
> > > On Wed, Apr 25, 2012 at 11:17 AM, vishy  wrote:
> > > > Hi,
>
> > > > I need to do spatial queries like find places within 5 miles of a
> > > > location given in latitude and longitude. So, I am thinking of
> > > > exploring PostGIS and GeoDjango. I have installed both. Now, I already
> > > > have a database which has a table for places with latitude and
> > > > longitude. Can I enable this db to use postgis and add column to this
> > > > table? Or, do I have to create a separate spatial db, create a table
> > > > with a column of geometry type and import data into that table (from
> > > > places table).? If I can use the existing database, how do I enable it
> > > > to use PostGIS?
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Django users" group.
> > > > To post to this group, send email to django-users@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > django-users+unsubscr...@googlegroups.com.
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/django-users?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> George R. C. Silva
>
> Desenvolvimento em 
> GIShttp://geoprocessamento.nethttp://blog.geoprocessamento.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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Where are the women?

2012-04-25 Thread Katie Cunningham
If you want to get more women to a conference, a few things have been
successful on this side of the pond:

 - Scholarships set aside for female attendees
 - Specifically invite potential female speakers to talk, or at least
submit a talk
 - Reach out to women-based tech groups, and make sure they know about
the conference
 - Talk to females that are already attending, and see if they can share a room
 - Encourage sponsors to sponsor costs for a female attendee.
 - Have a code of conduct that is public, explicit, and enforced.

Even doing the scholarships for a few spots shows that your conference
shows that you're serious about women attending. I don't know, when
looking into a conference, whether your conference is going to be one
where I'm going to get cat-called or one where I'm going to feel
completely at home.

Katie Cunningham

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



Re: Where are the women?

2012-04-25 Thread Jonas Obrist
Hi everyone,

I'm one of the organizers of DjangoCon Europe 2012 and as Daniele pointed 
out, it made me sad when seeing the amount of women that submitted a talk. 
While we have no statistics of a gender breakdown for the tickets sold so 
far, just glancing at the list of names makes me sad.

I wonder how much of this is just bad organizing and communication from our 
part, and how much it is because there are less women in the Django 
community than men (if that's even the case). On that note, thanks for 
giving your views on this topic everyone.

I will see which suggestions we can still implement for DjangoCon Europe 
and if you have any more suggestions, please feel free to contact me 
directly at ojiido...@gmail.com, as I often forget to check mailing lists.

We'll publish a code of conduct soon, the reason why this was not done yet 
is because I naively thought that it is unnecessary, as 
everything usually mentioned in a code of conduct is covered by Swiss law 
anyway (especially discrimination).

Jonas Obrist

On Wednesday, April 25, 2012 8:28:07 PM UTC+2, Katie Cunningham wrote:
>
> If you want to get more women to a conference, a few things have been 
> successful on this side of the pond: 
>
>  - Scholarships set aside for female attendees 
>  - Specifically invite potential female speakers to talk, or at least 
> submit a talk 
>  - Reach out to women-based tech groups, and make sure they know about 
> the conference 
>  - Talk to females that are already attending, and see if they can share a 
> room 
>  - Encourage sponsors to sponsor costs for a female attendee. 
>  - Have a code of conduct that is public, explicit, and enforced. 
>
> Even doing the scholarships for a few spots shows that your conference 
> shows that you're serious about women attending. I don't know, when 
> looking into a conference, whether your conference is going to be one 
> where I'm going to get cat-called or one where I'm going to feel 
> completely at home. 
>
> Katie Cunningham 

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



Re: Where are the women?

2012-04-25 Thread Katie Cunningham
If you want a quick code of conduct, check out the one that PyCon US
used this year. They borrowed it from another advocacy group, I
believe, so it's becoming pretty standard.

Katie

On Wed, Apr 25, 2012 at 4:07 PM, Jonas Obrist  wrote:
> Hi everyone,
>
> I'm one of the organizers of DjangoCon Europe 2012 and as Daniele pointed
> out, it made me sad when seeing the amount of women that submitted a talk.
> While we have no statistics of a gender breakdown for the tickets sold so
> far, just glancing at the list of names makes me sad.
>
> I wonder how much of this is just bad organizing and communication from our
> part, and how much it is because there are less women in the Django
> community than men (if that's even the case). On that note, thanks for
> giving your views on this topic everyone.
>
> I will see which suggestions we can still implement for DjangoCon Europe and
> if you have any more suggestions, please feel free to contact me directly at
> ojiido...@gmail.com, as I often forget to check mailing lists.
>
> We'll publish a code of conduct soon, the reason why this was not done yet
> is because I naively thought that it is unnecessary, as
> everything usually mentioned in a code of conduct is covered by Swiss law
> anyway (especially discrimination).
>
> Jonas Obrist
>
>
> On Wednesday, April 25, 2012 8:28:07 PM UTC+2, Katie Cunningham wrote:
>>
>> If you want to get more women to a conference, a few things have been
>> successful on this side of the pond:
>>
>>  - Scholarships set aside for female attendees
>>  - Specifically invite potential female speakers to talk, or at least
>> submit a talk
>>  - Reach out to women-based tech groups, and make sure they know about
>> the conference
>>  - Talk to females that are already attending, and see if they can share a
>> room
>>  - Encourage sponsors to sponsor costs for a female attendee.
>>  - Have a code of conduct that is public, explicit, and enforced.
>>
>> Even doing the scholarships for a few spots shows that your conference
>> shows that you're serious about women attending. I don't know, when
>> looking into a conference, whether your conference is going to be one
>> where I'm going to get cat-called or one where I'm going to feel
>> completely at home.
>>
>> Katie Cunningham
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/KCWMuExf0n8J.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: generic view 'create_object' inssue

2012-04-25 Thread Carlos Aboim
No answers yet?
Can anyone help me?!

Thank you

Quarta-feira, 25 de Abril de 2012 8:08:24 UTC-3, Carlos Aboim escreveu:
>
> I fellows
> I am getting a strange behavior from a simple generic view
>
> The problem is that I can not pass the data in the form to introducing a 
> new object in the database.
> Then the urls.py file > http://dpaste.com/hold/732643/
> The html form is this > http://dpaste.com/hold/732646/
>
> when I submit the form the page redirects to somewhere but the data 
> doesn't get into the database.
>
> What am I doing wrong?
> I thank you for your help!
> hugs
>

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



Unable to get result using distance query

2012-04-25 Thread vishy
Hi,

I am using PointField to store longitude and latitude with SRID 4326.
All my places are in USA. Now, given a reference point, I do

   lat = "41.881944"
   lng = "-87.627778"

ref_pnt = fromstr("POINT(%s %s)" % (lng, lat))
distance_from_point = {'m':'50'}
r_gis =
PLaces.objects.filter(poly__distance_lte=(ref_pnt,D(**distance_from_point)))


But, I am getting an error

   DatabaseError: Coordinate values are out of range [-180 -90,
180 90] for GEOGRAHY type

What is wrong?

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



(List objects(Recently Added - Most Common

2012-04-25 Thread mohamed wagdy
  please  i  want  a help

 I have some object stored  in a  databaseand i want  to
make   List of this object  (Recently Added object -
and
Most Common)

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



Re: Django deployment practices -- do people use setup.py?

2012-04-25 Thread Daniel Sokolowski
Thank you for taking the time to explain; I've reached a similar 'readme' 
approach here but was hoping for a better solution.


-Original Message- 
From: Andrew Cutler

Sent: Tuesday, April 24, 2012 8:21 AM
To: django-users@googlegroups.com
Subject: Re: Django deployment practices -- do people use setup.py?

On 24 April 2012 02:21, Daniel Sokolowski
 wrote:


Both, system libraries and not python files --- anything outside of Python
land that PIP can’t handle. How do you handle that if you want a self
contained easy to deploy project?


Well then it's safe to assume that if it's not pure Python, or
directly related to your project then it's out of scope for standard
Python packaging tools.

Python runs just about everywhere, and every platform handles
libraries and app dependencies differently. I don't think that an
elegant, and general cross-platform solution exists. Distutils does
however provide a general method for installing Python (C) extension
modules in a cross platform fashion and there is also a 'data_files'
option for installing non Python files within your virtualenv but this
is as far as it goes.

For Windows you'll need to create an EXE installer or MSI package with
every redistributable that you need (eg Apache/MySQL... oh and
Python). For *nix platforms use the relevant package format eg
RPM/DEB/DMG to install whatever your app depends on, whether it be
MySQL, or some Python module or system library.

The way we've solved it with our Django apps is quite simple. We have
a README file that explains what the general requirements are, and how
to install these requirements for the most popular Linux distros (eg
yum install foo). Our setup.py takes care of everything Python. It's
up to the end user/sysadmin to plumb everything together. Perhaps
later on I'll roll some generic Debs and RPMS that satisfy the
required dependencies, but for now we assume our end users are
technically proficient, so we can get away with a less integrated
approach.

Cheers,

--
Andrew Cutler

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.

To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Daniel Sokolowski
Web Engineer
Danols Web Engineering
http://webdesign.danols.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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: deploying django - including third party apps

2012-04-25 Thread Daniel Sokolowski
If you have shell access you could do a virtualenv/pip combo install. 

From: luke lukes 
Sent: Wednesday, April 25, 2012 11:14 AM
To: django-users@googlegroups.com 
Subject: deploying django - including third party apps

hi everyone. i'm developing a simple CRUD django app and my idea is to host it 
on a free web hosting site that supports django (e.g. alwaysdata.com or 
heliohost.org). I havent tried locally to deploy it on a web server such as 
Apache, i've alway used the development server by manage.py runserver. Now i'm 
using third application on it: reportlab (for pdf generation), django-evolution 
(for models changes). well these apps are installed via apt-get (i'm using 
ubuntu as host system) or by getting the packages from their own sites and 
installing them by setup.py install. Now i've checked on alwaysdata.com and 
reportlab is installed, but seems there's no django_evolution. what i have to 
do to include it in my app and to get it working? 

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

Daniel Sokolowski
Web Engineer
KL Insight
http://klinsight.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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Problem with accessing Audio files from server.

2012-04-25 Thread atul khairnar
Hi,
I am writing Internet Radio App using Django. When i load the stream page
in the browser (i.e. play_page.html) server does not stream the audio file
at all.
I have following settings in my project.

MEDIA_ROOT = '/home/atul/Atul/django_radio/'
MEDIA_URL = ''

Audio File's Model:

class Audio(models.Model):
title= models.CharField(max_length=200)
mp3  = models.FileField(upload_to = u'talks/', max_length=200)
seconds  = models.IntegerField(blank = True, null = True)
def __unicode__(self):
return self.title

Audio Files are stored at: '/home/atul/Atul/django_radio/talks/'

I don't get why server unable to access the media file stored at above
location??
or does problem lies elsewhere?

-- 
Atul Khairnar
College of Engineering , Pune
Cell - (+91)9579289613

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



Re: Confused about GeoDjango and PostGIS

2012-04-25 Thread Jani Tiainen

25.4.2012 19:17, vishy kirjoitti:

Hi,

I need to do spatial queries like find places within 5 miles of a
location given in latitude and longitude. So, I am thinking of
exploring PostGIS and GeoDjango. I have installed both. Now, I already
have a database which has a table for places with latitude and
longitude. Can I enable this db to use postgis and add column to this
table? Or, do I have to create a separate spatial db, create a table
with a column of geometry type and import data into that table (from
places table).? If I can use the existing database, how do I enable it
to use PostGIS?



It depends on your environment but basic workflow is same is in *nix 
instructions. And it's not even hard. :


createdb yourdatabase
createlang plpgsql yourdatabase
psql -d yourdatabase -f postgis.sql
psql -d yourdatabase -f postgis_comments.sql
psql -d yourdatabase -f spatial_ref_sys.sql


Of course in your case you can skip creation of database. Just create 
language and install postgis stuff.


After that you need to make sure that your database user has access to
geometry_columns and spatial_ref_sys tables.

Add new column (For PostGIS 1.5.x, newer postgis has simpler alternative 
syntax):


SELECT AddGeometryColumn('my_table', 'my_geom', 4326, 'POINT', 2)

And after that just update new geometry column:
update my_table set my_geom = GeomFromText('POINT(' + x + ' ' + y +')', 
4326)


And don't forget to commit. If you have lot's of geometries (1M+) you 
probably want to drop out spatial index and recreate it afterwards. 
Otherwise building index takes just long time.



--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

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



Re: Confused about GeoDjango and PostGIS

2012-04-25 Thread vishy
thanks. This is what I have done.

On Apr 26, 9:57 am, Jani Tiainen  wrote:
> 25.4.2012 19:17, vishy kirjoitti:
>
> > Hi,
>
> > I need to do spatial queries like find places within 5 miles of a
> > location given in latitude and longitude. So, I am thinking of
> > exploring PostGIS and GeoDjango. I have installed both. Now, I already
> > have a database which has a table for places with latitude and
> > longitude. Can I enable this db to use postgis and add column to this
> > table? Or, do I have to create a separate spatial db, create a table
> > with a column of geometry type and import data into that table (from
> > places table).? If I can use the existing database, how do I enable it
> > to use PostGIS?
>
> It depends on your environment but basic workflow is same is in *nix
> instructions. And it's not even hard. :
>
> createdb yourdatabase
> createlang plpgsql yourdatabase
> psql -d yourdatabase -f postgis.sql
> psql -d yourdatabase -f postgis_comments.sql
> psql -d yourdatabase -f spatial_ref_sys.sql
>
> Of course in your case you can skip creation of database. Just create
> language and install postgis stuff.
>
> After that you need to make sure that your database user has access to
> geometry_columns and spatial_ref_sys tables.
>
> Add new column (For PostGIS 1.5.x, newer postgis has simpler alternative
> syntax):
>
> SELECT AddGeometryColumn('my_table', 'my_geom', 4326, 'POINT', 2)
>
> And after that just update new geometry column:
> update my_table set my_geom = GeomFromText('POINT(' + x + ' ' + y +')',
> 4326)
>
> And don't forget to commit. If you have lot's of geometries (1M+) you
> probably want to drop out spatial index and recreate it afterwards.
> Otherwise building index takes just long time.
>
> --
> Jani Tiainen
>
> - Well planned is half done and a half done has been sufficient before...

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



Re: Soap web services with Soaplib in Django

2012-04-25 Thread Mario Gudelj
It's probably a problem with what you're passing to the template or what
you have in your template. You should supply some actual code from your
view and your template.

-m

On 25 April 2012 15:01, Meenakshi Ithape  wrote:

> I used the Soap web services with Soaplib in Django, for that i take
> the help from below link
> http://djangosnippets.org/snippets/979/
> When i run this code  through command prompt it runs properly, but
> when i run it on browser it shows nothing,
> Can anybody please help me, what should i done wrong?
>
> Thanks for any suggestions
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Ignoring empty forms in a formset

2012-04-25 Thread Martin Tiršel
Thanks, form.has_changed() seems to be the way. But I don't understand the 
empty_permitted attribute, it is usable only with ModelForm? I am using the 
formset only for mass form processing not for inserting/updating models.

Martin


On Wednesday, April 25, 2012 2:35:20 PM UTC+2, Tom Evans wrote:
>
> Hmm. Internally, model formsets do this differently - they are aware
> of which forms are extra forms, and which forms are existing forms.
>
> New forms will have form.empty_permitted=True, unmodified forms will
> return True from form.has_changed(). This should be enough to skip
> over blank new forms.
>
> Cheers
>
> Tom
>
> On Wed, Apr 25, 2012 at 12:55 PM, Martin Tiršel  
> wrote:
> > I am using class based views and my code is:
> >
> > class PayOrdersView(AdminFormSetView):
> > form_class = PayOrderForm
> > template_name = 'internal/orders/pay_orders_form.html'
> > active_item = 'order_pay_orders'
> > context_formset_name = 'pay_orders_formset'
> > extra = 2
> >
> > def formset_valid(self, formset):
> > logger.debug('Executing formset_valid')
> > for form in formset:
> > logger.debug('Is empty: %s' % form.empty_permitted)
> > form.save()
> > return super(PayOrdersView, self).formset_valid(formset)
> >
> >
> > formset_valid method is called after formset.is_valid(). I start with 2
> > empty forms, I insert into first form order number and the second form 
> stays
> > empty. After I submit, I get:
> >
> > [2012-04-25 13:42:07,776] DEBUG [31099 140249342375680]
> > [project.internal.mixins:304] Processing POSTed form
> > [2012-04-25 13:42:07,778] DEBUG [31099 140249342375680]
> > [project.internal.forms:29] Cleaning order_number
> > [2012-04-25 13:42:07,837] DEBUG [31099 140249342375680]
> > [project.internal.mixins:307] Formset is valid
> > [2012-04-25 13:42:07,842] DEBUG [31099 140249342375680]
> > [project.internal.views:93] Executing formset_valid
> > [2012-04-25 13:42:07,843] DEBUG [31099 140249342375680]
> > [project.internal.views:95] Is empty: True
> > [2012-04-25 13:42:07,843] DEBUG [31099 140249342375680]
> > [project.internal.forms:54] Saving PayOrderForm
> > [2012-04-25 13:42:09,914] DEBUG [31099 140249342375680]
> > [project.internal.views:95] Is empty: True
> > [2012-04-25 13:42:09,914] DEBUG [31099 140249342375680]
> > [project.internal.forms:54] Saving PayOrderForm
> >
> > So both forms have empty_permitted == True. Management form in time of
> > submit looks so:
> >
> >  > name="form-TOTAL_FORMS">
> >  > name="form-INITIAL_FORMS">
> >  name="form-MAX_NUM_FORMS">
> >
> > Thanks, Martin
> >
> > On Wednesday, April 25, 2012 11:03:49 AM UTC+2, Tom Evans wrote:
> >>
> >> On Sun, Apr 22, 2012 at 5:44 PM, Martin Tiršel  >
> >> wrote:
> >> > Hello,
> >> >
> >> > I have a formset and some JavaScript to add more forms into this
> >> > formset. In
> >> > a view, I iterate through the formset saving (not a ModelForm just 
> Form
> >> > with
> >> > save method) each form:
> >> >
> >> > for form in formset:
> >> > form.save()
> >> >
> >> > But I want to ignore empty forms that were added by JavasScript and 
> not
> >> > removed. How can I do this?
> >> >
> >> > Thanks,
> >> > Martin
> >> >
> >>
> >> You don't show much of your code, but I presume you have called
> >> formset.is_valid() at this point?
> >>
> >> If so, this pattern is pretty canonical:
> >>
> >> if formset.is_valid():
> >> for form in formset:
> >> if form.is_valid() and not form.empty_permitted:
> >> form.save()
> >>
> >> Extra forms in a formset are all instantiated with empty_permitted=True.
> >>
> >> There are other things to be aware of though. This logic will not take
> >> into account deleted forms etc, which is why there is a
> >> BaseModelFormSet with the right behaviour baked into it's save()
> >> method.
> >>
> >> Cheers
> >>
> >> Tom
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msg/django-users/-/aKliGdMNqGwJ.
> >
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
>

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