Re: Django mysite problem

2011-09-14 Thread Yves S. Garret
Is Python in your path?

On Wed, Sep 14, 2011 at 10:01 PM, PremAnand Lakshmanan
wrote:

> I have a problem executing this command,
>
>  C:\Python27\Lib\site-packages\django\bin\django-admin.py startproject
> mysite2
>
> SyntaxError: invalid syntax
>
> I get the above error..
>
> --
> Prem
>
> --
> 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 mysite problem

2011-09-14 Thread Kejun He
Maybe reinstall django would resolve this problem

On Thu, Sep 15, 2011 at 10:01 AM, PremAnand Lakshmanan
wrote:

> I have a problem executing this command,
>
>  C:\Python27\Lib\site-packages\django\bin\django-admin.py startproject
> mysite2
>
> SyntaxError: invalid syntax
>
> I get the above error..
>
> --
> Prem
>
> --
> 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.



Django mysite problem

2011-09-14 Thread PremAnand Lakshmanan
I have a problem executing this command,

 C:\Python27\Lib\site-packages\django\bin\django-admin.py startproject
mysite2

SyntaxError: invalid syntax

I get the above error..

-- 
Prem

-- 
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: Https with runserver

2011-09-14 Thread Gelonida N
On 09/15/2011 01:44 AM, Russell Keith-Magee wrote:
> 2011/9/14 Simon Bächler :
>> Any news considering HTTPS and runserver?
> 
> What "News" are you expecting?
> 
> The Django project has made no secret of the fact that we don't
> consider runserver to be a "real" webserver. It isn't intended for
> production use. We haven't spent any time or effort auditing it for
> production use. It is missing many key features that a "real"
> webserver needs to have.
> 
> runserver is intended to be the bare minimum necessary to support
> local development. If you have nontrivial needs, you should be looking
> at alternative options for local development.
> 
> Yours,
> Russ Magee %-)
> 
You can also create a minimalist https server with python twisted
(and the openssl module)

You just need  additional url rules, such, that django is also serving
/static amd /media directories:


just set PYTHONPATH
and
DJANGO_SETTINGS_MODULE
as needed,

create a file named django_wrapper.py with following contents:
#  File starts here ##
from django.core.handlers.wsgi import WSGIHandler

application=WSGIHandler()
#  end of file #

and call then

twistd -n web --https $HTTPS_PORT -p $HTTP_PORT \
--certificate yourcert.crt --privkey your_cert.key \
--wsgi django_wrapper.application





-- 
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: Https with runserver

2011-09-14 Thread Aljoša Mohorović
if you need to simulate https for development, like for facebook apps,
you can setup apache proxy.
something like:



ProxyPass / http://localhost:8000/ retry=1
ProxyPassReverse / http://localhost:8000/
ProxyPreserveHost On

ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined

SSLEngine on
SSLCertificateFile/etc/ssl/certificate.crt
SSLCertificateKeyFile /etc/ssl/example.com.key
SSLCertificateChainFile /etc/ssl/intermediate.crt
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
# MSIE 7 and newer should be able to use keepalive
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown



-- 
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: Https with runserver

2011-09-14 Thread Russell Keith-Magee
2011/9/14 Simon Bächler :
> Any news considering HTTPS and runserver?

What "News" are you expecting?

The Django project has made no secret of the fact that we don't
consider runserver to be a "real" webserver. It isn't intended for
production use. We haven't spent any time or effort auditing it for
production use. It is missing many key features that a "real"
webserver needs to have.

runserver is intended to be the bare minimum necessary to support
local development. If you have nontrivial needs, you should be looking
at alternative options for local development.

Yours,
Russ Magee %-)

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



nested forms from model with manytomany

2011-09-14 Thread Visgean
Hello  I have these two models:

class SubOrder(models.Model):
"""
This is model for single order
it should be used later in complex order
"""

product = models.ForeignKey(Product)
quantity = models.SmallIntegerField()

class Order(models.Model):
"Model for complex order containing many SubOrder instances"

customer = models.CharField(max_length = 20)
day = models.DateField(auto_now = True)
paid  = models.BooleanField(default = False)
delivered = models.BooleanField(default = False)

sub_orders = models.ManyToManyField(SubOrder)

selled_by = models.ForeignKey(User)

The problem is that I want to do views for adding Order model with
possibility to add as many SubOrders as user wants. Currently I solve
this by reading  POST data... ( code:
https://github.com/A3soft/Lisculea/blob/master/Lisculea/Cafe/views.py#L24
and 
https://github.com/A3soft/Lisculea/blob/master/Lisculea/Templates/cafe/order_new.djhtml
)

The problem is that I want users to be able to add SubOrders to Order
object using formset.

So I need to add/select subOrder from the same views as Order, I also
need to display Order formset and be able to edit/add suborders later.
And all SubOrders as their full widget -and not only as selection for
instance.


So, do you have any ideas how to do this without avoiding a lot of
coding - i mean using django forms and formsets?

-- 
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: Admin - delete with removing FK objects

2011-09-14 Thread galgal
I made what I wanted using signals:)
All works now. I use post delete to be sure that object is deleted, than I 
remove images.

-- 
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/-/EcDKuOgfY-oJ.
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: PostGIS version error

2011-09-14 Thread Lucian Nicolescu
Make sure you run step 2.5 here on the current database before running
syncdb: http://postgis.refractions.net/docs/ch02.html#id2619431
Did you do that?

