Re: Understanding the use of Apache and nginix with Django

2012-09-08 Thread Psamathos
If you are using only Apache with mod_wsgi, you will also need to set up 
Aliases for your media directories (like css, images, or user-uploaded 
files). This is because mod_wsgi doesn't serve static files, it is only 
used to generate the dynamic pages of your site. It's perfectly possible to 
use Apache alone to do this without employing another web server. However, 
if you are implementing a site that you expect will receive high load you 
may want to set up a separate web server to act as a reverse proxy to your 
apache/mod_wsgi server while also serving static files. This will allow you 
to use nginx to serve static files independently of apache, for which nginx 
is technically more efficient although in my opinion the actual difference 
in negligible. I would personally stick with an apache-only configuration 
unless you need the flexibility afforded by two separate web server 
configurations. 

If you're using Django 1.4 you should be using the built-in staticfiles 
app: https://docs.djangoproject.com/en/1.4/howto/static-files/

On Saturday, 8 September 2012 10:49:26 UTC-4, Reginald Choudari wrote:
>
> Hello,
>
> I've just started working on deploying a Django hosted website on my VPS. 
> Last night I finished configuring mod_wsgi with apache2.2 and had got the 
> 'It works!' page running from my Django project. I read here (
> https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/) the 
> following: 
>
> Django doesn't serve files itself; it leaves that job to whichever Web 
> server you choose.
> We recommend using a separate Web server -- i.e., one that's not also 
> running Django -- for serving media. Here are some good choices:
>
>- lighttpd 
>
>
>- Nginx 
>
> I don't really understand this. This morning I configured my urls.py and 
> views.py to direct the '/' site url to an index.html template I created on 
> the fly (just for sanity check). Although it wasn't working at first, I 
> restarted apache2.2 service and the web page shows fine now. I don't 
> understand the idea of hosting two web servers and how Django is involved 
> with this if at all. 
>
> To me, it seems like apache routes clients to the wsgi, and the wsgi 
> returns with whatever http response it conjures up? Can someone shed some 
> light on this?
>
> Thanks,
> RC
>

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



Re: Sending post request from Django to Couchdb remote server

2012-08-28 Thread Psamathos
CouchDB is meant to be used RESTfully, so go ahead and create those POST 
requests. That said, there are several Django backends that will help you 
to communicate with CouchDB but this might be more trouble than it's worth. 
It all depends on what you need from CouchDB. Personally I'd forego any 
wrappers and just use it directly. You sacrifice some of the flexibility 
and power of CouchDB by hiding behind Django's RDBMS-centric backend.

If you're worried about security, which is really only an issue if you 
choose to expose the CouchDB server to the Internet, then go ahead and look 
into the various authentication options offered by CouchDB. However, if 
it's just eavesdropping you're worried about, you can configure your 
CouchDB server to use SSL and limit its connections to those originating 
from your server only.

On Wednesday, 29 August 2012 00:33:20 UTC-4, psychok7 wrote:
>
> So, i have a fully operational django project with postgresql to manage 
> its contents.   Nevertheless i decided to create a second database using 
> couchdb to keep just one part of that data. Should i use *urllib2* and send 
> post requests to my couchdb to save the new data or this is just bad 
> programming (not secure,etc) and i should use something else?
> Thanks
>

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



Re: jquery, json and forms

2012-07-02 Thread Psamathos
It sounds like you want to initialize your form in the view. You can also 
do this by passing an initial keyword argument to the form constructor:

exampleform = ExampleForm(initial={"examplefield": 
request.user.first_name})

This would set the examplefield of ExampleForm to the requesting user's 
first name.


On Monday, 2 July 2012 11:12:49 UTC-4, David wrote:
>
> Hello
>
> I have a form that saves, and displays errors correctly when using 
> javascript and without.
>
> However, when my form saves I need to refresh the form with the new form 
> data. How can I pass the form object through json back to my template 
> please?
>
> Thank you for any help.
>

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



Re: javascript in django template not executed when request is sent via ajax

2012-06-30 Thread Psamathos
If your web server is in fact serving the content with the incorrect 
Content-Type header (You can verify this by inspecting the response in the 
Net tab of Firebug or Chrome) jQuery can convert the response regardless of 
the content-type if you specify a two space-separated values in your 
dataType. Try dataType: "text html" in your $.ajax function.

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



Re: Update database with model changes

2012-06-07 Thread Psamathos
South will handle schema migrations for you: http://south.aeracode.org/

This tutorial is a good place to start and covers the basic set-up: 
http://south.aeracode.org/docs/tutorial/part1.html

Basically, you want to revert your changes so your model matches your 
database, install south and configure your app to use it, then convert your 
models to use south by typing:

python manage.py schemamigration [appname] --initial

This creates migration files which are stored in [appname]/migrations/
You can then apply these migrations using this command:

python manage.py migrate [appname]

Note that you need to do this for each app in your project. When you change 
the model and want to update the database, you can create migration files 
automatically with:

python manage.py schemamigration [appname] --auto

