How to build RESTful API for django.contrib.comments?

2013-03-29 Thread Pratik Mandrekar


Hello,

I have a Generic Relationships in 
tastypie
 and 
incorporated the same in my resource for
django.contrib.comments.models.Comment

My resource looks like this. It works fine for GET without the generic 
relationship but when I add the Generic relationship neither the GET nor 
POST work.


class CommentContribResource(ModelResource):+ + from social.api.resources 
import StatusUpdateResource+ from social.models import StatusUpdate+ + 
content_object = GenericForeignKeyField({+ StatusUpdate: 
StatusUpdateResource,+ }, 'content_object')+ + + class Meta:+   
  queryset = Comment.objects.all()+ resource_name = 'comments'+ 
authorization= Authorization()

The error while doing GET is

error_message: "User matching query does not exist.",

While doing POST is

current transaction is aborted, commands ignored until end of transaction block

Is there a good way to build a RESTful interface with GenericForeignKeys 
and thedjango.contrib.comments framework?


Thanks,

Pratik


-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




How to manage django settings.py for Github, local, production

2013-03-29 Thread surya
Everyone talked about local, production settings.. 

try:
   from local_settings.py import *
except:
   # general settings.py 

my case needs three different settings: Github, local, production I have 
Django repo on github, and on pc (local). Now, need to push to another 
tree, the production server.

In our project, as its opensource, the master branch can't be directly 
pushed into Production server as it contains confidential settings.. For 
that I (admin of server) created a local branch to specifically contain 
production settings using local_settings.py.. The master is merged as into 
this branch as soon as we release new feature/ fix bug etc.. (any better 
way of handling. please tell me)

However, local_settings.py is included in .gitignore (remember, our master 
is on Github).. 
So, I need to edit .gitignore in local branch (containing production 
settings) and push to server..

As soon as I merge master into it..for adding new stable code, I need to 
update .gitignore (to track local_settings.py).. this is pathetic.. 

so.. i appreciate if you can provide a good working model!

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to manage django settings.py for Github, local, production

2013-03-29 Thread surya


On Friday, March 29, 2013 1:10:12 PM UTC+5:30, surya wrote:
>
> Everyone talked about local, production settings.. 
>
> try:
>from local_settings.py import *
> except:
># general settings.py 
>
> my case needs three different settings: Github, local, production I have 
> Django repo on github, and on pc (local). Now, need to push to another 
> tree, the production server.
>
> In our project, as its opensource, the master branch can't be directly 
> pushed into Production server as it contains confidential settings.. For 
> that I (admin of server) created a local branch to specifically contain 
> production settings using local_settings.py.. The master is merged as into 
> this branch as soon as we release new feature/ fix bug etc.. (any better 
> way of handling. please tell me)
>
> However, local_settings.py is included in .gitignore (remember, our master 
> is on Github).. 
> So, I need to edit .gitignore in local branch (containing production 
> settings) and push to server..
>
> As soon as I merge master into it..for adding new stable code, I need to 
> update .gitignore (to track local_settings.py).. this is pathetic.. 
>
> so.. i appreciate if you can provide a good working model!
>
>
In simple words.. 

There is a file (local-settings.py) in a local branch, should be ignored 
while pushing in github, but should be pushed into server.. :p .

Hope this seems lot complex.. any simple ideas? (the less the manual work, 
the better.. ) 

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to manage django settings.py for Github, local, production

2013-03-29 Thread Alexey Kinyov
Hi, Surya!

My practice is to have 'settings_template.py' in repository and
'settings.py' ignored, so 'settings.py' looks like:

   from settings_template import *

   # and here's confidential settings and other

There also may be many 'templates' for settings, like
'settings_dev.py', 'settings_production.py', but 'settings.py' is
always created on the host and never pushed to repo. And in addition
to that there may be an example file in repo, like
'settings.py.example'.


Regards,
Alex
///