Lucian

On Wed, Sep 14, 2011 at 11:39 PM, Dan H  wrote:

> I am getting the following error:
>
> django.core.exceptions.ImproperlyConfigured: Cannot determine PostGIS
> version for database "dbname". GeoDjango requires at least PostGIS
> version 1.3. Was the database created from a spatial database
> template?
>
> when i try to run: python manage.py syncdb
>
> and when i navigate to /usr/lib/postgis i see that i have version 1.4
> installed. What am I missing?
>
> Does anyone know a good tutorial on setting up GeoDjango? It has been
> nothing but error after error for me
>
> --
> 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.



PostGIS version error

2011-09-14 Thread Dan H
I am getting the following error:

django.core.exceptions.ImproperlyConfigured: Cannot determine PostGIS
version for database "dbname". GeoDjango requires at least PostGIS
version 1.3. Was the database created from a spatial database
template?

when i try to run: python manage.py syncdb

and when i navigate to /usr/lib/postgis i see that i have version 1.4
installed. What am I missing?

Does anyone know a good tutorial on setting up GeoDjango? It has been
nothing but error after error for me

-- 
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: newbie question on activating the automatic admin

2011-09-14 Thread nara
Finally! The admin interface worked, when I used the dev version
in a virtualenv. I cleaned every trace of Django in my system,
and I had to compile (requires python-dev package in
Ubuntu) and install MySQLdb into the virtualenv.

Not sure what exactly was wrong before, but Babatunde's suggestion
that I had mixed up code installed (some in system files, and also
mixed Django1.3 and the dev release) seems like the best guess.

Thanks for everyone's help ;)
Nara

On Sep 11, 10:44 pm, Babatunde Akinyanmi  wrote:
> And reply here if you don't see problems :)
>
> On 9/12/11, nara  wrote:
>
>
>
>
>
>
>
>
>
> > ok, i am planning to remove all traces of all django installations
> > from my
> > system, and re-install the dev version (and if that still does not
> > work 3.1)
> > under virtualenv.
>
> > Will repost here if I still see problems.
>
> > Nara
>
> > On Sep 10, 7:16 pm, Babatunde Akinyanmi  wrote:
> >> Hi nara,
> >> Please post the debug output you get when you try to view the admin
> >> page from your browser.
>
> >> Meanwhile, while switching versions of django, you have to make sure
> >> you remove completely every file from the old version. Failure to do
> >> that will break django.
>
> >> On 9/10/11, nara  wrote:
>
> >> > ok, I switched to the 1.3.1 released version of Django, and
> >> > also tried Python2.6 instead of Python2.7 on the dev version
> >> > of Django. Things are still majorly broken, see the following
> >> > in the django shell on a fresh startproject, I could not
> >> > import even the top level django module. Then,
> >> > I set PYTHONPATH to /home/nara/Django1.3/django,
> >> > and after that, in the shell, I am still unable to
> >> > directly import the admin module, I have to do this:
>
> >>  import django
> >>  import django.contrib
> >>  import django.contrib.admin
>
> >> > So, the problem is not just in the admin module, it
> >> > is likely all over the place (entire django module hierarchy).
>
> >> > Oh well, looks like I have to cool this off for a while.
>
> >> > Thanks for everyone's help.
> >> > Nara
>
> >> > On Sep 10, 2:17 pm, nara  wrote:
> >> >> I'll get through this yet :)
>
> >> >> I tried the commands you have under the django shell, and I got
> >> >> 'example.com'
> >> >> on the django.Site query, and not an error. Also, interestingly,
> >> >> within the shell, I don't see
> >> >> django on the sys.path at all (shown below), but I do see my project
> >> >> mblog. This could
> >> >> be the cause of not seeing the admin. I could switch to python 2.6
> >> >> instead
> >> >> of python 2.7, but I doubt that that is going fix this issue. Dropping
> >> >> my project
> >> >> table and doing a new syncdb did not help either.
>
> >> >> Here is the path, prettified:
>
> >> >> ['/home/nara/dj/mblog'
> >> >>  '/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg'
> >> >>  '/usr/local/lib/python2.7/dist-packages/grin-1.2.1-py2.7.egg'
> >> >>  '/usr/local/lib/python2.7/dist-packages/pip-1.0.2-py2.7.egg'
> >> >>  '/usr/lib/python2.7'
> >> >>  '/usr/lib/python2.7/plat-linux2'
> >> >>  '/usr/lib/python2.7/lib-tk'
> >> >>  '/usr/lib/python2.7/lib-old'
> >> >>  '/usr/lib/python2.7/lib-dynload'
> >> >>  '/usr/local/lib/python2.7/dist-packages'
> >> >>  '/usr/lib/python2.7/dist-packages'
> >> >>  '/usr/lib/python2.7/dist-packages/PIL'
> >> >>  '/usr/lib/pymodules/python2.7/gtk-2.0'
> >> >>  '/usr/lib/python2.7/dist-packages/gst-0.10'
> >> >>  '/usr/lib/python2.7/dist-packages/gtk-2.0'
> >> >>  '/usr/lib/pymodules/python2.7'
> >> >>  '/usr/lib/pymodules/python2.7/ubuntuone-control-panel'
> >> >>  '/usr/lib/pymodules/python2.7/libubuntuone'
> >> >>  '/usr/lib/pymodules/python2.7/ubuntuone-storage-protocol'
> >> >>  '/usr/lib/pymodules/python2.7/ubuntuone-client']
>
> >> >> Thanks
> >> >> Nara
>
> >> >> On Sep 9, 9:56 pm, Babatunde Akinyanmi  wrote:
>
> >> >> > Hi nara,
> >> >> > This error is normally thrown when the sites app is being used in a
> >> >> > django project. I think it can also occur if the sites tables in the
> >> >> > database is not properly created during django-admin startproject.
> >> >> > Someone else reported that he was able to solve the problem by using
> >> >> > a
> >> >> > user name without special characters.
>
> >> >> > This might be difficult to debug since you are using a development
> >> >> > version however:
> >> >> > 1. Go to the inbuilt django shell and enter these commands:
> >> >> > from django.contrib.sites.models import Site
> >> >> > From django.conf import settings
> >> >> > x = settings.SITE_ID
> >> >> > Site.objects.get(pk=x)
>
> >> >> > You should get the same "site matching query does not exist" error.
> >> >> > Now print x and then check the django_site_table in your database. x
> >> >> > should be the same as the primary key of what you have in the table.
> >> >> > If it isn't, drop the table and syncdb again.
>
> >> >> > On 9/10/11, nara  wrote:
>
> >> >> > > yes, admin is in INSTALLED_APPS. BTW, the basic site wo