Then just apply them as you did with the initial migration.

Some best practices for avoiding issues with South:

   - If your model has a NOT NULL field then it should always have a 
   default. That way South will know what value to fill in when it creates the 
   field.
   - If you are changing a pre-existing model field drastically and don't 
   care about losing data, I find it most convenient to remove the field, 
   migrate the schema, then add the field again with the new specification . 
   This way you will avoid conflicts with any existing constraints. Note that 
   to preserve the data you'll need to create a (more complicated) data 
   migration.
   
Hope this helps.


On Thursday, 7 June 2012 14:05:13 UTC-4, Surgemcgee wrote:
>
> Hey Gang, is there a way to update the database with a syncdb or 
> other command after a model has been changed? I added a field 
> the the model after the syncdb. 
>
>
> -- 
> Bust0ut, Surgemcgee: Systems Engineer --- 
> PBDefence.com 
> BudTVNetwork.com 
> RadioWeedShow.com 
> "Bringing entertainment to Unix" 
>

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



Re: Need help creating model.

2012-03-28 Thread Psamathos
I would create a many-to-many relationship between Student and Class 
through a custom intermediate model called Grade. You can then add a date 
field to Grade and any other extra fields you want.

Read up on m2m relationships here: 
https://docs.djangoproject.com/en/dev/topics/db/models/#many-to-many-relationships

Basically, you want to add a field to Student like

classes = models.ManyToManyField(Class, through='Grade')

Then add a new model like this:

class Grade(models.Model):
student = models.ForeignKey(Student)
class = models.ForeignKey(Class)
grade = models.IntegerField()
date = models.DateField(auto_now_add=True)


-Psamathos


On Tuesday, 27 March 2012 21:18:12 UTC-4, Zach wrote:
>
> I have the following in my Student model. I am wanting to track the 
> date of each point given to each student. The idea would be so that I 
> could see not only how many points each student has, but also see the 
> date each point was given. In the future I want to see the trend of 
> each students' points.   How should I go about this? Should I use a 
> Foreign Key in another class. I am new to this so thanks for reading. 
>
>
> class Student(models.Model): 
>
>   CLASS_CHOICES = ( 
> (u'Yoga','Yoga'), 
> (u'Spanish', 'Spanish'), 
> (u'French', 'French'), 
> (u'Dance', 'Dance'), 
>   ) 
>
>   name = models.CharField(max_length=30) 
>   points = models.IntegerField(max_length=4) 
>   classname = models.CharField("Class Name",max_length=20, choices = 
> CLASS_CHOICES) 
>
>
On Tuesday, 27 March 2012 21:18:12 UTC-4, Zach wrote:
>
> I have the following in my Student model. I am wanting to track the 
> date of each point given to each student. The idea would be so that I 
> could see not only how many points each student has, but also see the 
> date each point was given. In the future I want to see the trend of 
> each students' points.   How should I go about this? Should I use a 
> Foreign Key in another class. I am new to this so thanks for reading. 
>
>
> class Student(models.Model): 
>
>   CLASS_CHOICES = ( 
> (u'Yoga','Yoga'), 
> (u'Spanish', 'Spanish'), 
> (u'French', 'French'), 
> (u'Dance', 'Dance'), 
>   ) 
>
>   name = models.CharField(max_length=30) 
>   points = models.IntegerField(max_length=4) 
>   classname = models.CharField("Class Name",max_length=20, choices = 
> CLASS_CHOICES) 
>
>

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



Re: syncdb fails for auth and other "built-in" apps

2007-06-05 Thread Psamathos



On 5 Juni, 17:18, "Deryck Hodge" <[EMAIL PROTECTED]> wrote:
> On 6/4/07, Psamathos <[EMAIL PROTECTED]> wrote:
>
> >  Anyone with an idea what this could be?
>
> > Error: Couldn't install apps, because there were errors in one or more
> > models:
> > django.contrib.admin: 
> > django.contrib.sites: 
> > django.contrib.contenttypes: 
> > django.contrib.sessions: 
> > django.contrib.auth: 
>
> Hi, Magnus.
>
> What does running `./manage.py validate` say?  Is that error above the
> same as what validate says?
>
> Cheers,
> deryck

It does. I installed version 0.96 and it works there, but then I'd
have to change all my form.cleaned_data to form.clean_data, not a lot
of work but a tad annoying since I'll have to change back when 0.97 is
released :)

$ python manage.py validate
django.contrib.admin: 
django.contrib.sites: 
django.contrib.contenttypes: 
django.contrib.sessions: 
django.contrib.auth: 

regards,
Magnus


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



syncdb fails for auth and other "built-in" apps

2007-06-04 Thread Psamathos

Hi,

I'm trying to run syncdb for my site, but for some reason it doesn't
work anymore ( it used to work though ). I've tried to check the
models but I can't see anything wrong and the error-message isn't
really clear for me.

It does however work on my server. They're both using python 2.5.1,
psycopg2 from svn ( same version ) and I can't find any differences
really.

 Anyone with an idea what this could be?

