Re: querySet + select distinct

2009-11-19 Thread Andy McKay
On 09-11-19 3:36 PM, Benjamin Wolf wrote:
> I'm trying to create a select with the django query set which should
> give me the same result like this sql statement:
> SELECT distinct(YEAR(`mydate`)) FROM `table`
>
> I've tried it for a while but don't get it.

Try using values in the filter eg:

Disposal.objects.values("mydate").filter(mydate__year__gte=2008).distinct()

The problem is the default django query selects all the fields, messing 
up the distinct part.

http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-fields
-- 
   Andy McKay, @clearwind
   Training: http://clearwind.ca/training/
   Whistler conference: http://clearwind.ca/djangoski/

--

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




Re: passing vars to filters?

2009-11-19 Thread neridaj
Thanks Karen.

On Nov 19, 4:56 pm, Karen Tracey  wrote:
> On Thu, Nov 19, 2009 at 7:25 PM, neridaj  wrote:
> > Is it possible to pass vars to filters rather than hard coding the
> > field name, something like this:
>
> > def search(request):
> >    query = request.GET.get('q', '')
> >    bits = request.GET.get('models', '').partition('.')
> >    model_name = bits[0]
> >    field_name = bits[2]
> >    model_type = ContentType.objects.get(app_label="blog",
> > model=model_name)
> >    model_class = model_type.model_class()
> >    results = []
> >    if query:
> >        results = model_class.objects.filter
> > (field_name__icontains=query)
> >    return render_to_response('search/search.html',
> >                                { 'query': query, 'results':
> > results })
>
> Create a dictionary of keyword arguments and pass that. For example:
>
> results = model_class.objects.filter(**{field_name+'__icontains': query})
>
> Karen

--

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




Re: Multiple sites on a single server

2009-11-19 Thread Graham Dumpleton


On Nov 20, 4:33 am, Stodge  wrote:
> I got this working with several sites using Apache. I just created a
> configuration file for each site and pointed it to different settings
> files:
>
> 
>     SetHandler python-program
>     PythonHandler django.core.handlers.modpython
>     SetEnv DJANGO_SETTINGS_MODULE test.settings
>     PythonOption django.root /test
>     PythonDebug On
>     PythonPath "['/var/www/test'] + sys.path"
>     PythonAutoReload On
> 
>
> 
>     SetHandler python-program
>     PythonHandler django.core.handlers.modpython
>     SetEnv DJANGO_SETTINGS_MODULE fred.settings
>     PythonOption django.root /fred
>     PythonDebug On
>     PythonPath "['/var/www/fred'] + sys.path"
>     PythonAutoReload On
> 
>
> Something like this I think.

Missing PythonInterpreter directive in each to force each to run in
separate Python sub interpreter.

Graham

> On Nov 19, 12:23 pm, Mark Freeman  wrote:
>
>
>
> > I currently have a working site running Django and now want to move a
> > couple of other of my sites to Django as well. I'm in the process of
> > moving off a hosted VPS to my own local server, where the existing
> > Django site is.
>
> > My questions is more of best practice when deploying multiple sites to
> > the same server. Given that I have a running site, is it possible to
> > deploy multiple Django 'projects' to the same server and just use
> > Apache to serve them out separately or is it best to use the sites
> > module to do this from the same project? For code cleanliness, I would
> > prefer to have them as separate projects, but I don't want to kill
> > server performance either.
>
> > Thanks for any suggestions!- Hide quoted text -
>
> - Show quoted text -

--

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




Re: passing vars to filters?

2009-11-19 Thread Karen Tracey
On Thu, Nov 19, 2009 at 7:25 PM, neridaj  wrote:

> Is it possible to pass vars to filters rather than hard coding the
> field name, something like this:
>
> def search(request):
>query = request.GET.get('q', '')
>bits = request.GET.get('models', '').partition('.')
>model_name = bits[0]
>field_name = bits[2]
>model_type = ContentType.objects.get(app_label="blog",
> model=model_name)
>model_class = model_type.model_class()
>results = []
>if query:
>results = model_class.objects.filter
> (field_name__icontains=query)
>return render_to_response('search/search.html',
>{ 'query': query, 'results':
> results })
>

Create a dictionary of keyword arguments and pass that. For example:

results = model_class.objects.filter(**{field_name+'__icontains': query})

Karen

--

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




Re: Initial values for formwizard form

2009-11-19 Thread geraldcor
This worked perfectly. Thank you. I used parse_params because I needed
to add default company profile stuff to the first wizard form. Thank
you again for clearing up my ignorance.

Greg

On Nov 18, 9:10 pm, "Mark L."  wrote:
> On Nov 19, 1:28 am, geraldcor  wrote:
>
>
>
> > Ok,
>
> > Here is how I do it if I am using a regularformwith a regular view:
>
> > profile = request.user.get_profile()
> >form= MyForm('company': profile.defaultcompany, 'contact':
> > profile.defaultcontact, etc...})
> > return render_to_response('forms/submit.html', {'form':form},
> > context_instance=RequestContext(request))
>
> > pretty simple and basic.
>
> > How do I do this with aformwizard?
>
> > Greg
>
> > On Nov 17, 3:39 pm, geraldcor  wrote:
>
> > > Hello all,
>
> > > I began making aformthat used request.user.get_profile to get
> > > default values for company name, phone, email etc. I have since
> > > decided to move to a formwizard to split things up. I have no idea how
> > > to override methods for the formwizard class to be able to include
> > > thoseinitialvalues in theform. Can someone please help me with this
> > > problem or point me to the proper help? I have come up short with all
> > > of my searching. Thanks.
>
> Hello,
>
> The *initial* values for the forms in aformwizardare stored in the
> self.initial[] list. It means, that to set setinitialvalues for theformin 
> step X you do the following:
>
> init = {
>     'key1':'val1',
>     'key2':'val2',
>     etc..
>
> }
>
> self.initial[X] = init
>
> The best (and, indeed, about the only place to handle this) is the
> process_step method of thewizardinstance (or parse_params, if you
> need to setinitialvalues for theformin step 0).
>
> Hope that helps
>
> Mark

--

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




passing vars to filters?

2009-11-19 Thread neridaj
Is it possible to pass vars to filters rather than hard coding the
field name, something like this:

def search(request):
query = request.GET.get('q', '')
bits = request.GET.get('models', '').partition('.')
model_name = bits[0]
field_name = bits[2]
model_type = ContentType.objects.get(app_label="blog",
model=model_name)
model_class = model_type.model_class()
results = []
if query:
results = model_class.objects.filter
(field_name__icontains=query)
return render_to_response('search/search.html',
{ 'query': query, 'results':
results })


Thanks,

J

--

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




Re: FAQ?

2009-11-19 Thread Kenneth Gonsalves
On Thursday 19 Nov 2009 9:32:59 pm Andy McKay wrote:
> > Does anyone want to take a stab at an FAQ?  There are a lot of repeated
> > questions on the list.
> 
> How about http://docs.djangoproject.com/en/dev/faq/
> 

there was also an IRC faq - but it is no longer mentioned in the IRC topic.
-- 
regards
Kenneth Gonsalves
Senior Project Officer
NRC-FOSS
http://nrcfosshelpline.in/web/

--

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




Re: Multiple sites on a single server

2009-11-19 Thread Kenneth Gonsalves
On Thursday 19 Nov 2009 11:01:10 pm Eric Elinow wrote:
>  I currently do this for the 5 or so sites that I operate for a client.  A
>  single Apache setup for Django, with the various virtual hosts being
>  directed to their own path(s), and any static media requests being port
>  forwarded from apache to a lighttpd instance.  I have my sites path
>  containing each project  (sites/site1 sites/site2 etc.) and have had this
>  setup for quite some time with absolutely zero problems.
> 