Image upload / embedding

2011-09-14 Thread Petey
I have an application which is designed for publishing blog posts etc.

I upload images but normally they are at the end of the text because they 
are uploaded after I save the entry, that means I cant embedd them directly 
inside the text.

Is there any way I can add new images directly inside the text? (Something 
like link generator or image pre-uploader)

-- 
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/-/oJtgBRRpY9sJ.
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: Caching/Reload problem - cannot refresh model data

2011-09-14 Thread Ilian Iliev
Hi Tom,

I checked the link you send and probably you are right but
can you explain why this is a bad solution?
Yes using autocommit() or disabling transactions seems more right
are there any downsides of the update() that you are seeing?
Image a case when you want to update the result set without breaking the
transaction(is this possible)?

I am not trolling just asking?

Regards,
Ilian Iliev

-- 
eng. Ilian Iliev
Web Software Developer

Mobile: +359 88 66 08 400
Website: http://ilian.i-n-i.org

On Wed, Sep 14, 2011 at 2:34 PM, Tom Evans  wrote:

> On Wed, Sep 14, 2011 at 8:12 AM, Ilian Iliev  wrote:
> > How are you pulling the data from the database in the desktop app - using
> > pure SQL or using the ORM?
> >
> > If using the ORM it is possible it to cache the results of the database
> so
> > you can run:
> >
> > mymodel.objects.update()
> >
> > This should clear the cache.
> >
>
> Clear 'the cache' - as the side effect of performing a zero row update
> on your model!
>
> I wouldn't do that. The issue the user is hitting is that he is still
> within his original transaction - there is no caching going on. Read
> the documentation on managing transactions:
>
> https://docs.djangoproject.com/en/1.3/topics/db/transactions/
>
> In particular, how to completely disable transaction management, which
> you would probably want to do on the desktop app, and manage them
> manually if you need transactions.
>
>
> https://docs.djangoproject.com/en/1.3/topics/db/transactions/#how-to-globally-deactivate-transaction-management
>
> 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.
>
>

-- 
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: Class-based views or "Traditional" Views for Django 1.3?

2011-09-14 Thread PFL

Reinout van Rees has posted several articles on using Django class
based views that you might find useful  (posted Aug 23/24 2011 ):

http://reinout.vanrees.org/weblog/2011/08/24/class-based-views-walkthrough.html

-- 
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: SCGI error

2011-09-14 Thread Andre Terra
On Wed, Sep 14, 2011 at 6:10 AM, Tom Evans  wrote:

I'm not entirely experienced with scgi or uWSGI, but I'm almost
> certain that neither of them talk HTTP, which is what Firefox uses to
> talk to servers. You need to connect your WSGI/SCGI server to a HTTP
> server like Apache, lighttpd, Cherokee or similar. (...)
>

Don't forget nginx!


Cheers,
AT

-- 
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: Class-based views or "Traditional" Views for Django 1.3?

2011-09-14 Thread Kurtis Mullins
Thanks for the input from both of you! And Donald, I think I'll take you up
on that offer. I'd really like to learn them. Hopefully down the line, when
this initial project is out the door and I have solid understanding of the
CBV's, I'll be able to contribute a little to the documentation as well.

 Agreed, and fwiw both you Kurtis, and anyone else can feel free to ping me
> directly in #django if they need help getting the hang of CBV's, if i'm
> around (which I am most the day typically) I'll be more then happy to help.
>
> OTOH, getting the hang of it can be hard with the current state of the docs
> and given that they require a completely different mindset when coding
> views.
>
>  Class Based Views let you override and subclass views to modify their
> behavior, I find them to be very quick once you get the hang of them.
>
>

-- 
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: Class-based views or "Traditional" Views for Django 1.3?

2011-09-14 Thread Donald Stufft
 Agreed, and fwiw both you Kurtis, and anyone else can feel free to ping me 
directly in #django if they need help getting the hang of CBV's, if i'm around 
(which I am most the day typically) I'll be more then happy to help. 


