Problem with static in Django 1.5 virtualenv

2013-08-01 Thread Jairo Alonso Velásquez
Hi community, I posted a problem here:

http://stackoverflow.com/questions/18005574/django-1-5-get-404-on-static-files

I will do it again here if somebody can help me:

I need a little help with this, I've been searching for a solution with no 
results.

This are my settings: settings.py:

STATIC_ROOT = ''
# URL prefix for static files.# Example: "http://media.lawrence.com/static/";

STATIC_URL = '/static/'

PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))

STATICFILES_DIRS = (
PROJECT_ROOT + '/static/')

Installed apps:

INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin', . . .

Running with DEBUG = TRUE:

August 01, 2013 - 16:59:44Django version 1.5.1, using settings 
'settings'Development server is running at http://127.0.0.1:8000/Quit the 
server with CONTROL-C.[01/Aug/2013 16:59:50] "GET / HTTP/1.1" 200 
6161[01/Aug/2013 16:59:50] "GET 
/static/media/css/jquery-ui/ui-lightness/jquery-ui-1.10.3.custom.min.css 
HTTP/1.1" 404 5904[01/Aug/2013 16:59:50] "GET 
/static/media/css/bootstrap/bootstrap.css HTTP/1.1" 404 5904[01/Aug/2013 
16:59:50] "GET /static/media/css/bootstrap/bootstrap-responsive.min.css 
HTTP/1.1" 404 5904[01/Aug/2013 16:59:50] "GET /static/media/css/styles.css 
HTTP/1.1" 404 5904[01/Aug/2013 16:59:50] "GET 
/static/media/js/jquery/jquery-1.9.1.min.js HTTP/1.1" 404 5904[01/Aug/2013 
16:59:50] "GET /static/media/js/bootstrap/bootstrap.min.js HTTP/1.1" 404 
5904[01/Aug/2013 16:59:50] "GET 
/static/media/js/jquery-ui/jquery-ui-1.10.3.custom.min.js HTTP/1.1" 404 
5904[01/Aug/2013 16:59:50] "GET /static/media/js/messages.js HTTP/1.1" 404 
5904[01/Aug/2013 16:59:50] "GET 
/static/media/js/validate/jquery.validate.min.js HTTP/1.1" 404 5904[01/Aug/2013 
16:59:50] "GET /static/media/images/FERREMOLQUES2.png HTTP/1.1" 404 
5904[01/Aug/2013 16:59:50] "GET /static/media/js/dynamic-style.js HTTP/1.1" 404 
5904

As a special mention I'm running Django 1.5.1 and Python 2.7.5 in a *
VIRTUALENV*. I do not know if this configuration is causing the problem

Any help would be appreciate

Thanks.

*EDIT: When I off VIRTUALENV and install proper version of Django and the 
project's dependencies, My project works well, without any issue. . . 
statics are shown as it should*


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Django App - Accessing Remote MySQL Database

2013-08-01 Thread Ji Park
Hello, I'm trying to make an app that can periodically access a remote 
mysql database.

This app will query the remote database and copy some data to the local 
postgresql database.

So far I know that celery can be used to schedule periodic tasks, but I'm 
not sure what to do about querying the remote mysql database server.

Should I just use python's MySQLdb module, does anyone know any other 
python module that I can use to query mysql db?

Would this even be a good way to access remote database server from a 
django app? I'll have to be running a function that is within tasks.py 
periodically (via celery-django), would there be any better way to access 
remote mysql server from a django app in this case?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Integrate django app with EBS payment gateway

2013-08-01 Thread Russell Keith-Magee
On Thu, Aug 1, 2013 at 9:18 PM, steve jobs
wrote:

> I am using django and designed a website, and now i got to implement
> payment gateway functionality.
>
> Actually how to integrate a django app with payment gateways ?
> Whether there are any packages already available to get an idea because i
> am completely
> new in implementing this ?
> Particularly i want to integrate my app with EBS payment gateway, so can
> anyone point me
> in a right direction like
>
> 1. what needs to be done in order to integrate a `django web app with
> payment gateway` ?
>

Broadly: you make HTTP requests on specific URLs, providing data in a
documented format, and you set up views to handle responses.

However, the specifics are going to vary widely depending on the payment
gateway you choose to use.

2. Whether there is any code already available to save time and extend it ?
> 3. If possible please point me to some code examples that explains the
> integration of `django`
>app with `payment gateways`


Your best starting point is going to be:

https://www.djangopackages.com/grids/g/payment-processing/

A Google search for "django payment gateway" or "django " will also reveal a lot of help.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Importing project URLs without a database

2013-08-01 Thread Jon Dufresne
On Thu, Aug 1, 2013 at 2:38 PM, Phil  wrote:

> Could you post the entire content of your script? There is no way those 2
> lines (and the necessary "os" import) can cause this error.
>
>
>
You are right. I investigated much deeper. Turns out this is what I did.

1. Script imported root URL conf
2. Through an URL include, many other URL confs were imported
3. Many URL confs import CBVs from views.py
4. These views.py may import models or import modules that import models
5. At some point a queryset was evaluated during an import

In this particular case, it was a choices field on a form. I have since
changed this to use ModelMultipleChoiceField.

I guess I'll need to be really careful to not evaluate a queryset or stop
using CBV (to avoid the imports). Seems a bit fragile.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Importing project URLs without a database

2013-08-01 Thread Phil
Could you post the entire content of your script? There is no way those 2 
lines (and the necessary "os" import) can cause this error.

Regards,
Phil

On Thursday, August 1, 2013 5:39:46 PM UTC-3, Jon Dufresne wrote:
>
> Hi,
>
> I am trying to write a script that outputs information about all URLs in 
> the project. The script should be able to do this without having a database 
> populated or even created.
>
> Right now the script gets to the following line:
>
> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
> from project import urls
>
> However, this raises an exception _mysql_exceptions.OperationalError: 
> (1049, "Unknown database 'project'").
>
> It appears that Django is trying to connect to the database, but all I 
> want to do is analyze the URLs. Is this possible?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Importing project URLs without a database

2013-08-01 Thread Jon Dufresne
Hi,

I am trying to write a script that outputs information about all URLs in
the project. The script should be able to do this without having a database
populated or even created.

Right now the script gets to the following line:

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
from project import urls

However, this raises an exception _mysql_exceptions.OperationalError:
(1049, "Unknown database 'project'").

It appears that Django is trying to connect to the database, but all I want
to do is analyze the URLs. Is this possible?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django Signal DataBase Change on Template

2013-08-01 Thread carlos
Hi if you need create app for real time try this app can help you
https://github.com/stephenmcd/django-socketio
or find other app https://www.djangopackages.com/grids/g/websockets/

Cheers


On Thu, Aug 1, 2013 at 10:59 AM,  wrote:

> Hi,
>
> Flot is your friend. Http://flotgraphs.org
>
>
>
>
> Sent from my iPhone
>
> On Aug 1, 2013, at 10:54 AM, Saif Jerbi  wrote:
>
> I'm building a GPS Tracking System using Django, i should have a grid on
> my template that display real time information of cars (position,vitesse,
> temperature...). GPS send data to Postgres DataBase via a module that parse
> Data and saved it in specific table. What i need is how to make my Web App
> display data in real time? (when a row is inserted in Db, how can i display
> it in grid)
>
> i tried this package https://pypi.python.org/pypi/django-db-signals/0.1.1,
> but my DataParser is external from my django web app, it work independently
> from other side
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Ordering a queryset on a reverse foreign key's attribute

2013-08-01 Thread Daniele Procida
On Thu, Aug 1, 2013, Simon Charette  wrote:

>>From a quick look I'd also expect `order_by('-children__date')` to work.
>
>Can you provide the generated SQL query and some results?

I have in fact raised a ticket about this 
 which shows the generated sequel 
and describes the issue in more detail.

Maybe this is just a limitation of the ORM and should be noted more clearly in 
the documentation, or maybe it's behaviour that could be improved.

Daniele

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django Signal DataBase Change on Template

2013-08-01 Thread acheraime
Hi,

Flot is your friend. Http://flotgraphs.org




Sent from my iPhone

On Aug 1, 2013, at 10:54 AM, Saif Jerbi  wrote:

> I'm building a GPS Tracking System using Django, i should have a grid on my 
> template that display real time information of cars (position,vitesse, 
> temperature...). GPS send data to Postgres DataBase via a module that parse 
> Data and saved it in specific table. What i need is how to make my Web App 
> display data in real time? (when a row is inserted in Db, how can i display 
> it in grid)
> 
> i tried this package https://pypi.python.org/pypi/django-db-signals/0.1.1, 
> but my DataParser is external from my django web app, it work independently 
> from other side
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Upgrading to 1.5 on Centos