I used to do this - I find it much easier to do it with nginx
-- 
regards
Kenneth Gonsalves
Senior Project Officer
NRC-FOSS
http://nrcfosshelpline.in/web/

--

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




Re: How should I use manage.py dumpdata, and loaddata?

2009-11-19 Thread Russell Keith-Magee
On Thu, Nov 19, 2009 at 9:59 AM, Sachi  wrote:
> Hi, all,
>
> I have been developing a website, where I use the same postgresql
> database server for both development and production. Now that I have
> had many users and a significant amount of data, I am trying to use
> sqlite3 engine when I do development locally instead of connecting to
> the production server. In my settings.py, I have something that looks
> like:
>
> if ON_PRODUCTION_SERVER: DATABASE_ENGINE  = "postgresql_psycopg2" ...
> else: DATABASE_ENGINE = "sqlite3" ...
>
> My task right now is to dump data (I wish to dump all of them) from
> the production server, and install them in the local sqlite database.
> This is what I did:
>
> python manage.py dumpdata > data.json
>
> Then, I switched to sqlite3 database, and did
>
> python manage.py syncdb
> python manage.py loaddata data.json
>
> However, I met the following errors:
>
> Installing json fixture 'data' from absolute path.
> Problem installing fixture 'data.json': Traceback (most recent call
> last):
>  File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/core/management/commands/loaddata.py",
> line 153, in handle
>    obj.save()
>  File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/core/serializers/base.py", line 163, in
> save
>    models.Model.save_base(self.object, raw=True)
>  File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/db/models/base.py", line 474, in
> save_base
>    rows = manager.filter(pk=pk_val)._update(values)
>  File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/db/models/query.py", line 444, in
> _update
>    return query.execute_sql(None)
>  File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/db/models/sql/subqueries.py", line 120,
> in execute_sql
>    cursor = super(UpdateQuery, self).execute_sql(result_type)
>  File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/db/models/sql/query.py", line 2369, in
> execute_sql
>    cursor.execute(sql, params)
>  File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/db/backends/util.py", line 19, in
> execute
>    return self.cursor.execute(sql, params)
>  File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/db/backends/sqlite3/base.py", line 193,
> in execute
>    return Database.Cursor.execute(self, query, params)
> IntegrityError: columns app_label, model are not unique
>
>
> Could anybody let me know why this error happened, and how I get
> correctly dump/load data?

Was there something wrong with the answer I gave to this question when
you posted it last night?

[1] 
http://groups.google.com/group/django-users/browse_thread/thread/83716fe2a9a376d6

Yours,
Russ Magee %-)

--

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




querySet + select distinct

2009-11-19 Thread Benjamin Wolf
Hello,

I'm trying to create a select with the django query set which should 
give me the same result like this sql statement:
SELECT distinct(YEAR(`mydate`)) FROM `table`

I've tried it for a while but don't get it.

Something like
self.fields['field'].choices =  [('x', 'x') for disp in 
Disposal.objects.filter(mydate__year__gte =  2008).distinct()]

What's obvisously wrong.
Hope you can give me a tip.
Thanks very much,
regards Ben

--

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




Re: autogenerated 'id' field from Django model doesn't autoincrement?

2009-11-19 Thread Karen Tracey
On Thu, Nov 19, 2009 at 4:50 PM, Ken MacDonald  wrote:

> Define a models.py as:
>
> from django.db import models
>
> # Create your models here.
> class Cardrange(models.Model):
> minbin = models.DecimalField(max_digits=12, decimal_places=0)
> maxbin = models.DecimalField(max_digits=12, decimal_places=0)
>
> minpan = models.IntegerField()
> maxpan = models.IntegerField()
>
> ... more fields and 'def __unicode__() ...
>
>
Are you absolutely sure there is not:

id = models.IntegerField(primary_key=True)

among the "more fields"?

Karen

--

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




Re: Automatic swapping of field data?

2009-11-19 Thread Doug Blank
On Thu, Nov 19, 2009 at 4:36 PM, Preston Holmes  wrote:
> There are some details left out of how you want this to look.
>
> The lower the level you try to make an object self protecting, the
> trickier it's going to be.
>
> The sweet spot I think here is a custom manager that adds a protect
> filter, and perhaps a subclass of ModelForm if you need this in
> forms.  The custom manager method would take a user obj as a
> parameter, then loop through the objects in the queryset and modify
> protected fields as needed.
>
> http://www.djangoproject.com/documentation/models/custom%5Fmanagers/
> http://www.djangosnippets.org/snippets/562/

Thanks for the links! These got me thinking along a line of thought,
and I came up with something like:

class MyModel(models.Model):
...
def __getattribute__(self, item):
if item == "fieldname":
return ""
else:
return super(MyModel, self).__getattribute__(item)

In the getattribute method, I can check some conditions (ie, to see if
the user is logged in), and provide my own data if not. This way, I
can write my django code and never have to worry that the value of
fieldname will ever accidentally not be protected as this is the only
way to get it.

See any problems with this (other than taking a small hit on every
field access)?

-Doug

> On Nov 18, 4:17 pm, Doug Blank  wrote:
>> Django users,
>>
>> I have data that needs to be handled in two different manners,
>> depending on if the user has certain permissions or not. For example,
>> if a record is marked "private" and a user is not permitted, I want to
>> substitute the word "PROTECTED" for a particular field's value.
>>
>> Now, of course I realize that each and every place I refer to
>> table.fieldname I could wrap a protection around that, either in my
>> Python code, or in my templates.
>>
>> What I'm really looking for is something closer to the model code so
>> that I can be assured that no private data accidentally slips out.
>> Does Django have any built in support that does this, or could be
>> adapted to do this?
>>
>> Any ideas appreciated!
>>
>> -Doug
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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=.
>
>
>

--

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




Re: autogenerated 'id' field from Django model doesn't autoincrement?

2009-11-19 Thread Karen Tracey
On Thu, Nov 19, 2009 at 4:50 PM, Ken MacDonald  wrote:

> > 1) is it a bug that 'id' is generated as an 'integer' rather than
>> 'serial'
>> > type?
>>
>> I'd be curious as to how your DB got set up that way, since Django's
>> table-creation routines map AutoField to SERIAL:
>>
>>
>> http://code.djangoproject.com/browser/django/trunk/django/db/backends/postgresql/creation.py#L10
>>
>
> Define a models.py as:
>
> from django.db import models
>
> # Create your models here.
> class Cardrange(models.Model):
> minbin = models.DecimalField(max_digits=12, decimal_places=0)
> maxbin = models.DecimalField(max_digits=12, decimal_places=0)
>
> minpan = models.IntegerField()
> maxpan = models.IntegerField()
>
> ... more fields and 'def __unicode__() ...
>
> then run  'manage.py sysncdb'
>
> Just dropped my table and re-created it, and the 'id' autogenerated field
> is an integer as shown by pgadmin III.
>
>
>
I cannot recreate this.  Cut-and-paste of your model into a new app, set:

DATABASE_ENGINE = 'postgresql_psycopg2'

in settings.py, add the app to INSTALLED_APPS, run syncdb, and  pgadmin III
report the autogenerated id field is 'id serial NOT NULL'.  manage.py sql on
the app reports:

BEGIN;
CREATE TABLE "ttt_cardrange" (
"id" serial NOT NULL PRIMARY KEY,
"minbin" numeric(12, 0) NOT NULL,
"maxbin" numeric(12, 0) NOT NULL,
"minpan" integer NOT NULL,
"maxpan" integer NOT NULL
)
;
COMMIT;

In your case, what does manage.py sql for the app report?

Karen

--

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




Re: casting unicode to model

2009-11-19 Thread neridaj
I just found out that get() returns only one object.

On Nov 19, 2:30 pm, neridaj  wrote:
> Thanks for the help. Is get_object_for_this_type() not made to handle
> multiple objects? If more than one object is returned I get this
> error: get() returned more than one Entry.
>
> On Nov 19, 4:10 am, David De La Harpe Golden
>
>  wrote:
> > Karen Tracey wrote:
> > > Undocumented internal routine, but unlikely to change:
>
> > Just to note the contenttypes framework has a documented 
> > way:http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#method...
>
> > from django.contrib.contenttypes.models import ContentType
> > model_type = ContentType.objects.get(app_label=app_name, model=model_name)
> > model_class = model_type.model_class()

--

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




Re: casting unicode to model

2009-11-19 Thread neridaj
Thanks for the help. Is get_object_for_this_type() not made to handle
multiple objects? If more than one object is returned I get this
error: get() returned more than one Entry.

On Nov 19, 4:10 am, David De La Harpe Golden
 wrote:
> Karen Tracey wrote:
> > Undocumented internal routine, but unlikely to change:
>
> Just to note the contenttypes framework has a documented 
> way:http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#method...
>
> from django.contrib.contenttypes.models import ContentType
> model_type = ContentType.objects.get(app_label=app_name, model=model_name)
> model_class = model_type.model_class()

--

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




Strange debugger behavior

2009-11-19 Thread Nick Arnett
I'm not sure if this is a bug... couldn't find anything quite like it in the
tracker.  I'm using Komodo as my IDE.  When I step through source, the
filters in a Model.objects.filter method are ignored.  Instead of getting
the handful of rows that I want from my database, Django (1.1) grabs the
entire table -- there's no WHERE clause in the SQL it executes (this is with
MySQL).  When I run it outside the debugger, or avoid stepping into the
"magic" parts of the database stuff, it behaves properly - the WHERE clause
is present.

For an awful moment, I thought it was trying to cache the entire table...

This makes debugging with Komodo somewhat challenging, since the table where
I first encountered this has 50,000 rows that include the full text of web
pages.  Lots of data and even with plenty of memory, my machine starts
thrashing horribly when this happens.

Anybody aware of this as a known issue?  Any fix?

Since I can avoid it by not stepping through the "magic" parts of the
database stuff, it isn't critical.

Nick

--

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




Re: autogenerated 'id' field from Django model doesn't autoincrement?

2009-11-19 Thread Ken MacDonald
>
> > 1) is it a bug that 'id' is generated as an 'integer' rather than
> 'serial'
> > type?
>
> I'd be curious as to how your DB got set up that way, since Django's
> table-creation routines map AutoField to SERIAL:
>
>
> http://code.djangoproject.com/browser/django/trunk/django/db/backends/postgresql/creation.py#L10
>

Define a models.py as:

from django.db import models

# Create your models here.
class Cardrange(models.Model):
minbin = models.DecimalField(max_digits=12, decimal_places=0)
maxbin = models.DecimalField(max_digits=12, decimal_places=0)

minpan = models.IntegerField()
maxpan = models.IntegerField()

... more fields and 'def __unicode__() ...

then run  'manage.py sysncdb'

Just dropped my table and re-created it, and the 'id' autogenerated field is
an integer as shown by pgadmin III.


>
> > 3) Failing that, is there a better way to do the raw SQL steps outlined
> > above?
>
>
> http://docs.djangoproject.com/en/dev/ref/django-admin/#sqlsequencereset-appname-appname
>
> Thanks, that's a bit nicer!
Ken

--

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




Re: Automatic swapping of field data?

2009-11-19 Thread Preston Holmes
There are some details left out of how you want this to look.

The lower the level you try to make an object self protecting, the
trickier it's going to be.

The sweet spot I think here is a custom manager that adds a protect
filter, and perhaps a subclass of ModelForm if you need this in
forms.  The custom manager method would take a user obj as a
parameter, then loop through the objects in the queryset and modify
protected fields as needed.

http://www.djangoproject.com/documentation/models/custom%5Fmanagers/
http://www.djangosnippets.org/snippets/562/

On Nov 18, 4:17 pm, Doug Blank  wrote:
> Django users,
>
> I have data that needs to be handled in two different manners,
> depending on if the user has certain permissions or not. For example,
> if a record is marked "private" and a user is not permitted, I want to
> substitute the word "PROTECTED" for a particular field's value.
>
> Now, of course I realize that each and every place I refer to
> table.fieldname I could wrap a protection around that, either in my
> Python code, or in my templates.
>
> What I'm really looking for is something closer to the model code so
> that I can be assured that no private data accidentally slips out.
> Does Django have any built in support that does this, or could be
> adapted to do this?
>
> Any ideas appreciated!
>
> -Doug

--

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




Re: how to run django with fastcgi, but not run as user "root" on linux

2009-11-19 Thread Carl Zmola
OOPS,

sudo -u nobody (rest of the command line)
but you have to be set up with appropriate privledges.

check
sudo -l
to see what commands you are allowed to sudo.

Carl

Carl Zmola wrote:
> su -u nobody  (rest of the command line) works for me.
>
> Fm wrote:
>   
>> I know how to solve it .
>> su nobody -c cmdline -s /bin/sh
>> Thanks
>>
>> On Nov 19, 11:12 am, Fm  wrote:
>>   
>> 
>>> Hi,
>>> I'm am green-hand to linux.
>>> When I use /usr/bin/su nobody -c /usr/local/bin/python /home/admin/cc/
>>> manage.py runfcgi
>>> method=threaded host=127.0.0.1 port=12345
>>> it say "This account is currently not available."
>>>
>>> Because nobody's shell is /sbin/nologin,I could not use su?
>>>
>>> what is the normal way of RC system provided to set the user to run?
>>>
>>> Thanks a lot
>>> Fm
>>>
>>> On Nov 18, 7:37 pm, Tom Evans  wrote:
>>>
>>>
>>>
>>> 
>>>   
 On Wed, Nov 18, 2009 at 8:25 AM, Fm  wrote:
   
 
> Hi all,
> I have write a script in /etc/rc.d/init.d so that Django can start
> with my server.
> It may look like
> start () {
>echo -n $"Starting $prog: "
> /usr/local/bin/python /home/admin/cc/manage.py runfcgi method=threaded
> host=127.0.0.1 port=12345
> }
> 
>   
 /usr/bin/su nobody -c /usr/local/bin/python /home/admin/cc/manage.py 
 runfcgi
 method=threaded host=127.0.0.1 port=12345
   
 I'd be surprised if your RC system didn't provide a cleaner way of setting
 the user to run as though.
   
 Cheers
   
 Tom
   
 
>> --
>>
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@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=.
>>
>>
>>   
>> 
>
>   

-- 
Carl Zmola
301-562-1900 x315
czm...@woti.com


--

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




Re: autogenerated 'id' field from Django model doesn't autoincrement?

2009-11-19 Thread James Bennett
On Thu, Nov 19, 2009 at 1:57 PM, Ken MacDonald  wrote:
> So, a couple questions:
>
> 1) is it a bug that 'id' is generated as an 'integer' rather than 'serial'
> type?

