Re: How make CSRF middleware emit html4 rather than xhtml1.0 (closing tags issue) so will validate?

2011-03-14 Thread Ian Clelland
On Mon, Mar 14, 2011 at 10:57 AM, Chris Seberino  wrote:
> My Django app's html won't validate because CSRF middleware adds
> hidden
> tags like this...
>
>  name='csrfmiddlewaretoken' value='ebcf3d41f32a70a209e27ef7fdf06d72' />
>
> The only problem is the slash "/>" at the end.
>
> How make Django templates not automatically add hidden tags that won't
> validate?

You have access to a context variable called "csrf_token", which just
contains the actual token string. If you don't like the output of the

{% csrf_token %}

template tag, then just write it yourself in a template. The simplest
way would be to put, in your template, some code like this:





(Note the '{{', '}}' delimiters, rather than '{%', '%}')

A more complicated, but more reusable way to do it would be to write
your own template tag (it's really simple, you can use the CSRF-token
code in django/template/defaulttags.py as a starting point) which
would render whatever markup you need.

-- 
Regards,
Ian Clelland


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



Tests with test specific models

2011-03-14 Thread Mike Ramirez

Example: 

I have an app that uses ContentType and I want to test that against an 
arbitrary model to make sure that the usage of ContentType is correct.


Ex:

In my app.models I have:

class Rating(models.Model): 
  total = models.DecimalField(default=0, decimal_places=2, max_digits=8)
  score = models.DecimalField(default=decimal.Decimal('0.00'), 
decimal_places=2, max_digits=6)
  votes = models.IntegerField(max_length=6, default=0, blank=True)

class RatedItem(models.Model):
  user = models.ForeignKey(User, related_name="RatedItem_User")
  content_type = models.ForeignKey(ContentType, related_name="RatedItem")
  object_id = models.PositiveIntegerField()
  item = generic.GenericForeignKey('content_type', 'object_id')


RatedItem is used to check if the user has rated an item already. For testing, 
I would like to have something like:

class TestItem(models.Model):
  name = models.CharField(max_length=20)
  rating = models.ForeignKey(Rating)

I don't want to clutter up my apps model.py with testing only stuff, that 
might confuse/encourage devs to do the wrong thing.

django-tagging gives the example, have a tests directory in your app, with 
__init__.py, tests.py , models.py, a settings.py with db info and an installed 
apps settings, that has only django.contrib.contentypes, tagging and 
tagging.tests.  OK I get this is the setup (mostly, the env variables in 
settings.py are rather annoying, but understandable). but two things about 
this bother me. 

A. How do the tests know to look for this setup and use the settings/model 
supplied?

B. Where is it documented?  (B. is the more important question)

I think way back something about this was mentioned on the list a long time 
ago. I rememeber a letter about tests/ or tests.py in apps. I just don't 
remember any information given on how to setup the testing environment this 
way, as it's own standalone app.

Also for south users/devs, how well does south cope with this situtaion?



Mike
-- 
Tcl tends to get ported to weird places like routers.
 -- Larry Wall in <199710071721.kaa19...@wall.org>

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



Re: help to finish my 1st Django app.

2011-03-14 Thread christian.posta
Your template file checks to see whether a variable named
"latest_poll_list" exists.
I don't see anywhere in your views where you add this to your context.
Look at part 3 of the tutorial about half way down. They add the
"latest_poll_list" object to the Context that gets passed to your
template. Try doing that.

On Mar 14, 4:26 pm, Rogelio Gonzalez  wrote:
> Hi Igor.
>
> Thanks for your reply. My poll_list.html code is:
>
> {% if latest_poll_list %}
>     
>     {% for poll in latest_poll_list %}
>         {{ poll.question }}
>     {% endfor %}
>     
> {% else %}
>     No polls are available.
> {% endif %}
> What i'm doing wrong?..
>
> 2011/3/14 royy 
>
>
>
>
>
>
>
> > Hi.
>
> > I've finished the tutorial for the polls app.
>
> > I tought everythin was OK till I load the server and type the addres:
> >http://127.0.0.1:8000/polls/
>
> > web browser shows me the message "No polls are available" isn't a web
> > browser error message, because it is plain text.
>
> > I've created 3 polls with 3 choices each one.
>
> > admin page works fine, just the polls address is the one that don't
> > loads well. This is my final views.py code:
>
> > from django.shortcuts import get_object_or_404, render_to_response
> > from django.http import HttpResponseRedirect, HttpResponse
> > from django.core.urlresolvers import reverse
> > from django.template import RequestContext
> > from polls.models import Choice, Poll
>
> > def vote(request, poll_id):
> >    p = get_object_or_404(Poll, pk=poll_id)
> >    try:
> >        selected_choice = p.choice_set.get(pk=request.POST['choice'])
> >    except (KeyError, Choice.DoesNotExist):
>
> >        return render_to_response('polls/poll_detail.html', {
> >            'poll': p,
> >            'error_message': "You didn't select a choice.",
> >        }, context_instance=RequestContext(request))
> >    else:
> >        selected_choice.votes += 1
> >        selected_choice.save()
> >        return HttpResponseRedirect(reverse('poll_results',
> > args=(p.id,)))
>
> > --- 
> > --
>
> > and this is my final polls/urls.py code:
>
> > from django.conf.urls.defaults import *
> > from polls.models import Poll
>
> > info_dict = {
> >    'queryset': Poll.objects.all(),
> > }
>
> > urlpatterns = patterns('',
> >    (r'^$', 'django.views.generic.list_detail.object_list',
> > info_dict),
> >    (r'^(?P\d+)/$',
> > 'django.views.generic.list_detail.object_detail', info_dict),
> >    url(r'^(?P\d+)/results/$',
> > 'django.views.generic.list_detail.object_detail', dict(info_dict,
> > template_name='polls/results.html'), 'poll_results'),
> >    (r'^(?P\d+)/vote/$', 'polls.views.vote'),
> > )
>
> > Please help me to find what's wrong.
>
> > 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-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: Why is the first Manager defined in a model the default?

2011-03-14 Thread James Bennett
On Mon, Mar 14, 2011 at 6:14 PM, gamingdroid  wrote:
> So if the default manager isn't named objects, then how does the code
> know where the default lives?

There's internal API for asking a model class what its default manager
is, and Django makes use of it. Most things you'd want to find out
about a model are available that way.

> Basically, it seems the default manager should always be the one that
> normally lives in objects at all time since it is guaranteed to
> support a subset of commonly used database operations.

No it's not. Here:

class StupidManager(models.Manager):
def filter(self):
raise NotImplementedError

class StupidModel(models.Model):
objects = StupidManager()

Whoops.

> Sorry, this discussion is actually spawning many more questions, but I
> think I'm getting closer. I just wish Django had a nice documentation
> system like Javadocs. The docs available at Django seems to  introduce
> you on how to use the class/feature more than explain what each method
> does.

There are many tools available which will spit out Javadoc-style API
references from Python source code (e.g., epydoc). Since that requires
no effort whatsoever to do, we spend our time on documentation that
*can't* just be automatically generated on demand.


-- 
"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-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: Why is the first Manager defined in a model the default?

2011-03-14 Thread gamingdroid
I guess what is the point of having a default manager?

So if the default manager isn't named objects, then how does the code
know where the default lives?

Without the default (non-custom) manager, how is the code able to
support commonly used operations such as model.objects.filter(...)?

Basically, it seems the default manager should always be the one that
normally lives in objects at all time since it is guaranteed to
support a subset of commonly used database operations.

Sorry, this discussion is actually spawning many more questions, but I
think I'm getting closer. I just wish Django had a nice documentation
system like Javadocs. The docs available at Django seems to  introduce
you on how to use the class/feature more than explain what each method
does.

On Mar 14, 2:33 pm, Shawn Milochik  wrote:
> I also have a copy of that book, and I believe that what you're
> referring to pages 197 and 198.
>
> Here is what the authors are doing there:
>
>     1. Creating a special manager that does one thing -- return a
> filtered subset of the model instances.
>
>     2. Creating a replacement 'objects' manager since otherwise the
> custom manager would become the default (and only) manager.
>
> The reason for this is not because you *have to* always have a manager
> named 'objects.' The reason is that the custom manager created in that
> example was a specialized one that is only useful for certain
> situations. So you need a "normal" one for everything else. Also, that
> "normal" one has to be declared as the first manager in the model
> because Django apps (including the admin) will take the first manager
> as the default.
>
> To answer your question specifically, if you create a custom manager
> (and name it anything other than 'objects') in your model, then your
> model will not have an 'objects.' However, the Django admin (and any
> other software which uses the default manager instead of hard-coding
> 'objects' in the querysets) will work fine. Other code will have to
> refer to the name you gave your manager.
>
> Shawn

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



Re: help to finish my 1st Django app.

2011-03-14 Thread Rogelio Gonzalez
Hi Igor.

Thanks for your reply. My poll_list.html code is:

{% if latest_poll_list %}