2013-08-01 Thread Bill Freeman
Move at least your settings.py into a new sub-directory named for the
project (as with new projects in 1.4 or 1.5 -- you might make one if you
haven't just to look at the directory structure), and add an __init__.py to
that directory.

You may need to (probably should) move your top level urls.py there as well.

You may also need a wsgi.py file there (again, look at a newly made 1.5
project).

Additionally, if you have any app directories as siblings to your (original
location of) manage.py, and you are refering to them prefixed by your
project name, you will either need to fix all the references
(INSTALLED_APPS, when one module imports another) to not include the
project name, or you will need to move those apps into the new
subdirectory.  (This is because the top directory is no longer a loaded
package relative to which you can import, though it is still on sys.path,
so you can import things in it *without* using the project name.  There was
a lot of clever fiddling in pre 1.4 to get that package imported.)


On Thu, Aug 1, 2013 at 11:43 AM, Larry Martell wrote:

> On Thu, Aug 1, 2013 at 9:27 AM, Tom Evans 
> wrote:
> > On Thu, Aug 1, 2013 at 4:10 PM, Larry Martell 
> wrote:
> >> Thanks very much Tom. This explains a lot - we were using the 1.3
> >> manage file with 1.4. I'm very close now, but I'm not sure what to put
> >> in for project_name - my project is called 'motor'. I tried
> >> motor.settings, but I got 'could not import motor.settings: No module
> >> named motor.settings'. I tried just 'settings' and that made manage
> >> happy, but then it could not import any of my installed apps (which
> >> all start with motor.).
> >
> > This is all covered by the same link I gave you earlier. You may need
> > to restructure your project and/or adjust what you import your apps
> > as.
>
> OK, I see. Moving manage.py one dir level up makes it all work, but
> that dir is not part of our project structure and not under version
> control. If I leave it where it is I have to change a lot of
> references that start with 'motor.' - not just the few in settings,
> but all over the place. I guess I'm going to go with the latter and
> make it part of the install procedure to copy manage. Ugh.
>
> Thanks!
> -larry
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: SESSION_COOKIE_DOMAIN on multiple domains.

2013-08-01 Thread J. Cliff Dyer
Thanks so much!  That's very helpful.

On Thursday, August 1, 2013 11:46:27 AM UTC-4, Tomáš Ehrlich wrote:
>
> Ah, sorry, I understand now. 
>
> You can set up middleware, which modifies SESSION_COOKIE_DOMAIN based 
> on request.get_host() and put it before session middleware. I did 
> similar thing to set SITE_ID. 
>
> Only think you have to take care of is thread safety. You need to 
> override settings.SESSION_COOKIE_DOMAIN value with thread safe object, 
> and assign value to it. 
>
> Take a look at: 
>
> https://bitbucket.org/uysrc/django-dynamicsites/src/e3c6cad807f0328ed3020d28158b3d6ba0b67025/dynamicsites/middleware.py?at=default
>  
>
> https://bitbucket.org/uysrc/django-dynamicsites/src/e3c6cad807f0328ed3020d28158b3d6ba0b67025/dynamicsites/utils.py?at=default
>  
>
> I took that idea there. 
>
>
> Cheers, 
>   Tom 
>
> Dne Thu, 1 Aug 2013 08:40:18 -0700 (PDT) 
> "J. Cliff Dyer" > napsal(a): 
>
> > That doesn't make my use case impossible.  I'm not looking for a session 
> > that works on both domains.  I'm looking for a site that can create 
> > sessions for either domain. 
> > 
> > On Thursday, August 1, 2013 11:10:59 AM UTC-4, Tomáš Ehrlich wrote: 
> > > 
> > > This isn't possible. The problem is with cookies: You have to bind 
> them 
> > > to certain domain ('example.com') or set of subdomains ('.example.com'). 
>
> > > 
> > > About a month ago I've created app to bypass this limitation: 
> > > 
> > > - There is one "master" domain, where new session keys are created. 
> > > - When user access any of "slave" sites, his browser has to go through 
> > >   several redirects: 
> > > 
> > >   1. First, it's redirected to "master" site. There he gets token 
> > >  representing current session key. 
> > >   2. Then it's redirected back to "slave" site, where django sets 
> > >  appropriate cookie with session key (extracted from token). 
> > >   3. After then, it's redirected back to original page (on slave 
> site). 
> > >  Session cookie is set so user can access the same session as on 
> > >  master site. 
> > > 
> > > - Cookie needs to be set only once. When session (on any site) is 
> > >   invalid, the other sites will notice that and automatically 
> generates 
> > >   new session key. 
> > > 
> > > Another solution I've seen was distributing session key through 
> > > iframes, but when you have lot of domains, it's easier to do it this 
> > > way. 
> > > 
> > > I could share the code, if you were interested. It isn't published 
> > > anywhere yet. 
> > > 
> > > 
> > > Cheers, 
> > >   Tom 
> > > 
> > > Dne Thu, 1 Aug 2013 06:41:20 -0700 (PDT) 
> > > "J. Cliff Dyer" > napsal(a): 
> > > 
> > > > Is there a way to set the SESSION_COOKIE_DOMAIN for multiple 
> domains, 
> > > > possibly using the contrib.sites framework? 
> > > > 
> > > > We deploy on AWS, and when we roll out an update to one of our site, 
> we 
> > > > first create a new cloudformation stack, and attach a domain name to 
> it 
> > > > like prod-oursite-20130801.devstacks.net. 
> > > > 
> > > > When we decide it's ready for production, we point www.oursite.comto 
> > > the 
> > > > stack.  This causes problems with the SESSION_COOKIE_DOMAIN, as we 
> need 
> > > to 
> > > > have the cookies domain set to .oursite.com if someone is visiting 
> from 
> > > > www.oursite.com (or fl.oursite.com, or wa.oursite.com, etc, etc.), 
> but 
> > > if 
> > > > they are visiting from prod-oursite-20130801.devstacks.net, we want 
> to 
> > > > either set the SESSION_COOKIE_DOMAIN to 
> > > > prod-oursite-20130801.devstacks.net, or unset it altogether, and 
> just 
> > > use 
> > > > the default session domain. 
> > > > 
> > > > I would love if SESSION_COOKIE_DOMAIN could be set to a dictionary, 
> like 
> > > > this: 
> > > > 
> > > > SESSION_COOKIE_DOMAIN = { 
> > > > 'www.oursite.com': '.oursite.com', 
> > > > 'prod-oursite-20130801.devstacks.net': '.devstacks.net', 
> > > > } 
> > > > 
> > > > but it doesn't seem like that's possible. 
> > > > 
> > > > 
> > > 
> > 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django Signal DataBase Change on Template

2013-08-01 Thread Bill Freeman
A lot of JavaScript is involved in doing this.  I see three possible
approaches:

1. Use a timer in JavaScript to cause the page to reload itself
frequently.  This isn't pretty.  The page will glitch as it reloads.  You
will be reloading the whole page each time, which includes much that the
browser already has.  There is a trade off between update latency and
useless request rate.  If your GPS updates come in at a dependable rate you
can make a good guess for polling rate.

Don't do this.

The only advantage that it has is that it will work with a browser that
doesn't support AJAX (read very old browser).