I'd be curious as to how your DB got set up that way, since Django's
table-creation routines map AutoField to SERIAL:

http://code.djangoproject.com/browser/django/trunk/django/db/backends/postgresql/creation.py#L10

> 3) Failing that, is there a better way to do the raw SQL steps outlined
> above?

http://docs.djangoproject.com/en/dev/ref/django-admin/#sqlsequencereset-appname-appname


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--

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




Re: how to run django with fastcgi, but not run as user "root" on linux

2009-11-19 Thread Carl Zmola
su -u nobody  (rest of the command line) works for me.

Fm wrote:
> I know how to solve it .
> su nobody -c cmdline -s /bin/sh
> Thanks
>
> On Nov 19, 11:12 am, Fm  wrote:
>   
>> Hi,
>> I'm am green-hand to linux.
>> When I use /usr/bin/su nobody -c /usr/local/bin/python /home/admin/cc/
>> manage.py runfcgi
>> method=threaded host=127.0.0.1 port=12345
>> it say "This account is currently not available."
>>
>> Because nobody's shell is /sbin/nologin,I could not use su?
>>
>> what is the normal way of RC system provided to set the user to run?
>>
>> Thanks a lot
>> Fm
>>
>> On Nov 18, 7:37 pm, Tom Evans  wrote:
>>
>>
>>
>> 
>>> On Wed, Nov 18, 2009 at 8:25 AM, Fm  wrote:
>>>   
 Hi all,
 I have write a script in /etc/rc.d/init.d so that Django can start
 with my server.
 It may look like
 start () {
echo -n $"Starting $prog: "
 /usr/local/bin/python /home/admin/cc/manage.py runfcgi method=threaded
 host=127.0.0.1 port=12345
 }
 
>>> /usr/bin/su nobody -c /usr/local/bin/python /home/admin/cc/manage.py runfcgi
>>> method=threaded host=127.0.0.1 port=12345
>>>   
>>> I'd be surprised if your RC system didn't provide a cleaner way of setting
>>> the user to run as though.
>>>   
>>> Cheers
>>>   
>>> Tom
>>>   
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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=.
>
>
>   

-- 
Carl Zmola
301-562-1900 x315
czm...@woti.com


--

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




Re: @login_required decorator sends me to the wrong URL

2009-11-19 Thread Preston Holmes
http://docs.djangoproject.com/en/1.1/ref/settings/#login-url

There are going to be some other places you will have to be careful
running django on a path other than /

-Preston


On Nov 19, 7:11 am, Stodge  wrote:
> I added the @login_required decorator to my view but it redirects me
> to:
>
> http://localhost/accounts/login
>
> whereas the URL for my site is:
>
> http://localhost/test/accounts/login
>
> This is on Apache. Did I forget to configure something in settings.py?
>
> Thanks

--

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




Re: Django website stats

2009-11-19 Thread Brian McKeever
I haven't had a chance to play with this yet:
http://code.google.com/p/django-tracking/
but it might do what you want.

On Nov 19, 11:35 am, Fabio Natali  wrote:
> Martin Lundberg wrote:
> > I am very new to Django but can't this be handled by middleware
> > instead? It should have access to user and page data should it not?
>
> > -Martin
>
> > On Thursday, November 19, 2009, Fabio Natali
> >  wrote:
> > > Hi there!
>
> > > I have a Django based website with a few dozen users. Only logged
> > > users can enter the website and browse its pages.
>
> [...]
>
> Hi Martin,
>
> thank you so much for your reply. I'll look for some information on
> middleware then and post again if I encounter any problem.
>
> All the best,
> Fabio.
>
> --
> Fabio Natali

--

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




autogenerated 'id' field from Django model doesn't autoincrement?

2009-11-19 Thread Ken MacDonald
I have a postgreSQL / psycopg2 DB generated by my Django model with a single
user table (normally read-only) that will be updated via batch job about
once a week. The PK is the autogenerated 'id' field; however in postgreSQL
the generated field is of type 'integer' rather than type 'serial' which is
the postgreSQL auto-incrementing type. So, in my batch update job (no Django
involved here) I tried to:

INSERT INTO tablename (a, b, c) VALUES ('aa', 'bb', 'cc')

but it complained about a 'duplicate PK error' on id. I found that the
sequence 'tablename_id_seq' was not being updated, since it's not a 'serial'
field.

What I ended up doing:

First time through the update/insert loop, set the auto-increment sequence
counter:
SELECT setval('tablename_id_seq', (SELECT max(id) from tablename))

which ensures that the sequence starts at the proper spot;

then for each INSERT:
INSERT INTO tablename (id, a, b, c) VALUES (nextval('tablename_id_seq'),
'aa', 'bb', 'cc')

So, a couple questions:

1) is it a bug that 'id' is generated as an 'integer' rather than 'serial'
type?

2) Is there a way to get Django's model to generate a 'serial' 'id' column
that is designated as the PK, so I don't have to explicit specify the 'id'
value in my INSERT?

3) Failing that, is there a better way to do the raw SQL steps outlined
above?

Thanks,
Ken

--

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




Re: Apache/mod_wsgi woes

2009-11-19 Thread Brandon Taylor
Well, for whatever reason, my setup is working again after updating to
Fusion 3. I'm not sure if something within Fusion got hosed, but I
doubt it, since I was seeing the same behavior on two different Macs,
one at home, one at the office.

After a clean install of Ubuntu 9.1, Apache2 and mod_wsgi,
everything's working again, finally. Ugh.

Cheers,
Brandon

On Nov 19, 9:40 am, Brandon Taylor  wrote:
> Hi Andy,
>
> Thanks for the reply. The Ubuntu instance only has one Python
> installed - 2.6.4. I thought it might be a problem related to that as
> well. This has been a really, really frustrating problem! Even setting
> up a new VM from scratch and re-installing everything hasn't solved
> this issue.
>
> I can't explain why it won't work in a VM, but it will if I'm dual-
> booting, or just running Ubuntu native.
>
> b
>
> On Nov 19, 9:14 am, Andy McKay  wrote:
>
>
>
> > On 09-11-19 6:40 AM, Brandon Taylor wrote:
>
> > > ImproperlyConfigured: ImportError filebrowser: No module named
> > > filebrowser
>
> > > I can start python from the command line, and import filebrowser,
> > > django, or any of my other modules without errors.
>
> > You could be using a different python. If you installed mod_wsgi through
> > a package manager, which Python does it use 2.5 or 2.6 (I don't know the
> > answer to that, but the traceback might). Do you have multiple pythons
> > on your machine?
> > --
> >    Andy McKay, @clearwind
> >    Training:http://clearwind.ca/training/

--

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




Re: Django website stats

2009-11-19 Thread Fabio Natali
Martin Lundberg wrote:
> I am very new to Django but can't this be handled by middleware
> instead? It should have access to user and page data should it not?
> 
> -Martin
> 
> On Thursday, November 19, 2009, Fabio Natali
>  wrote:
> > Hi there!
> >
> > I have a Django based website with a few dozen users. Only logged
> > users can enter the website and browse its pages.
[...]

Hi Martin,

thank you so much for your reply. I'll look for some information on
middleware then and post again if I encounter any problem.

All the best,
Fabio.

-- 
Fabio Natali

--

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




Re: Internal server error 500 with mod_wsgi

2009-11-19 Thread Karen Tracey
On Thu, Nov 19, 2009 at 11:51 AM, Alessandro Ronchi <
alessandro.ron...@soasi.com> wrote:

>
>
> On Thu, Nov 19, 2009 at 5:28 PM, Alessandro Ronchi <
> alessandro.ron...@soasi.com> wrote:
>
>>
>>> Really, you can get both pretty debug pages and emails with mod_wsgi as
>>> well as you can with the development server or mod_python.  I've seen both.
>>> The problem with both exception traces you have shown is that the exception
>>> is occurring too early in the processing -- neither of these exceptions you
>>> have posted would ever result in a debug page or an error email, regardless
>>> of deployment setup.
>>>
>>>
>> You're right.
>> I dont' understand why the trackback refers to another project django
>> source. the pythonpath is correct in django.wsgi and empty in shell.
>>
>> Is there something wrong?
>>
>
> as you can see here:
> http://dpaste.com/122437/
>
> my python path is correct, but the trackback points to another django
> directory.
>

I don't see where that page shows the PYTHONPATH setting?  Based on the
traceback the python path apparently includes:

/var/www/vhosts/detectorpoint.com/django/django_src
/var/www/vhosts/detectorpoint.com/django/satchmo_src
/var/www/vhosts/hobbygiochi.com/django/projects

In the wsgi script you pointed to earlier you have:

BASE = '/var/www/vhosts/hobbygiochi.com/django/'

sys.path.append(BASE + 'projects/')
sys.path.append(BASE + 'satchmo_src/satchmo/apps/')
sys.path.append(BASE + 'django_src/')
sys.path.append(BASE + 'libraries/')

So I guess you are looking to pull django and satchmo out of
/var/www/vhosts/hobbygiochi.com/django/, not /var/www/vhosts/
detectorpoint.com/django/.  I'd guess the detectorpoint.com paths are
already in sys.path when your wsgi script runs, and they aren't being
over-ridden because you append to the existing path instead of putting the
paths you are adding in front.

Karen

--

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




Re: Django website stats

2009-11-19 Thread Martin Lundberg
I am very new to Django but can't this be handled by middleware
instead? It should have access to user and page data should it not?

-Martin

On Thursday, November 19, 2009, Fabio Natali
 wrote:
> Hi there!
>
> I have a Django based website with a few dozen users. Only logged
> users can enter the website and browse its pages.
>
> I wish I could set up a stats page, i.e. some sort of table listing
> how many accesses to the website for a given user. Specifically, I
> need:
>
> - per-user number of accesses
> - per-page number of accesses
> - detailed listing: how many times user x has accessed page y?
> - I should be able to select the period of time (i.e. accesses in
>   November)
>
> I wonder if all those informations are somehow already contained in my
> user model. I guess they aren't.
>
> What's my best bet? Should I extend my db with a new model
> (e.g. "access", with fields: user, page, date)?
>
> Is there any "right" way to do this?
>
> Thanks and regards,
>
> --
> Fabio Natali
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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=.
>
>
>

--

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




Re: Multiple sites on a single server

2009-11-19 Thread andreas schmid
i would suggest to everyone start using buildout to develop or deploy.
it gives so many advantages about separation between projects.
a huge advantage is the repetibility of the project and you dont have to
touch the pythonpath of your server, everything is done by the buildout
configuration!

Stodge wrote:
> I got this working with several sites using Apache. I just created a
> configuration file for each site and pointed it to different settings
> files:
>
> 
> SetHandler python-program
> PythonHandler django.core.handlers.modpython
> SetEnv DJANGO_SETTINGS_MODULE test.settings
> PythonOption django.root /test
> PythonDebug On
> PythonPath "['/var/www/test'] + sys.path"
> PythonAutoReload On
> 
>
> 
> SetHandler python-program
> PythonHandler django.core.handlers.modpython
> SetEnv DJANGO_SETTINGS_MODULE fred.settings
> PythonOption django.root /fred
> PythonDebug On
> PythonPath "['/var/www/fred'] + sys.path"
> PythonAutoReload On
> 
>
> Something like this I think.
>
> On Nov 19, 12:23 pm, Mark Freeman  wrote:
>   
>> I currently have a working site running Django and now want to move a
>> couple of other of my sites to Django as well. I'm in the process of
>> moving off a hosted VPS to my own local server, where the existing
>> Django site is.
>>
>> My questions is more of best practice when deploying multiple sites to
>> the same server. Given that I have a running site, is it possible to
>> deploy multiple Django 'projects' to the same server and just use
>> Apache to serve them out separately or is it best to use the sites
>> module to do this from the same project? For code cleanliness, I would
>> prefer to have them as separate projects, but I don't want to kill
>> server performance either.
>>
>> Thanks for any suggestions!
>> 
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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=.
>
>
>
>   

--

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




Re: Multiple sites on a single server

2009-11-19 Thread Stodge
I got this working with several sites using Apache. I just created a
configuration file for each site and pointed it to different settings
files:


SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE test.settings
PythonOption django.root /test
PythonDebug On
PythonPath "['/var/www/test'] + sys.path"
PythonAutoReload On



SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE fred.settings
PythonOption django.root /fred
PythonDebug On
PythonPath "['/var/www/fred'] + sys.path"
PythonAutoReload On


Something like this I think.

On Nov 19, 12:23 pm, Mark Freeman  wrote:
> I currently have a working site running Django and now want to move a
> couple of other of my sites to Django as well. I'm in the process of
> moving off a hosted VPS to my own local server, where the existing
> Django site is.
>
> My questions is more of best practice when deploying multiple sites to
> the same server. Given that I have a running site, is it possible to
> deploy multiple Django 'projects' to the same server and just use
> Apache to serve them out separately or is it best to use the sites
> module to do this from the same project? For code cleanliness, I would
> prefer to have them as separate projects, but I don't want to kill
> server performance either.
>
> Thanks for any suggestions!

--

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




Re: Multiple sites on a single server

2009-11-19 Thread Eric Elinow

On 19 Nov, 2009, at 12:23 , Mark Freeman wrote:

> I currently have a working site running Django and now want to move a
> couple of other of my sites to Django as well. I'm in the process of
> moving off a hosted VPS to my own local server, where the existing
> Django site is.
> 
> My questions is more of best practice when deploying multiple sites to
> the same server. Given that I have a running site, is it possible to
> deploy multiple Django 'projects' to the same server and just use
> Apache to serve them out separately or is it best to use the sites
> module to do this from the same project? For code cleanliness, I would
> prefer to have them as separate projects, but I don't want to kill
> server performance either.

I currently do this for the 5 or so sites that I operate for a client.  
A single Apache setup for Django, with the various virtual hosts being directed 
to their own path(s), and any static media requests being port forwarded from 
apache to a lighttpd instance.  I have my /sites/ path containing each project  
(sites/site1 sites/site2 etc.) and have had this setup for quite some time with 
absolutely zero problems.

Eric G. Elinow
http://www.codedevl.com


> 
> Thanks for any suggestions!
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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=.
> 
> 

--

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




Multiple sites on a single server

2009-11-19 Thread Mark Freeman
I currently have a working site running Django and now want to move a
couple of other of my sites to Django as well. I'm in the process of
moving off a hosted VPS to my own local server, where the existing
Django site is.

My questions is more of best practice when deploying multiple sites to
the same server. Given that I have a running site, is it possible to
deploy multiple Django 'projects' to the same server and just use
Apache to serve them out separately or is it best to use the sites
module to do this from the same project? For code cleanliness, I would
prefer to have them as separate projects, but I don't want to kill
server performance either.

Thanks for any suggestions!

--

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




Re: How should I use manage.py dumpdata, and loaddata?