On Fri, Mar 29, 2013 at 12:11 PM, surya  wrote:
>
>
> On Friday, March 29, 2013 1:10:12 PM UTC+5:30, surya wrote:
>>
>> Everyone talked about local, production settings..
>>
>> try:
>>from local_settings.py import *
>> except:
>># general settings.py
>>
>> my case needs three different settings: Github, local, production I have
>> Django repo on github, and on pc (local). Now, need to push to another tree,
>> the production server.
>>
>> In our project, as its opensource, the master branch can't be directly
>> pushed into Production server as it contains confidential settings.. For
>> that I (admin of server) created a local branch to specifically contain
>> production settings using local_settings.py.. The master is merged as into
>> this branch as soon as we release new feature/ fix bug etc.. (any better way
>> of handling. please tell me)
>>
>> However, local_settings.py is included in .gitignore (remember, our master
>> is on Github)..
>> So, I need to edit .gitignore in local branch (containing production
>> settings) and push to server..
>>
>> As soon as I merge master into it..for adding new stable code, I need to
>> update .gitignore (to track local_settings.py).. this is pathetic..
>>
>> so.. i appreciate if you can provide a good working model!
>>
>
> In simple words..
>
> There is a file (local-settings.py) in a local branch, should be ignored
> while pushing in github, but should be pushed into server.. :p .
>
> Hope this seems lot complex.. any simple ideas? (the less the manual work,
> the better.. )
>
> --
> 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?hl=en.
> 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to manage django settings.py for Github, local, production

2013-03-29 Thread Branko Majic
On Fri, 29 Mar 2013 00:40:12 -0700 (PDT)
surya  wrote:

> In our project, as its opensource, the master branch can't be
> directly pushed into Production server as it contains confidential
> settings.. For that I (admin of server) created a local branch to
> specifically contain production settings using local_settings.py..
> The master is merged as into this branch as soon as we release new
> feature/ fix bug etc.. (any better way of handling. please tell me)

Well, one interesting concept I've see is from the Two Scoops of Django
(I join the minions on this group that recommend this book - probably
one of the best buys in my life) - the authors use separate
configuration files for production, test, development (even
per-developer settings), storing all of them in the repo, _but_ they
don't store any confidential data in those files.

Instead of that they use environment variables to make the passwords
available to user running the code, and then inside of "base"
settings.py they use a bit of Python code to read them and assign them
to appropriate variables.

There's probably a couple of variations on this as well - for example
storing path to file containing the password in environment variable,
and then reading from there etc.

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


Re: Redirects working locally but not in live server

2013-03-29 Thread angelika
Thanks for the tips! I am absolutely sure that I restarted both nginx and 
gunicorn. But I'm gonna check with the server dudes if they can give me 
some insight into the inner workings of their universe. 

/Angelika