The Django code is easy.  No signals are required.  ORM does a fetch for
current coordinates for each request.  If you have lots of users you will
will have lots of database traffic, as well as lots of web traffic.  You
can reduce the database overhead by caching the current set of coordinates
in RAM (and maybe not use the database at all, if you don't need to keep
historical records.  If  you do use RAM, beware of threading issues on this
shared data.

2.  Use a time in JavaScript to trigger frequent AJAX requests for data
which has changed since the last data sent.

An outline is to have the server include a timestamp when it does send
data.  The request includes the timestamp, and if the server has no new
information, it sends an empty response (should be as cheap as a 304
response, but changing the response code is easy, and is arguably more
correct, but may or may not be harder on the JavaScript side).

Should work on all modern browsers.

The Django code is still easy.  In order to use RAM cache and still just
send what has changed, you will need to annotate each unit's position with
a timestamp (and it still wants to be the server timestamp, not the GPS
time of the sample) so that the view code can search for those newer than
the request's indicated time.  Think even harder about threading issues,
though I'm still pretty sure that I could do this without locks.

3.  Use a PUSH technique (see below).  The browser maintains a long
duration connection to the server.  When new data comes in, the server
distributes it to all connected browsers.  The chunk gets sent over the
connection to each browser, but the connection remains open for the next
data.  No timer is needed in JavaScript unless you want to indicate that
you haven't gotten data for a given unit in too long a time.

The downside is that you must support many simultaneous connections.  Any
of the OS, the front end (if used, e.g. Apache, nginx), or Django/python
could be a limiting factor here.  (I'm pretty sure that mod_wsgi can't
support WebSockets at all, at least at the moment.)  Otherwise the burden
on the server is very low, and latency is minimal.

The best, in my opinion, PUSH technique is WebSockets.  Since it part of
HTML5, it is probably here to stay, and even the usual suspect software
vender may implement (at least a usable sub-set) in the standard fashion.
Recent Firefox, Chrome, and, I believe, IE, and probably some others,
already support it.  All browsers will likely support it soon.  The
original technique was called COMET, but had some cross browser issues.
Another technique is called long poll.  If you really need wide browser
support now, look at the sockjs scheme.  A JavaScript library uses
WebSockets if available, but transparently falls back to older techniques
in preference order, and can even fall back to periodic polling (like
option 2).

At last fall's DjangoconUS there was talk of push for Django, but I don't
know where it has gotten.  If Django isn't there yet, and especially if
you're willing to insist on WebSockets capable browsers, you might consider
tornado, which supports WebSockets out of the box, instead of Django.  I'm
using tornado and WebSockets in a rather similar application.  (I'd be
happy to hear of progress in Django on the PUSH front.)

Bill




On Thu, Aug 1, 2013 at 10:54 AM, Saif Jerbi  wrote:

> I'm building a GPS Tracking System using Django, i should have a grid on
> my template that display real time information of cars (position,vitesse,
> temperature...). GPS send data to Postgres DataBase via a module that parse
> Data and saved it in specific table. What i need is how to make my Web App
> display data in real time? (when a row is inserted in Db, how can i display
> it in grid)
>
> i tried this package https://pypi.python.org/pypi/django-db-signals/0.1.1,
> but my DataParser is external from my django web app, it work independently
> from other side
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Re: SESSION_COOKIE_DOMAIN on multiple domains.

2013-08-01 Thread Tomas Ehrlich
Ah, sorry, I understand now.

You can set up middleware, which modifies SESSION_COOKIE_DOMAIN based
on request.get_host() and put it before session middleware. I did
similar thing to set SITE_ID.

Only think you have to take care of is thread safety. You need to
override settings.SESSION_COOKIE_DOMAIN value with thread safe object,
and assign value to it.

Take a look at:
https://bitbucket.org/uysrc/django-dynamicsites/src/e3c6cad807f0328ed3020d28158b3d6ba0b67025/dynamicsites/middleware.py?at=default
https://bitbucket.org/uysrc/django-dynamicsites/src/e3c6cad807f0328ed3020d28158b3d6ba0b67025/dynamicsites/utils.py?at=default

I took that idea there.


Cheers,
  Tom

Dne Thu, 1 Aug 2013 08:40:18 -0700 (PDT)
"J. Cliff Dyer"  napsal(a):

> That doesn't make my use case impossible.  I'm not looking for a session 
> that works on both domains.  I'm looking for a site that can create 
> sessions for either domain.
> 
> On Thursday, August 1, 2013 11:10:59 AM UTC-4, Tomáš Ehrlich wrote:
> >
> > This isn't possible. The problem is with cookies: You have to bind them 
> > to certain domain ('example.com') or set of subdomains ('.example.com'). 
> >
> > About a month ago I've created app to bypass this limitation: 
> >
> > - There is one "master" domain, where new session keys are created. 
> > - When user access any of "slave" sites, his browser has to go through 
> >   several redirects: 
> > 
> >   1. First, it's redirected to "master" site. There he gets token 
> >  representing current session key. 
> >   2. Then it's redirected back to "slave" site, where django sets 
> >  appropriate cookie with session key (extracted from token). 
> >   3. After then, it's redirected back to original page (on slave site). 
> >  Session cookie is set so user can access the same session as on 
> >  master site. 
> >
> > - Cookie needs to be set only once. When session (on any site) is 
> >   invalid, the other sites will notice that and automatically generates 
> >   new session key. 
> >
> > Another solution I've seen was distributing session key through 
> > iframes, but when you have lot of domains, it's easier to do it this 
> > way. 
> >
> > I could share the code, if you were interested. It isn't published 
> > anywhere yet. 
> >
> >
> > Cheers, 
> >   Tom 
> >
> > Dne Thu, 1 Aug 2013 06:41:20 -0700 (PDT) 
> > "J. Cliff Dyer" > napsal(a): 
> >
> > > Is there a way to set the SESSION_COOKIE_DOMAIN for multiple domains, 
> > > possibly using the contrib.sites framework? 
> > > 
> > > We deploy on AWS, and when we roll out an update to one of our site, we 
> > > first create a new cloudformation stack, and attach a domain name to it 
> > > like prod-oursite-20130801.devstacks.net. 
> > > 
> > > When we decide it's ready for production, we point www.oursite.com to 
> > the 
> > > stack.  This causes problems with the SESSION_COOKIE_DOMAIN, as we need 
> > to 
> > > have the cookies domain set to .oursite.com if someone is visiting from 
> > > www.oursite.com (or fl.oursite.com, or wa.oursite.com, etc, etc.), but 
> > if 
> > > they are visiting from prod-oursite-20130801.devstacks.net, we want to 
> > > either set the SESSION_COOKIE_DOMAIN to 
> > > prod-oursite-20130801.devstacks.net, or unset it altogether, and just 
> > use 
> > > the default session domain. 
> > > 
> > > I would love if SESSION_COOKIE_DOMAIN could be set to a dictionary, like 
> > > this: 
> > > 
> > > SESSION_COOKIE_DOMAIN = { 
> > > 'www.oursite.com': '.oursite.com', 
> > > 'prod-oursite-20130801.devstacks.net': '.devstacks.net', 
> > > } 
> > > 
> > > but it doesn't seem like that's possible. 
> > > 
> > > 
> >
> 


signature.asc
Description: PGP signature


Re: Upgrading to 1.5 on Centos

2013-08-01 Thread Larry Martell
On Thu, Aug 1, 2013 at 9:27 AM, Tom Evans  wrote:
> On Thu, Aug 1, 2013 at 4:10 PM, Larry Martell  wrote:
>> Thanks very much Tom. This explains a lot - we were using the 1.3
>> manage file with 1.4. I'm very close now, but I'm not sure what to put
>> in for project_name - my project is called 'motor'. I tried
>> motor.settings, but I got 'could not import motor.settings: No module
>> named motor.settings'. I tried just 'settings' and that made manage
>> happy, but then it could not import any of my installed apps (which
>> all start with motor.).
>
> This is all covered by the same link I gave you earlier. You may need
> to restructure your project and/or adjust what you import your apps
> as.

OK, I see. Moving manage.py one dir level up makes it all work, but
that dir is not part of our project structure and not under version
control. If I leave it where it is I have to change a lot of
references that start with 'motor.' - not just the few in settings,
but all over the place. I guess I'm going to go with the latter and
make it part of the install procedure to copy manage. Ugh.

Thanks!
-larry

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: SESSION_COOKIE_DOMAIN on multiple domains.

2013-08-01 Thread J. Cliff Dyer
That doesn't make my use case impossible.  I'm not looking for a session 
that works on both domains.  I'm looking for a site that can create 
sessions for either domain.

On Thursday, August 1, 2013 11:10:59 AM UTC-4, Tomáš Ehrlich wrote:
>
> This isn't possible. The problem is with cookies: You have to bind them 
> to certain domain ('example.com') or set of subdomains ('.example.com'). 
>
> About a month ago I've created app to bypass this limitation: 
>
> - There is one "master" domain, where new session keys are created. 
> - When user access any of "slave" sites, his browser has to go through 
>   several redirects: 
> 
>   1. First, it's redirected to "master" site. There he gets token 
>  representing current session key. 
>   2. Then it's redirected back to "slave" site, where django sets 
>  appropriate cookie with session key (extracted from token). 
>   3. After then, it's redirected back to original page (on slave site). 
>  Session cookie is set so user can access the same session as on 
>  master site. 
>
> - Cookie needs to be set only once. When session (on any site) is 
>   invalid, the other sites will notice that and automatically generates 
>   new session key. 
>
> Another solution I've seen was distributing session key through 
> iframes, but when you have lot of domains, it's easier to do it this 
> way. 
>
> I could share the code, if you were interested. It isn't published 
> anywhere yet. 
>
>
> Cheers, 
>   Tom 
>
> Dne Thu, 1 Aug 2013 06:41:20 -0700 (PDT) 
> "J. Cliff Dyer" > napsal(a): 
>
> > Is there a way to set the SESSION_COOKIE_DOMAIN for multiple domains, 
> > possibly using the contrib.sites framework? 
> > 
> > We deploy on AWS, and when we roll out an update to one of our site, we 
> > first create a new cloudformation stack, and attach a domain name to it 
> > like prod-oursite-20130801.devstacks.net. 
> > 
> > When we decide it's ready for production, we point www.oursite.com to 
> the 
> > stack.  This causes problems with the SESSION_COOKIE_DOMAIN, as we need 
> to 
> > have the cookies domain set to .oursite.com if someone is visiting from 
> > www.oursite.com (or fl.oursite.com, or wa.oursite.com, etc, etc.), but 
> if 
> > they are visiting from prod-oursite-20130801.devstacks.net, we want to 
> > either set the SESSION_COOKIE_DOMAIN to 
> > prod-oursite-20130801.devstacks.net, or unset it altogether, and just 
> use 
> > the default session domain. 
> > 
> > I would love if SESSION_COOKIE_DOMAIN could be set to a dictionary, like 
> > this: 
> > 
> > SESSION_COOKIE_DOMAIN = { 
> > 'www.oursite.com': '.oursite.com', 
> > 'prod-oursite-20130801.devstacks.net': '.devstacks.net', 
> > } 
> > 
> > but it doesn't seem like that's possible. 
> > 
> > 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Ordering a queryset on a reverse foreign key's attribute

2013-08-01 Thread Simon Charette
>From a quick look I'd also expect `order_by('-children__date')` to work.

Can you provide the generated SQL query and some results?

Le jeudi 1 août 2013 09:58:25 UTC-4, Daniele Procida a écrit :
>
> I have an Event model: 
>
> class Event(Model): 
> parent = models.ForeignKey('self', related_name='children') 
> date = models.DateField() 
>
> My question is: given a queryset of this model, how can I order it based 
> on the Events' children's dates so that (say) Events with child Events with 
> more recent dates are first? 
>
> (I thought that 
>
> .order_by('-children__date') 
>
> might be a start, but in fact that seems to do something very odd to the 
> items in the list, which I am looking at separately). 
>
> Thanks, 
>
> Daniele 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django Signal DataBase Change on Template

2013-08-01 Thread C. Kirby
You are describing a push mechanism, ie. the server pushes new data to the 
client when it becomes available. That is basically untenable in a standard 
web server/client paradigm, and django explicitly is built for 
request/response pairs.

That said, you can initiate the updates from the client.

The easiest way would to set up client polling, using an ajax call on the 
client side to fetch new/updated data.

You would do something like:

while(true){

setTimeout(function() {
//Put ajax call here, that fetched data and on success updates the DOM with 
the new data}, 3000);//This would trigger every three seconds, tailor to your 
needs.

}


Depending on how many clients you are expecting to serve and how often you set 
the poll this has the potential to seriously tax your server.


On Thursday, August 1, 2013 9:54:58 AM UTC-5, Saif Jerbi wrote:
>
> I'm building a GPS Tracking System using Django, i should have a grid on 
> my template that display real time information of cars (position,vitesse, 
> temperature...). GPS send data to Postgres DataBase via a module that parse 
> Data and saved it in specific table. What i need is how to make my Web App 
> display data in real time? (when a row is inserted in Db, how can i display 
> it in grid)
>
> i tried this package https://pypi.python.org/pypi/django-db-signals/0.1.1, 
> but my DataParser is external from my django web app, it work independently 
> from other side
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Upgrading to 1.5 on Centos

2013-08-01 Thread Tom Evans
On Thu, Aug 1, 2013 at 4:10 PM, Larry Martell  wrote:
> Thanks very much Tom. This explains a lot - we were using the 1.3
> manage file with 1.4. I'm very close now, but I'm not sure what to put
> in for project_name - my project is called 'motor'. I tried
> motor.settings, but I got 'could not import motor.settings: No module
> named motor.settings'. I tried just 'settings' and that made manage
> happy, but then it could not import any of my installed apps (which
> all start with motor.).

This is all covered by the same link I gave you earlier. You may need
to restructure your project and/or adjust what you import your apps
as.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: SESSION_COOKIE_DOMAIN on multiple domains.

2013-08-01 Thread Tomas Ehrlich
This isn't possible. The problem is with cookies: You have to bind them
to certain domain ('example.com') or set of subdomains ('.example.com').

About a month ago I've created app to bypass this limitation:

- There is one "master" domain, where new session keys are created.
- When user access any of "slave" sites, his browser has to go through
  several redirects:
   
  1. First, it's redirected to "master" site. There he gets token
 representing current session key.
  2. Then it's redirected back to "slave" site, where django sets
 appropriate cookie with session key (extracted from token).
  3. After then, it's redirected back to original page (on slave site).
 Session cookie is set so user can access the same session as on
 master site.

- Cookie needs to be set only once. When session (on any site) is
  invalid, the other sites will notice that and automatically generates
  new session key.

Another solution I've seen was distributing session key through
iframes, but when you have lot of domains, it's easier to do it this
way.

I could share the code, if you were interested. It isn't published
anywhere yet.


Cheers,
  Tom

Dne Thu, 1 Aug 2013 06:41:20 -0700 (PDT)
"J. Cliff Dyer"  napsal(a):

> Is there a way to set the SESSION_COOKIE_DOMAIN for multiple domains, 
> possibly using the contrib.sites framework?
> 
> We deploy on AWS, and when we roll out an update to one of our site, we 
> first create a new cloudformation stack, and attach a domain name to it 
> like prod-oursite-20130801.devstacks.net.
> 
> When we decide it's ready for production, we point www.oursite.com to the 
> stack.  This causes problems with the SESSION_COOKIE_DOMAIN, as we need to 
> have the cookies domain set to .oursite.com if someone is visiting from 
> www.oursite.com (or fl.oursite.com, or wa.oursite.com, etc, etc.), but if 
> they are visiting from prod-oursite-20130801.devstacks.net, we want to 
> either set the SESSION_COOKIE_DOMAIN to 
> prod-oursite-20130801.devstacks.net, or unset it altogether, and just use 
> the default session domain.
> 
> I would love if SESSION_COOKIE_DOMAIN could be set to a dictionary, like 
> this:
> 
> SESSION_COOKIE_DOMAIN = {
> 'www.oursite.com': '.oursite.com',
> 'prod-oursite-20130801.devstacks.net': '.devstacks.net',
> }
> 
> but it doesn't seem like that's possible.
> 
> 


signature.asc
Description: PGP signature


Re: Upgrading to 1.5 on Centos

2013-08-01 Thread Larry Martell
On Thu, Aug 1, 2013 at 8:41 AM, Tom Evans  wrote:
> On Thu, Aug 1, 2013 at 3:17 PM, Larry Martell  wrote:
>> On Thu, Aug 1, 2013 at 2:30 AM, Branko Majic  wrote:
>>> On Wed, 31 Jul 2013 17:59:56 -0600
>>> Larry Martell  wrote:
>>>
 On my Mac, running python 2.7, I upgraded from 1.4 to 1.5 by doing this:

 rm -rf /Library/Python/2.7/site-packages/django

 Followed by python setup.py install in the dir I untar-ed Django-1.5.1
 to. This all worked fine.


 On a Centos system running python 2.6 I did:

 rm -rf /usr/lib/python2.6/site-packages/django followed by the
 setup.py install. My django app is working, and appears to be running
 1.5, however anytime I use manage.py (for collectstatic or syncdb or
 test, for example) I get these messages:

 /usr/lib/python2.6/site-packages/django/core/management/__init__.py:465:
 DeprecationWarning: The 'execute_manager' function is deprecated, you
 likely need to update your 'manage.py'; please see the Django 1.4
 release notes (https://docs.djangoproject.com/en/dev/releases/1.4/).
   DeprecationWarning)
 /usr/lib/python2.6/site-packages/django/core/management/__init__.py:409:
 DeprecationWarning: The 'setup_environ' function is deprecated, you
 likely need to update your 'manage.py'; please see the Django 1.4
 release notes (https://docs.djangoproject.com/en/dev/releases/1.4/).
   DeprecationWarning)

 So it seems I still have some 1.4 stuff around. I don't get this on my
 Mac. How can I get rid of these messages?

>>>
>>> How are you running management commands? Using the ./manage.py from the
>>> project? In that case you probably just need to replace the manage.py
>>> with a newer version (from Django 1.5).
>>
>> Yes, I'm running manage from the project. I copied in the new 1.5
>> manage and now I'm getting this:
>>
>> Traceback (most recent call last):
>>   File "manage.py", line 10, in 
>> execute_from_command_line(sys.argv)
>>   File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py",
>> line 453, in execute_from_command_line
>> utility.execute()
>>   File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py",
>> line 392, in execute
>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>   File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py",
>> line 263, in fetch_command
>> app_name = get_commands()[subcommand]
>>   File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py",
>> line 109, in get_commands
>> apps = settings.INSTALLED_APPS
>>   File "/usr/lib/python2.6/site-packages/django/conf/__init__.py",
>> line 53, in __getattr__
>> self._setup(name)
>>   File "/usr/lib/python2.6/site-packages/django/conf/__init__.py",
>> line 48, in _setup
>> self._wrapped = Settings(settings_module)
>>   File "/usr/lib/python2.6/site-packages/django/conf/__init__.py",
>> line 134, in __init__
>> raise ImportError("Could not import settings '%s' (Is it on
>> sys.path?): %s" % (self.SETTINGS_MODULE, e))
>> ImportError: Could not import settings '{{ project_name }}.settings'
>> (Is it on sys.path?): No module named {{ project_name }}.settings
>>
>> There is a settings.py file in the dir I an running from. The actual
>> error is coming here"
>>
>> (Pdb) l
>> 104 _commands = dict([(name, 'django.core') for name in
>> find_commands(__path__[0])])
>> 105
>> 106 # Find the installed apps
>> 107 from django.conf import settings
>> 108 try:
>> 109 B-> apps = settings.INSTALLED_APPS
>> 110 except ImproperlyConfigured:
>> 111 # Still useful for commands that do not require
>> functional settings,
>> 112 # like startproject or help
>> 113 apps = []
>> 114
>> (Pdb) print settings.INSTALLED_APPS
>> *** ImportError: Could not import settings '{{ project_name
>> }}.settings' (Is it on sys.path?): No module named {{ project_name
>> }}.settings
>
> You've copied the template of manage.py. This template is usually
> filled in by django-admin.py when you create a new project, so two
> options, run django-admin.py to create a filled in template of
> manage.py, copy manage.py into place and remove the new stub project
> from which it came, or fill in the template manually.
>
> This was covered in the release notes for 1.4, which is when it
> changed (1.5 stopped working with manage.py from 1.3, where as 1.4
> would work with a manage.py from 1.3.)
>
> https://docs.djangoproject.com/en/1.5/releases/1.4/#updated-default-project-layout-and-manage-py

