Re: SystemError from django.conf.settings

2011-05-29 Thread Cameron
As suggested on #django yesterday I swapped the site over to manage.py
runserver and also tried gunicorn and they are both stable so it looks
like a problem with uwsgi.

Gunicorn is also surprisingly fast, beating uwsgi on a httperf test to
one of the heavier pages on the site.
-
Cameron


On 29 May, 21:48, А. Р. <4d876...@gmail.com> wrote:
> 2011/5/29 Cameron 
>
>
>
> >    from django.conf import settings
> > SystemError: ../Objects/tupleobject.c:118: bad argument to internal
> > function
>
> Seems to me as a Python bug, not something wrong in Django, so upgrading to
> newer Python version may 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.



Re: Dynamic template loader with TemplateResponse

2011-05-29 Thread Brian Morton
Here is the solution I settled on for now.  This is obviously not
optimally efficient because I have to hit the filesystem twice for
every page load.  Does anyone know of a way to raise Http404 during
template rendering?  I tried it with a TemplateResponse subclass but
ran into some problems with _is_rendered.  I can't think of a way to
handle a 404 at the template rendering stage.

from django.http import Http404
from django.template import TemplateDoesNotExist
from django.template.loader import get_template
from django.views.generic import TemplateView

class ContentView(TemplateView):
def get_template_names(self):
return [self.kwargs['template_name']]

def render_to_response(self, context, **response_kwargs):
try:
get_template(self.get_template_names()[0])
except TemplateDoesNotExist:
raise Http404

return super(ContentView, self).render_to_response(context,
**response_kwargs)

On May 23, 3:01 pm, Brian Morton  wrote:
> I have some legacy code that I used to dynamically load a template based on
> url if it exists and render a 404 if it doesn't exist.
>
> def content(request, template_name='index'):
>     try:
>         return direct_to_template(request, '%s.html' % template_name)
>     except TemplateDoesNotExist:
>         raise Http404
>
> I'm having difficulty conceptualizing how to do this in trunk (1.4) with
> TemplateResponse.  Since everything happens inside response.render() outside
> of the view, I do not have that level of control at this stage.
>
> Should I extend BaseLoader to load the 404 template instead of raising an
> exception if it is not found?  Or should I extend SimpleTemplateResponse to
> do something similar?  Or is there a better way to do this?

-- 
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: save out a test database?

2011-05-29 Thread Jason Culverhouse

On May 29, 2011, at 7:13 PM, Margie Roginski  wrote:

> Anyone know if there is a way to save out a test database that is
> created through the django TestCase module?
> 

I think this gets you close:

https://docs.djangoproject.com/en/1.2/ref/django-admin/#testserver-fixture-fixture

django-admin.py testserver
Runs a Django development server (as in runserver) using data from the given 
fixture(s).



> IE, say I have a test that runs part way through.   I'd like to save
> it out and then modify my settings.py to refer to the saved out test
> database and take a look at it via my web client (ie, runserver) - is
> that possible?
> 
> Thanks for any pointers,
> 
> 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.
> 

-- 
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.



save out a test database?

2011-05-29 Thread Margie Roginski
Anyone know if there is a way to save out a test database that is
created through the django TestCase module?

IE, say I have a test that runs part way through.   I'd like to save
it out and then modify my settings.py to refer to the saved out test
database and take a look at it via my web client (ie, runserver) - is
that possible?

Thanks for any pointers,

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: How do I override default behaviour for foreign keys in an inline formset?

2011-05-29 Thread King
Though I originally asked for a "detailed solution", even some
suggestions as to what I should be googling would be helpful at this
point.  I know I'm not the only one to have tried to do this, so I
can't imagine someone doesn't have an answer somewhere.