2009-11-19 Thread f4nt
I typically dump all of my apps individually, and load them
individually. Unfortunately finding out where/why imports break with
loaddata is problematic without inserting some debugging code in your
django stack. Hence, I dump all my stuff individually, and I can at
least somewhat narrow down what's breaking the importer.

On Nov 18, 7:59 pm, Sachi  wrote:
> Hi, all,
>
> I have been developing a website, where I use the same postgresql
> database server for both development and production. Now that I have
> had many users and a significant amount of data, I am trying to use
> sqlite3 engine when I do development locally instead of connecting to
> the production server. In my settings.py, I have something that looks
> like:
>
> if ON_PRODUCTION_SERVER: DATABASE_ENGINE  = "postgresql_psycopg2" ...
> else: DATABASE_ENGINE = "sqlite3" ...
>
> My task right now is to dump data (I wish to dump all of them) from
> the production server, and install them in the local sqlite database.
> This is what I did:
>
> python manage.py dumpdata > data.json
>
> Then, I switched to sqlite3 database, and did
>
> python manage.py syncdb
> python manage.py loaddata data.json
>
> However, I met the following errors:
>
> Installing json fixture 'data' from absolute path.
> Problem installing fixture 'data.json': Traceback (most recent call
> last):
>   File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/core/management/commands/loaddata.py",
> line 153, in handle
>     obj.save()
>   File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/core/serializers/base.py", line 163, in
> save
>     models.Model.save_base(self.object, raw=True)
>   File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/db/models/base.py", line 474, in
> save_base
>     rows = manager.filter(pk=pk_val)._update(values)
>   File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/db/models/query.py", line 444, in
> _update
>     return query.execute_sql(None)
>   File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/db/models/sql/subqueries.py", line 120,
> in execute_sql
>     cursor = super(UpdateQuery, self).execute_sql(result_type)
>   File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/db/models/sql/query.py", line 2369, in
> execute_sql
>     cursor.execute(sql, params)
>   File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/db/backends/util.py", line 19, in
> execute
>     return self.cursor.execute(sql, params)
>   File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/db/backends/sqlite3/base.py", line 193,
> in execute
>     return Database.Cursor.execute(self, query, params)
> IntegrityError: columns app_label, model are not unique
>
> Could anybody let me know why this error happened, and how I get
> correctly dump/load data?
>
> Thanks a lot!
>
> Sachi

--

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




How should I use manage.py dumpdata, and loaddata?

2009-11-19 Thread Sachi
Hi, all,

I have been developing a website, where I use the same postgresql
database server for both development and production. Now that I have
had many users and a significant amount of data, I am trying to use
sqlite3 engine when I do development locally instead of connecting to
the production server. In my settings.py, I have something that looks
like:

if ON_PRODUCTION_SERVER: DATABASE_ENGINE  = "postgresql_psycopg2" ...
else: DATABASE_ENGINE = "sqlite3" ...

My task right now is to dump data (I wish to dump all of them) from
the production server, and install them in the local sqlite database.
This is what I did:

python manage.py dumpdata > data.json

Then, I switched to sqlite3 database, and did

python manage.py syncdb
python manage.py loaddata data.json

However, I met the following errors:

Installing json fixture 'data' from absolute path.
Problem installing fixture 'data.json': Traceback (most recent call
last):
  File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
python2.6/site-packages/django/core/management/commands/loaddata.py",
line 153, in handle
obj.save()
  File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
python2.6/site-packages/django/core/serializers/base.py", line 163, in
save
models.Model.save_base(self.object, raw=True)
  File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
python2.6/site-packages/django/db/models/base.py", line 474, in
save_base
rows = manager.filter(pk=pk_val)._update(values)
  File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
python2.6/site-packages/django/db/models/query.py", line 444, in
_update
return query.execute_sql(None)
  File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
python2.6/site-packages/django/db/models/sql/subqueries.py", line 120,
in execute_sql
cursor = super(UpdateQuery, self).execute_sql(result_type)
  File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
python2.6/site-packages/django/db/models/sql/query.py", line 2369, in
execute_sql
cursor.execute(sql, params)
  File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
python2.6/site-packages/django/db/backends/util.py", line 19, in
execute
return self.cursor.execute(sql, params)
  File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
python2.6/site-packages/django/db/backends/sqlite3/base.py", line 193,
in execute
return Database.Cursor.execute(self, query, params)
IntegrityError: columns app_label, model are not unique


Could anybody let me know why this error happened, and how I get
correctly dump/load data?

Thanks a lot!

Sachi

--

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




Re: Internal server error 500 with mod_wsgi

2009-11-19 Thread Alessandro Ronchi
On Thu, Nov 19, 2009 at 5:28 PM, Alessandro Ronchi <
alessandro.ron...@soasi.com> wrote:

>
>> Really, you can get both pretty debug pages and emails with mod_wsgi as
>> well as you can with the development server or mod_python.  I've seen both.
>> The problem with both exception traces you have shown is that the exception
>> is occurring too early in the processing -- neither of these exceptions you
>> have posted would ever result in a debug page or an error email, regardless
>> of deployment setup.
>>
>>
> You're right.
> I dont' understand why the trackback refers to another project django
> source. the pythonpath is correct in django.wsgi and empty in shell.
>
> Is there something wrong?
>

as you can see here:
http://dpaste.com/122437/

my python path is correct, but the trackback points to another django
directory.




-- 
Alessandro Ronchi

SOASI
Sviluppo Software e Sistemi Open Source
http://www.soasi.com
http://www.linkedin.com/in/ronchialessandro

--

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




Re: Internal server error 500 with mod_wsgi

2009-11-19 Thread Alessandro Ronchi
>
>
> Really, you can get both pretty debug pages and emails with mod_wsgi as
> well as you can with the development server or mod_python.  I've seen both.
> The problem with both exception traces you have shown is that the exception
> is occurring too early in the processing -- neither of these exceptions you
> have posted would ever result in a debug page or an error email, regardless
> of deployment setup.
>
>
You're right.
I dont' understand why the trackback refers to another project django
source. the pythonpath is correct in django.wsgi and empty in shell.

Is there something wrong?

-- 
Alessandro Ronchi

SOASI
Sviluppo Software e Sistemi Open Source
http://www.soasi.com
http://www.linkedin.com/in/ronchialessandro

--

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




Re: FAQ?

2009-11-19 Thread Andy McKay
On 09-11-19 7:57 AM, Carl Zmola wrote:
> Does anyone want to take a stab at an FAQ?  There are a lot of repeated
> questions on the list.

How about http://docs.djangoproject.com/en/dev/faq/
-- 
   Andy McKay, @clearwind
   Training: http://clearwind.ca/training/

--

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




FAQ?

2009-11-19 Thread Carl Zmola
Does anyone want to take a stab at an FAQ?  There are a lot of repeated 
questions on the list.  I am fairly new to Django, and I see many people 
asking questions about what I ran into.  Also, I am running into new 
problems that I have seen asked before, but didn't appreciate at the time.

Carl

-- 
Carl Zmola
czm...@woti.com


--

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




Re: Apache/mod_wsgi woes

2009-11-19 Thread Brandon Taylor
Hi Andy,

Thanks for the reply. The Ubuntu instance only has one Python
installed - 2.6.4. I thought it might be a problem related to that as
well. This has been a really, really frustrating problem! Even setting
up a new VM from scratch and re-installing everything hasn't solved
this issue.

I can't explain why it won't work in a VM, but it will if I'm dual-
booting, or just running Ubuntu native.

b