Thanks very much Tom. This explains a lot - we were using the 1.3
manage file with 1.4. I'm very close now, but I'm not sure what to put
in for project_name - my project is called 'motor'. I tried
motor.settings, but I got 'could not import motor.settings: No module
named motor.settings'. I tried just 'settings' a

Re: How template tag can receive values JS

2013-08-01 Thread Bill Freeman
If this is only to be done when loading a new page, then you could add the
JS var value to the request as a query parameter.  Then the view would have
to pass the value to the template for the new page.


On Thu, Aug 1, 2013 at 9:51 AM, Christian Erhardt <
christian.erha...@mojo2k.de> wrote:

> No, what you are trying is not possible. The template tags are rendered on
> the server. They never appear on the client machine. Javascript is running
> on the client machine. They both will never see each other.
>
> You will always have to do a roundtrip to interact between Javascript and
> django templates: send a request from Javascript to the server, server
> renders the page and returns it.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: SESSION_COOKIE_DOMAIN on multiple domains.

2013-08-01 Thread Bill Freeman
Maybe use your own custom session middleware?


On Thu, Aug 1, 2013 at 9:41 AM, J. Cliff Dyer  wrote:

> Is there a way to set the SESSION_COOKIE_DOMAIN for multiple domains,
> possibly using the contrib.sites framework?
>
> We deploy on AWS, and when we roll out an update to one of our site, we
> first create a new cloudformation stack, and attach a domain name to it
> like prod-oursite-20130801.devstacks.net.
>
> When we decide it's ready for production, we point www.oursite.com to the
> stack.  This causes problems with the SESSION_COOKIE_DOMAIN, as we need to
> have the cookies domain set to .oursite.com if someone is visiting from
> www.oursite.com (or fl.oursite.com, or wa.oursite.com, etc, etc.), but if
> they are visiting from prod-oursite-20130801.devstacks.net, we want to
> either set the SESSION_COOKIE_DOMAIN to
> prod-oursite-20130801.devstacks.net, or unset it altogether, and just use
> the default session domain.
>
> I would love if SESSION_COOKIE_DOMAIN could be set to a dictionary, like
> this:
>
> SESSION_COOKIE_DOMAIN = {
> 'www.oursite.com': '.oursite.com',
> 'prod-oursite-20130801.devstacks.net': '.devstacks.net',
> }
>
> but it doesn't seem like that's possible.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Django Signal DataBase Change on Template

2013-08-01 Thread Saif Jerbi


I'm building a GPS Tracking System using Django, i should have a grid on my 
template that display real time information of cars (position,vitesse, 
temperature...). GPS send data to Postgres DataBase via a module that parse 
Data and saved it in specific table. What i need is how to make my Web App 
display data in real time? (when a row is inserted in Db, how can i display 
it in grid)

i tried this package https://pypi.python.org/pypi/django-db-signals/0.1.1, 
but my DataParser is external from my django web app, it work independently 
from other side

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to store position of current/active navigation entry

2013-08-01 Thread Bill Freeman
One traditional place to store navigation state is in the URL.

If you are reloading the page with a new GET (such as because a link was
clicked), you have to indicate what page to load in the URL, whether in the
path or in the parameters.  The view has access to the URL, and uses it to
know where you are in the hierarchy, in turn allowing it to load the
correct page.

But since it knows where you are, it can encode the Nav side bar
accordingly.  (Use RequestContexts in all views and render the Nav with a
template tag in your base template.  The tag can see the request object, so
it knows the path, etc.)  So far this doesn't require any JavaScript.  But
the better Navs can open sub-trees on hover, etc., and that does require
JavaScript, and means that the whole tree is sent every time anyway, with,
for example, CSS classes to control what's highlighted and what's open by
default.

If, on the other hand, you are not reloading the page, but filling in stuff
using AJAX, the AJAX request still has to indicate what is needed.
Probably the JavaScript (required to do AJAX) already knows the new spot in
the hierarchy, and can perform the highlighting.  If not, because, for
instance, information the user entered will be looked up in the database to
determine the place in the hierarchy, the AJAX response must include Nav
information for the AJAX.

But, yes, you can store pretty much anything on the session object.  But
note that this probably does the wrong thing if the user hits back, or uses
a bookmark, or otherwise enters a specific path on your site, since the
information on the session (he gets the same session)  is for where you
thought he was.  Also, suppose he has two windows or tabs of the same
browser open on you site, intending to view separate pages: they use the
same session.


On Thu, Aug 1, 2013 at 9:30 AM, DJ-Tom  wrote:

> Hi,
>
> I'm currently creating a web app with django that will have a side bar
> menu with several sub-sections.
>
> I'm wondering if there is a "standard" way to store the "current" or
> "active" menu entry so I can highlite it in the menu area each time a
> request takes place.
>
> Is it possible to attach arbitrary information to the current users
> session object?
>
> thanks
> thomas
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Upgrading to 1.5 on Centos