{% for poll in latest_poll_list %}
{{ poll.question }}
{% endfor %}

{% else %}
No polls are available.
{% endif %}
What i'm doing wrong?..

2011/3/14 royy 

> Hi.
>
> I've finished the tutorial for the polls app.
>
> I tought everythin was OK till I load the server and type the addres:
> http://127.0.0.1:8000/polls/
>
> web browser shows me the message "No polls are available" isn't a web
> browser error message, because it is plain text.
>
> I've created 3 polls with 3 choices each one.
>
> admin page works fine, just the polls address is the one that don't
> loads well. This is my final views.py code:
>
> from django.shortcuts import get_object_or_404, render_to_response
> from django.http import HttpResponseRedirect, HttpResponse
> from django.core.urlresolvers import reverse
> from django.template import RequestContext
> from polls.models import Choice, Poll
>
> def vote(request, poll_id):
>p = get_object_or_404(Poll, pk=poll_id)
>try:
>selected_choice = p.choice_set.get(pk=request.POST['choice'])
>except (KeyError, Choice.DoesNotExist):
>
>return render_to_response('polls/poll_detail.html', {
>'poll': p,
>'error_message': "You didn't select a choice.",
>}, context_instance=RequestContext(request))
>else:
>selected_choice.votes += 1
>selected_choice.save()
>return HttpResponseRedirect(reverse('poll_results',
> args=(p.id,)))
>
>
> -
>
> and this is my final polls/urls.py code:
>
> from django.conf.urls.defaults import *
> from polls.models import Poll
>
> info_dict = {
>'queryset': Poll.objects.all(),
> }
>
> urlpatterns = patterns('',
>(r'^$', 'django.views.generic.list_detail.object_list',
> info_dict),
>(r'^(?P\d+)/$',
> 'django.views.generic.list_detail.object_detail', info_dict),
>url(r'^(?P\d+)/results/$',
> 'django.views.generic.list_detail.object_detail', dict(info_dict,
> template_name='polls/results.html'), 'poll_results'),
>(r'^(?P\d+)/vote/$', 'polls.views.vote'),
> )
>
>
> Please help me to find what's wrong.
>
> 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-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Why is the first Manager defined in a model the default?

2011-03-14 Thread gamingdroid
I guess what is the point of having a default manager?

So if the default manager isn't named objects, then how does the code
know where the default lives?

Without the default (non-custom) manager, how is the code able to
support commonly used operations such as model.objects.filter(...)?

Basically, it seems the default manager should always be the one that
normally lives in objects at all time since it is guaranteed to
support a subset of commonly used database operations.

Sorry, this discussion is actually spawning many more questions, but I
think I'm getting closer. I just wish Django had a nice documentation
system like Javadocs. The docs available at Django seems to  introduce
you on how to use the class/feature more than explain what each method
does.

On Mar 14, 2:33 pm, Shawn Milochik  wrote:
> I also have a copy of that book, and I believe that what you're
> referring to pages 197 and 198.
>
> Here is what the authors are doing there:
>
>     1. Creating a special manager that does one thing -- return a
> filtered subset of the model instances.
>
>     2. Creating a replacement 'objects' manager since otherwise the
> custom manager would become the default (and only) manager.
>
> The reason for this is not because you *have to* always have a manager
> named 'objects.' The reason is that the custom manager created in that
> example was a specialized one that is only useful for certain
> situations. So you need a "normal" one for everything else. Also, that
> "normal" one has to be declared as the first manager in the model
> because Django apps (including the admin) will take the first manager
> as the default.
>
> To answer your question specifically, if you create a custom manager
> (and name it anything other than 'objects') in your model, then your
> model will not have an 'objects.' However, the Django admin (and any
> other software which uses the default manager instead of hard-coding
> 'objects' in the querysets) will work fine. Other code will have to
> refer to the name you gave your manager.
>
> Shawn

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



Re: better options for hosting multiple django based websites?