On Thursday, March 28, 2013 6:18:59 PM UTC+1, ke1g wrote:
>
> Are you sure that you restarted after making redirection changes in 
> production?  Unlike runserver, most deployment schemes do not automatically 
> restart when a .py file is changed, so changes to them are not picked up.  
> You would have restarted when you switched DEBUG on and off, and other 
> changes would have been picked up at that time.
>
> But it could be cacheing, and that is somewhat outside Django's scope.  
> While you can arrange particular cache control headers to control which 
> pages are cacheable and for how long, proxy caches (e.g.; varnish on your 
> server, others in the great wide world), and even browsers, may have their 
> own ideas.  If you are running a proxy cache on your server, you should 
> look up the commands required to purge it, assuming your hosting provider 
> allows that.  (But only purge it if you seem to be having cacheing 
> problems, particularly if it is shared.)
>
> On Thu, Mar 28, 2013 at 11:21 AM, angelika 
> > wrote:
>
>> Hm, well, I've solved it myself, I guess. It must have been a caching 
>> problem. I changed Debug to True in settings.py to look for errors, and 
>> then it started working. Something must have reloaded, cuz it still works 
>> when I change it back. 
>>
>> For future reference, does anyone know how I can get this type of 
>> reload/empty cache of the server without having to edit my settings.py?
>>
>> /Angelika
>>
>>
>> On Thursday, March 28, 2013 4:10:24 PM UTC+1, angelika wrote:
>>>
>>> Hi,
>>>
>>> I'm using the django redirects app: https://docs.**
>>> djangoproject.com/en/1.4/ref/**contrib/redirects/
>>>  
>>> I've created a couple of redirect objects in the admin interface and 
>>> when I run it locally it works fine, but when I do the same thing on my 
>>> live server it has no effect. The regular 404 page is showing in stead. The 
>>> installation is very simple, just a couple of settings and a db table and 
>>> nothing went wrong there as far as I can see. What am I missing? Locally I 
>>> run the site with runserver, my liveserver is running nginx and gunicorn. 
>>> I've restarted both, but it makes no difference. 
>>>
>>> Thoughts? Guesses?
>>>
>>> /Angelika
>>>
>>  -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Django HTML controls and CRUD creation functionalities

2013-03-29 Thread jackuct1


I am new to Django, and read through some of the tutorials and cannot find 
the answer the below.

I just learn about asp.net/and Yii in PhP, for the HTML control(textbox, 
button, image, etc.) they have their own built in controls, in order to 
save state across page posting back, I am not sure does Django has similar 
built-in controls, or it is using only the html control? If it is using 
HTML control, does it have any special functionalists built into the HTML 
control?

The other question is, for Yii, it has user interface for generating CRUD, 
does Django have such features?

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




How to get the the filename of WGET?

2013-03-29 Thread lx
hi all:
I want to send information to django use this:
wget -v --post-file=conf.xml http://192.168.23.73:8001/ipdb_file/

And the Python code is:

def receive(request):
"""
receive all the xml form myCONF.
"""
if request.method == 'POST':
conf_xml =  request.body
result = handle_xml(conf_xml)
else:
result = "42"

html = "It is now %s." % result

return HttpResponse(html)



I want to know how to get the filename in the WGET like conf.xml

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Django wiki and notify

2013-03-29 Thread Josue Balandrano
Hi everyone. I just installed django in a test local server. Within a 
virtualenv and postgres. Everything is working ok, in a basic installation 
sense of the word.
The thing is that I am trying to install django-wiki and I have installed 
all of the requirements but I am getting some trouble with django_notify.
I have installed it with by executin `pip install django_notify` and also 
tryed `easy_install django_notify` and even `pip install 
git+https://{django_notify git reporistoy}` and when ever I add it to my 
Install apps (like so 'django_notify',) and I try to sync my DBs I get an 
"Import Error: could not find name notify". If I remove django_notify and 
wiki from my installed apps the sync DB works. Anybody has any idea why 
`python manage.py syncdb` would be looking for 'notify' instead of 
'django_notify'?
I have even tryed making a soft link `ln -s 
lib/python2.7/site-packages/django-notify 
lib/python2.7/site-packages/notify` with no luck.
Here es my settings.py: http://pastebin.com/52kTHKKR
Thanks!

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django HTML controls and CRUD creation functionalities

2013-03-29 Thread Pankaj Singh
Hey,

On Fri, Mar 29, 2013 jacku...@gmail.com wrote:
> I just learn about asp.net/and Yii in PhP, for the HTML control(textbox,
> button, image, etc.) they have their own built in controls, in order to save
> state across page posting back, I am not sure does Django has similar
> built-in controls, or it is using only the html control? If it is using HTML
> control, does it have any special functionalists built into the HTML
> control?
I have never used ASP.NET or Yii, but you can achieve everything
offered by HTML Control from Forms, Templates, Models and Views in
Django.

> The other question is, for Yii, it has user interface for generating CRUD,
> does Django have such features?
Yes, Django has a very powerful admin site[1]. For screenshots of
admin site visit[2].

Links-
1. https://docs.djangoproject.com/en/1.5/ref/contrib/admin/
2. http://goo.gl/H9B5S

-- 

Sincerely,
Pankaj Singh
http://about.me/psjinx

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django wiki and notify

2013-03-29 Thread Tim Cook
It might help to have the traceback to see 'where' the actual error is occuring.

--Tim

On Fri, Mar 29, 2013 at 9:31 AM, Josue Balandrano  wrote:
> Hi everyone. I just installed django in a test local server. Within a
> virtualenv and postgres. Everything is working ok, in a basic installation
> sense of the word.
> The thing is that I am trying to install django-wiki and I have installed
> all of the requirements but I am getting some trouble with django_notify.
> I have installed it with by executin `pip install django_notify` and also
> tryed `easy_install django_notify` and even `pip install
> git+https://{django_notify git reporistoy}` and when ever I add it to my
> Install apps (like so 'django_notify',) and I try to sync my DBs I get an
> "Import Error: could not find name notify". If I remove django_notify and
> wiki from my installed apps the sync DB works. Anybody has any idea why
> `python manage.py syncdb` would be looking for 'notify' instead of
> 'django_notify'?
> I have even tryed making a soft link `ln -s
> lib/python2.7/site-packages/django-notify
> lib/python2.7/site-packages/notify` with no luck.
> Here es my settings.py: http://pastebin.com/52kTHKKR
> Thanks!
>
> --
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



-- 

Timothy Cook, MSc   +55 21 94711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to get the the filename of WGET?

2013-03-29 Thread Michael Elkins
In order to get the filename, you will need to use the 
multipart/form-data encoding (RFC2388).  wget does not support 
this, but curl does when you use the -F option:


curl -F file=@conf.xml http://192.168.23.73:8001/ipdb_file/

However, your code will need to be modified to use the 
request.POST dictionary rather than the raw form data 
(request.body), since the raw form data will contain the encoding 
of the file and the filename fields.


--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django wiki and notify

2013-03-29 Thread Josue Balandrano
Yeap. Sorry about this. It's working now. Apparently the version installed 
with pip or easy_install is not worknig correctly. I fixed it by 
uninstalling and installing it like so:
pip install git+https://github.com/benjaoming/django-wiki.git


El viernes, 29 de marzo de 2013 09:42:08 UTC-5, Tim Cook escribió:
>
> It might help to have the traceback to see 'where' the actual error is 
> occuring. 
>
> --Tim 
>
> On Fri, Mar 29, 2013 at 9:31 AM, Josue Balandrano 
> > 
> wrote: 
> > Hi everyone. I just installed django in a test local server. Within a 
> > virtualenv and postgres. Everything is working ok, in a basic 
> installation 
> > sense of the word. 
> > The thing is that I am trying to install django-wiki and I have 
> installed 
> > all of the requirements but I am getting some trouble with 
> django_notify. 
> > I have installed it with by executin `pip install django_notify` and 
> also 
> > tryed `easy_install django_notify` and even `pip install 
> > git+https://{django_notify git reporistoy}` and when ever I add it to my 
> > Install apps (like so 'django_notify',) and I try to sync my DBs I get 
> an 
> > "Import Error: could not find name notify". If I remove django_notify 
> and 
> > wiki from my installed apps the sync DB works. Anybody has any idea why 
> > `python manage.py syncdb` would be looking for 'notify' instead of 
> > 'django_notify'? 
> > I have even tryed making a soft link `ln -s 
> > lib/python2.7/site-packages/django-notify 
> > lib/python2.7/site-packages/notify` with no luck. 
> > Here es my settings.py: http://pastebin.com/52kTHKKR 
> > Thanks! 
> > 
> > -- 
> > 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...@googlegroups.com . 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > Visit this group at http://groups.google.com/group/django-users?hl=en. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>
>
>
> -- 
>  
> Timothy Cook, MSc   +55 21 94711995 
> MLHIM http://www.mlhim.org 
> Like Us on FB: https://www.facebook.com/mlhim2 
> Circle us on G+: http://goo.gl/44EV5 
> Google Scholar: http://goo.gl/MMZ1o 
> LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook 
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Clarification on building urls

2013-03-29 Thread CatDude
I am making my first attempt to get django working with Apache.
Specifically, I'm trying to add some django functionality to a site
that is already running other web-based applications (mostly nagios).
So what I've done is create a project with "django-admin.py
startproject dashboard" in /home/source/django-projects and 'django-
admin.py startapp events" in /home/source/django-projects/dashboard.

I've added an Apache config file named "dashboard.conf" that contains:
LoadModule wsgi_module modules/mod_wsgi.so

WSGIScriptAlias /wsgitest /home/source/django-projects/dashboard/
test.wsgi

WSGIScriptAlias /dashboard/ /home/source/django-projects/dashboard/
dashboard/wsgi.py
WSGIPythonPath /home/source/django-projects/dashboard


Order allow,deny
Allow from all


"startproject" created /home/source/django-projects/dashboard/
dashboard/wsgi.py. It's the basic WSGI config file described in the
tutorials and the Djengo book, with some explanatory comments added.

Now I've got to build /home/source/django-projects/dashboard/dashboard/
urls.py. For testing purposes I would like a request for
http:///dashboard/hello to execute function "hello" in /home/
source/django-projects/events/views.py. Do I understand the Django
book properly, that views.py should then contain:

from django.conf.urls import patterns, include, url
from events.views import hello

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
url('^hello/$', hello),
#url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
#url(r'^admin/', include(admin.site.urls)),
)

This is how I've got things configured now, but when I try to go to
http:///dashboard/hello I get a 404 error. And while playing
around I see that trying to go to http:///dashboard/ gives me
a 500 error. Here's where it gets interesting: When I look in Apache's
error_log I see the following:

[Fri Mar 29 18:32:09 2013] [notice] Apache/2.2.3 (Red Hat) configured
-- resuming normal operations
[Fri Mar 29 18:32:09 2013] [info] Server built: May 28 2012 08:45:26
[Fri Mar 29 18:32:09 2013] [debug] prefork.c(996): AcceptMutex:
sysvsem (default: sysvsem)
[Fri Mar 29 18:32:09 2013] [info] mod_wsgi (pid=10818): Attach
interpreter ''.
[Fri Mar 29 18:32:09 2013] [info] mod_wsgi (pid=10818): Adding '/home/
source/django-projects/dashboard' to path.
[Fri Mar 29 18:32:09 2013] [info] mod_wsgi (pid=10820): Attach
interpreter ''.
[Fri Mar 29 18:32:09 2013] [info] mod_wsgi (pid=10820): Adding '/home/
source/django-projects/dashboard' to path.
[Fri Mar 29 18:32:09 2013] [info] mod_wsgi (pid=10817): Attach
interpreter ''.
[Fri Mar 29 18:32:09 2013] [info] mod_wsgi (pid=10817): Adding '/home/
source/django-projects/dashboard' to path.
[Fri Mar 29 18:32:23 2013] [error] [client 127.0.0.1] Target WSGI
script not found or unable to stat: /home/source/django-projects/
dashboard/dashboard/wsgi.pyhello

Where is the "hello" at the end of that last line coming from? I get
the same message in error_log whether I request http:///dashboard/events
or http:///dashboard/events/.

I realize that I must be screwing up something very simple, but trying
to django to cooperate with Apache is proving to be frustrating.

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Confusion about Static Files

2013-03-29 Thread David Pitchford
I am experienced with Python but new to Django and web development in 
general. I am struggling to understand its static files system from the 
documentation . 
It seems like I have to set multiple settings variables and create multiple 
folders in order to get the server to accomplish the simple task of 
"finding" these files. After toying with it for a few hours I haven't been 
able to get the static files system to work and and have resorted to the 
following system which is probably a very bad idea:

In views.py:

from django.http import HttpResponse
from django.shortcuts import render_to_response
from django.template import RequestContext
import datetime
import os.path
import settings

statictypes = {".css": "text/css",
   ".js": "text/javascript"}

def servestatic(request, filename):
fullfilename = os.path.join(settings.STATIC_ROOT, filename)
ext = os.path.splitext(filename)[1]
return HttpResponse(open(fullfilename).read(), 
content_type=statictypes[ext])

And in urls.py:

from django.conf.urls import patterns, include, url
import mysite.views as views

staticextensions = [ext[1:] for ext in views.statictypes.keys()]
staticextstring = '|'.join(staticextensions)

urlpatterns = patterns('',
...
(r"([^/]+\.(?:%s))$" % staticextstring, views.servestatic)
)

This actually works (and I could optimize it by caching the static file 
contents in memory rather than continually rereading them), but of course 
it's circumventing Django's built-in system for managing static files. My 
project architecture looks like this:

mysite
|
|--manage.py
|--mysite
   |
   |__init__.py
   |settings.py
   |urls.py
   |views.py
   |wgsi.py
   |--static
   |  |
   |  |--jquery.js
   |  |--TestFormat.css
   |
   |--templates
  |
  |--TestTemplate.html

At the beginning, the documentation page mentions, "For small projects, 
this isn’t a big deal, because you can just keep the static files somewhere 
your web server can find it." This sounds like the simple solution I'm 
looking for; what does it mean and how do I do it? I'm also frequently 
confused by how when I created the project it created two nested folders 
with the same name. Which is considered to be the "project root"?

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Confusion about Static Files

2013-03-29 Thread Brian Schott
David,

This took me a while to figure out also when I first started.  Running with 
debug on and runserver works great, then you try to use it in production and 
things break.  The big picture idea is that static files are intended to be 
hosted by something in front of Django, be that Apache or Ngnix or whatever.  
All of the django.contrib.static module does is define a) how/where the 
manage.py collectstatic command finds static files, STATICFILES_FINDERS, 
STATICFILES_DIRS, b) where it will save them on the local filesystem 
STATIC_ROOT, and c) what URL prefix will get used in templates STATIC_URL.

With settings.DEBUG  = True, you can add static files to your url pattern with 
the code below so that your server will work with manage.py runserver, but as 
soon as you go production and turn off DEBUG, this will stop working by design.
---
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
# ... the rest of your URLconf goes here ...
urlpatterns += staticfiles_urlpatterns()
---

You really want not to serve files through Django.  Just do a collectstatic 
before runserver, and point your web server /static/ location at that 
directory. Here is a link to the nginx.conf file used by Mezzanine (a Django 
CMS app).
https://github.com/nimbis/mezzanine-project/blob/master/deploy/
Notice that location /static/ is served directly and everything else for the 
most part is a redirect to the Django server running on another port.  You can 
find Apache examples all over the place.  


Brian Schott
bfsch...@gmail.com



On Mar 29, 2013, at 3:36 PM, David Pitchford  
wrote:

> I am experienced with Python but new to Django and web development in 
> general. I am struggling to understand its static files system from the 
> documentation. It seems like I have to set multiple settings variables and 
> create multiple folders in order to get the server to accomplish the simple 
> task of "finding" these files. After toying with it for a few hours I haven't 
> been able to get the static files system to work and and have resorted to the 
> following system which is probably a very bad idea:
> 
> In views.py:
> 
> from django.http import HttpResponse
> from django.shortcuts import render_to_response
> from django.template import RequestContext
> import datetime
> import os.path
> import settings
> 
> statictypes = {".css": "text/css",
>".js": "text/javascript"}
> 
> def servestatic(request, filename):
> fullfilename = os.path.join(settings.STATIC_ROOT, filename)
> ext = os.path.splitext(filename)[1]
> return HttpResponse(open(fullfilename).read(), 
> content_type=statictypes[ext])
> 
> And in urls.py:
> 
> from django.conf.urls import patterns, include, url
> import mysite.views as views
> 
> staticextensions = [ext[1:] for ext in views.statictypes.keys()]
> staticextstring = '|'.join(staticextensions)
> 
> urlpatterns = patterns('',
> ...
> (r"([^/]+\.(?:%s))$" % staticextstring, views.servestatic)
> )
> 
> This actually works (and I could optimize it by caching the static file 
> contents in memory rather than continually rereading them), but of course 
> it's circumventing Django's built-in system for managing static files. My 
> project architecture looks like this:
> 
> mysite
> |
> |--manage.py
> |--mysite
>|
>|__init__.py
>|settings.py
>|urls.py
>|views.py
>|wgsi.py
>|--static
>|  |
>|  |--jquery.js
>|  |--TestFormat.css
>|
>|--templates
>   |
>   |--TestTemplate.html
> 
> At the beginning, the documentation page mentions, "For small projects, this 
> isn’t a big deal, because you can just keep the static files somewhere your 
> web server can find it." This sounds like the simple solution I'm looking 
> for; what does it mean and how do I do it? I'm also frequently confused by 
> how when I created the project it created two nested folders with the same 
> name. Which is considered to be the "project root"?
> 
> -- 
> 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?hl=en.
> 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Question about documentauion under Managers>Adding extra Manager methods

2013-03-29 Thread James Durham
In the example:

class PollManager(models.Manager):
def with_counts(self):
from django.db import connection
cursor = connection.cursor()
cursor.execute("""SELECT p.id, p.question, p.poll_date, 
COUNT(*)FROM polls_opinionpoll p, polls_response rWHERE 
p.id = r.poll_idGROUP BY 1, 2, 3ORDER BY 3 DESC""")
result_list = []
for row in cursor.fetchall():
p = self.model(id=row[0], question=row[1], poll_date=row[2])
p.num_responses = row[3]
result_list.append(p)
return result_list
class OpinionPoll(models.Model):
question = models.CharField(max_length=200)
poll_date = models.DateField()
objects = PollManager()
class Response(models.Model):
poll = models.ForeignKey(OpinionPoll)
person_name = models.CharField(max_length=50)
response = models.TextField()

What is the sql dialect that is 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Question about documentauion under Managers>Adding extra Manager methods

2013-03-29 Thread Russell Keith-Magee
On Sat, Mar 30, 2013 at 6:20 AM, James Durham wrote:

> In the example:
>
> class PollManager(models.Manager):
> def with_counts(self):
> from django.db import connection
> cursor = connection.cursor()
> cursor.execute("""SELECT p.id, p.question, p.poll_date, 
> COUNT(*)FROM polls_opinionpoll p, polls_response r
> WHERE p.id = r.poll_idGROUP BY 1, 2, 3ORDER BY 3 
> DESC""")
> result_list = []
> for row in cursor.fetchall():
> p = self.model(id=row[0], question=row[1], poll_date=row[2])
> p.num_responses = row[3]
> result_list.append(p)
> return result_list
> class OpinionPoll(models.Model):
> question = models.CharField(max_length=200)
> poll_date = models.DateField()
> objects = PollManager()
> class Response(models.Model):
> poll = models.ForeignKey(OpinionPoll)
> person_name = models.CharField(max_length=50)
> response = models.TextField()
>
> What is the sql dialect that is used.
>
> In this case you're opening a cursor, so you use whatever dialect your
database uses. If you're using PostgreSQL, use PostgreSQL syntax; if you're
using MySQL, use MySQL syntax.

Django's ORM hides syntax differences from you; but once you start dealing
with database cursors or raw() queries, you're coding right to the metal,
so your deployment environment matters.

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.