2013-08-01 Thread Tom Evans
On Thu, Aug 1, 2013 at 3:17 PM, Larry Martell  wrote:
> On Thu, Aug 1, 2013 at 2:30 AM, Branko Majic  wrote:
>> On Wed, 31 Jul 2013 17:59:56 -0600
>> Larry Martell  wrote:
>>
>>> On my Mac, running python 2.7, I upgraded from 1.4 to 1.5 by doing this:
>>>
>>> rm -rf /Library/Python/2.7/site-packages/django
>>>
>>> Followed by python setup.py install in the dir I untar-ed Django-1.5.1
>>> to. This all worked fine.
>>>
>>>
>>> On a Centos system running python 2.6 I did:
>>>
>>> rm -rf /usr/lib/python2.6/site-packages/django followed by the
>>> setup.py install. My django app is working, and appears to be running
>>> 1.5, however anytime I use manage.py (for collectstatic or syncdb or
>>> test, for example) I get these messages:
>>>
>>> /usr/lib/python2.6/site-packages/django/core/management/__init__.py:465:
>>> DeprecationWarning: The 'execute_manager' function is deprecated, you
>>> likely need to update your 'manage.py'; please see the Django 1.4
>>> release notes (https://docs.djangoproject.com/en/dev/releases/1.4/).
>>>   DeprecationWarning)
>>> /usr/lib/python2.6/site-packages/django/core/management/__init__.py:409:
>>> DeprecationWarning: The 'setup_environ' function is deprecated, you
>>> likely need to update your 'manage.py'; please see the Django 1.4
>>> release notes (https://docs.djangoproject.com/en/dev/releases/1.4/).
>>>   DeprecationWarning)
>>>
>>> So it seems I still have some 1.4 stuff around. I don't get this on my
>>> Mac. How can I get rid of these messages?
>>>
>>
>> How are you running management commands? Using the ./manage.py from the
>> project? In that case you probably just need to replace the manage.py
>> with a newer version (from Django 1.5).
>
> Yes, I'm running manage from the project. I copied in the new 1.5
> manage and now I'm getting this:
>
> Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py",
> line 453, in execute_from_command_line
> utility.execute()
>   File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py",
> line 392, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py",
> line 263, in fetch_command
> app_name = get_commands()[subcommand]
>   File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py",
> line 109, in get_commands
> apps = settings.INSTALLED_APPS
>   File "/usr/lib/python2.6/site-packages/django/conf/__init__.py",
> line 53, in __getattr__
> self._setup(name)
>   File "/usr/lib/python2.6/site-packages/django/conf/__init__.py",
> line 48, in _setup
> self._wrapped = Settings(settings_module)
>   File "/usr/lib/python2.6/site-packages/django/conf/__init__.py",
> line 134, in __init__
> raise ImportError("Could not import settings '%s' (Is it on
> sys.path?): %s" % (self.SETTINGS_MODULE, e))
> ImportError: Could not import settings '{{ project_name }}.settings'
> (Is it on sys.path?): No module named {{ project_name }}.settings
>
> There is a settings.py file in the dir I an running from. The actual
> error is coming here"
>
> (Pdb) l
> 104 _commands = dict([(name, 'django.core') for name in
> find_commands(__path__[0])])
> 105
> 106 # Find the installed apps
> 107 from django.conf import settings
> 108 try:
> 109 B-> apps = settings.INSTALLED_APPS
> 110 except ImproperlyConfigured:
> 111 # Still useful for commands that do not require
> functional settings,
> 112 # like startproject or help
> 113 apps = []
> 114
> (Pdb) print settings.INSTALLED_APPS
> *** ImportError: Could not import settings '{{ project_name
> }}.settings' (Is it on sys.path?): No module named {{ project_name
> }}.settings

You've copied the template of manage.py. This template is usually
filled in by django-admin.py when you create a new project, so two
options, run django-admin.py to create a filled in template of
manage.py, copy manage.py into place and remove the new stub project
from which it came, or fill in the template manually.

This was covered in the release notes for 1.4, which is when it
changed (1.5 stopped working with manage.py from 1.3, where as 1.4
would work with a manage.py from 1.3.)

https://docs.djangoproject.com/en/1.5/releases/1.4/#updated-default-project-layout-and-manage-py

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Upgrading to 1.5 on Centos

2013-08-01 Thread Larry Martell
On Thu, Aug 1, 2013 at 2:30 AM, Branko Majic  wrote:
> On Wed, 31 Jul 2013 17:59:56 -0600
> Larry Martell  wrote:
>
>> On my Mac, running python 2.7, I upgraded from 1.4 to 1.5 by doing this:
>>
>> rm -rf /Library/Python/2.7/site-packages/django
>>
>> Followed by python setup.py install in the dir I untar-ed Django-1.5.1
>> to. This all worked fine.
>>
>>
>> On a Centos system running python 2.6 I did:
>>
>> rm -rf /usr/lib/python2.6/site-packages/django followed by the
>> setup.py install. My django app is working, and appears to be running
>> 1.5, however anytime I use manage.py (for collectstatic or syncdb or
>> test, for example) I get these messages:
>>
>> /usr/lib/python2.6/site-packages/django/core/management/__init__.py:465:
>> DeprecationWarning: The 'execute_manager' function is deprecated, you
>> likely need to update your 'manage.py'; please see the Django 1.4
>> release notes (https://docs.djangoproject.com/en/dev/releases/1.4/).
>>   DeprecationWarning)
>> /usr/lib/python2.6/site-packages/django/core/management/__init__.py:409:
>> DeprecationWarning: The 'setup_environ' function is deprecated, you
>> likely need to update your 'manage.py'; please see the Django 1.4
>> release notes (https://docs.djangoproject.com/en/dev/releases/1.4/).
>>   DeprecationWarning)
>>
>> So it seems I still have some 1.4 stuff around. I don't get this on my
>> Mac. How can I get rid of these messages?
>>
>
> How are you running management commands? Using the ./manage.py from the
> project? In that case you probably just need to replace the manage.py
> with a newer version (from Django 1.5).

Yes, I'm running manage from the project. I copied in the new 1.5
manage and now I'm getting this:

Traceback (most recent call last):
  File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py",
line 453, in execute_from_command_line
utility.execute()
  File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py",
line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py",
line 263, in fetch_command
app_name = get_commands()[subcommand]
  File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py",
line 109, in get_commands
apps = settings.INSTALLED_APPS
  File "/usr/lib/python2.6/site-packages/django/conf/__init__.py",
line 53, in __getattr__
self._setup(name)
  File "/usr/lib/python2.6/site-packages/django/conf/__init__.py",
line 48, in _setup
self._wrapped = Settings(settings_module)
  File "/usr/lib/python2.6/site-packages/django/conf/__init__.py",
line 134, in __init__
raise ImportError("Could not import settings '%s' (Is it on
sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings '{{ project_name }}.settings'
(Is it on sys.path?): No module named {{ project_name }}.settings

There is a settings.py file in the dir I an running from. The actual
error is coming here"

(Pdb) l
104 _commands = dict([(name, 'django.core') for name in
find_commands(__path__[0])])
105
106 # Find the installed apps
107 from django.conf import settings
108 try:
109 B-> apps = settings.INSTALLED_APPS
110 except ImproperlyConfigured:
111 # Still useful for commands that do not require
functional settings,
112 # like startproject or help
113 apps = []
114
(Pdb) print settings.INSTALLED_APPS
*** ImportError: Could not import settings '{{ project_name
}}.settings' (Is it on sys.path?): No module named {{ project_name
}}.settings

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




SOLVED: modelformset_factory not validating multiple forms

2013-08-01 Thread Chris Ryan
I found the problem!   
The fields were being processed as expected but since I am using the 
FamilyMember table as the authentication table I needed to include the 
username and other fields (as hidden).