On Nov 19, 9:14 am, Andy McKay  wrote:
> On 09-11-19 6:40 AM, Brandon Taylor wrote:
>
> > ImproperlyConfigured: ImportError filebrowser: No module named
> > filebrowser
>
> > I can start python from the command line, and import filebrowser,
> > django, or any of my other modules without errors.
>
> You could be using a different python. If you installed mod_wsgi through
> a package manager, which Python does it use 2.5 or 2.6 (I don't know the
> answer to that, but the traceback might). Do you have multiple pythons
> on your machine?
> --
>    Andy McKay, @clearwind
>    Training:http://clearwind.ca/training/

--

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




Re: Apache/mod_wsgi woes

2009-11-19 Thread Andy McKay
On 09-11-19 6:40 AM, Brandon Taylor wrote:
> ImproperlyConfigured: ImportError filebrowser: No module named
> filebrowser
 >
> I can start python from the command line, and import filebrowser,
> django, or any of my other modules without errors.

You could be using a different python. If you installed mod_wsgi through 
a package manager, which Python does it use 2.5 or 2.6 (I don't know the 
answer to that, but the traceback might). Do you have multiple pythons 
on your machine?
-- 
   Andy McKay, @clearwind
   Training: http://clearwind.ca/training/

--

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




@login_required decorator sends me to the wrong URL

2009-11-19 Thread Stodge
I added the @login_required decorator to my view but it redirects me
to:

http://localhost/accounts/login

whereas the URL for my site is:

http://localhost/test/accounts/login

This is on Apache. Did I forget to configure something in settings.py?

Thanks

--

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




URLs created by custom python-markup filter are incorrect

2009-11-19 Thread Stodge
I'm using a custom python-markup filter, which seems to be working
well. However, my URLs aren't relative to my site. So if the rendered
text before filtering contains:

[/login Login]

and the login page is at:

http://localhost/test/login

the filter produces an URL of:

http://localhost/login

which is wrong. How do I get URLs from a filter like this that are
correct?

Thanks

--

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




Apache/mod_wsgi woes

2009-11-19 Thread Brandon Taylor
Hi everyone,

I'm developing on Ubuntu 9.1 in a VM Ware Fusion instance on OS X,
10.5.8. I have apache2-mpm-worker and mod_wsgi installed through
aptitude.

I have Django 1.1.1 installed in /usr/local/lib/python2.6/dist-
packages.

My django project is in:
/home/btaylor/django_projects/cit

My .wsgi file is in:
/home/btaylor/django_projects/cit/apache/django.wsgi

My wsgi file code is at: http://dpaste.com/122399/


I created a virtual server in my /etc/apache2/sites-available and
symlinked it into /etc/apache2/sites-enabled, stopped, and restarted
apache.

My virtual server config is at: http://dpaste.com/122400/


I have several python packages installed, like filebrowser, sorl,
django-tinymce, django-tagging, etc. When I hit:
local.careersintax.com, I get a 500 error:

ImproperlyConfigured: ImportError filebrowser: No module named
filebrowser

I can start python from the command line, and import filebrowser,
django, or any of my other modules without errors.

Obviously the Python Path isn't being set properly, but I have
absolutely no idea what the problem is. The exact same code, and
apache setup works perfectly if I boot into Ubuntu instead of running
it in a VM.

Can someone please shed some light onto what might be happening? I'm
stumped, and have been at this for hours.

TIA,
Brandon

--

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




Re: Use manage.py dumpdata, and loaddata?

2009-11-19 Thread Russell Keith-Magee
On Thu, Nov 19, 2009 at 10:07 PM, Dawei Shen  wrote:
> Hi, all,
>
> I have been developing a website, where I use the same postgresql
> database server for both development and production. Now that I have
> had many users and a significant amount of data, I am trying to use
> sqlite3 engine when I do development locally instead of connecting to
> the production server. In my settings.py, I have something that looks
> like:
>
> if ON_PRODUCTION_SERVER: DATABASE_ENGINE  = "postgresql_psycopg2" ...
> else: DATABASE_ENGINE = "sqlite3" ...
>
> My task right now is to dump data (I wish to dump all of them) from
> the production server, and install them in the local sqlite database.
> This is what I did:
>
> python manage.py dumpdata > data.json
>
> Then, I switched to sqlite3 database, and did
>
> python manage.py syncdb
> python manage.py loaddata data.json
>
> However, I met the following errors:
>
> Installing json fixture 'data' from absolute path.
> Problem installing fixture 'data.json': Traceback (most recent call
> last):
>  File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/core/management/commands/loaddata.py",
> line 153, in handle
>    obj.save()
>  File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/core/serializers/base.py", line 163, in
> save
>    models.Model.save_base(self.object, raw=True)
>  File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/db/models/base.py", line 474, in
> save_base
>    rows = manager.filter(pk=pk_val)._update(values)
>  File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/db/models/query.py", line 444, in
> _update
>    return query.execute_sql(None)
>  File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/db/models/sql/subqueries.py", line 120,
> in execute_sql
>    cursor = super(UpdateQuery, self).execute_sql(result_type)
>  File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/db/models/sql/query.py", line 2369, in
> execute_sql
>    cursor.execute(sql, params)
>  File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/db/backends/util.py", line 19, in
> execute
>    return self.cursor.execute(sql, params)
>  File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
> python2.6/site-packages/django/db/backends/sqlite3/base.py", line 193,
> in execute
>    return Database.Cursor.execute(self, query, params)
> IntegrityError: columns app_label, model are not unique
>
>
> Could anybody let me know why this error happened, and how I get
> correctly dump/load data?

This sounds like you've hit ticket #7052. The ticket description in
Trac explains the problem, as well as some possible workarounds.

The good news is that there will hopefully be a solution for this in
v1.2. I've been working on it recently, and hope to be able to commit
soon.

Yours,
Russ Magee %-)

--

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




Use manage.py dumpdata, and loaddata?

2009-11-19 Thread Dawei Shen
Hi, all,

I have been developing a website, where I use the same postgresql
database server for both development and production. Now that I have
had many users and a significant amount of data, I am trying to use
sqlite3 engine when I do development locally instead of connecting to
the production server. In my settings.py, I have something that looks
like:

if ON_PRODUCTION_SERVER: DATABASE_ENGINE  = "postgresql_psycopg2" ...
else: DATABASE_ENGINE = "sqlite3" ...

My task right now is to dump data (I wish to dump all of them) from
the production server, and install them in the local sqlite database.
This is what I did:

python manage.py dumpdata > data.json

Then, I switched to sqlite3 database, and did

python manage.py syncdb
python manage.py loaddata data.json

However, I met the following errors:

Installing json fixture 'data' from absolute path.
Problem installing fixture 'data.json': Traceback (most recent call
last):
 File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
python2.6/site-packages/django/core/management/commands/loaddata.py",
line 153, in handle
   obj.save()
 File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
python2.6/site-packages/django/core/serializers/base.py", line 163, in
save
   models.Model.save_base(self.object, raw=True)
 File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
python2.6/site-packages/django/db/models/base.py", line 474, in
save_base
   rows = manager.filter(pk=pk_val)._update(values)
 File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
python2.6/site-packages/django/db/models/query.py", line 444, in
_update
   return query.execute_sql(None)
 File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
python2.6/site-packages/django/db/models/sql/subqueries.py", line 120,
in execute_sql
   cursor = super(UpdateQuery, self).execute_sql(result_type)
 File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
python2.6/site-packages/django/db/models/sql/query.py", line 2369, in
execute_sql
   cursor.execute(sql, params)
 File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