On May 26, 12:43 am, King  wrote:
> I want to do something like 
> this...http://groups.google.com/group/django-users/browse_thread/thread/db03...
> ...but unfortunately there was no reply to this particular posting.
> I've found other posts on the web of people looking for the same sort
> of solution, and have not been able to find any helpful answers, so I
> was hoping someone here could clear this up.
>
> For example, let's say I had an app that kept a list of books for each
> user like this:
>
> class BookList(models.Model):
>     user = models.ForeignKey(User)
>     book = models.ForeignKey(Book)
>
> class Book(models.Model):
>     author = models.ForeignKey(Author)
>     name = models.CharField(max_length=300)
>
> class Author(models.Model):
>     name = models.CharField(max_length=300)
>
> I had thought that to generate a bunch of forms for BookList (so that
> the current user could for example, enter in all of the books that
> they've read on a single page), I would use an inlineformset like so:
>
> BookListFormSet = inlineformset_factory(User, BookList)
> booklist_formset = BookListFormSet(instance=currentUser)
>
> However, the resulting formset I get results in a dropdown menu for
> each book field in the forms, but I don't want that. I want two
> TextInput widgets in the form such that the user can type out:
>    Alice in Wonderland
>    Lewis Carroll
> and if some other user has already added "Alice in Wonderland" to
> their book list, then BookList.book will just point to that book.  BUT
> if this is the first user to add "Alice in Wonderland" to their book
> list, I want the form to create a brand new row in the Book table (and
> a brand new row in Author if there is no "Lewis Carroll" books yet
> either).
>
> I'm new to Django, so maybe the solution is obvious to many.  But like
> I said, I'm finding lots of people asking this question, but without
> any good answers posted.
>
> If someone could please provide a detailed solution I would very much
> appreciate it, and I imagine others would as well.
>
> Thanks in advance.  If any part of what I'm asking isn't clear, don't
> hesitate to ask me about it.

-- 
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.



Rendering django message stops script

2011-05-29 Thread Gabe
Hi,

my problem is that I have somewhere in my .html file this code:

{% if messages %}

{% for message in messages %}
{{ message }}
{% endfor %}

{% endif %}

In one of my views when somebody adds commend I add django info
message. In response there should be the message and the rest of
comments redered but it stops on message.

Can anyone tell me what is the problem? Is it the normal behaviour?

thx in advance, sorry for my English
Gabe

-- 
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.



[SOLVED] primary key auto increment with PostgreSQL and non Django standard column name

2011-05-29 Thread Naoko Reeves
I was missing this from schema:
ALTER SEQUENCE tablename_colname_seq OWNED BY tablename.colname;

Now everything is happy. Thank you!


On 5/28/11 8:32 AM, "Naoko Reeves"  wrote:

> Malcolm, Thank you for your advice!
> I changed my model as follows:
> poll_key = models.AutoField(primary_key=True, db_column='poll_key')
> However, the result remain the same as shown below. If you could point me out
> to right direction again, I would appreciate. Thank you very much for your
> time.
> 
 from mysite.polls.models import Poll2
 p3 = Poll2(poll2_question='3')
 p3.save()
 p3.pk
> 4L
 from mysite.polls.models import Poll
 p5 = Poll(poll_question='5')
 p5.save()
 print p5.pk
> None
> 
> 
> On 5/28/11 12:23 AM, "Malcolm Box"  wrote:
> 
>> You need to tell django what the db column name for your pollkey field is.
>> Look at the dbname field option in the docs.
>> 
>> 
>> Sent from my iPhone, please excuse any typos
>> 
>> On 28 May 2011, at 05:13, Naoko Reeves  wrote:
>> 
>>> I see if column is set to AutoField then Django won't send INSERT poll_key
>>> as null.
>>> Now my problem is that it doesn't return newly assigned primary key value
>>> for me if primary key name is _key instead of _id
>>> It looks as if sequence name is not understood correctly.
>>> Could you tell me if
>>> 1) I need to change sequence name to something else? Currently it is
>>> poll_key_seq
>>> 2) Is there a way to specify the sequence name?
>>> 
>>> 
>>> class Poll(models.Model):
>>>poll_key = models.AutoField(primary_key=True)
>>>poll_question = models.CharField(max_length=200, default='')
>>> 
>>> class Poll2(models.Model):
>>>poll2_id = models.AutoField(primary_key=True)
>>>poll2_question = models.CharField(max_length=200, default='')
>>> 
>> from mysite.polls.models import Poll2
>> p3 = Poll2(poll2_question='3')
>> p3.save()
>> p3.pk
>>> 2L
>> p4 = Poll2(poll2_question='4')
>> p4.save()
>> p4.pk
>>> 3L
>> from mysite.polls.models import Poll
>> p5 = Poll(poll_question='5')
>> p5.save()
>> print p5.pk
>>> None
>>> 
>>> 
>>> On 5/27/11 5:31 PM, "Casey Greene"  wrote:
>>> 
 Doesn't autofield with primary_key=True handle this for you (instead of
 making it an IntegerField):
 
 https://docs.djangoproject.com/en/1.3/ref/models/fields/#autofield
 
 Hope this helps!
 Casey
 
 On 05/27/2011 07:22 PM, Naoko Reeves wrote:
> Hi, I have a Django newbie question.
> My goal is to auto increment primary key with non Django standard column
> name.
> We are converting from existing database and primary key schema is
> "tablename_key" and not "id".
> I googled it and end up reaching to this ticket:
> https://code.djangoproject.com/ticket/13295
> So I understand that there is work in progress but I wanted find work
> around..
> 
> 1. My first try was to let postgres handle it.
> 
> my postgreSQL table looks like this:
> 
> CREATE TABLE poll
> (
>   poll_key integer NOT NULL DEFAULT nextval('poll_key_seq'::regclass),
>   poll_question character varying(200) NOT NULL,
>   poll_pub_date timestamp with time zone NOT NULL,
>   CONSTRAINT poll_pkey PRIMARY KEY (poll_key)
> )
> 
> My model look like this:
> class Poll(models.Model):
> poll_key = models.IntegerField(primary_key=True)
> poll_question = models.CharField(max_length=200, default='')
> poll_pub_date = models.DateTimeField('date published',
> default=datetime.date.today())
> class Meta:
> db_table = u'poll'
> 
> I was hoping that with this, I could
> p = Poll(poll_question="Question 1?")
> p.save()
> 
> but this fails because Django is actually sending the following statement:
> INSERT INTO "poll" ("poll_key", "poll_question", "poll_pub_date")
> VALUES (NULL, 'Question 1?', NULL)
> 
> 
> 2. My Second attempt is then to add default to model
> 
> Created a function to return sequence value
> from django.db import connection
> def c_get_next_key(seq_name):
> """ return next value of sequence """
> c = connection.cursor()
> c.execute("SELECT nextval('%s')" % seq_name)
> row = c.fetchone()
> return int(row[0])
> 
> Calling like below works just fine. Everytime I call it, I get new number.
> c_get_next_key('poll_key_seq')
> 
> Then I modify Poll_key in Poll model as follows:
> Poll_key = models.IntegerField(primary_key=True,
> default=c_get_next_key('poll_key_seq'))
> 
> I went to Django Shell and created first record.
> p1 = Poll(poll_question="P1")
> p1.poll_key
> # this will return let's say 37
> p1.save()
> # saves just fine.
> 
> # instantiating new object
> p2 = 

Odp: Re: signals pre_save vs model's save()

2011-05-29 Thread Mateusz Harasymczuk
W dniu niedziela, 29 maja 2011, 15:36:13 UTC+2 użytkownik Malcolm Box 
napisał:
>
> On 28 May 2011 11:05, Mateusz Harasymczuk  wrote:
>
>> I am thinking about splitting my model's save() method over few signals.
>>
>> For example, stripping spaces and making string capitalized.
>>
>>
> Why would you want to do that?
>

Because I am writing CRM, and my end users are non-technical ladies :}
And each one of them inputs data in different format (id numbers, phone 
numbers, dates, names [upper cased, capitalized, lower cased])
Therefore I have to normalize an input to store, and then print contract 
agreements in normalized way.
You may say normalize via template tags at rendering level.
Yes, but I use those data for example to calculate date ranges and text 
search.
If someone has an resignation addendum I have to make some other changes to 
model.
It is easier to normalize them in pre_save or at the save() method
 

>  
>
>> I have even more sophisticated problems such as making an object field 
>> active set to False basing on various parameters from other fields, such as 
>> expiration date, or good or bad karma points.
>>
>> What do you think, it is generally good idea, to keep models file clean 
>> out of heavily overloaded save() methods?
>>
>>
> If this logic is tied to your model, what is the advantage of moving it out 
> of the save() method in your model definition?  
> You would more usefully serve the same purpose by decomposing the save() 
> method into several functions e.g.:
>

my largest model is about 20 fields length.
where save methods are about at least 50 lines long.