Error: Couldn't install apps, because there were errors in one or more
models:
django.contrib.admin: 
django.contrib.sites: 
django.contrib.contenttypes: 
django.contrib.sessions: 
django.contrib.auth: 

regards,
Magnus Sjöstrand


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



Re: Problems with i18n support

2007-05-12 Thread Psamathos



On 12 Maj, 11:39, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> On Sat, 2007-05-12 at 02:25 -0700, Psamathos wrote:
> > Hi,
>
> > I'm trying to get some basic i18n support going but I'm get some weird
> > errors.
>
> > 1) I had to include the project in INSTALLED_APPS before anything
> > would happend at all, but I've since removed that and I'm trying to
> > translate a single app.
> > 2) I've been digging around the django code to figure out which part
> > wasn't working, and in django/template/__init__.py:727 I changed to
> > return "%s" % bits, just to see what was in the list. Every
> > translation comes back as a  which might or
> > might not be correct. I thought it was supposed to be a string though.
>
> > Currently I'm stuck with this error:
>
> > AssertionError at /users/signup
> >  should be a basestring
> > Request Method:POST
> > Request URL:  http://naring.dev/users/signup
> > Exception Type:AssertionError
> > Exception Value:should be a basestring
> > Exception Location:/usr/lib/python2.5/site-packages/django/newforms/
> > util.py in __init__, line 47
>
> This does look unusual. Since I don't remember us completely breaking
> the i18n support recently, I suspect there is something not quite right
> in your code. You've given us a very clear indication of what the error
> is that you're seeing. Now, it would be good to see what you are doing
> to generate those pieces.
>
> Can you make a (preferably very small) example that demonstrates the
> problem you are seeing? What is the smallest template you can make that
> shows this issue? It will be easier to help work out what's going wrong
> if we can replicate the problem.
>
> Regards,
> Malcolm

I made a new template:

{% load i18n %}
{% trans "login:" %}

with which I get the error:

TypeError at /users/signup
sequence item 2: expected string, instance found
Request Method: GET
Request URL:http://naring.dev/users/signup
Exception Type: TypeError
Exception Value:sequence item 2: expected string, instance found
Exception Location: /usr/lib/python2.5/site-packages/django/template/
__init__.py in render, line 726

I could start a new project and see if I messed something up in this
one.


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



Re: Problems with i18n support

2007-05-12 Thread Psamathos



On 12 Maj, 11:25, Psamathos <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm trying to get some basic i18n support going but I'm get some weird
> errors.
>
> 1) I had to include the project in INSTALLED_APPS before anything
> would happend at all, but I've since removed that and I'm trying to
> translate a single app.
> 2) I've been digging around the django code to figure out which part
> wasn't working, and in django/template/__init__.py:727 I changed to
> return "%s" % bits, just to see what was in the list. Every
> translation comes back as a  which might or
> might not be correct. I thought it was supposed to be a string though.
>
> Currently I'm stuck with this error:
>
> AssertionError at /users/signup
>  should be a basestring
> Request Method: POST
> Request URL:http://naring.dev/users/signup
> Exception Type: AssertionError
> Exception Value: should be a basestring
> Exception Location: /usr/lib/python2.5/site-packages/django/newforms/
> util.py in __init__, line 47
>
> Anyone that could help me with this? Django is the best web framework
> I've used so far and I'd like to use it. I've checked out the latest
> version from subversion (5199). Django is running with mod_python in a
> prefork apache2, I've set the max request limit to 1.
>
> regards,
> Magnus Sjöstrand

If I move the LocaleMiddleWare I can end up with the following error:

TypeError at /users/signup
sequence item 0: expected string, instance found
Request Method: GET
Request URL:http://naring.dev/users/signup
Exception Type: TypeError
Exception Value:sequence item 0: expected string, instance found
Exception Location: /usr/lib/python2.5/site-packages/django/template/
__init__.py in render, line 726

Seems to me this is the same error just occuring at a different place
though.

//Magnus


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



Problems with i18n support

2007-05-12 Thread Psamathos

Hi,

I'm trying to get some basic i18n support going but I'm get some weird
errors.

1) I had to include the project in INSTALLED_APPS before anything
would happend at all, but I've since removed that and I'm trying to
translate a single app.
2) I've been digging around the django code to figure out which part
wasn't working, and in django/template/__init__.py:727 I changed to
return "%s" % bits, just to see what was in the list. Every
translation comes back as a  which might or
might not be correct. I thought it was supposed to be a string though.

Currently I'm stuck with this error:

AssertionError at /users/signup
 should be a basestring
Request Method: POST
Request URL:http://naring.dev/users/signup
Exception Type: AssertionError
Exception Value: should be a basestring
Exception Location: /usr/lib/python2.5/site-packages/django/newforms/
util.py in __init__, line 47

Anyone that could help me with this? Django is the best web framework
I've used so far and I'd like to use it. I've checked out the latest
version from subversion (5199). Django is running with mod_python in a
prefork apache2, I've set the max request limit to 1.

regards,
Magnus Sjöstrand


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