python2.6/site-packages/django/db/backends/util.py", line 19, in
execute
   return self.cursor.execute(sql, params)
 File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
python2.6/site-packages/django/db/backends/sqlite3/base.py", line 193,
in execute
   return Database.Cursor.execute(self, query, params)
IntegrityError: columns app_label, model are not unique


Could anybody let me know why this error happened, and how I get
correctly dump/load data?

Thanks a lot!

Sachi

--

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




Re: Strange reverse behaviour

2009-11-19 Thread Karen Tracey
On Thu, Nov 19, 2009 at 6:25 AM, Maksymus007  wrote:

> I got my main urls.py file
>
> urlpatterns = patterns('',
> (...)
>(r'^wakers/$', include('appname.wakers.urls')),
> (...)
> )
>
> and this works well
>
> then i got wakers.urls.py
>
> urlpatterns = patterns('wakers',
>(r'^$', 'views.add', {}, 'wakers-add'),
>(r'^b$',  'views.add', {}, 'wakers-add2'),
> )
>
> And then in template i try to do
>
> {% url wakers-add %} everything works well, /wakers/ is returned
> but
> {% url wakers-add2 %} throws "Caught an exception while rendering:
> Reverse for 'wakers-add2' with arguments '()' and keyword arguments
> '{}' not found."
>
> which should work, just like the wakers-add.
>
>
No, wakers-add2 has no reverse because the pattern leading to wakers.urls
being considered requires that the url terminate with the slash after
wakers/.  Remove the $ from the end of the pattern specification in the main
urls file and you will be able to reverse wakers-add2.

Karen

--

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




Re: how to run django with fastcgi, but not run as user "root" on linux

2009-11-19 Thread Fm
I know how to solve it .
su nobody -c cmdline -s /bin/sh
Thanks

On Nov 19, 11:12 am, Fm  wrote:
> Hi,
> I'm am green-hand to linux.
> When I use /usr/bin/su nobody -c /usr/local/bin/python /home/admin/cc/
> manage.py runfcgi
> method=threaded host=127.0.0.1 port=12345
> it say "This account is currently not available."
>
> Because nobody's shell is /sbin/nologin,I could not use su?
>
> what is the normal way of RC system provided to set the user to run?
>
> Thanks a lot
> Fm
>
> On Nov 18, 7:37 pm, Tom Evans  wrote:
>
>
>
> > On Wed, Nov 18, 2009 at 8:25 AM, Fm  wrote:
> > > Hi all,
> > > I have write a script in /etc/rc.d/init.d so that Django can start
> > > with my server.
> > > It may look like
> > > start () {
> > >    echo -n $"Starting $prog: "
> > > /usr/local/bin/python /home/admin/cc/manage.py runfcgi method=threaded
> > > host=127.0.0.1 port=12345
> > > }
>
> > /usr/bin/su nobody -c /usr/local/bin/python /home/admin/cc/manage.py runfcgi
> > method=threaded host=127.0.0.1 port=12345
>
> > I'd be surprised if your RC system didn't provide a cleaner way of setting
> > the user to run as though.
>
> > Cheers
>
> > Tom

--

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




Re: casting unicode to model

2009-11-19 Thread David De La Harpe Golden
Karen Tracey wrote:

> Undocumented internal routine, but unlikely to change:
> 

Just to note the contenttypes framework has a documented way:
http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#methods-on-contenttype-instances

from django.contrib.contenttypes.models import ContentType
model_type = ContentType.objects.get(app_label=app_name, model=model_name)
model_class = model_type.model_class()


--

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




Strange reverse behaviour

2009-11-19 Thread Maksymus007
I got my main urls.py file

urlpatterns = patterns('',
(...)
(r'^wakers/$', include('appname.wakers.urls')),
(...)
)

and this works well

then i got wakers.urls.py

urlpatterns = patterns('wakers',
(r'^$', 'views.add', {}, 'wakers-add'),
(r'^b$',  'views.add', {}, 'wakers-add2'),
)

And then in template i try to do

{% url wakers-add %} everything works well, /wakers/ is returned
but
{% url wakers-add2 %} throws "Caught an exception while rendering:
Reverse for 'wakers-add2' with arguments '()' and keyword arguments
'{}' not found."

which should work, just like the wakers-add.

App is in settings.py. Anyone had same problem?

--

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




how to serve multiple files using mod_wsgi

2009-11-19 Thread Amit Sethi
Hi , I have been trying to make a project work with mod_wsgi under
apache . The project is not exactly in django . It has a development
server of its own for adapting I was using this as a reference .The
mod_wsgi manual says that you have to send the response in following
manner

def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'

response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)

return [output]

Now this is fine it you have one file to serve but i need to serve
multiple files a sample call on the development server is :

localhost - - [19/Nov/2009 16:29:16] "GET /_static/basic.css HTTP/1.1" 200 6385
public/_static/jquery.js
localhost - - [19/Nov/2009 16:29:16] "GET /_static/jquery.js HTTP/1.1" 200 55774
public/_static/doctools.js
localhost - - [19/Nov/2009 16:29:16] "GET /_static/doctools.js
HTTP/1.1" 200 6618
public/_static/jquery.form.js
localhost - - [19/Nov/2009 16:29:16] "GET /_static/jquery.form.js
HTTP/1.1" 200 23288
public/_static/comments.js
localhost - - [19/Nov/2009 16:29:16] "GET /_static/comments.js
HTTP/1.1" 200 20337
localhost - - [19/Nov/2009 16:29:16] "HEAD
/comments/803b4d0984c5317e5800109ec12bb439 HTTP/1.1" 200 0
localhost - - [19/Nov/2009 16:29:16] "HEAD
/fixes/803b4d0984c5317e5800109ec12bb439 HTTP/1.1" 404 0
localhost - - [19/Nov/2009 16:29:16] "GET
/comments/803b4d0984c5317e5800109ec12bb439?id=803b4d0984c5317e5800109ec12bb439
HTTP/1.1" 200 464

How do I create a script that can serve all these files ?  I am sure
django has a way in which it does the same thing what is it. Any
reference to code i should look at?



-- 
A-M-I-T S|S

--

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




Re: digg style pagination

2009-11-19 Thread Tim Chase
> But getting an exception. Could you help to fix it please?
> 
> TemplateSyntaxError at /section/home
> 
> Caught an exception while rendering: 'request'
> 
> Original Traceback (most recent call last):
>   File "/opt/local/lib/python2.5/site-packages/django/template/debug.py",
> line 71, in render_node
> result = node.render(context)
>   File 
> "/opt/local/lib/python2.5/site-packages/django_pagination-1.0.5-py2.5.egg/pagination/templatetags/pagination_tags.py",
> line 90, in render
> page_obj = paginator.page(context['request'].page)
>   File "/opt/local/lib/python2.5/site-packages/django/template/context.py",
> line 49, in __getitem__
> raise KeyError(key)
> KeyError: 'request'

Sounds exactly like the error suggests:  you haven't included the 
request in your rendering context.  What is your view for 
rendering this template?  Does it pass a RequestContext to 
render_to_response or does it just pass a dictionary without

   'request': request,

in it?

-tim


--

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




Forms ModelMultipleChoiceField with checkboxes?

2009-11-19 Thread Benjamin Wolf
Hello,

I'm using Django's form and ModelMultipleChoiceField.
ModelMultipleChoiceField produces a select list with multiple options. 
Is it possible to use
checkboxes instead?

Thanks,
Greets Ben

--

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