On Wednesday, September 14, 2011 at 9:54 AM, Andre Terra wrote:

> OTOH, getting the hang of it can be hard with the current state of the docs 
> and given that they require a completely different mindset when coding views.
> 
> 
> Cheers,
> AT
> 
> On Wed, Sep 14, 2011 at 10:35 AM, Donald Stufft  (mailto:donald.stu...@gmail.com)> wrote:
> >  Class Based Views let you override and subclass views to modify their 
> > behavior, I find them to be very quick once you get the hang of them. 
> > 
> > On Wednesday, September 14, 2011 at 9:33 AM, Kurtis wrote:
> > 
> > > Hey Guys,
> > > 
> > > I'm relatively new to Django 1.3. As others have noticed, there is
> > > less documentation around the Class-Based views than typical for
> > > Django. No needs for apologies as I have seen in other threads. I
> > >  don't blame others for my lack of knowledge :)
> > > 
> > > If I am working on a large project from scratch, would it be smart to
> > > just use the traditional, function/method-based views? Or should I go
> > > ahead and try to adapt the class-based views? I am working on a
> > >  deadline so the amount of time burnt searching more in-depth for my
> > > answers could be a problem. On the other hand, if there are any
> > > advantages to using Class-based views, I may want to take advantage of
> > > them. Unfortunately, I don't know enough about the Class-based views
> > >  to really weigh that out on my own. Any information regarding this
> > > decision would be greatly appreciated.
> > > 
> > > Thanks!
> > > -Kurtis Mullins
> > > 
> > > -- 
> > > 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 
> > > (mailto:django-users@googlegroups.com).
> > > To unsubscribe from this group, send email to 
> > > django-users+unsubscr...@googlegroups.com 
> > > (mailto: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 
> > (mailto:django-users@googlegroups.com).
> >  To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com 
> > (mailto:django-users%2bunsubscr...@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 
> (mailto:django-users@googlegroups.com).
>  To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com 
> (mailto: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: Class-based views or "Traditional" Views for Django 1.3?

2011-09-14 Thread Andre Terra
OTOH, getting the hang of it can be hard with the current state of the docs
and given that they require a completely different mindset when coding
views.


Cheers,
AT

On Wed, Sep 14, 2011 at 10:35 AM, Donald Stufft wrote:

>  Class Based Views let you override and subclass views to modify their
> behavior, I find them to be very quick once you get the hang of them.
>
> On Wednesday, September 14, 2011 at 9:33 AM, Kurtis wrote:
>
> Hey Guys,
>
> I'm relatively new to Django 1.3. As others have noticed, there is
> less documentation around the Class-Based views than typical for
> Django. No needs for apologies as I have seen in other threads. I
> don't blame others for my lack of knowledge :)
>
> If I am working on a large project from scratch, would it be smart to
> just use the traditional, function/method-based views? Or should I go
> ahead and try to adapt the class-based views? I am working on a
> deadline so the amount of time burnt searching more in-depth for my
> answers could be a problem. On the other hand, if there are any
> advantages to using Class-based views, I may want to take advantage of
> them. Unfortunately, I don't know enough about the Class-based views
> to really weigh that out on my own. Any information regarding this
> decision would be greatly appreciated.
>
> Thanks!
> -Kurtis Mullins
>
> --
> 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: Class-based views or "Traditional" Views for Django 1.3?

2011-09-14 Thread Donald Stufft
 Class Based Views let you override and subclass views to modify their 
behavior, I find them to be very quick once you get the hang of them. 


On Wednesday, September 14, 2011 at 9:33 AM, Kurtis wrote:

> Hey Guys,
> 
> I'm relatively new to Django 1.3. As others have noticed, there is
> less documentation around the Class-Based views than typical for
> Django. No needs for apologies as I have seen in other threads. I
> don't blame others for my lack of knowledge :)
> 
> If I am working on a large project from scratch, would it be smart to
> just use the traditional, function/method-based views? Or should I go
> ahead and try to adapt the class-based views? I am working on a
> deadline so the amount of time burnt searching more in-depth for my
> answers could be a problem. On the other hand, if there are any
> advantages to using Class-based views, I may want to take advantage of
> them. Unfortunately, I don't know enough about the Class-based views
> to really weigh that out on my own. Any information regarding this
> decision would be greatly appreciated.
> 
> Thanks!
> -Kurtis Mullins
> 
> -- 
> 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 
> (mailto:django-users@googlegroups.com).
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com 
> (mailto: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.



Class-based views or "Traditional" Views for Django 1.3?

2011-09-14 Thread Kurtis
Hey Guys,

I'm relatively new to Django 1.3. As others have noticed, there is
less documentation around the Class-Based views than typical for
Django. No needs for apologies as I have seen in other threads. I
don't blame others for my lack of knowledge :)

If I am working on a large project from scratch, would it be smart to
just use the traditional, function/method-based views? Or should I go
ahead and try to adapt the class-based views? I am working on a
deadline so the amount of time burnt searching more in-depth for my
answers could be a problem. On the other hand, if there are any
advantages to using Class-based views, I may want to take advantage of
them. Unfortunately, I don't know enough about the Class-based views
to really weigh that out on my own. Any information regarding this
decision would be greatly appreciated.

Thanks!
-Kurtis Mullins

-- 
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: order by + group by

2011-09-14 Thread Jani Tiainen

14.9.2011 12:46, Jonas H. kirjoitti:

On 09/14/2011 11:37 AM, Иван Иванов wrote:

The problem here is, like Peter said, that you cannot order before
grouping. And that's very annoying.


Of course you can, using a subselect just like I showed. SQLite example:

 > .schema
CREATE TABLE a (name varchar, mod int);

e> select * from a;
b1|1
b1|2
b1|3

 > select * from a group by name;
b1|3

 > select * from (select * from a order by mod desc) group by name;
b1|1



Problem is that is not standard SQL.

In standard implemetation group by _requires_ aggregation function that 
is applied to groups so you won't be able to get "last" that way.


It might work non-standard way in some implementations. And thus Django 
usually follows standard or smallest common nominator for db backends 
such a thing is not possible to support.


--

Jani Tiainen

--
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: refreshing a page loaded via POST

2011-09-14 Thread Jacob Kaplan-Moss
On Wed, Sep 14, 2011 at 2:12 AM, mohammed safeer.mtp
 wrote:
> if a user hits “Refresh” on a page that was loaded via POST, that request is
> be repeated.
> is there any remedy for this problem??

No, you can't prevent a web browser from re-POSTing forms.

What you can do is prevent the browser from ever staying on a
POST-generated page: the standard best practice is a technique called
"Post/Redirect/Get": see
http://en.wikipedia.org/wiki/Post/Redirect/Get for a high-level
description.

In Django, this translates to view functions that look like::

from django.shortcuts import redirect, render

def my_post_view(request):
if request.method == 'POST'
# do something here...
return redirect('some_other_view')
else:
# the request was a GET, so render a template:
return render(request, 'some/template.html')

The key part here to get is that you should always issue a redirect
after a successful POST request.

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.



Https with runserver

2011-09-14 Thread Simon Bächler
Any news considering HTTPS and runserver?

I tried the stunnel method but I get the message: Line 5: End of
section https: SSL server needs a certificate.
Stunnel also complains about the openssl version. I have 0.9.8r
installed. The build of 1.0 fails on OSX.

When I then try to access the page I get the error: (Fehlercode:
ssl_error_rx_record_too_long).

I need the https connection for local Facebook development.

Regards
Simon

-- 
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: setting the database when using a rawqueryset

2011-09-14 Thread Andre Terra
And I apologize for not even saying yours, Robert!


Yours,
André


On Wed, Sep 14, 2011 at 9:32 AM, Andre Terra  wrote:

> Take a look at the aggregation docs at http://django.me/aggregation for
> sum, group by, etc.
>
>
> Cheers,
> AT
>
>
> On Tue, Sep 13, 2011 at 7:44 PM, Robert  wrote:
>
>>
>> I apologize for using AT rather than your name, Andre.
>>
>> On Sep 13, 6:42 pm, Robert  wrote:
>> > Thanks, AT.  Actually this is the article where I learned how to do
>> > raw SQL in Django. It made life easy for complex queries.
>> > Unfortunately it does not specify how to dynamically set the database
>> > for the RawQuerySet.  I am hoping there is an easy way to do it so I
>> > can avoid a complete rewrite.  The alternative is to figure out how to
>> > do what I think are complex queries (includes subqueries, group by,
>> > having, sum commands) using the ORM QuerySet.
>> >
>> > On Sep 13, 5:01 pm, Andre Terra  wrote:
>> >
>> >
>> >
>> > > Not exactly what you want, buthttps://
>> docs.djangoproject.com/en/dev/topics/db/sql/#executing-custom...
>> >
>> > > Cheers,
>> > > AT
>> >
>> > > On Tue, Sep 13, 2011 at 5:51 PM, Robert  wrote:
>> >
>> > > > I have inherited the support of a Django application and am new to
>> the
>> > > > language so I would appreciate some advice.  The application
>> requires
>> > > > getting data from different databases depending on the client.
>> >
>> > > > The existing code uses the syntax:  > > > > table>.objects.using(self.CLIENT_DB).get to connect to the correct
>> > > > databse.
>> >
>> > > > However, I have some queries that are so complex I have had to use
>> the
>> > > > rawqueryset with SQL commands such as "for record in > > > > table>.objects.raw() . . .".  Apparently "using" is
>> > > > not an available attribute of the rawqueryset.  What is the best way
>> > > > to dynamically change databases when using a rawqueryset?
>> >
>> > > > Thanks for your guidance.
>> >
>> > > > --
>> > > > 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.-Hide quoted text
>> -
>> >
>> > > - Show quoted text -- Hide quoted text -
>> >
>> > - Show quoted text -
>>
>> --
>> 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: Use of threading.local() ... what is the risk?

2011-09-14 Thread Russell Keith-Magee
On Sun, Sep 11, 2011 at 7:40 AM, Micah Carrick  wrote:
> I have
> read https://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser and
> numerous other discussions about the use of threading.local() yet I still
> see it being employed in various projects.
> I have recently implemented a referral system in which the use of
> threading.local() makes the app very portable and very simple as I can
> simply use the post_save signal (which cannot access the session). What I'm
> doing...
> 1. When a user first gets to the site, middleware stores the referral ID
> found in the URL and puts it into a session variable.
> 2. The session variable is copied to a threading.local() variable on every
> request.
> 3. A handler for the post_save on the User model checks this
> threading.local() variable, finds the User the referral code belongs to, and
> associates the referral user with the referred user in referral model. This
> handler also creates the referral code for the new user.
> I like this approach because there is no need to think about the referral
> system in the views, forms, or models of the auth system. I haven't deployed
> this because of the big threading.local() warnings.
> So this referral code is the only thing vulnerable here. This code is a
> uniquely generated code which is associated with a User. What risks does
> this pose and why?

The biggest reason to avoid the use of threadlocals is a very simple
architectural one: It doesn't matter how you rename it to make it more
palatable; a threadlocal is a global variable. Global variables
increase coupling, decrease cohesion, and make it harder to test a
system. For this reason alone, threadlocals should be avoided.

Aside from the basic engineering risk of building a system based on
global variables, there is also a potential risk associated with data
leakage. If you're building a system using global variables, you're
making yourself vulnerable to situations where you put data in a
location where it can be seen across threads. If this happens, you've
just opened a big security hole in your app, because a user on one
thread can observe the state of another user.

Now, I will admit that it's entirely possible to use threadlocals in a
completely "safe" manner, without any data leakage. The extent to
which this is a problem in practice depends entirely on exactly what
you're doing, and how you do it.

At the end of the day, it comes down to this: If you don't use global
state, the data leakage problem *can't* exist, and you get easier to
test code as a bonus. If you *do* use global state, leakage problems
*might* exist, you need to be vigilant to ensure that they don't, and
your code is harder to test anyway.

For my money, avoiding threadlocals is a no-brainer.

Yours,
Russ Magee %-)

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



Re: setting the database when using a rawqueryset

2011-09-14 Thread Andre Terra
Take a look at the aggregation docs at http://django.me/aggregation for sum,
group by, etc.


Cheers,
AT

On Tue, Sep 13, 2011 at 7:44 PM, Robert  wrote:

>
> I apologize for using AT rather than your name, Andre.
>
> On Sep 13, 6:42 pm, Robert  wrote:
> > Thanks, AT.  Actually this is the article where I learned how to do
> > raw SQL in Django. It made life easy for complex queries.
> > Unfortunately it does not specify how to dynamically set the database
> > for the RawQuerySet.  I am hoping there is an easy way to do it so I
> > can avoid a complete rewrite.  The alternative is to figure out how to
> > do what I think are complex queries (includes subqueries, group by,
> > having, sum commands) using the ORM QuerySet.
> >
> > On Sep 13, 5:01 pm, Andre Terra  wrote:
> >
> >
> >
> > > Not exactly what you want, buthttps://
> docs.djangoproject.com/en/dev/topics/db/sql/#executing-custom...
> >
> > > Cheers,
> > > AT
> >
> > > On Tue, Sep 13, 2011 at 5:51 PM, Robert  wrote:
> >
> > > > I have inherited the support of a Django application and am new to
> the
> > > > language so I would appreciate some advice.  The application requires
> > > > getting data from different databases depending on the client.
> >
> > > > The existing code uses the syntax:   > > > table>.objects.using(self.CLIENT_DB).get to connect to the correct
> > > > databse.
> >
> > > > However, I have some queries that are so complex I have had to use
> the
> > > > rawqueryset with SQL commands such as "for record in  > > > table>.objects.raw() . . .".  Apparently "using" is
> > > > not an available attribute of the rawqueryset.  What is the best way
> > > > to dynamically change databases when using a rawqueryset?
> >
> > > > Thanks for your guidance.
> >
> > > > --
> > > > 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.-Hide quoted text -
> >
> > > - Show quoted text -- Hide quoted text -
> >
> > - Show quoted text -
>
> --
> 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: refreshing a page loaded via POST

2011-09-14 Thread Micah Carrick
After you successfully process a POST request, you can use a redirect to
send the user back to the orginal page.

On Wed, Sep 14, 2011 at 4:24 AM, Tom Evans  wrote:

> On Wed, Sep 14, 2011 at 8:12 AM, mohammed safeer.mtp
>  wrote:
> > if a user hits “Refresh” on a page that was loaded via POST, that request
> is
> > be repeated.
> > is there any remedy for this problem??
> >
>
> Yes, don't load the page via POST.
>
> POST requests are meant to be used for data modifying requests, which
> is why all user agents prompt you whether you really want to resubmit
> the request. GET requests are not meant to be used for data modifying
> requests, which is why they don't prompt you.
>
> 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.
>
>

-- 
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: Caching/Reload problem - cannot refresh model data

2011-09-14 Thread Tom Evans
On Wed, Sep 14, 2011 at 8:12 AM, Ilian Iliev  wrote:
> How are you pulling the data from the database in the desktop app - using
> pure SQL or using the ORM?
>
> If using the ORM it is possible it to cache the results of the database so
> you can run:
>
> mymodel.objects.update()
>
> This should clear the cache.
>

Clear 'the cache' - as the side effect of performing a zero row update
on your model!

I wouldn't do that. The issue the user is hitting is that he is still
within his original transaction - there is no caching going on. Read
the documentation on managing transactions:

https://docs.djangoproject.com/en/1.3/topics/db/transactions/

In particular, how to completely disable transaction management, which
you would probably want to do on the desktop app, and manage them
manually if you need transactions.

https://docs.djangoproject.com/en/1.3/topics/db/transactions/#how-to-globally-deactivate-transaction-management

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: refreshing a page loaded via POST

2011-09-14 Thread Tom Evans
On Wed, Sep 14, 2011 at 8:12 AM, mohammed safeer.mtp
 wrote:
> if a user hits “Refresh” on a page that was loaded via POST, that request is
> be repeated.
> is there any remedy for this problem??
>

Yes, don't load the page via POST.

POST requests are meant to be used for data modifying requests, which
is why all user agents prompt you whether you really want to resubmit
the request. GET requests are not meant to be used for data modifying
requests, which is why they don't prompt you.

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.



refreshing a page loaded via POST

2011-09-14 Thread mohammed safeer.mtp
if a user hits “Refresh” on a page that was loaded via POST, that request is
be repeated.
is there any remedy for this problem??

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: order by + group by

2011-09-14 Thread Jonas H.

On 09/14/2011 11:37 AM, Иван Иванов wrote:

The problem here is, like Peter said, that you cannot order before
grouping. And that's very annoying.


Of course you can, using a subselect just like I showed. SQLite example:

> .schema
CREATE TABLE a (name varchar, mod int);

e> select * from a;
b1|1
b1|2
b1|3

> select * from a group by name;
b1|3

> select * from (select * from a order by mod desc) group by name;
b1|1

--
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 relation content_type does not exist

2011-09-14 Thread Bastian Ballmann

Hi again,

maybe I get an answer if I ask the other way round.

I've got an inline admin model with a generic foreignkey and I want to 
validate a set of it's properties in the models clean() method. If I add 
a new model neither content_type nor object_id is set in the clean() 
method, but if I try to change an existing model of course I can access 
the content_type property.


Is there any work-around to get the content_type when I first add a new 
model?


Any hint or url is appreciated :)
TIA && greets

Basti

--
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: order by + group by

2011-09-14 Thread Иван Иванов
На Wed, 14 Sep 2011 10:59:01 +0200
"Jonas H."  написа:

> On 09/14/2011 04:35 AM, Peter of the Norse wrote:
> > What are you trying to do? The outer GROUP BY destroys the inner
> > ORDER BY. Try putting them on the same level and see what happens.
> 
> Say I've got an Event table and some records like this
> 
>name: foo, timestamp: 9 pm
>name: foo, timestamp: 10pm
>name: bar, timestamp: 3pm
> 
> I want the latest event for every `name`:
> 
>name: foo, timestamp: 10pm
>name: bar, timestamp: 3pm
> 
> On PostgreSQL one could use DISTINCT ON but it's not yet supported by 
> Django, either.


I've done something like this on MySQL before several weeks. 

The problem here is, like Peter said, that you cannot order before
grouping. And that's very annoying.

I haven't found a way to do it without raw sql. Here is my approach:


cursor = connection.cursor()
cursor.execute("CREATE TEMPORARY TABLE `tmp` LIKE `your_table_name`;")
cursor.execute("ALTER TABLE `tmp` ADD UNIQUE KEY `uniq_name` (`name`);")
cursor.execute("INSERT IGNORE INTO `tmp` (SELECT * FROM `your_table_name` 
WHERE time<=%s ORDER BY `time` DESC);", [mydate])
transaction.commit_unless_managed()
cursor.execute("SELECT name, time FROM tmp;")
result = cursor.fetchall()

Explained:
First we create temporary table, which copies the structure of your table, 
where you've got the timestamps.
Then we add unique key, which is the column, you want to group by.
Then you make an insert ignore statement with nested select, 
where you make your ordering by timestamp.
Here I've got where clause too, where I want only theese rows, 
before specified time. I don't know if you need it.

And at the end you just select all rows from the tmp table, and they are all 
rows you actually need.

In Django, every request is new sql connection, so you don't need to worry 
about the livetime of the tmp table.

That's it.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: SCGI error

2011-09-14 Thread David Markey
Correct,

You need a webserver in front of manage.py runfcgi, which understands the
protocol.

To talk to django directly with your browser use manage.py runserver




On 14 September 2011 10:10, Tom Evans  wrote:

> On Sat, Sep 10, 2011 at 9:05 PM, Brian Myers 
> wrote:
> > It seems I am getting an error from the WSGI server after all. As a
> reminder, my uwsgi process is started from upstart like this:
> >
> > exec python /var/www/NurseTriage/triagedb/manage.py runfcgi protocol=scgi
> method=threaded host=127.0.0.1 port = 3033
> >
> > When I use Firefox to browse to 127.0.0.1:3033, I get this error
> message:
> >
> > XML Parsing Error: undefined entity
> > Location:
> jar:file:///usr/lib/firefox-3.6.21/chrome/toolkit.jar!/content/global/netError.xhtml
> > Line Number 60, Column 12:&loadError.label;
> > ---^
> >
> > Any ideas what this means? I get the same error with uWSGI. Is this a
> Firefox error?
> >
> > Thanx,
> >
> > Brian
> >
>
> I'm not entirely experienced with scgi or uWSGI, but I'm almost
> certain that neither of them talk HTTP, which is what Firefox uses to
> talk to servers. You need to connect your WSGI/SCGI server to a HTTP
> server like Apache, lighttpd, Cherokee or similar. See the extensive
> docs:
>
> https://docs.djangoproject.com/en/1.3/howto/deployment/modwsgi/
> https://docs.djangoproject.com/en/1.3/howto/deployment/fastcgi/
>
> 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.
>
>

-- 
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: SCGI error

2011-09-14 Thread Tom Evans
On Sat, Sep 10, 2011 at 9:05 PM, Brian Myers  wrote:
> It seems I am getting an error from the WSGI server after all. As a reminder, 
> my uwsgi process is started from upstart like this:
>
> exec python /var/www/NurseTriage/triagedb/manage.py runfcgi protocol=scgi 
> method=threaded host=127.0.0.1 port = 3033
>
> When I use Firefox to browse to 127.0.0.1:3033, I get this error message:
>
> XML Parsing Error: undefined entity
> Location: 
> jar:file:///usr/lib/firefox-3.6.21/chrome/toolkit.jar!/content/global/netError.xhtml
> Line Number 60, Column 12:    &loadError.label;
> ---^
>
> Any ideas what this means? I get the same error with uWSGI. Is this a Firefox 
> error?
>
> Thanx,
>
> Brian
>

I'm not entirely experienced with scgi or uWSGI, but I'm almost
certain that neither of them talk HTTP, which is what Firefox uses to
talk to servers. You need to connect your WSGI/SCGI server to a HTTP
server like Apache, lighttpd, Cherokee or similar. See the extensive
docs:

https://docs.djangoproject.com/en/1.3/howto/deployment/modwsgi/
https://docs.djangoproject.com/en/1.3/howto/deployment/fastcgi/

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: Is there a way to provide a delete-hook on a custom field?

2011-09-14 Thread Иван Иванов
It's a bit offtopic, but:

There is a project for non relational Django, and they have released
backend for django and mongoDB. It might be interesting for you, if you
don't know about the project:
http://www.allbuttonspressed.com/blog/django/2010/05/MongoDB-backend-for-Django-nonrel-released

На Tue, 13 Sep 2011 10:40:38 -0600
Jeff Heard  написа:

> I have a custom field class that very nicely references a document in
> MongoDB, but I would like to have the document deleted if the record
> is deleted.  That is, I have a MongoDBField that stores an object ID
> in a structured database using the regular Django ORM.  The field
> back-references to the record's primary key, so I can use NoSQL
> lookups and SQL lookups interchangeably to find the same record, even,
> which is quite nice.  However right now, Ihave to write a custom
> delete() function for every model that uses it.  I'd like to have
> something in the field that whenever the model instance's delete()
> function is called. Perhaps the best thing is just to have a class
> HybridModel(Model) and have all models that use both databases inherit
> from that?
> 
> -- Jeff
> 

-- 
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: order by + group by

2011-09-14 Thread Jonas H.

On 09/14/2011 04:35 AM, Peter of the Norse wrote:

What are you trying to do? The outer GROUP BY destroys the inner ORDER BY. Try 
putting them on the same level and see what happens.


Say I've got an Event table and some records like this

  name: foo, timestamp: 9 pm
  name: foo, timestamp: 10pm
  name: bar, timestamp: 3pm

I want the latest event for every `name`:

  name: foo, timestamp: 10pm
  name: bar, timestamp: 3pm

On PostgreSQL one could use DISTINCT ON but it's not yet supported by 
Django, either.


--

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

--
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: Caching/Reload problem - cannot refresh model data

2011-09-14 Thread puppriss
Brilliant - that does the trick! Many thanks Ilian. A very simple solution 
yet I trawled the documentation and never came across it. Must've been 
looking in the wrong place. Yes, I'm using the ORM... and occasionally raw 
SQL for the app.

Cheers
Phil

-- 
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/-/1xWzPAXAjVEJ.
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: Caching/Reload problem - cannot refresh model data

2011-09-14 Thread Ilian Iliev
How are you pulling the data from the database in the desktop app - using
pure SQL or using the ORM?

If using the ORM it is possible it to cache the results of the database so
you can run:

mymodel.objects.update()

This should clear the cache.

-- 
eng. Ilian Iliev
Web Software Developer

Mobile: +359 88 66 08 400
Website: http://ilian.i-n-i.org


On Tue, Sep 13, 2011 at 9:00 AM, puppriss  wrote:

> Greetings All,
>
> Now, you may think me a bit of an asshat for doing it this way, but
>
> I have a MySQL db backend, DJANGO admin, and a self-coded desktop
> application ('InsectApp') written in Python. The 2 apps, DJANGO-Admin &
> InsectApp, both use the same 'settings' file and access the same data (I
> coded InsectApp so it would use the DJANGO database API because I thought it
> would make life easier!).
>
> The problem: is that there are now 2 ways of entering data, one via either
> app. For example, I'm in InsectApp and have imported model 'species'
> (InsectApp.models.speices) - meanwhile I add a new 'species' record via the
> Admin. On returning to InsectApp, I cannot access the new record unless I
> exit and restart the app. I have tried reloading InsectApp.models but it
> doesn't work.
>
> I'm assuming it's something to do with caching the data on first import of
> model 'species', but I have no CACHES in my settings.py. In any case both
> apps use the same settings.py.
>
> Can anyone explain and/or help me? Is there even a way of doing it?
> Thanks in advance
>
> p.s. I need the Admin site because we need certain database info, eg
> species taxonomy, to be updated remotely by taxonomists. The InsectApp is
> for rapid entering of large amounts of data wihtin our local network, which
> would be too clunky using the Admin alone. Hence the 2 apps
>
> --
> 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/-/eSnLEH5uZBkJ.
> 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.