it gives me a mess.

and then there are list_display functions (each is 1 to 3 lines long) which 
almost doubles fields length and gives me a 150-200 lines length model file, 
with only 20 fileds

and I have not included comments and docstrings...



> Clean, simple and makes it very obvious what you're doing in the save() 
> method. Compare that with the signals version, which will give someone 
> reading the code no clue at all that when they call save() the values of the 
> fields will change.
>

I can provide a comment in a model file, that normalize functions are stored 
in signals file.

 

> How about making more than one signal pre_save to the same model?
>>
>> It will work, but it's the wrong approach.
>

I am not saying this is a good approach,
I am thinking this might be a good solution in my case.

Looking forward to hearing some more opinions.
I might reconsider, if someone points me a better solution, than I am 
thinking of.


--
Matt Harasymczuk
http://www.matt.harasymczuk.pl

-- 
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: SystemError from django.conf.settings

2011-05-29 Thread А . Р .
2011/5/29 Cameron 

>
>from django.conf import settings
> SystemError: ../Objects/tupleobject.c:118: bad argument to internal
> function
>
>
Seems to me as a Python bug, not something wrong in Django, so upgrading to
newer Python version may 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.



Re: signals pre_save vs model's save()

2011-05-29 Thread Malcolm Box
On 28 May 2011 11:05, Mateusz Harasymczuk  wrote:

> I am thinking about splitting my model's save() method over few signals.
>
> For example, stripping spaces and making string capitalized.
>
>
Why would you want to do that?


> I have even more sophisticated problems such as making an object field
> active set to False basing on various parameters from other fields, such as
> expiration date, or good or bad karma points.
>
> What do you think, it is generally good idea, to keep models file clean out
> of heavily overloaded save() methods?
>
>
If this logic is tied to your model, what is the advantage of moving it out
of the save() method in your model definition?
You would more usefully serve the same purpose by decomposing the save()
method into several functions e.g.:

def save(self,...):
self._strip_chars()
self._validate_and_set_fields()
super(Model, self).save()

Clean, simple and makes it very obvious what you're doing in the save()
method. Compare that with the signals version, which will give someone
reading the code no clue at all that when they call save() the values of the
fields will change.

How about making more than one signal pre_save to the same model?
>
> It will work, but it's the wrong approach.

Malcolm

-- 
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: choice_set.all()

2011-05-29 Thread Malcolm Box
On 29 May 2011 06:20, bahare hoseini  wrote:

> hi there,
> i followed the structure in
> https://docs.djangoproject.com/en/dev/intro/tutorial01/  ,every thing was
> allright till i wrote the code: >>> "p.choice_set.all()" , then i got
> "AttributeError: 'function' object has no attribute choice_set" . :(
> can somone help?!
>

Psychic debugging: you previously typed:

p = Poll.objects.get
rather than
p = Poll.objects.get(pk=1)

If you did type the former, then p is a method reference and thus you would
get the error above.

Malcolm


>  --
> 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.
>



-- 
Malcolm Box
malcolm@gmail.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.



Unable to log into custom Admin Site

2011-05-29 Thread dfoerster
Hi,

in order to create a second admin site for a project, I created a new
app, instantiated AdminSite in the app's admin.py and hooked it into
the project's url configuration. The login page for the new admin site
is displayed when accessing the configured url, however I'm unable to
login. (Invalid credentials trigger an error message, with valid
credentials the login form is displayed again with no error message.)

Any help is appreciated. I attached some code snippets below.

Thanks,
David

Project's url.py:
urlpatterns = patterns('',
# ...
(r'^cockpit/', include(cockpit.urls)),
)

cockpit app's url.py:
from admin import cockpit

urlpatterns = patterns('',
(r'^$', include(cockpit.urls)),
)

admin.py in the cockpit app:
cockpit = AdminSite('cockpit')
cockpit.register(MyModel, MyModelAdmin)

-- 
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: Similar site for Django

2011-05-29 Thread Nikhil Somaru
https://docs.djangoproject.com/en/1.3/intro/tutorial01/
http://www.djangobook.com

On Sun, May 29, 2011 at 2:49 PM, kracekumar ramaraju <
kracethekingma...@gmail.com> wrote:

> I have been trying to learn django,I followed django documentation,books
> snippets.I was really impressed and clear explanation of the site regarding
> rails Check out this site about Rails 
> tutorial,i
> am looking forward for something similar for Django.
>
> --
> 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.
>



-- 
Yours,
Nikhil Somaru

-- 
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.



SystemError from django.conf.settings

2011-05-29 Thread Cameron
So I have this stack trace on my production server. I can't reproduce
it locally and it doesn't occur with an older version of the same site
deployed on the same server.

Traceback (most recent call last):
  File "./dependencies/django/core/handlers/wsgi.py", line 222, in
__call__
from django.conf import settings
SystemError: ../Objects/tupleobject.c:118: bad argument to internal
function

Some details:
 - nginx 0.8.54
 - uwsgi 0.9.7.2
 - django 1.3 (previous version which is working is 1.2.5)
 - python 2.5.2
 - debian 5.0.8

Since the older deployment which is running fine I have added some new
apps:
 - django.contrib.comments
 - south
 - cumulus
 - pagination
 - taggit
 - djangoratings
 - compressor

Plus added a few extra custom settings for the various apps. So on
with the questions:

1. Anyone seen this before? The only other reference that I can find
to that line of python is here (http://bugs.debian.org/cgi-bin/
bugreport.cgi?bug=581626)

2. Any tips on how I can find out what has changed to cause it? Aside
from rolling back through weeks of revisions to find what triggered
it.

3. I am about to try upgrading python to a newer version, is that
likely to make any difference? I have already tried 2 different
versions of uwsgi (0.9.6.8 and 0.9.7.2), but I don't want to mess
around with the production environment too much, or risk breaking the
live sites.

Cheers-

-- 
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.



Similar site for Django

2011-05-29 Thread kracekumar ramaraju
I have been trying to learn django,I followed django documentation,books 
snippets.I was really impressed and clear explanation of the site regarding 
rails Check out this site about Rails 
tutorial,i 
am looking forward for something similar for Django. 

-- 
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: Form and ForeignKey Limiting

2011-05-29 Thread Christoffer Viken
That worked, thanks a lot.

--Desktop Browser-
Christoffer Viken / CVi
i=0
str="kI4dJMtXAv0m3cUiPKx8H"
while i<=20:
    if i%3 and not i%4:
        print str[i],
    i=i+1



On Sun, May 29, 2011 at 10:30 AM, Ryan  wrote:
> You could always try this:
>
> class TaskForm(models.ModelForm):
>     class Meta:
>         model = Task
>
>     def __init__(self, queryset, *args, **kwargs):
>         super(TaskForm, self).__init__(*args, **kwargs)
>         self.fields['manager'].queryset = queryset
>
> and then just pass the required queryset when you create the form instance
> in your view.
>
> Ryan
>
> --
> 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 - UserProfile m2m field in admin - error

2011-05-29 Thread Ryan
I can confirm that I get the same error.  I wonder if it is anything to do 
with the two different forms auth uses for user creation and  change?

On a side note, how did you get your code so nicely formatted?

Ryan

-- 
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: Form and ForeignKey Limiting

2011-05-29 Thread Ryan
You could always try this:

class TaskForm(models.ModelForm):
class Meta:
model = Task

def __init__(self, queryset, *args, **kwargs):
super(TaskForm, self).__init__(*args, **kwargs)
self.fields['manager'].queryset = queryset

and then just pass the required queryset when you create the form instance 
in your view.

Ryan

-- 
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: Form and ForeignKey Limiting

2011-05-29 Thread Christoffer Viken
No no, I think you got it right in the first place.
manager is a configuration set on how to handle the task.
You can reuse a manager for more tasks but only your own managers
(whereas the restriction)
and every user have have multiple managers.

Where do i go looking for info on how to (non-hacky) change the queryset?

--Desktop Browser-
Christoffer Viken / CVi
i=0
str="kI4dJMtXAv0m3cUiPKx8H"
while i<=20:
    if i%3 and not i%4:
        print str[i],
    i=i+1

On Sun, May 29, 2011 at 10:08 AM, Ryan  wrote:
> Yes it is possible, but I think I may have misunderstood you at first.  All
> you want to do is to force the user who created the task to become its
> manager? If so you can do this very simply in the django admin using this
> code:
> https://docs.djangoproject.com/en/1.3/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_model.
> Just make sure you set editable=False in your model definition for manager
> in the Task model.
>
> Ryan
>
> --
> 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: custom User class

2011-05-29 Thread Ryan
If all you want to do is store additional information about your users, the 
recommended way to do this is to use a user profile: 
https://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users

Ryan

-- 
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: Form and ForeignKey Limiting

2011-05-29 Thread Ryan
Yes it is possible, but I think I may have misunderstood you at first.  All 
you want to do is to force the user who created the task to become its 
manager? If so you can do this very simply in the django admin using this 
code: 
https://docs.djangoproject.com/en/1.3/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_model.
  
Just make sure you set editable=False in your model definition for manager 
in the Task model.

Ryan

-- 
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: Form and ForeignKey Limiting

2011-05-29 Thread Christoffer Viken
Does Django let me do that?
I've looked everywhere in the documentation on how to do that.
Am i looking in the wrong places?

--Desktop Browser-
Christoffer Viken / CVi
i=0
str="kI4dJMtXAv0m3cUiPKx8H"
while i<=20:
    if i%3 and not i%4:
        print str[i],
    i=i+1



On Sun, May 29, 2011 at 9:29 AM, Ryan  wrote:
> Could you not change the queryset of the ModelChoiceField in the view? That
> way you will have access to the current user from request.user.
>
> --
> 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 dynamic form simple Example

2011-05-29 Thread Ryan
I do not know the details of implementing this, however I do know that the 
approach you are trying to take is incorrect.  It is not generally a good 
idea to dynamically change the definition of a form like that.  What I 
suggest is that you use 
formsetsto 
display multiple instances of the same form.  So for example, if you 
changed your form definition to:

class testform(forms.Form):
Q = forms.CharField()

You could then create a formset like so:

from django.forms.formsets import formset_factory
formset = formset_factory(testform, extra=2)

Once displayed in the template, this would show two instances of the form 
giving you the two fields you require.  You could then either change the 
extra attribute in the view if you know how many fields you require, or you 
could use the 
django-dynamic-formsetjQuery 
plugin in order to allow the user to add or remove more forms 
dynamically.

Hope this helps,

Ryan

-- 
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: markup

2011-05-29 Thread Praveen Krishna R
*I have used tiny_mce with django.
*
On Sat, May 28, 2011 at 3:34 PM, Vladimir  wrote:

> Has anyone any experience in CKeditor or tinymce using with django ?
>
> On 26 май, 20:25, Oscar Carballal  wrote:
> > 2011/5/26 Brett Parker :
> >
> > > On 26 May 08:27, Vladimir wrote:
> > >> Is there a tool to transform MS WORD file into HTML ? I know there is
> > >> markdown and textile, but I would prefer MS WORD.
> >
> > >http://wvware.sourceforge.net/
> >
> > > --
> > > Brett Parker
> >
> > Alsohttp://ginstrom.com/software/doc2html/
>
> --
> 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.
>
>


-- 
Thanks and Regards,
*Praveen Krishna R*

-- 
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: Auditing Record Changes in All Admin Tables

2011-05-29 Thread Ryan
This will show you how to achieve this in the django admin: 
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_model

-- 
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: Form and ForeignKey Limiting

2011-05-29 Thread Ryan
Could you not change the queryset of the ModelChoiceField in the view? That 
way you will have access to the current user from request.user.

-- 
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: choice_set.all()

2011-05-29 Thread Ryan
Can you post your model code please?

-- 
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: Reload a view pass X seconds

2011-05-29 Thread Praveen Krishna R
*This you could achieve with a javascript/jQuery snippet on the page.
*
On Sun, May 29, 2011 at 10:03 AM, javier  wrote:

> Hi,
>
> I'm developing a django project and I want to put a chronometer in one
> of my pages, so pass X seconds the view will be reload again.
>
> Can anyone help me?
>
> --
> 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.
>
>


-- 
Thanks and Regards,
*Praveen Krishna R*

-- 
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.



Reload a view pass X seconds

2011-05-29 Thread javier
Hi,

I'm developing a django project and I want to put a chronometer in one
of my pages, so pass X seconds the view will be reload again.

Can anyone help me?

-- 
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.