On Thursday, August 1, 2013 9:13:18 AM UTC-4, Chris Ryan wrote:
>
> Hopefully this is an easy one. I have read through the documentation, 
> searched online and just can't find a way around this error.
> I have two formsets that I've displayed in one view. The second formset is 
> not validating upon POST so it won't save to the database.  None of the 
> fields are required so there is no reason for it not to save.
>
> If I load the page and just click submit without changing anything I 
> receive 20 "This field is required". They load at the top of the page and 
> don't tell me what fields seem to be missing.   Extra credit if you can 
> correct my {{ form.error }} tag so that the error shows up next to the form 
> field instead of the top of the page. You can see in my code that I've 
> tried multiple things and none work.
>
>
> Here are my views:
>
> class FamilyBaseFormSet(BaseModelFormSet):
> def add_fields(self, form, index):
> super(FamilyBaseFormSet, self).add_fields(form, index)
> form.fields['state'].widget.attrs['class'] = 'input-mini'
> form.fields['zip_code'].widget.attrs['class'] = 'input-small'
>
> class FamilyMemberBaseFormSet(BaseModelFormSet):
> def add_fields(self, form, index):
> super(FamilyMemberBaseFormSet, self).add_fields(form, index)
> form.fields['first_name'].widget.attrs['class'] = 'input-small'
> form.fields['middle_name'].widget.attrs['class'] = 'input-mini'
> form.fields['last_name'].widget.attrs['class'] = 'input-small'
>
> form.fields['state'].widget.attrs['class'] = 'input-mini'
> form.fields['zip_code'].widget.attrs['class'] = 'input-small'
>
> def manage_family_member(request):
> FamilyInlineFormSet = modelformset_factory(Family, extra=0, 
> formset=FamilyBaseFormSet)
> FamilyMemberInlineFormSet = modelformset_factory(FamilyMember,
> extra=0, formset=FamilyMemberBaseFormSet)
> if request.method == "POST":
> family_formset = FamilyInlineFormSet(request.POST, request.FILES,
> queryset=Family.objects.filter(id = '1'), prefix='f')
> family_member_formset = FamilyMemberInlineFormSet(request.POST, 
> request.FILES,
> queryset=FamilyMember.objects.filter(family = '1'), 
> prefix='fm')
> if family_formset.is_valid() and family_member_formset.is_valid():
> family_formset.save()
> family_member_formset.save()
> else:
> family_formset = 
> FamilyInlineFormSet(queryset=Family.objects.filter(id = '1'), prefix='f')
> family_member_formset = 
> FamilyMemberInlineFormSet(queryset=FamilyMember.objects.filter(family = 
> '1'), prefix='fm')
>
> context = RequestContext(request,{
> 'family_formset': family_formset,
> 'family_member_formset': family_member_formset,
> })
> return render_to_response("school/family/manage_family_members.html", 
> context)
>
>
>
> Here is the template:
>
>
>
> {% extends 'school/base.html' %}
> {% block title %}{{object_name}} Form{% endblock %}
>
> {% block content %}
> This is very useful when enrolling your children in their courses.
> {% for dict in family_member_formset.errors %}
> {{ dict.errors }}
> {% for error in dict.values %}
> {{ error }}
> {% endfor %}
> {% endfor %}
> 
> {{ family_formset.management_form }}
> {% for form in family_formset.forms %}
> 
> {{ form.id }} 
> 
>  Name
> {{ form.error }}
> {{ form.name }}
> 
> 
>  Address 1
> {{ form.error }}
> {{ form.address1 }}
> 
> 
>  Address 2
> {{ form.error }}
> {{ form.address2 }}
> 
> 
>  City
> {{ form.error }}
> {{ form.city }}
> 
> 
>  State
> {{ form.error }}
> {{ form.state }}
> 
> 
>  Zip
> {{ form.error }}
> {{ form.zip_code }}
> 
> 
>  Email
> {{ form.error }}
> {{ form.email_address }}
> 
> 
>  phone_number
> {{ form.error }}
> {{ form.phone_number }}
> 
> {% endfor %}
>
> {{ family_member_formset.management_form }}
> {% for form in family_member_formset.forms %}
> 
> {{ form.id }} 
> {{ form.first_name.error }} {{ form.error }}
> 
>  First
> {{ form.first_name }}
> 
> {{ form.middle_name.error }}
> 
>  Middle
> {{ form.middle_name }}
> 
> {{ form.last_name.error }}
> 
>  Last
> {{ form.last_name }}
> 
> {{ form.address1_error }}
> 
>  Address 1
> {{ form.address1 }}
> 
> {{ form.address.error }}
> 
>  Address 2
> {{ form.address2 }}
> 
> {{ form.city.error }}
> 
>  City
> {{ form.city }}
> 
> {{ form.state.error }}
> 
>  State
> {{ form.state }}
> 
> {{ form.zip_code.error }}
> 
>  Zip
> {{ form.zip_code }}
> 
> {{ form.email_address.error }}
> 
>  Email
> {{ form.email_addre

Re: django jquery

2013-08-01 Thread Jonathan Baker
If you're a Django newb, I'd recommend first going through the Poll
tutorial and
then The Django Book . You
need a fundamental understanding of Django (and HTML+JavaScript) to
effectively develop what you're describing.

For a client to communicate with Django via ajax using jQuery, you'll use
the ajax method: http://api.jquery.com/jQuery.ajax/

On the server side with Django, you have a few options as to how you
develop an API. A small scale solution that is good for testing is to
simply serialize your HTTP response to JSON before returning it. This will
allow your client to hit URL endpoints and receive JSON responses (which
jQuery handles quite easily) Although arguably not very scalable, you've
effectively created a light API at this point.

A more robust solution using Django is to develop a formal API using an
available framework. I've used Django REST
Frameworkand
Tastypie  (and enjoyed
both in different ways), but I'm sure there are others.

With the knowledge gained from the links above, you'll be able to use
jQuery within a HTML template to create and send a request using AJAX to an
API on a server (Django), receive the response from the server, and then
update your template accordingly based upon the response you received.

Jonathan

On Wed, Jul 31, 2013 at 5:41 PM, Robin Lery  wrote:

> I was thinking about client communication via ajax and jquery, but also
> interested in jquery ui. I am a django noob and also with ajax. So its very
> confusing for me how to integrate these two. Can you please advice where to
> start?
> Thank you.
>
>
> On Wed, Jul 31, 2013 at 9:54 PM, Jonathan Baker <
> jonathandavidba...@gmail.com> wrote:
>
>> You've posed a pretty open-ended question. Are you looking to provide an
>> API using Django that then a client communicates with via Ajax using
>> jQuery? Or are you interested in, say, using jQuery to manipulate the UI
>> generated by Django templates? If you can be more specific in your goals,
>> more direction can provided.
>>
>> Jonathan
>>
>>
>> On Wed, Jul 31, 2013 at 10:14 AM, Robin Lery  wrote:
>>
>>> Hi,
>>> Can any one please suggest good book or tutorials if possible regarding
>>> django and ajax (jquiry). I looked at one book "Django JavaScript
>>> Integration AJAX and jQuery", but it was very confusing and outdated as
>>> well,  didn't help much.Please suggest tutorials or books with latest
>>> version. Would be very thankful.
>>>
>>> Thank you.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>
>>
>> --
>> Jonathan D. Baker
>> Developer
>> http://jonathandbaker.com
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Jonathan D. Baker
Developer
http://jonathandbaker.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: multiple templates fro single view

2013-08-01 Thread Fred Stluka

Can also use render_to_string().

--Fred

Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.


On 8/1/13 9:17 AM, Lukas Nemec wrote:

On 08/01/2013 03:04 PM, Harjot Mann wrote:

On Thu, Aug 1, 2013 at 6:10 PM, Lukas Nemec  wrote:

Well, after some consideration,

result of a view is rendered HTML page which you send to browser,

what do you mean by rendering multiple templates?
are you talking about template inheritance = one root template which 
all

other templates use?

in that case, use {% extends 'root.html' %} tag,
or are you talking about splitting your big template into a few 
smaller?

in that cas, use {% include 'page.html' %} tag

No, I didn;t mean that.
Actually I have a function in views.py file which is hitting an html
file like this:
"return render_to_response('tcc/suspence_bill.html', dict(\
 template.items() + tmp.items()), context_instance =
RequestContext(request))"
here I want to return two html templates from this function.


Hmm. ... alright, how exactly, you have 2 different templates and you 
want to pass context data to both of them, and just append those two 
resulting html together?


so just don't return it

do this:

first try it as debug

html1 = render_to_response(template1 rendering here)
html2 = render_to_response(template 2 rendering)

try to print
print html1
print html2 # so you know if it even is representable as text because 
of http headers etc..


return html1 # or whatever you want

try dir(html1) if it is not a string

or dig into django shortcuts
https://docs.djangoproject.com/en/dev/topics/http/shortcuts/#render


Enjoy!
Lukas



--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Ordering a queryset on a reverse foreign key's attribute

2013-08-01 Thread Daniele Procida
I have an Event model:

class Event(Model):
parent = models.ForeignKey('self', related_name='children')
date = models.DateField()

My question is: given a queryset of this model, how can I order it based on the 
Events' children's dates so that (say) Events with child Events with more 
recent dates are first?

(I thought that 

.order_by('-children__date')

might be a start, but in fact that seems to do something very odd to the items 
in the list, which I am looking at separately).

Thanks,

Daniele

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Avatar save

2013-08-01 Thread Harjot Mann
On Thu, Aug 1, 2013 at 2:37 PM, Deepak Sharma  wrote:
> I want that user save that cropped image to his/her favorite
> destination (client side).


You need to create a view in which you need to return
response = HttpResponse(file(fullpath).read())
response['Content-Type'] = 'application/jpg'
response['Content-Disposition'] =
'attachment;filename=%s'%(os.path.basename(fullpath),)
an link it with the download button in your file.

-- 
Harjot Kaur Mann
Blog: http://harjotmann.wordpress.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




How template tag can receive values JS

2013-08-01 Thread Christian Erhardt
No, what you are trying is not possible. The template tags are rendered on the 
server. They never appear on the client machine. Javascript is running on the 
client machine. They both will never see each other.

You will always have to do a roundtrip to interact between Javascript and 
django templates: send a request from Javascript to the server, server renders 
the page and returns it.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How template tag can receive values JS

2013-08-01 Thread Larry Martell
On Thu, Aug 1, 2013 at 6:48 AM, Mário Idival  wrote:
> Good morning everyone,
> I wonder how I can do (and if it is possible), pass a value of javascript
> variable to a template tag Django.
>
> eg
> how it works:
> {{Document.id | split_filter}} -> split_filter is just a random method,
> receives an ID
>
> as would
> {{"Value Var JS" | split_filter}} -> pass the id that comes from a JS
> variable to the template tag.

You could pass something from js using ajax back to python, which then
passes it to a template.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




SESSION_COOKIE_DOMAIN on multiple domains.

2013-08-01 Thread J. Cliff Dyer
Is there a way to set the SESSION_COOKIE_DOMAIN for multiple domains, 
possibly using the contrib.sites framework?

We deploy on AWS, and when we roll out an update to one of our site, we 
first create a new cloudformation stack, and attach a domain name to it 
like prod-oursite-20130801.devstacks.net.

When we decide it's ready for production, we point www.oursite.com to the 
stack.  This causes problems with the SESSION_COOKIE_DOMAIN, as we need to 
have the cookies domain set to .oursite.com if someone is visiting from 
www.oursite.com (or fl.oursite.com, or wa.oursite.com, etc, etc.), but if 
they are visiting from prod-oursite-20130801.devstacks.net, we want to 
either set the SESSION_COOKIE_DOMAIN to 
prod-oursite-20130801.devstacks.net, or unset it altogether, and just use 
the default session domain.

I would love if SESSION_COOKIE_DOMAIN could be set to a dictionary, like 
this:

SESSION_COOKIE_DOMAIN = {
'www.oursite.com': '.oursite.com',
    'prod-oursite-20130801.devstacks.net': '.devstacks.net',
}

but it doesn't seem like that's possible.


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




How to store position of current/active navigation entry

2013-08-01 Thread DJ-Tom
Hi,

I'm currently creating a web app with django that will have a side bar menu 
with several sub-sections.

I'm wondering if there is a "standard" way to store the "current" or 
"active" menu entry so I can highlite it in the menu area each time a 
request takes place.

Is it possible to attach arbitrary information to the current users session 
object?

thanks
thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Help getting started: Which server setup for a beginner? Apache? lighttpd? To use or not virtualenv?

2013-08-01 Thread Kelvin Wong
It is def worth taking the trouble to learn how to use virtualenv and 
virtualenvwrapper. Once they are set up and assuming that you haven't 
already put too much already into your global site-packages, they will save 
you time and greatly simplify keeping different project environments 
separate.

You didn't mention if you were on a Mac or what. On a UNIX dev machine 
setting up virtualenv and the wrapper are fairly straightforward.

K



On Tuesday, July 30, 2013 8:48:18 AM UTC-7, Jared Nielsen wrote:
>
> I'm trying to learn Django but finding myself lost in troubleshooting 
> hell. I can't find consistent information on the best approach for a 
> beginner to get set up.
>
> I started setting up Apache with mod_wsgi, but ran into innumerable config 
> errors. After some Googling about, I found a number of suggestions to use 
> lighttpd instead. Installed that and more troubleshooting. And what's this 
> about gunicorn? 
>
> What's the best approach for a beginner? Where is my time best spent 
> troubleshooting? 
>
> Also, should I be using virtualenv? Inconsistent use across the various 
> tutorials I'm reading. 
>
> Many thanks in advance! 
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Avatar save

2013-08-01 Thread Harjot Mann
On Thu, Aug 1, 2013 at 2:37 PM, Deepak Sharma  wrote:
> I want that user save that cropped image to his/her favorite
> destination (client side).

Hope this may help you.
http://stackoverflow.com/questions/6121200/how-to-save-an-image-using-url-in-python-django

-- 
Harjot Kaur Mann
Blog: http://harjotmann.wordpress.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Integrate django app with EBS payment gateway

2013-08-01 Thread steve jobs
I am using django and designed a website, and now i got to implement 
payment gateway functionality. 

Actually how to integrate a django app with payment gateways ?
Whether there are any packages already available to get an idea because i 
am completely 
new in implementing this ?
Particularly i want to integrate my app with EBS payment gateway, so can 
anyone point me
in a right direction like

1. what needs to be done in order to integrate a `django web app with 
payment gateway` ?
2. Whether there is any code already available to save time and extend it ?
3. If possible please point me to some code examples that explains the 
integration of `django` 
   app with `payment gateways`

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: multiple templates fro single view

2013-08-01 Thread Lukas Nemec

On 08/01/2013 03:04 PM, Harjot Mann wrote:

On Thu, Aug 1, 2013 at 6:10 PM, Lukas Nemec  wrote:

Well, after some consideration,

result of a view is rendered HTML page which you send to browser,

what do you mean by rendering multiple templates?
are you talking about template inheritance = one root template which all
other templates use?

in that case, use {% extends 'root.html' %} tag,
or are you talking about splitting your big template into a few smaller?
in that cas, use {% include 'page.html' %} tag

No, I didn;t mean that.
Actually I have a function in views.py file which is hitting an html
file like this:
"return render_to_response('tcc/suspence_bill.html', dict(\
 template.items() + tmp.items()), context_instance =
RequestContext(request))"
here I want to return two html templates from this function.