2011-03-14 Thread garagefan
i meant ScriptAlias :( how embarrassing.

And no... it does not appear that i am using it in daemon mode as the
only reference of wsgi in my http.conf file are those WSGIScriptAlias'
within virtualhost's

On Mar 14, 4:46 pm, Graham Dumpleton 
wrote:
> On Monday, March 14, 2011 4:27:19 PM UTC-4, garagefan wrote:
>
> > I've got a server hosting multiple websites. Currently its not a big
> > deal to add another virtual host entry to apache2. Now, i'm using a
> > bad habit and using an http.conf instead of learning about, and
> > setting up "available sites".
>
> > I'm using mod_wsgi as well.
>
> > Now, in consideration of using "available sites" instead of the
> > http.conf, i'm looking for a better option than manually creating
> > entries for projects. for instance i'm using subdomains on my
> > development server... project.name.website.com where all projects are
> > served under my website. I'd like to set the server up in such a way
> > that i don't have to add a new entry within apache to understand name
> > points to a specific directory. However, the issue appears to be that
> > WSGIServerAlias doesn't accept any wildcards.
>
> > is there a way around this? Is my question even understood?
>
> Are you using daemon mode of mod_wsgi?
>
> If you are, then there is no way as there is not currently any way to have
> dynamic creation of new daemon process groups.
>
> If you are using embedded mode (which you really shouldn't in general), then
> there are ways as WSGIScriptAlias (no such thing as WSGIServerAlias), is not
> the only way of configuring Apache/mod_wsgi to map sites.
>
> More details of which mode you are using would need to be provided before
> can comment further.
>
> Graham

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



Re: Why is the first Manager defined in a model the default?

2011-03-14 Thread Shawn Milochik
I also have a copy of that book, and I believe that what you're
referring to pages 197 and 198.

Here is what the authors are doing there:

1. Creating a special manager that does one thing -- return a
filtered subset of the model instances.

2. Creating a replacement 'objects' manager since otherwise the
custom manager would become the default (and only) manager.

The reason for this is not because you *have to* always have a manager
named 'objects.' The reason is that the custom manager created in that
example was a specialized one that is only useful for certain
situations. So you need a "normal" one for everything else. Also, that
"normal" one has to be declared as the first manager in the model
because Django apps (including the admin) will take the first manager
as the default.

To answer your question specifically, if you create a custom manager
(and name it anything other than 'objects') in your model, then your
model will not have an 'objects.' However, the Django admin (and any
other software which uses the default manager instead of hard-coding
'objects' in the querysets) will work fine. Other code will have to
refer to the name you gave your manager.

Shawn

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



Re: Why is the first Manager defined in a model the default?

2011-03-14 Thread gamingdroid
Hi Shawn,

Thank you for your response.

So is it correct then that if I assign a Manager object in my model,
there will be no default Manager in model.object field?

My book, The Definite Guide to Django, seem to suggest so, but it
doesn't make sense. It essentially means you are breaking the ability
to rely on a certain features existing in objects of a specific class.

On Mar 14, 10:14 am, Shawn Milochik  wrote:
> I can't address the first question because it was probably discussed
> among the developers and was a design decision.
>
> As for the second, you don't *have to* create an 'objects' manager at
> all. If you do nothing, you get a Manager() for free
> by default, and because it has to be named *something*, it's 'objects'
> -- just because that's what someone picked as a default long ago.
>
> Remember that 'objects' is not some special property of a Django
> model. It's the name (by convention) that the default manager has.
> It's like using **kwargs in a function -- it could just as easily be
> **ponies, but most people just do it the way the community does it.
>
> If you choose to make your own manager then Django politely accepts
> your decision and doesn't thrust the default upon you.
>
> You could always name your custom Manager 'objects' if you like. It's
> even a good idea in some circumstances, like when you need to enforce
> special filtering in your querysets.
>
> Shawn

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



Re: django-registration - Activate view not works

2011-03-14 Thread Sergio Berlotto Jr
I´ll try it..

In my template I wrote the URL manually ! Oh god.. heheh

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



How to use extra to count based on the value of a field?

2011-03-14 Thread Margie Roginski
class Queue(models.Model):
  # fields here, not relevant for this discussion

class Task(models.Mode):
  queue = models.ForeignKey("Queue")
  status = models.IntegerField(choices=STATUS_CHOICES)

I am trying to create a Queue queryset that will annotate each Queue
with the number of tasks whose queue field is pointing to that Queue
and status field has a certain value.

I don't think annotate will work for me due to me needing to count up
only tasks whose status field has a certain value.  I think I might
need extra?  But I'm having touble making that work.

qs = Queue.objects.extra(select={'task_open_count':"select count(*)
from taskmanager_task inner join taskmanager_queue on
taskmanager_task.queue_id = taskmanager_queue.id where
taskmanager_task.status=1"})

I know this isn't doing the right thing.  This seems to be annotating
all of the resulting queues withthe total number of open tasks (I
think).

Can anyone give me a hand?  Thank you!

Margie


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



Re: better options for hosting multiple django based websites?

2011-03-14 Thread Graham Dumpleton


On Monday, March 14, 2011 4:27:19 PM UTC-4, garagefan wrote:
>
> I've got a server hosting multiple websites. Currently its not a big 
> deal to add another virtual host entry to apache2. Now, i'm using a 
> bad habit and using an http.conf instead of learning about, and 
> setting up "available sites". 
>
> I'm using mod_wsgi as well. 
>
> Now, in consideration of using "available sites" instead of the 
> http.conf, i'm looking for a better option than manually creating 
> entries for projects. for instance i'm using subdomains on my 
> development server... project.name.website.com where all projects are 
> served under my website. I'd like to set the server up in such a way 
> that i don't have to add a new entry within apache to understand name 
> points to a specific directory. However, the issue appears to be that 
> WSGIServerAlias doesn't accept any wildcards. 
>
> is there a way around this? Is my question even understood? 
>

Are you using daemon mode of mod_wsgi?

If you are, then there is no way as there is not currently any way to have 
dynamic creation of new daemon process groups.

If you are using embedded mode (which you really shouldn't in general), then 
there are ways as WSGIScriptAlias (no such thing as WSGIServerAlias), is not 
the only way of configuring Apache/mod_wsgi to map sites. 

More details of which mode you are using would need to be provided before 
can comment further.

Graham

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



Re: How do I run test and get results programmatically? (django, south, fixtures, sqlite)

2011-03-14 Thread Jumpfroggy
@gladys,

While that didn't solve my original question, it did solve another
related problem.  Before, I had issue with migrations failing since
they depended on pre-existing data (which did not exist in the blank
testing database).  But if I added an initial_data.json fixture, it
gets run for every migration - during prod and testing.  This is bad.

So I went with "SOUTH_TESTS_MIGRATE = False", then I manually load the
"test_data" fixture during the first test.  Works great.

I still can't figure out why running "python manage.py test" and
running the above code have such different results.  I'd love to
figure out why, since it would be easier to use the API calls and look
in the "failures" var than it is to run the "python manage.py test"
command and parse through the output.  But for now, the latter gets
things working.

So thanks!  My original question is still open, but I'm un-stuck and
can continue working for now.

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



better options for hosting multiple django based websites?

2011-03-14 Thread garagefan
I've got a server hosting multiple websites. Currently its not a big
deal to add another virtual host entry to apache2. Now, i'm using a
bad habit and using an http.conf instead of learning about, and
setting up "available sites".

I'm using mod_wsgi as well.

Now, in consideration of using "available sites" instead of the
http.conf, i'm looking for a better option than manually creating
entries for projects. for instance i'm using subdomains on my
development server... project.name.website.com where all projects are
served under my website. I'd like to set the server up in such a way
that i don't have to add a new entry within apache to understand name
points to a specific directory. However, the issue appears to be that
WSGIServerAlias doesn't accept any wildcards.

is there a way around this? Is my question even understood?

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-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 experts to develop for you? Try Bixly

2011-03-14 Thread Cal Leeming
In regards to your original post, one thing I'd certainly like to see from
this, is some example code from your developers. It doesn't need to be
anything conclusive, just random snippets of code you guys have written. For
a company to say they "specialise" in Django development, but to not have
any clear evidence of open source contributions, or anywhere we can see your
standards of code, doesn't look very good.

Just my two cents.

If you want to discuss further, please reply to my email and/or django-users
(as django-developers is not appropriate for such a discussion)

Also, FYI, this mail hit Outlook Spam filter, so might want to look into
that..

-Original Message-
From: django-develop...@googlegroups.com
[mailto:django-develop...@googlegroups.com] On Behalf Of bixly.com
Sent: 14 March 2011 16:37
To: Django developers
Subject: Need experts to develop for you? Try Bixly

CEO of Bixly, Adam Temple, has learned something you probably already
know - it's puzzling to find a company that has both high quality and
economic. Finding just one of those qualities in a company isn't very
difficult. A group that is both? This is essentially where Bixly is
positioned. Paying for the quality your project deserves doesn't have
to break the bank

Here at Bixly, we specialize in writing Python/Django code for our
clients. That's all we do. Since our startup in 2008, we have seen
tremendous growth year over year. We are still small however, and take
very good care of our clients. If you haven't introduced yourself,
pick up the phone and we your current needs and our past projects.

You can check us out at http://bixly.com and see what we're all about.
Our rates are also posted on the website.

Vana Moua
Senior Consultant
email: v...@bixly.com
Website: http://bixly.com
Skype #: (559) 761-0588
Office #: (877) 673-7059

Want to learn more about Django? Here's a link you can watch:
http://www.youtube.com/watch?v=ZqYxML3_coc

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

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



Explicitly telling django that the reverse OneToOne relationship doesn't exist

2011-03-14 Thread Viktor Kojouharov
Hello,

I have a database function that returns the necessary data for constructing 
a bunch of related objects in one go. One of the objects has a OneToOne 
relationship with my main model instance, and it doesn't exists for every 
object of the main model. Since the main model has a reverse relationship 
with that class, I am looking for a good way to emulate the select_related 
behaviour for it. My problem is that, even if I set the relationships in the 
instances that have it, the rest will not be set, and Django will hit the 
database, trying to figure out if such relationships exist (I already know 
they don't). So I am looking for the method which 'select_related' uses to 
tell Django that certain objects don't have reverse relationships.

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



Documentation error?

2011-03-14 Thread Adam Knight
On the description for django.contrib.auth.views.login at
http://docs.djangoproject.com/en/1.2/topics/auth/#django.contrib.auth.views.loginthe
documentation says:

If you are using alternate authentication (see Other authentication sources)
> you can pass a custom authentication form to the login view via the
> authentication_form parameter. This form must accept a request keyword
> argument in its __init__ method, and provide a get_user method which returns
> the authenticated user object (this method is only ever called after
> successful form validation).


Note the phrase "This form must accept a request keyword argument in its
__init__ method".  When I do this as it literally states and expect a
"request" keyword argument, I don't get a request.  When I looked at
django.contrib.auth.views.login on line 31 I see that it's actually setting
the keyword argument "data" instead.

Did I miss something or is this a bug I should file?

(Yes, expecting the "data" keyword works perfectly, but it's not in the
documentation that I can see.)
-- 
Adam

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



How make CSRF middleware emit html4 rather than xhtml1.0 (closing tags issue) so will validate?

2011-03-14 Thread Chris Seberino
My Django app's html won't validate because CSRF middleware adds
hidden
tags like this...



The only problem is the slash "/>" at the end.

How make Django templates not automatically add hidden tags that won't
validate?

Thanks!

cs

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



Re: Django projects, apps, and git repos

2011-03-14 Thread Shawn Milochik
Think of your pluggable Django apps like they were any other Python
module, such as your database driver, Django itself, South, Celery, or
whatever.

The easiest and cleanest way to do it is to package your pluggable
apps so you can install them with pip or setuptools. If there's an
update, upgrade them as you would any other package. There's nothing
special about them just because they're Django apps -- you still have
to somehow get them on your PYTHONPATH and import them.

This is roughly the equivalent of what you're doing now with git. It's
messy because it's a manual process.

Here's a link to distutils. I'm no expert in this area, so if
distribute or distutils2 is generally preferred by the community then
I hope someone will jump in and clarify.
http://docs.python.org/library/distutils.html

Shawn

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



Re: Is it safe to change the "id" field of a model from int to bigint in the DB schema?

2011-03-14 Thread David De La Harpe Golden
On 13/03/11 05:02, Andy wrote:
> I have a model that may have a lot (billions) of records. I understand
> that the "id" field of a model is defined as a 32-bits int. So it may
> not be big enough.
> 
> Is it safe to just ALTER the database schema to change the "id" field
> from int to bigint? Would Django break? 

It would be best to also set your id field on your model to be a
BigIntegerField at the ORM level if you're doing that.

http://docs.djangoproject.com/en/1.2/ref/models/fields/#bigintegerfield

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



Re: Looking for Django developers in Sydney!

2011-03-14 Thread bixly.com
Hi Zac Altman,

I was searching through job postings for Django, looking for companies
such as yourself who could use our help. I found your listing and
wanted to let you know, I'm the Senior Consultant for a Django company
called Bixly. I know your posting was looking for an on-site developer
however, if you were open to working with a company to augment your
hiring, we might just fit the bill. We often times allow companies
like yourself to contract our Django developers directly and even work
with them one on one if desired. We have an on-site project manager to
track and report everything as well so you don't have to guess which
direction the project is heading and where you can go to get instant
status updates.

You can check us out at http://bixly.com and see what we're all about.
We've worked alongside with many companies that already have
developers before and it's worked out great. I would love to talk with
you some time, if you find us interesting?

Thank you for your time and hope to hear from you soon.

Vana Moua
Senior Consultant
email: v...@bixly.com
Website: http://bixly.com
Skype #: (559) 761-0588
Office #: (877) 673-7059

Want to learn more about Django? Here's a link you can watch:
http://www.youtube.com/watch?v=ZqYxML3_coc





On Mar 14, 2:56 am, Zac Altman  wrote:
> Hey,
>
> I am looking for one (or two) great Django developers who live in
> Sydney, Australia. I have two opportunities for you. The first is to
> join a social restaurant discovery startup. It is a great project with
> immense (and tasty) rewards. The second is a 2 month paid contact to
> build the backend for a charity-related project (looks great on the
> resume).
>
> I need people to start work yesterday. I am available all week to meet
> up and discuss either opportunity further.
>
> Please send me a message if you are interested in either.
>
> Thanks,
> Zac Altman

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



Re: Why is the first Manager defined in a model the default?

2011-03-14 Thread Shawn Milochik
I can't address the first question because it was probably discussed
among the developers and was a design decision.

As for the second, you don't *have to* create an 'objects' manager at
all. If you do nothing, you get a Manager() for free
by default, and because it has to be named *something*, it's 'objects'
-- just because that's what someone picked as a default long ago.

Remember that 'objects' is not some special property of a Django
model. It's the name (by convention) that the default manager has.
It's like using **kwargs in a function -- it could just as easily be
**ponies, but most people just do it the way the community does it.

If you choose to make your own manager then Django politely accepts
your decision and doesn't thrust the default upon you.

You could always name your custom Manager 'objects' if you like. It's
even a good idea in some circumstances, like when you need to enforce
special filtering in your querysets.

Shawn

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



Re: request in model

2011-03-14 Thread Mike Ramirez
On Monday, March 14, 2011 07:45:23 am Igor Nemilentsev wrote:
> I am new in Django.
> I am looking for a solution for my problem.
> I want to have a base model class
> inheriting all other model classes from that class.
> In the base model class I want to check
> some permissions for users.
> So, need pass request to model class so that
> to have request.user.
> Is it possible?
> Sorry for the obscure explanation,
> I just want to know whether it is possible to go this way.

class MyModel(models.Model):
  ...
  def __init__(self, user=None, *args, **kwargs):
super(MyModel, self).__init__(*args, **kwargs)
self.user = user

or:

class MyModel(models.Model):
  ...
  def setUser(self, user=None):
self.user = user


Call setUser before you call any method that requires the user. If user is 
None, you can raise an error in your model.  Though it's best to do perm 
checking in the view/templates or a form, though with the form you're going to 
be passing around request.user also, but passing it part of the __init__() is 
normal with forms.


please note this for models:

http://docs.djangoproject.com/en/dev/topics/db/models/#field-name-hiding-is-
not-permitted

Also, you might want to research the admin source to see how it handles the 
user and permission model.


Mike






-- 
A copy of the universe is not what is required of art; one of the damned
things is ample.
-- Rebecca West

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



Re: Help using internationalization feature

2011-03-14 Thread Juan Gabriel Aldana Jaramillo
Thanks for your comprehensive reply. Now everything is clear to me.



On Mon, Mar 14, 2011 at 11:30 AM, Tom Evans wrote:

> On Mon, Mar 14, 2011 at 4:05 PM, Juan Gabriel Aldana Jaramillo
>  wrote:
> > Thanks for your response.
> > Now, If I have a text that will be translated ( {% trans "text_1" %}),
> Where
> > should I call the _("text_1") view to store the label and its
> translation?
> > According to the documentation, this view could be called inside the .py
> > file but I think that doing that I am breaking the template's
> encapsulation
> > because that means that the .py file must know the text that conforms the
> > template. isnt it?
> >
>
> Please just reply to the group when replying to a mailing list - I'm
> subscribed, I don't need to be cc'ed.
>
> There is no 'label' and 'translation'. The 'label' is the original
> string, and typically is the english version of the translation.
>
> Here is a complete run-down of how it works:
>
> You put '{% trans "foo" %}' in your template.
> You run "python manage.py makemessages -a"
> This generates /locale//LC_MESSAGES/django.po
> This is a po file - it contains translations
>
> The format looks like this:
>
> #: app/templates/foo.html:11
> msgid "foo"
> msgstr ""
>
> You give this file to your translator, he fills in the msgstr portion
> of the pofile. He can do this with a text editor, or an application
> (poedit +others), or even a django app (django-rosetta).
>
> Eg, he may make this change:
>
> #: app/templates/foo.html:11
> msgid "foo"
> msgstr "föö"
>
> The translator gives the file back, and you put it in the right place
> in the locale directory.
> You run "python manage.py compilemessages"
> This turns po files into mo files - a binary, efficient way of
> accessing the data.
> Now, whenever django encounters the exact string "foo" in a
> translation context (eg {% trans "foo" %} or _("foo") in a view), it
> replaces it with the translation.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Django projects, apps, and git repos

2011-03-14 Thread Mike Ramirez
On Monday, March 14, 2011 08:22:23 am br wrote:
> Just curious if there is a best way to manage this both from a project-
> management and a git perspective.
> 
> Thanks
> 
> br

Before I begin, 'best' is completely subjective and I think all this comes 
down to what works for you and the situation. 

On my dev box I contain one directory that has django apps in development and 
those checked out from other repos, there is the global site-packages which 
contain apps installed from pypi and the package manager (using pm supplied 
modules before pypi stuff), another dir for projects, that may use it's own 
apps or from the other places (including other projects).  It's a cluster f*ck 
sometimes, because prototyping is done in this area also.

Apps in development have thier own repos. With git, using the git-submodule[1] 
command, you can use git like svn with svn externals.  Importing from other 
repos into a super repo/project. 

Staging/Q-C are a different server (physically) that mimics production in 
everyway possible (small sites can have qc on the same box as production to 
get the closest environmnet). This server is for one project only, the one 
you're testing, I really don't recommend one staging system for multiple sites 
unless you're using one user for one site. Ideally the user this exists as is 
a special user, specifically for staging/qc.

During setup/configuration run a script that installs django and any django-
apps you're getting from pypi, These don't go in the global site-packages, 
these go into a seperate directory.  like ~/lib/python/site-packages.  Unless 
your package manager supports using a prefix other than /usr for installing 
apps, avoid the pm at this point. You want fine grain control over what 
apps/version your project is using at this point.

The project is then one of the super-project git checkouts, pulling in the 
apps it needs from the different repos. Lives in it's own directory. this is 
the only area I need/want to update with git or modify.  With the only real 
work going on is checking/testing of the site, looking for runtime errors, 
verifying configurations.  


>From here package up the staging environment to be deployed in production. 


Mike

[1] https://git.wiki.kernel.org/index.php/GitSubmoduleTutorial




-- 
Men use thought only to justify their wrong doings, and speech only to
conceal their thoughts.
-- Voltaire

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



Re: Help using internationalization feature

2011-03-14 Thread Juan Gabriel Aldana Jaramillo
Thanks for your response.

Now, If I have a text that will be translated ( {% trans "text_1" %}), Where
should I call the _("text_1") view to store the label and its translation?
According to the documentation, this view could be called inside the .py
file but I think that doing that I am breaking the template's encapsulation
because that means that the .py file must know the text that conforms the
template. isnt it?


On Mon, Mar 14, 2011 at 9:24 AM, Tom Evans  wrote:

> On Mon, Mar 14, 2011 at 1:27 PM, hassan  wrote:
> > take a look at
> http://docs.djangoproject.com/en/1.2/topics/i18n/internationalization/
> > it is clear,
> > but for short:
> >
> > 1 - in .py files:
> >from django.utils.translation import ugettext as _
> >and mark each text you want to traslate like this _("My string")
> >
> > 2 - in .html files:
> >{% load i18n %}
> >and mark with {% trans "My string" %}
> >
>
> Or:
>  {{ _("foo") }}
>
> You'll need to use this syntax to do things like filters:
>  {{ _("foo")|linebreaksbr }}
>
> Or:
>  {% blocktrans with foo as bar %}Some string with a {{ bar }}
> placeholder{% endblocktrans %}
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Help using internationalization feature

2011-03-14 Thread Tom Evans
On Mon, Mar 14, 2011 at 4:05 PM, Juan Gabriel Aldana Jaramillo
 wrote:
> Thanks for your response.
> Now, If I have a text that will be translated ( {% trans "text_1" %}), Where
> should I call the _("text_1") view to store the label and its translation?
> According to the documentation, this view could be called inside the .py
> file but I think that doing that I am breaking the template's encapsulation
> because that means that the .py file must know the text that conforms the
> template. isnt it?
>

Please just reply to the group when replying to a mailing list - I'm
subscribed, I don't need to be cc'ed.

There is no 'label' and 'translation'. The 'label' is the original
string, and typically is the english version of the translation.

Here is a complete run-down of how it works:

You put '{% trans "foo" %}' in your template.
You run "python manage.py makemessages -a"
This generates /locale//LC_MESSAGES/django.po
This is a po file - it contains translations

The format looks like this:

#: app/templates/foo.html:11
msgid "foo"
msgstr ""

You give this file to your translator, he fills in the msgstr portion
of the pofile. He can do this with a text editor, or an application
(poedit +others), or even a django app (django-rosetta).

Eg, he may make this change:

#: app/templates/foo.html:11
msgid "foo"
msgstr "föö"

The translator gives the file back, and you put it in the right place
in the locale directory.
You run "python manage.py compilemessages"
This turns po files into mo files - a binary, efficient way of
accessing the data.
Now, whenever django encounters the exact string "foo" in a
translation context (eg {% trans "foo" %} or _("foo") in a view), it
replaces it with the translation.

Cheers

Tom

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



Django projects, apps, and git repos

2011-03-14 Thread br
I have a question about how people relate django projects & apps
(including django apps that are shared between projects) to git
repositories.

We are using a gitolite setup on a central server to share
repositories between developers.

Right now we have two different projects, each with a corresponding
git repo, which function as standalone sites.  I am evolving one of
the two sites to basically "merge" the two projects and include
several apps from both. For now I am just leaving the repositories
separate, and setting up the master project to include apps from the
other project in settings.py and make sure they end up in the
PYTHONPATH, which seems to work.

As this stands, different apps pertain to different repos, even though
I am using them all in the same project.  I am not yet completely
comfortable with this setup, and am wondering how people usually
manage their  git repositories with respect to their projects and
apps, while dealing with shared apps and remaining true to DRY
principles?  Do you use a 1 to 1 repo-to-project relationship? Or do
you have multiple projects in 1 repo? Or do you have a different
directory & corresponding repo for all shared apps, and then a repo
for each project and corresponding project-specific files and apps?
or just 1 centralized repo for all your django projects? Something
else?

Just curious if there is a best way to manage this both from a project-
management and a git perspective.

Thanks

br

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



Re: Is it safe to change the "id" field of a model from int to bigint in the DB schema?

2011-03-14 Thread Bill Freeman
You ill have to start by asking about your specific database, preferably
from someone who knows that database definitively.  The id field is generally
set up to be automatically populated using a database sequence object, so
one question is whether your database's sequences can be bigint.  Another
is whether it has restrictions on foreign key field sizes, since by default they
are in the id field.  And the unique constraint is typically implemented in an
index, so you would need to confirm that you can have an index on a bigint.

I suspect that most databases support all of these, but you should check
in the case of yours.

So long as the ORM supports your db's bigints at all, which I believe is a
function of the database back end, python deals with int versus long
transparently, especially in the newer versions.

But test.

Bill

On Sun, Mar 13, 2011 at 12:02 AM, Andy  wrote:
> I have a model that may have a lot (billions) of records. I understand
> that the "id" field of a model is defined as a 32-bits int. So it may
> not be big enough.
>
> Is it safe to just ALTER the database schema to change the "id" field
> from int to bigint? Would Django break? What happens when the "id"
> value returned by the database is larger than 32 bits, would Django be
> able to handle that?
>
> 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-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Difference between RequestContext and Context?

2011-03-14 Thread gamingdroid
I see, so I completely misunderstood RequestContext.

There is only two differences, RequestContext takes a HttpRequest
object as it's first argument and automatically includes
TEMPLATE_CONTEXT_PROCESSOR dictionaries into the context.

Question then is why using RequestContext forced me to include
'django.contrib.auth.context_processors.auth' in
TEMPLATE_CONTEXT_PROCESSOR for the admin section to work, while just
using Context did not? That suggest Context somehow get's
django.contrib.auth.context_processors.auth

Thanks!

On Mar 14, 6:16 am, Tom Evans  wrote:
> On Mon, Mar 14, 2011 at 8:16 AM, gamingdroid  wrote:
> > 1. So beyond the fact that RequestContext can accept a dictionary with
> > values to be included in the Context, what is the difference between
> > RequestContext and Context?
>
> > I tried reviewing the source code, but it still isn't really clear
> > (i.e. meaning I didn't quite understand the source code).
>
> > 2. Why is it that Context automatically loads some context processors
> > while RequestContext does NOT?
>
> > At least it almost seem like it, because when I tried to use
> > RequestContext, I had to include
> > ''django.contrib.auth.context_processors.auth'' in the
> > TEMPLATE_CONTEXT_PROCESSOR variable in settings.py for the admin site
> > to work, but did not when just using the standard Context.
>
> Context doesn't 'load' (execute) any context processors. All context
> processors are callables that take a request as their only argument,
> this alone should convince you that a standard Context doesn't call
> any context processors.
>
> As for the differences between Context and RequestContext, the docs
> are quite clear:
>
> http://docs.djangoproject.com/en/1.2/ref/templates/api/#subclassing-c...
>
> Cheers
>
> Tom

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



request in model

2011-03-14 Thread Igor Nemilentsev
I am new in Django.
I am looking for a solution for my problem.
I want to have a base model class 
inheriting all other model classes from that class.
In the base model class I want to check
some permissions for users.  
So, need pass request to model class so that
to have request.user.
Is it possible?
Sorry for the obscure explanation,
I just want to know whether it is possible to go this way.

-- 
Oh, by the way, which one's Pink?
-- Pink Floyd

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



Re: app/model not showing in admin interface?

2011-03-14 Thread shofty
100%

documented here.

http://docs.djangoproject.com/en/dev/intro/tutorial02/#make-the-poll-app-modifiable-in-the-admin

easy enough to test, new app, new admin.py, refresh the admin, not
there.
stop/start, it;ll be there.

caught me out more than once til i properly read the tut.

Matt

On Mar 14, 7:18 am, Kenneth Gonsalves  wrote:
> On Mon, 2011-03-14 at 00:14 -0700, shofty wrote:
> > stop/start the dev server. It doesn't spot new files being created,
> > only changes to existing files.
>
> are you sure?
> --
> regards
> KGhttp://lawgon.livejournal.com
> Coimbatore LUG roxhttp://ilugcbe.techstud.org/

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



Re: Help using internationalization feature

2011-03-14 Thread Tom Evans
On Mon, Mar 14, 2011 at 1:27 PM, hassan  wrote:
> take a look at 
> http://docs.djangoproject.com/en/1.2/topics/i18n/internationalization/
> it is clear,
> but for short:
>
> 1 - in .py files:
>    from django.utils.translation import ugettext as _
>    and mark each text you want to traslate like this _("My string")
>
> 2 - in .html files:
>    {% load i18n %}
>    and mark with {% trans "My string" %}
>

Or:
  {{ _("foo") }}

You'll need to use this syntax to do things like filters:
  {{ _("foo")|linebreaksbr }}

Or:
  {% blocktrans with foo as bar %}Some string with a {{ bar }}
placeholder{% endblocktrans %}

Cheers

Tom

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



Re: django-registration - Activate view not works

2011-03-14 Thread Cromulent
Sounds to me like you have done the wrong thing in your templates.

My registration email template contains this line:

http://{{ site }}{% url registration_activate
activation_key=activation_key %}

which should provide the correct information.

If you already have that and it still does not work have you also made
sure to include an ACCOUNT_ACTIVATION_DAYS = 7 setting in your
settings.py file? The number denotes the number of days before an
account expires if not activated.

On Mar 13, 6:14 pm, Sergio Berlotto Jr 
wrote:
> The variable "activation_key" is blank, with no value, and the result os
> activation redirect always to activation_failed view.

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



Re: how to search data from tables

2011-03-14 Thread scarab
Read some Django documentation about querysets, filters etc. There are
answers there ;)
Try this:
result = Person.objects.filter(nationality="American", age=17)

On 14 Mar, 04:20, django beginner  wrote:
> Hi all,
>
> I would like to know is there any way I can search any data from
> tables given some parameters:
> Suppose I have this person model:
>
> class Person(models.Model):
>     userid = models.AutoField(primary_key=True)
>     fname = models.CharField(max_length=30)
>     lname = models.CharField(max_length=30)
>     age = models.IntegerField(max_length=2)
>     nationality = models.CharField(max_length=50)
>     def __unicode__(self):
>         return self.fname
>
> --
> and, suppose I have these existing data from person_table:
>
> userid      fname              lname                 age
> nationality
> 1             Marie              Santos
> 21                Canadian
> 2             Ann                Reyes
> 18                Canadian
> 3             John               Smith
> 17                American
> 4             Beth               Anderson
> 17                American
> 5             Lani                Jackson
> 17               American
>
> -
> Now, I have these user input as search parameters:
> Nationality:  American
> Age: 17
>
> ---
> The results should output these data:
> userid      fname              lname                 age
> nationality
> 3             John               Smith
> 17                American
> 4             Beth               Anderson
> 17                American
> 5             Lani                Jackson
> 17               American
>
> ---
> Could someone please give me a sample code for this simple search
> query using Django? Thank you so much.

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



Re: Help using internationalization feature

2011-03-14 Thread hassan
take a look at 
http://docs.djangoproject.com/en/1.2/topics/i18n/internationalization/
it is clear,
but for short:

1 - in .py files:
from django.utils.translation import ugettext as _
and mark each text you want to traslate like this _("My string")

2 - in .html files:
{% load i18n %}
and mark with {% trans "My string" %}


On Mar 14, 4:00 pm, aldanajaramillo  wrote:
> Hi,
>
> I am new with Python and Django. Currently I am working on a new
> project using Django and I already have some templates ready to be
> used but now I want to use the internationalization feature to
> translate some texts of these templates. I already read the
> documentation about it but I don't know where to start.
>
> Can anyone please give me some detailed instructions about how to
> translate text of the templates?
>
> Where should I put the call to the _("text_to_translate") view? inside
> the .py file that launch the template?
>
> Thanks in advance,

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



Re: Admin Site Error

2011-03-14 Thread Tom Evans
On Mon, Mar 14, 2011 at 5:21 AM, sahana bhat  wrote:
> I am getting this error when i try to activate the admin site... i
> followed all the steps of the django tutorials. please help...
>
> AttributeError at /admin/
> 'WSGIRequest' object has no attribute 'user'
>
> This is the stack trace..
> Traceback (most recent call last):
>
>  File "C:\Python26\lib\site-packages\django\core\servers
> \basehttp.py", line 280, in run
>    self.result = application(self.environ, self.start_response)
>
>  File "C:\Python26\lib\site-packages\django\core\servers
> \basehttp.py", line 674, in __call__
>    return self.application(environ, start_response)
>
>  File "C:\Python26\lib\site-packages\django\core\handlers\wsgi.py",
> line 248, in __call__
>    response = self.get_response(request)
>
>  File "C:\Python26\lib\site-packages\django\core\handlers\base.py",
> line 141, in get_response
>    return self.handle_uncaught_exception(request, resolver,
> sys.exc_info())
>
>  File "C:\Python26\lib\site-packages\django\core\handlers\base.py",
> line 180, in handle_uncaught_exception
>    return callback(request, **param_dict)
>
>  File "C:\Python26\lib\site-packages\django\utils\decorators.py",
> line 76, in _wrapped_view
>    response = view_func(request, *args, **kwargs)
>
>  File "C:\Python26\lib\site-packages\django\views\defaults.py", line
> 30, in server_error
>    t = loader.get_template(template_name) # You need to create a
> 500.html template.
>
>  File "C:\Python26\lib\site-packages\django\template\loader.py", line
> 157, in get_template
>    template, origin = find_template(template_name)
>
>  File "C:\Python26\lib\site-packages\django\template\loader.py", line
> 138, in find_template
>    raise TemplateDoesNotExist(name)
>
> TemplateDoesNotExist: 500.html
>
>
>
> Snippets of my settings.py file:
>
> MIDDLEWARE_CLASSES = (
>
> )
> INSTALLED_APPS = (
>   'django.contrib.auth',
>    'django.contrib.contenttypes',
>   'django.contrib.sessions',
>    'django.contrib.sites',
>    'django.contrib.admin',
>    'newsite.employees',
>    'polls',
> )
> TEMPLATE_CONTEXT_PROCESSORS =
> ( 'django.core.context_processors.debug',
>                                'django.core.context_processors.i18n',
>                                'django.core.context_processors.auth', )
>

Your site isn't working correctly, and there is no 500 template to
display the error, so you get a double failure. Turn on DEBUG, or
provide a valid 500 error template so that you can determine why your
site isn't working.

Cheers

Tom

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



Re: Difference between RequestContext and Context?

2011-03-14 Thread Tom Evans
On Mon, Mar 14, 2011 at 8:16 AM, gamingdroid  wrote:
> 1. So beyond the fact that RequestContext can accept a dictionary with
> values to be included in the Context, what is the difference between
> RequestContext and Context?
>
> I tried reviewing the source code, but it still isn't really clear
> (i.e. meaning I didn't quite understand the source code).
>
> 2. Why is it that Context automatically loads some context processors
> while RequestContext does NOT?
>
> At least it almost seem like it, because when I tried to use
> RequestContext, I had to include
> ''django.contrib.auth.context_processors.auth'' in the
> TEMPLATE_CONTEXT_PROCESSOR variable in settings.py for the admin site
> to work, but did not when just using the standard Context.
>

Context doesn't 'load' (execute) any context processors. All context
processors are callables that take a request as their only argument,
this alone should convince you that a standard Context doesn't call
any context processors.

As for the differences between Context and RequestContext, the docs
are quite clear:

http://docs.djangoproject.com/en/1.2/ref/templates/api/#subclassing-context-requestcontext


Cheers

Tom

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



Help using internationalization feature

2011-03-14 Thread aldanajaramillo
Hi,

I am new with Python and Django. Currently I am working on a new
project using Django and I already have some templates ready to be
used but now I want to use the internationalization feature to
translate some texts of these templates. I already read the
documentation about it but I don't know where to start.

Can anyone please give me some detailed instructions about how to
translate text of the templates?

Where should I put the call to the _("text_to_translate") view? inside
the .py file that launch the template?

Thanks in advance,

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



Looking for Django developers in Sydney!

2011-03-14 Thread Zac Altman
Hey,

I am looking for one (or two) great Django developers who live in
Sydney, Australia. I have two opportunities for you. The first is to
join a social restaurant discovery startup. It is a great project with
immense (and tasty) rewards. The second is a 2 month paid contact to
build the backend for a charity-related project (looks great on the
resume).

I need people to start work yesterday. I am available all week to meet
up and discuss either opportunity further.

Please send me a message if you are interested in either.

Thanks,
Zac Altman

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



Difference between RequestContext and Context?

2011-03-14 Thread gamingdroid
1. So beyond the fact that RequestContext can accept a dictionary with
values to be included in the Context, what is the difference between
RequestContext and Context?

I tried reviewing the source code, but it still isn't really clear
(i.e. meaning I didn't quite understand the source code).

2. Why is it that Context automatically loads some context processors
while RequestContext does NOT?

At least it almost seem like it, because when I tried to use
RequestContext, I had to include
''django.contrib.auth.context_processors.auth'' in the
TEMPLATE_CONTEXT_PROCESSOR variable in settings.py for the admin site
to work, but did not when just using the standard Context.

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



Why is the first Manager defined in a model the default?

2011-03-14 Thread gamingdroid
I'm a little confused about Manager classes and how they function:

1. Why is the first custom Manager class defined in a model, the
default? It would seem more reasonable to have the default manager
field, re-assigned as opposed to figuring it out by order of
definition declaration.

2. Suppose I included a custom Manger class in my model, why is it
that I still have to re-assign the model.objects field with the
default manager, models.Manager()?

Example code:

class Book(models.Model):
   # Some fields here

  objects = models.Manager() # Why doesn't this automatically get
assigned
  mycustommanager = MyCustomManager()

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



Admin Site Error

2011-03-14 Thread sahana bhat
I am getting this error when i try to activate the admin site... i
followed all the steps of the django tutorials. please help...

AttributeError at /admin/
'WSGIRequest' object has no attribute 'user'

This is the stack trace..
Traceback (most recent call last):

  File "C:\Python26\lib\site-packages\django\core\servers
\basehttp.py", line 280, in run
self.result = application(self.environ, self.start_response)

  File "C:\Python26\lib\site-packages\django\core\servers
\basehttp.py", line 674, in __call__
return self.application(environ, start_response)

  File "C:\Python26\lib\site-packages\django\core\handlers\wsgi.py",
line 248, in __call__
response = self.get_response(request)

  File "C:\Python26\lib\site-packages\django\core\handlers\base.py",
line 141, in get_response
return self.handle_uncaught_exception(request, resolver,
sys.exc_info())

  File "C:\Python26\lib\site-packages\django\core\handlers\base.py",
line 180, in handle_uncaught_exception
return callback(request, **param_dict)

  File "C:\Python26\lib\site-packages\django\utils\decorators.py",
line 76, in _wrapped_view
response = view_func(request, *args, **kwargs)

  File "C:\Python26\lib\site-packages\django\views\defaults.py", line
30, in server_error
t = loader.get_template(template_name) # You need to create a
500.html template.

  File "C:\Python26\lib\site-packages\django\template\loader.py", line
157, in get_template
template, origin = find_template(template_name)

  File "C:\Python26\lib\site-packages\django\template\loader.py", line
138, in find_template
raise TemplateDoesNotExist(name)

TemplateDoesNotExist: 500.html



Snippets of my settings.py file:

MIDDLEWARE_CLASSES = (

)
INSTALLED_APPS = (
   'django.contrib.auth',
'django.contrib.contenttypes',
   'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'newsite.employees',
'polls',
)
TEMPLATE_CONTEXT_PROCESSORS =
( 'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.auth', )

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



Re: Can I sort a related model reference in a template?

2011-03-14 Thread Tom Evans
On Sat, Mar 12, 2011 at 1:27 PM, Shawn Milochik  wrote:
> You can put a sort order in the model's meta info. That way you'll always
> have a default sort.
>

If you do this, every query you execute returning that model will be
sorted. This can lead to serious performance issues if sorting is only
required in certain scenarios - sorting is never free.

Cheers

Tom

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



Re: file upload size problem

2011-03-14 Thread Tom Evans
On Mon, Mar 14, 2011 at 9:02 AM, vamsy krishna  wrote:
> I'm facing a new problem now. I have a defined a custom error page and
> using the handler413 in my urls file to load this template. However
> this is not getting picked up. I would like to handle this at django
> level instead of apache. The ErrorDocument definition in apache works
> fine.
>
> Also the handler404 and handler500 are working without any issue. Can
> someone point me in the right direction?
>
> Thanks,
> Vamsy
>

handler404 and handler500 get called if django tries to serve a page
that doesn't exist or a page that errors. Your 413 is generated from
apache, and so does not ever call django, therefore django cannot
handle this error.

To get around this, set

ErrorHandler 413 /some/django/url

Apache will use an internal redirect to fetch this URL, so it should
be transparent to your users.

Cheers

Tom

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



Re: template loader is missing a character.

2011-03-14 Thread Tom Evans
On Sun, Mar 13, 2011 at 7:16 AM, royy  wrote:
> Hi.
>
> I'm following the tutotial for my first Django app, in part 3 after
> edit the views.py file  I'm getting the error.
> •Using loader django.template.loaders.filesystem.Loader:
>..
> As you can see template loader is missing the letter " t "  of
> templates
>

This normally means you had a string like this:

"c:\foo\bar\templates"

In a character string, '\t' is shorthand for the tab character.

Be very careful when specifying file system locations on windows.
Either use raw strings - r'c:\foo\templates' is fine - or use '/' as
the separator.

Cheers

Tom

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



Re: help to finish my 1st Django app.

2011-03-14 Thread Igor Ischenko
Hi

Show your template file

2011/3/14 royy 

> Hi.
>
> I've finished the tutorial for the polls app.
>
> I tought everythin was OK till I load the server and type the addres:
> http://127.0.0.1:8000/polls/
>
> web browser shows me the message "No polls are available" isn't a web
> browser error message, because it is plain text.
>
> I've created 3 polls with 3 choices each one.
>
> admin page works fine, just the polls address is the one that don't
> loads well. This is my final views.py code:
>
> from django.shortcuts import get_object_or_404, render_to_response
> from django.http import HttpResponseRedirect, HttpResponse
> from django.core.urlresolvers import reverse
> from django.template import RequestContext
> from polls.models import Choice, Poll
>
> def vote(request, poll_id):
>p = get_object_or_404(Poll, pk=poll_id)
>try:
>selected_choice = p.choice_set.get(pk=request.POST['choice'])
>except (KeyError, Choice.DoesNotExist):
>
>return render_to_response('polls/poll_detail.html', {
>'poll': p,
>'error_message': "You didn't select a choice.",
>}, context_instance=RequestContext(request))
>else:
>selected_choice.votes += 1
>selected_choice.save()
>return HttpResponseRedirect(reverse('poll_results',
> args=(p.id,)))
>
>
> -
>
> and this is my final polls/urls.py code:
>
> from django.conf.urls.defaults import *
> from polls.models import Poll
>
> info_dict = {
>'queryset': Poll.objects.all(),
> }
>
> urlpatterns = patterns('',
>(r'^$', 'django.views.generic.list_detail.object_list',
> info_dict),
>(r'^(?P\d+)/$',
> 'django.views.generic.list_detail.object_detail', info_dict),
>url(r'^(?P\d+)/results/$',
> 'django.views.generic.list_detail.object_detail', dict(info_dict,
> template_name='polls/results.html'), 'poll_results'),
>(r'^(?P\d+)/vote/$', 'polls.views.vote'),
> )
>
>
> Please help me to find what's wrong.
>
> 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-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.
>
>


-- 
Best regards,
Igor Ishchenko

iPhone dev team
NIX Solutions, Ltd.

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



Re: Use admin interface in public facing pages?

2011-03-14 Thread Derek
On Mar 11, 12:40 am, gbl  wrote:
> The admin interface is perfect for the site I'm working on. Automatic
> pagination, customizable search fields, filter via boolean or date
> fields in a sidebar, clickable sorting on column headings. Easy to
> modify
>
> Is there really no way to use all this code in a read-only situation?
>
> Do I have to rewrite all that code or is there some way to use what is
> already built in?
>
> Pointers to relevant docs would be great. It seems a variant of this
> question is asked frequently so I'm guessing there is no easy way to
> do this...but I ask anyway with fingers crossed.
>
> databrowse is cool as well but not customizable, nor as full featured
> as the admin interface
>
> The admin interface is nearly exactly what I need to view and search a
> databasebut I don't want people editing what they're browsing and
> I need to customize the detail view a bit.
>
> I'm new to django so if this is truly basic and I've missed something
> my apologies.

As has been said in many other place - the Admin interface is designed
for Administrators - people who really do need to add, change and/or
delete data ... not just view it.  If you do need this option - have a
look at:
http://gremu.net/blog/2010/django-admin-read-only-permission/

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



Re: how to search data from tables

2011-03-14 Thread Kenneth Gonsalves
On Mon, 2011-03-14 at 15:47 +0600, Gennadiy Zlobin wrote:
> Yes, because you will have to update age every time on person's
> birthday and
> if you forget to do it, you get the invalid data.
> 
> age = models.DateField() 

date_of_birth = models.DateField()
def age(self):
return (datetime.datetime.today() - date_of_birth).years

(pseudo code)
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Re: No fixtures found

2011-03-14 Thread Shakthi Kannan
Hi,

--- On Fri, Mar 11, 2011 at 6:25 PM, Kenneth Gonsalves
 wrote:
| I tried this out after you brought it up in IRC and made the smallest
| possible test. It works for me regardless of what name I give the
| fixtures file as long as it is in the fixtures directory of the
| application. You must be doing something wrong - although as far as I
| can see your code is identical to mine.
\--

Just for the record, I manually installed Django 1.3 RC1, and it worked.

Thanks for your help,

SK

-- 
Shakthi Kannan
http://www.shakthimaan.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-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: file upload size problem

2011-03-14 Thread vamsy krishna
I'm facing a new problem now. I have a defined a custom error page and
using the handler413 in my urls file to load this template. However
this is not getting picked up. I would like to handle this at django
level instead of apache. The ErrorDocument definition in apache works
fine.

Also the handler404 and handler500 are working without any issue. Can
someone point me in the right direction?

Thanks,
Vamsy

On Mar 14, 11:07 am, vamsy krishna  wrote:
> Oh yes. Thanks Karen.
>
> On Mar 12, 7:06 pm, Karen Tracey  wrote:
>
> > On Sat, Mar 12, 2011 at 12:06 AM, vamsy krishna 
> > wrote:
>
> > > I'm doing a file upload from one of my forms and writing the content
> > > to a temp file on the server. The problem is any file of size more
> > > than 250 KB is throwing the below error:
>
> > > Request Entity Too Large
> > > The requested resource
> > > /tera/tera_upload/
> > > does not allow request data with POST requests, or the amount of data
> > > provided in the request exceeds the capacity limit.
>
> > > I read through the django file uploads documentation and it says the
> > > default file upload size in memory is about 2.5 MB. Can anyone tell me
> > > what I'm overlooking? Also how do I set a maximum file size limit and
> > > handle it?
>
> > This error isn't coming from Django, it's coming from your web server which
> > has apparently been configured to limit request body size. How to change the
> > limit will depend on what server you are using. If Apache, see for example
> > LimitRequestBody here:http://httpd.apache.org/docs/2.0/mod/core.html
>
> > Karen
> > --http://tracey.org/kmt/
>
>

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



Re: how to search data from tables

2011-03-14 Thread Gennadiy Zlobin
Yes, because you will have to update age every time on person's birthday and
if you forget to do it, you get the invalid data.

age = models.DateField()

- Gennadiy 


On Mon, Mar 14, 2011 at 3:19 PM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

> On 14 mar, 04:20, django beginner  wrote:
>
> Main question already answered. As a side note:
>
> > Suppose I have this person model:
> >
> > class Person(models.Model):
> > userid = models.AutoField(primary_key=True)
> > fname = models.CharField(max_length=30)
> > lname = models.CharField(max_length=30)
> > age = models.IntegerField(max_length=2)
>
>
> Storing the age of a person is _usually_ plain wrong - better to store
> the birth date...
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Multiple modelforms in single POST

2011-03-14 Thread Anoop Thomas Mathew
Thanks buddy.
Sure!! I'll try next time.
regards,
atm

___
Life is short, Live it hard.




On 14 March 2011 14:46, bruno desthuilliers
wrote:

> On 14 mar, 08:16, Anoop Thomas Mathew  wrote:
> >
> > @bruno: If this(http://dpaste.de/ODOJ/) was not enough for you,  ...
>
> No, it was not enough. "No success" is just a variant of "doesn't
> work", which is about the most useless possible description of a
> problem.
>
> http://www.catb.org/~esr/faqs/smart-questions.html#beprecise
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: how to search data from tables

2011-03-14 Thread bruno desthuilliers
On 14 mar, 04:20, django beginner  wrote:

Main question already answered. As a side note:

> Suppose I have this person model:
>
> class Person(models.Model):
>     userid = models.AutoField(primary_key=True)
>     fname = models.CharField(max_length=30)
>     lname = models.CharField(max_length=30)
>     age = models.IntegerField(max_length=2)


Storing the age of a person is _usually_ plain wrong - better to store
the birth date...

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



Re: Multiple modelforms in single POST

2011-03-14 Thread bruno desthuilliers
On 14 mar, 08:16, Anoop Thomas Mathew  wrote:
>
> @bruno: If this(http://dpaste.de/ODOJ/) was not enough for you,  ...

No, it was not enough. "No success" is just a variant of "doesn't
work", which is about the most useless possible description of a
problem.

http://www.catb.org/~esr/faqs/smart-questions.html#beprecise

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



Re: Chaining stacked inline

2011-03-14 Thread gontran
Hi,
back from my WE and still no answers.
Should  I presume that what I want to do is impossible?

On 11 mar, 17:40, gontran  wrote:
> Hi,
>
> I'm wondering if it's possible to chain StackedInlined object in a
> django admin page.
> Let me explain it:
> I have a class UserProfile which is linked by a OneToOneField to the
> django auth module class User. By this way (which is recommended) I
> store additionnal informations about my users. In those informations,
> I have a ForeignKey to the school of the user.
> With a StackedInline class, I can edit user's profile in a user admin
> page but I also want to be able to edit the school of a inside this
> page, not with a pop-up.
>
> Is it possible to achieve this?
>
> Just to sum-up:
>
> My model:
> Class UserProfile(models.Model):
>     user  = models.OneToOneField(User)
>                  extra fields
>     school = models.ForeignKey(School)
>
> My admin.py:
> admin.site.unregister(User)
>
> class UserProfileInline(admin.StackedInline):
>
>     model = UserProfile
>
> class UserProfileAdmin(UserAdmin):
>
>     inlines = [UserProfileInline]
>
> admin.site.register(User, UserProfileAdmin)
>
> Thank you for your help

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



help to finish my 1st Django app.

2011-03-14 Thread royy
Hi.

I've finished the tutorial for the polls app.

I tought everythin was OK till I load the server and type the addres:
http://127.0.0.1:8000/polls/

web browser shows me the message "No polls are available" isn't a web
browser error message, because it is plain text.

I've created 3 polls with 3 choices each one.

admin page works fine, just the polls address is the one that don't
loads well. This is my final views.py code:

from django.shortcuts import get_object_or_404, render_to_response
from django.http import HttpResponseRedirect, HttpResponse
from django.core.urlresolvers import reverse
from django.template import RequestContext
from polls.models import Choice, Poll

def vote(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
try:
selected_choice = p.choice_set.get(pk=request.POST['choice'])
except (KeyError, Choice.DoesNotExist):

return render_to_response('polls/poll_detail.html', {
'poll': p,
'error_message': "You didn't select a choice.",
}, context_instance=RequestContext(request))
else:
selected_choice.votes += 1
selected_choice.save()
return HttpResponseRedirect(reverse('poll_results',
args=(p.id,)))

-

and this is my final polls/urls.py code:

from django.conf.urls.defaults import *
from polls.models import Poll

info_dict = {
'queryset': Poll.objects.all(),
}

urlpatterns = patterns('',
(r'^$', 'django.views.generic.list_detail.object_list',
info_dict),
(r'^(?P\d+)/$',
'django.views.generic.list_detail.object_detail', info_dict),
url(r'^(?P\d+)/results/$',
'django.views.generic.list_detail.object_detail', dict(info_dict,
template_name='polls/results.html'), 'poll_results'),
(r'^(?P\d+)/vote/$', 'polls.views.vote'),
)


Please help me to find what's wrong.

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-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: app/model not showing in admin interface?

2011-03-14 Thread Kenneth Gonsalves
On Mon, 2011-03-14 at 00:14 -0700, shofty wrote:
> stop/start the dev server. It doesn't spot new files being created,
> only changes to existing files. 

are you sure?
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Re: Multiple modelforms in single POST

2011-03-14 Thread Anoop Thomas Mathew
Hi all,
I solved it out..
I got a good tutorial on it, from James Bennett:
http://www.b-list.org/weblog/2008/nov/09/dynamic-forms/

@bruno: If this(http://dpaste.de/ODOJ/) was not enough for you,  ...
@Gladys: Thanks for your time.

regards,
atm


___
Life is short, Live it hard.




On 13 March 2011 21:40, gladys bixly  wrote:

> If you look at this code:
>
> class Profileform(forms.ModelForm):
>
>   class Meta:
>
>   model = User
>   fields = ('first_name','last_name','email',)
>
>   class Employeeform(forms.ModelForm):
>
> """self explanatory"""
>
> class Meta(Profileform):
> model = Profile
> exclude = ('user',)
>
>
> Your Profileform is associated with the User model.
> Now your Employeeform, I assume, you want to associate with the Profile
> model. But why did you have to inherit the Meta from Profileform with this
> line "Class Meta(Profileform)"? Do you want to override it?
>
>
>
> On Fri, Mar 11, 2011 at 6:16 PM, bruno desthuilliers <
> bruno.desthuilli...@gmail.com> wrote:
>
>>
>>
>> On 11 mar, 07:58, Anoop Thomas Mathew  wrote:
>> > Hi all,
>> >
>> > I have a Profile model, which has a ForiegnKey to User model. I want to
>> edit
>> > both of it at same form.
>> >
>> > this is what I tried,http://dpaste.de/ODOJ/
>> > Still, no success. Please help.
>>
>> You'll have to provide a bit more informations if you hope to get some
>> help - like, what "no success" means *exactly*
>>
>> Now just for the record, chances are your Profile.id is not the same
>> as User.id so there's probably something wrong with your view.
>>
>> Also and FWIW, I had the same need (editing user and profile fields in
>> a same form) in a couple apps, and always ended up writing my own (non-
>> model) form. ModelForms are quite handy, but it's sometimes easier and
>> quicker to write a custom form instead.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>
>
> --
> Gladys
> http://bixly.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-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: app/model not showing in admin interface?

2011-03-14 Thread shofty
stop/start the dev server. It doesn't spot new files being created,
only changes to existing files.

On Mar 13, 8:37 pm, "Mark J. Nenadov"  wrote:
> Sorry, that code from admin.py should read:
>
> >> from app.models import Task
> >> from django.contrib import admin
> >> admin.site.register(Task)
>
> ~Mark


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-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: test cannot find assertContains

2011-03-14 Thread Mike Ramirez
On Sunday, March 13, 2011 10:58:10 pm Kenneth Gonsalves wrote:
> On Sun, 2011-03-13 at 22:40 -0700, Mike Ramirez wrote:
> > > I know it is there - but it is half way down the page. My point is
> > 
> > that
> > 
> > > it should be at the top of the page. For what it's worth I filed a
> > > ticket.
> > 
> > I've een wondering about this myself, but I'm not sure that it's in
> > the wrong
> > place, but it's not in the perfect place.
> 
> all I am doing is giving the devs feedback from a dumb user ;-) The docs
> have evolved historically, but now and then maybe a restructuring has to
> be done - and some times the restructuring doesn't help. For example the
> internationalisation docs have now been split into i18n and l10n
> sections. This causes some confusion as most people are not clear about
> the difference between these two.


As I was writing that I was wondering if I should have done that in your bug 
report. I just linked my message to it.

Mike
-- 
UNIX was not designed to stop you from doing stupid things, because that
would also stop you from doing clever things.
-- Doug Gwyn

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



Re: file upload size problem

2011-03-14 Thread vamsy krishna
Oh yes. Thanks Karen.

On Mar 12, 7:06 pm, Karen Tracey  wrote:
> On Sat, Mar 12, 2011 at 12:06 AM, vamsy krishna wrote:
>
> > I'm doing a file upload from one of my forms and writing the content
> > to a temp file on the server. The problem is any file of size more
> > than 250 KB is throwing the below error:
>
> > Request Entity Too Large
> > The requested resource
> > /tera/tera_upload/
> > does not allow request data with POST requests, or the amount of data
> > provided in the request exceeds the capacity limit.
>
> > I read through the django file uploads documentation and it says the
> > default file upload size in memory is about 2.5 MB. Can anyone tell me
> > what I'm overlooking? Also how do I set a maximum file size limit and
> > handle it?
>
> This error isn't coming from Django, it's coming from your web server which
> has apparently been configured to limit request body size. How to change the
> limit will depend on what server you are using. If Apache, see for example
> LimitRequestBody here:http://httpd.apache.org/docs/2.0/mod/core.html
>
> Karen
> --http://tracey.org/kmt/

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