Hmm. ... alright, how exactly, you have 2 different templates and you 
want to pass context data to both of them, and just append those two 
resulting html together?


so just don't return it

do this:

first try it as debug

html1 = render_to_response(template1 rendering here)
html2 = render_to_response(template 2 rendering)

try to print
print html1
print html2 # so you know if it even is representable as text because of 
http headers etc..


return html1 # or whatever you want

try dir(html1) if it is not a string

or dig into django shortcuts
https://docs.djangoproject.com/en/dev/topics/http/shortcuts/#render


Enjoy!
Lukas

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




modelformset_factory not validating multiple forms

2013-08-01 Thread Chris Ryan
Hopefully this is an easy one. I have read through the documentation, 
searched online and just can't find a way around this error.
I have two formsets that I've displayed in one view. The second formset is 
not validating upon POST so it won't save to the database.  None of the 
fields are required so there is no reason for it not to save.

If I load the page and just click submit without changing anything I 
receive 20 "This field is required". They load at the top of the page and 
don't tell me what fields seem to be missing.   Extra credit if you can 
correct my {{ form.error }} tag so that the error shows up next to the form 
field instead of the top of the page. You can see in my code that I've 
tried multiple things and none work.


Here are my views:

class FamilyBaseFormSet(BaseModelFormSet):
def add_fields(self, form, index):
super(FamilyBaseFormSet, self).add_fields(form, index)
form.fields['state'].widget.attrs['class'] = 'input-mini'
form.fields['zip_code'].widget.attrs['class'] = 'input-small'

class FamilyMemberBaseFormSet(BaseModelFormSet):
def add_fields(self, form, index):
super(FamilyMemberBaseFormSet, self).add_fields(form, index)
form.fields['first_name'].widget.attrs['class'] = 'input-small'
form.fields['middle_name'].widget.attrs['class'] = 'input-mini'
form.fields['last_name'].widget.attrs['class'] = 'input-small'

form.fields['state'].widget.attrs['class'] = 'input-mini'
form.fields['zip_code'].widget.attrs['class'] = 'input-small'

def manage_family_member(request):
FamilyInlineFormSet = modelformset_factory(Family, extra=0, 
formset=FamilyBaseFormSet)
FamilyMemberInlineFormSet = modelformset_factory(FamilyMember,
extra=0, formset=FamilyMemberBaseFormSet)
if request.method == "POST":
family_formset = FamilyInlineFormSet(request.POST, request.FILES,
queryset=Family.objects.filter(id = '1'), prefix='f')
family_member_formset = FamilyMemberInlineFormSet(request.POST, 
request.FILES,
queryset=FamilyMember.objects.filter(family = '1'), 
prefix='fm')
if family_formset.is_valid() and family_member_formset.is_valid():
family_formset.save()
family_member_formset.save()
else:
family_formset = 
FamilyInlineFormSet(queryset=Family.objects.filter(id = '1'), prefix='f')
family_member_formset = 
FamilyMemberInlineFormSet(queryset=FamilyMember.objects.filter(family = 
'1'), prefix='fm')

context = RequestContext(request,{
'family_formset': family_formset,
'family_member_formset': family_member_formset,
})
return render_to_response("school/family/manage_family_members.html", 
context)



Here is the template:



{% extends 'school/base.html' %}
{% block title %}{{object_name}} Form{% endblock %}

{% block content %}
This is very useful when enrolling your children in their courses.
{% for dict in family_member_formset.errors %}
{{ dict.errors }}
{% for error in dict.values %}
{{ error }}
{% endfor %}
{% endfor %}

{{ family_formset.management_form }}
{% for form in family_formset.forms %}

{{ form.id }} 

 Name
{{ form.error }}
{{ form.name }}


 Address 1
{{ form.error }}
{{ form.address1 }}


 Address 2
{{ form.error }}
{{ form.address2 }}


 City
{{ form.error }}
{{ form.city }}


 State
{{ form.error }}
{{ form.state }}


 Zip
{{ form.error }}
{{ form.zip_code }}


 Email
{{ form.error }}
{{ form.email_address }}


 phone_number
{{ form.error }}
{{ form.phone_number }}

{% endfor %}

{{ family_member_formset.management_form }}
{% for form in family_member_formset.forms %}

{{ form.id }} 
{{ form.first_name.error }} {{ form.error }}

 First
{{ form.first_name }}

{{ form.middle_name.error }}

 Middle
{{ form.middle_name }}

{{ form.last_name.error }}

 Last
{{ form.last_name }}

{{ form.address1_error }}

 Address 1
{{ form.address1 }}

{{ form.address.error }}

 Address 2
{{ form.address2 }}

{{ form.city.error }}

 City
{{ form.city }}

{{ form.state.error }}

 State
{{ form.state }}

{{ form.zip_code.error }}

 Zip
{{ form.zip_code }}

{{ form.email_address.error }}

 Email
{{ form.email_address }}

{% endfor %}
{% csrf_token %}




{% endblock %}





-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: I all django's user I'm new here and also new to Python+ django technology. but i wanna learn phython........

2013-08-01 Thread Lynn Fu
I very agree with Phil/

在 2013年8月1日星期四UTC+8下午5时28分48秒,Rakesh Balhara写道:
>
> I all django's user I'm new here and also new to Python+ django 
> technology. but i wanna learn phython and i hv to make a project in this 
> technology so plzz tell me where from i start to learning i just want 
> to learn it within one week...
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: multiple templates fro single view

2013-08-01 Thread Harjot Mann
On Thu, Aug 1, 2013 at 6:10 PM, Lukas Nemec  wrote:
> Well, after some consideration,
>
> result of a view is rendered HTML page which you send to browser,
>
> what do you mean by rendering multiple templates?
> are you talking about template inheritance = one root template which all
> other templates use?
>
> in that case, use {% extends 'root.html' %} tag,
> or are you talking about splitting your big template into a few smaller?
> in that cas, use {% include 'page.html' %} tag

No, I didn;t mean that.
Actually I have a function in views.py file which is hitting an html
file like this:
"return render_to_response('tcc/suspence_bill.html', dict(\
template.items() + tmp.items()), context_instance =
RequestContext(request))"
here I want to return two html templates from this function.
-- 
Harjot Kaur Mann
Blog: http://harjotmann.wordpress.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to display Chinese in django webpage

2013-08-01 Thread Lukas Nemec

Hi

I'd suggest you to contact the developers of Zinnia blog,
they should be able to help you easily

Cheers :)
Lukas

On 08/01/2013 10:50 AM, zhao yan wrote:

HELLO:
I am a new django user
I want to display Chinese in my webpage
but it can't

this is my settings.py:
-

TIME_ZONE = 'Asia/Shanghai'
USE_TZ = True
USE_I18N = True
USE_L10N = True
LANGUAGE_CODE = 'zh-cn'
LANGUAGES = (
('zh_CN', gettext('Simplified Chinese')),
('en', gettext('English')),
)
--
Additional, I using a app "zinnia", all file
are contained:".mo, .po"
When I run:python manage.py runserver
The webpage is always display English.

Is it something wrong in settings.py?

--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to django-users+unsubscr...@googlegroups.com.

To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




How template tag can receive values JS

2013-08-01 Thread Mário Idival
Good morning everyone,
I wonder how I can do (and if it is possible), pass a value of javascript
variable to a template tag Django.

eg
how it works:
{{Document.id | split_filter}} -> split_filter is just a random method,
receives an ID

as would
{{"Value Var JS" | split_filter}} -> pass the id that comes from a JS
variable to the template tag.

Thanks.
Mário Idival

*Twitter *: *@marioigd*
*Facebook*: *mario.idival*
*User Linux : **#554446*
Skype*: marioidival*
*Blog:  *https://conconcus.wordpress.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: multiple templates fro single view

2013-08-01 Thread Lukas Nemec

Well, after some consideration,

result of a view is rendered HTML page which you send to browser,

what do you mean by rendering multiple templates?
are you talking about template inheritance = one root template which all 
other templates use?


in that case, use {% extends 'root.html' %} tag,
or are you talking about splitting your big template into a few smaller?
in that cas, use {% include 'page.html' %} tag

for more information look here:
https://docs.djangoproject.com/en/dev/topics/templates/


Enjoy!
Lukas


On 08/01/2013 01:14 PM, Harjot Mann wrote:

In my project I have a view which renders to an html template but I
want to render two templates at the same time from one view. How ca I
do it??



--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: I all django's user I'm new here and also new to Python+ django technology. but i wanna learn phython........

2013-08-01 Thread Phil
Hi,

There are lots of excellent resources online to learn Django. I am myself 
going through that process. 

The best place to get started is, of course, the excellent Django 
documentation: https://docs.djangoproject.com/en/1.5/intro/tutorial01/

Finally, once you have a good grasp on the basics, I would recommend the 
excellent https://django.2scoops.org/. Their book will really take you to 
the next level, and if you can't afford to buy it, they will give it you 
for free. In the same vein, http://www.deploydjango.com/ is very 
interesting. Of course Google will yield tons of other interesting blogs on 
the topic.

For Python itself, http://learnpythonthehardway.org/ or (my favourite) 
http://www.diveintopython.net/ are excellent resources to get you started.

Regards,
Phil

On Thursday, August 1, 2013 6:28:48 AM UTC-3, Rakesh Balhara wrote:
>
> I all django's user I'm new here and also new to Python+ django 
> technology. but i wanna learn phython and i hv to make a project in this 
> technology so plzz tell me where from i start to learning i just want 
> to learn it within one week...
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: User Permissions

2013-08-01 Thread Carlos Leite
On Wed, Jul 31, 2013 at 2:01 AM, Jani Tiainen  wrote:
> On Tue, 30 Jul 2013 16:39:27 -0300
> Carlos Leite  wrote:
>
>> Django do not have a "per-row" permission system in the box.
>> You will have to create that by yourself.
>
> That is slightly incorrect - Django _does_ have foundation for object (row) 
> level permission system. There is just no default implementation in standard 
> auth

Exactly.
per row perms Is not something that you just need some configs or
fixture to use with Groups and Permis. It needs code to be written to
be used.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




How to display Chinese in django webpage

2013-08-01 Thread zhao yan
HELLO:
I am a new django user
I want to display Chinese in my webpage
but it can't

this is my settings.py:
-

TIME_ZONE = 'Asia/Shanghai'
USE_TZ = True
USE_I18N = True
USE_L10N = True
LANGUAGE_CODE = 'zh-cn'
LANGUAGES = (
('zh_CN', gettext('Simplified Chinese')),
('en', gettext('English')),
)
--
Additional, I using a app "zinnia", all file 
are contained:".mo, .po" 
When I run:python manage.py runserver
The webpage is always display English.

Is it something wrong in settings.py?
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Redirect Domain to specific Django App

2013-08-01 Thread BadStorm
Hi, 
I have a django project with 2 django app. My intent is to use the site 
framework to redirect one specific domain to one specific app. It is 
possible?

Thanks

Marco

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




I all django's user I'm new here and also new to Python+ django technology. but i wanna learn phython........

2013-08-01 Thread Rakesh Balhara
I all django's user I'm new here and also new to Python+ django technology. 
but i wanna learn phython and i hv to make a project in this technology so 
plzz tell me where from i start to learning i just want to learn it 
within one week...

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




multiple templates fro single view

2013-08-01 Thread Harjot Mann
In my project I have a view which renders to an html template but I
want to render two templates at the same time from one view. How ca I
do it??

-- 
Harjot Kaur Mann
Blog: http://harjotmann.wordpress.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: South with MySQL?

2013-08-01 Thread Tom Evans
On Thu, Aug 1, 2013 at 10:56 AM, Nigel Legg  wrote:
> So is it something I have done wrong?  From what you are saying it has run
> the migration but I am not seeing that - still getting errors when I try to
> access the page.  If I do manag.py sql myapp I see the schema including the
> new fields, but if I go into the shell, import the view, and do
> DataTable.objects.all() I get "Unknown column 'myapp_datatable.type2stub' in
> 'field list'".
> So is there a way to resolve this without deleting the database and starting
> again with one that does not have so many issues working with South?

What South is telling you is that it has not successfully applied the
migration, that something went wrong, and because you chose to use
MySQL, it has no way of reverting it to a sane, known state.
Therefore, that's up to you.

South may have been able to apply some of the migration, and not other
parts. Look at the migration, what models does it change, what changes
are necessary, then look at the database and see what has been
changed. At this point, you have two choices, you can revert the
changes that south made and attempt to fix and re-run the migration,
or you can manually apply the migration.

If you were preparing a migration for production, you would definitely
do the former, as the end result you want is a migration that will run
perfectly on your production system.

The 'sql' and 'sqlall' commands only represent translating your models
in to SQL, they have nothing to do with what the table structure in
your database is.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: South with MySQL?

2013-08-01 Thread Masklinn
On 2013-08-01, at 11:56 , Nigel Legg wrote:
> So is it something I have done wrong?

No.

>  From what you are saying it has run
> the migration

No, it has run *part* of the migration, then something failed during the
migration. The part that's run is there, what came after the error did
not run.

> but I am not seeing that - still getting errors when I try to
> access the page.  If I do manag.py sql myapp I see the schema including the
> new fields, but if I go into the shell, import the view, and do
> DataTable.objects.all() I get "Unknown column 'myapp_datatable.type2stub'
> in 'field list'".
> So is there a way to resolve this without deleting the database

You can try running the missing part of the migration by hand, and more
generally you should take up your question to South's support lists, not
Django's.

> and
> starting again with one that does not have so many issues working with
> South?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: South with MySQL?

2013-08-01 Thread Nigel Legg
So is it something I have done wrong?  From what you are saying it has run
the migration but I am not seeing that - still getting errors when I try to
access the page.  If I do manag.py sql myapp I see the schema including the
new fields, but if I go into the shell, import the view, and do
DataTable.objects.all() I get "Unknown column 'myapp_datatable.type2stub'
in 'field list'".
So is there a way to resolve this without deleting the database and
starting again with one that does not have so many issues working with
South?

Regards,
Nigel Legg
07914 740972
http://www.trevanianlegg.co.uk
http://twitter.com/nigellegg
http://uk.linkedin.com/in/nigellegg



On 1 August 2013 10:46, Masklinn  wrote:

> On 2013-08-01, at 11:23 , Nigel Legg wrote:
> > So are you saying the migration wil or will not work with South using
> > MySQL??
>
> No. I'm saying if the migration fails the database will be left in an
> intermediate (and likely incorrect) state.
>
> > What do I have to do, in addition to everything in the South
> > documentation, in orde3r to make a South migration work with MySQL, given
> > what you have posted above?
>
> South *works* with mysql. But because of *mysql's limitations* if there
> is a problem while South is *modifying the database schema* (the DDL) it
> has no way to *rollback the changes*.
>
> That's what it tells you: if there is a a problem during the migration
> (because there's a bug in your migration), south *can not* put the
> database back in the state it was before you started the migration
> because mysql *does not provide the tools to do so*.
>
> It's not an incompatibility, it's mysql being a gigantic turd, no
> migration tool can fix that no matter how much they polish it.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: South with MySQL?

2013-08-01 Thread Masklinn
On 2013-08-01, at 11:23 , Nigel Legg wrote:
> So are you saying the migration wil or will not work with South using
> MySQL??

No. I'm saying if the migration fails the database will be left in an
intermediate (and likely incorrect) state.

> What do I have to do, in addition to everything in the South
> documentation, in orde3r to make a South migration work with MySQL, given
> what you have posted above?

South *works* with mysql. But because of *mysql's limitations* if there
is a problem while South is *modifying the database schema* (the DDL) it
has no way to *rollback the changes*.

That's what it tells you: if there is a a problem during the migration
(because there's a bug in your migration), south *can not* put the
database back in the state it was before you started the migration
because mysql *does not provide the tools to do so*.

It's not an incompatibility, it's mysql being a gigantic turd, no
migration tool can fix that no matter how much they polish it.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: South with MySQL?

2013-08-01 Thread Nigel Legg
So are you saying the migration wil or will not work with South using
MySQL?? What do I have to do, in addition to everything in the South
documentation, in orde3r to make a South migration work with MySQL, given
what you have posted above?

Regards,
Nigel Legg
07914 740972
http://www.trevanianlegg.co.uk
http://twitter.com/nigellegg
http://uk.linkedin.com/in/nigellegg



On 1 August 2013 09:40, Masklinn  wrote:

> On 2013-08-01, at 10:09 , Nigel Legg wrote:
>
> > I tried to run a migration using south, and got the message:
> > "Since you have a database that does not support running schema-altering
> > statements in transactions, we have had to leave it in an interim state
> > between migrations."
> > Is this an incompatibility with MySQL, or because my DB is incorrectly
> > configured?  I have not seen in any of the South documentation that it
> can
> > not be used with MySQL.
> > Cheers, N//
>
> Please read the message. It doesn't note that South is *incompatible*
> with mysql, it notes that a failed migration will leave the database in
> an intermediate (broken) state.
>
> This is because MySQL does not implement transactional DDL[0]: table
> alterations are performed outside of transactions and thus can not be
> rollbacked (and will implicitly commit any pending transaction when
> using InnoDB). This by comparison to PostgreSQL, where pretty much all
> commands (including DDL) are executed in transaction and will be
> rollbacked with it (a quick search notes database and tablespace
> alterations are not transactional, 2-phase transactions obviously aren't
> either, and sequence operations don't rollback for different reasons).
>
> [0]
> http://wiki.postgresql.org/wiki/Transactional_DDL_in_PostgreSQL:_A_Competitive_Analysis#MySQL
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Avatar save

2013-08-01 Thread Deepak Sharma
Hello

I am using django-avatar croping tool. Image crop well. That cropped
image goes to avatar folder which is in
/usr/local/lib/python2.7/dist-packages/django/contrib/admin/media/avatar/.
I want that user save that cropped image to his/her favorite
destination (client side).



-- 
Deepak Kumar Sharma
Blog:
http://deekysharma.wordpress.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: South with MySQL?

2013-08-01 Thread Masklinn
On 2013-08-01, at 10:09 , Nigel Legg wrote:

> I tried to run a migration using south, and got the message:
> "Since you have a database that does not support running schema-altering
> statements in transactions, we have had to leave it in an interim state
> between migrations."
> Is this an incompatibility with MySQL, or because my DB is incorrectly
> configured?  I have not seen in any of the South documentation that it can
> not be used with MySQL.
> Cheers, N//

Please read the message. It doesn't note that South is *incompatible*
with mysql, it notes that a failed migration will leave the database in
an intermediate (broken) state.

This is because MySQL does not implement transactional DDL[0]: table
alterations are performed outside of transactions and thus can not be
rollbacked (and will implicitly commit any pending transaction when
using InnoDB). This by comparison to PostgreSQL, where pretty much all
commands (including DDL) are executed in transaction and will be
rollbacked with it (a quick search notes database and tablespace
alterations are not transactional, 2-phase transactions obviously aren't
either, and sequence operations don't rollback for different reasons).

[0] 
http://wiki.postgresql.org/wiki/Transactional_DDL_in_PostgreSQL:_A_Competitive_Analysis#MySQL

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Upgrading to 1.5 on Centos

2013-08-01 Thread Branko Majic
On Wed, 31 Jul 2013 17:59:56 -0600
Larry Martell  wrote:

> On my Mac, running python 2.7, I upgraded from 1.4 to 1.5 by doing this:
> 
> rm -rf /Library/Python/2.7/site-packages/django
> 
> Followed by python setup.py install in the dir I untar-ed Django-1.5.1
> to. This all worked fine.
> 
> 
> On a Centos system running python 2.6 I did:
> 
> rm -rf /usr/lib/python2.6/site-packages/django followed by the
> setup.py install. My django app is working, and appears to be running
> 1.5, however anytime I use manage.py (for collectstatic or syncdb or
> test, for example) I get these messages:
> 
> /usr/lib/python2.6/site-packages/django/core/management/__init__.py:465:
> DeprecationWarning: The 'execute_manager' function is deprecated, you
> likely need to update your 'manage.py'; please see the Django 1.4
> release notes (https://docs.djangoproject.com/en/dev/releases/1.4/).
>   DeprecationWarning)
> /usr/lib/python2.6/site-packages/django/core/management/__init__.py:409:
> DeprecationWarning: The 'setup_environ' function is deprecated, you
> likely need to update your 'manage.py'; please see the Django 1.4
> release notes (https://docs.djangoproject.com/en/dev/releases/1.4/).
>   DeprecationWarning)
> 
> So it seems I still have some 1.4 stuff around. I don't get this on my
> Mac. How can I get rid of these messages?
> 

How are you running management commands? Using the ./manage.py from the
project? In that case you probably just need to replace the manage.py
with a newer version (from Django 1.5).

Best regards

-- 
Branko Majic
Jabber: bra...@majic.rs
Please use only Free formats when sending attachments to me.

Бранко Мајић
Џабер: bra...@majic.rs
Молим вас да додатке шаљете искључиво у слободним форматима.


signature.asc
Description: PGP signature


South with MySQL?

2013-08-01 Thread Nigel Legg
I tried to run a migration using south, and got the message:
"Since you have a database that does not support running schema-altering
statements in transactions, we have had to leave it in an interim state
between migrations."
Is this an incompatibility with MySQL, or because my DB is incorrectly
configured?  I have not seen in any of the South documentation that it can
not be used with MySQL.
Cheers, N//

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.