download more records

2013-02-12 Thread Vittorino Parenti
Hi,
by admin interface I have to download about 20,000 records using action and 
checkboxes.
The page times out. What other alternative could I use?
Thank you,
Vittorino

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




store admin selected action checkbox

2013-02-12 Thread Vittorino Parenti
Hi,
in Admin changelist I need to store selected action checkbox without lose 
selections between pages.
Selected checkboxes number could be of 1.000/10.000 selections.
Someone can give me some advice on how to proceed.
Thanks,
Vittorino  

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




Re: Django 1.5 AbstractBaseUser with char primary key not JSON serializable

2013-02-12 Thread Russell Keith-Magee
On Tue, Feb 12, 2013 at 9:03 PM, Kaloian  wrote:

> I am having the following custom user model trying to use the Django 1.5
> AbstractBaseUser:
>
> class Merchant(AbstractBaseUser):
> email = models.EmailField()
> company_name = models.CharField(max_length=256)
> website = models.URLField()
> description = models.TextField(blank=True)
> api_key = models.CharField(blank=True, max_length=256, primary_key=True)
>
> USERNAME_FIELD = 'email'
> REQUIRED_FIELDS = ['company_name','website']
>
>
>class Meta:
> verbose_name = _('Merchant')
> verbose_name_plural = _('Merchants')
>
>def __unicode__(self):
> return self.company_name
>
>
> The model works perfectly and database is as expected, but the problem is
> when I try to dumpdata to create fixtures for my tests.
>
> python manage.py dumpdata --natural --exclude=contenttypes 
> --exclude=auth.permission --indent=4 > fixtures/initial_data.json
>
>
> Then I get the error:
>
> CommandError: Unable to serialize database:  is not JSON 
> serializable
>
>
>
> Do you have ideas what could be the reason for this. Could it be the 
> charfield primary key or something with the abstractbaseuser model?
>
> It's not immediately clear. The use of natural keys could also be a
contributing factor here.

What you've described isn't a problem I've seen previously, so you should
open a ticket to track it. It would also be exceedingly helpful if you can
try running a few tests to remove possible causes - e.g.,

 * Does serialising *without* natural keys work?
 * Do you have any models with foreign keys to your custom user? (i.e., is
the problem manifesting when serialising Merchant, or serialising foreign
keys to Merchant?)
 * Do you still have problems if you use a 'normal' integer key?

Essentially, any help you can provide in narrowing down the exact cause
would be most helpful.

Also, if you can run the tests with --traceback, we can get the full error
logs.

As a side note -- if you're using email as your username field, you should
set it as unique=True -- USERNAME_FIELD needs to be unique or you'll
experience problems later on. This is something that should probably be
caught by validation - which is a bug deserving of it's own report. For
performance reasons, you also probably want to set it db_index=True, since
you're going to be searching on that field fairly often, so having an index
on it makes sense.

Yours,
Russ Magee %-)

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




Re: use app_label

2013-02-12 Thread Russell Keith-Magee
On Tue, Feb 12, 2013 at 10:52 AM, carlos  wrote:

> Hi I have an app called myapp within my models eg
>
> class Foo(models):
> fields1 = models(blabla)
> fields2 = models(blabla)
>
> class Meta:
> verbose_name = "Foo model"
> app_label = 'candy'
> db_table = 'myapp_foo'
>
> class Bar(models):
>fields1 = models(blabla)
> fields2 = models(blabla)
>
> class Meta:
> verbose_name = "Bar model"
> app_label = 'chocolate'
> db_table = 'myapp_bar'
>
> now I separate them for the admin i use app_label that this show
> separately and it works but as super user when i create group
> but do not see it does not appear
>

It's not entirely clear to me what you're doing, or what you're trying to
achieve. However, it appears you're using app_label to provide a custom app
for each of your models. That isn't what app_label is intended for. The
label you use in app_label must already exist as an app that has been added
to your INSTALLED_APPS list.

app_label is intended for use when you break a large models.py file into
smaller submodules; app_label provides a way to point to the name of the
module that contains the base models module.

It *isn't* a mechanism for describing the apps you want to appear in admin.
If you want a new app to appear in admin, you need to define a separate app
-- that means a separate directory, with a separate models.py file, listed
in your INSTALLED_APPS.

Yours,
Russ Magee %-)

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




Re: How to associate a formset with a field in a form

2013-02-12 Thread mmuk2
Thanks Sanjay, your tips were really helpful, and clears things up for me :)

cheers

On Wednesday, February 13, 2013 1:51:27 AM UTC+11, Sanjay Bhangar wrote:
>
> Hey, 
>
> I, too, initially found the formsets documentation a bit confusing, 
> but they're quite straightforward to work with once you figure them 
> out.. 
>
> Firstly, you probably want to use inlineformset_factory and not 
> formset_factory: 
>
> https://docs.djangoproject.com/en/dev/ref/forms/models/#django.forms.models.inlineformset_factory
>  
>
> With this, you would do something like: 
> ingredient_formset_factory = inlineformset_factory(Recipe, Ingredient, 
> form=IngredientForm) 
>
> Now you have your formset "factory" to be able to instantiate, either 
> an empty formset, with something like: 
> ingredient_formset = ingredient_formset_factory() 
>
> or with data with something like: 
> ingredient_formset = ingredient_formset_factory(request.POST) 
>
> then you can pass the ingredient_formset as context to your view and 
> render it in your html, inside your parent , probably after you 
> render your Recipe form, with something like {{ ingredient_formset }} 
> on your template .. as long as its within the  tag, the POST 
> data will be sent on form submit, and you can process it in your view. 
>
> Another thing you're probably going to want is the ability for your 
> users to Add additional forms on the page - there's a jquery plugin 
> for that: 
> http://blog.stanisla.us/2009/10/10/jquery-plugin-django-dynamic-formset/ 
>
> You should also probably read the documentation at 
>
> https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#inline-formsets
>  
> which covers these things better than my email :-) 
>
> All the best, 
> Sanjay 
>
>
> On Tue, Feb 12, 2013 at 10:28 AM, mmuk2  
> wrote: 
> > I'm trying to create a simple "recipe" form with a title and a list of 
> > ingredients, which allows a user to add additional ingredients to the 
> > recipe. 
> > 
> > I'm struggling, however, to implement this in Django. Particularly how 
> to 
> > associate a formset with a field in a form. I'm sure it's a simple 
> solution 
> > and one that's been done many times, but I must be missing something. 
> > 
> > I've got a model called Recipe that has a 1:n relationship with 
> Ingredient. 
> > That means, a Recipe can have many Ingredients, but an Ingredient can 
> only 
> > belong to 1 Recipe. 
> > 
> > models.py: 
> > 
> > class Recipe(models.Model): 
> > 
> > title = models.CharField(blank=True, null=True, max_length=100) 
> > 
> > 
> > class Ingredient(models.Model): 
> > 
> > title = models.CharField(blank=True, null=True, max_length=1000) 
> > recipe = models.ForeignKey(Recipe) 
> > 
> > The next step would be to set up model forms using the above 2 Models, 
> which 
> > I've done. 
> > 
> > forms.py: 
> > 
> > class IngredientForm(forms.ModelForm): 
> > class Meta: 
> > model = Ingredient 
> > 
> > class RecipeForm(forms.ModelForm): 
> > class Meta: 
> > model = Recipe 
> > 
> > I know I now need to use formset_factory in order to display a list of 
> > Ingredients. This is where I'm stuck. 
> > 
> > views.py 
> > 
> > from django.forms.formsets import formset_factory 
> > 
> > # This obviously just gives me a Recipe form 
> > recipe_form = RecipeForm(request.POST or None) 
> > 
> > # This gives me a list of Ingredient forms in a formset, which is what I 
> > want, but I would like it to be associated with a Recipe 
> > ingredient_formset = formset_factory(IngredientForm) 
> > 
> > The above 2 lines of code will give the IngredientForm and RecipeForm as 
> two 
> > separate forms that I can send to the template. However, there must be a 
> way 
> > to display the recipe_form so that it displays the ingredient_formset as 
> a 
> > "field" of a recipe_form. Subsequently, the user should be able to add 
> extra 
> > ingredients to the recipe. 
> > 
> > I've had a read of the django documentation and haven't been able to 
> come 
> > across anything there. Is there a particular section of the django docs 
> that 
> > I should be focusing my attention on to get me unstuck? Or is there 
> another 
> > way I should be approaching this? 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Django users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to django-users...@googlegroups.com . 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > Visit this group at http://groups.google.com/group/django-users?hl=en. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email 

Re: def __unicode__(self) in models.py is not working

2013-02-12 Thread Lachlan Musicman
On Wed, Feb 13, 2013 at 9:45 AM, David  wrote:

> I am working through the tutorial and find that the *def
> __unicode__(self):* command to give an object a readable name in admin is
> not working.  I am cutting code from the tutorial.  When I access the
> detail screen in /admin/ all I see is [table name] object and not the name
> I defined in def __unicode__(self): return: self.name
>
> I am working with the 1.6dev release in a 64bit Win7 environment.
>
> Is this a known issue with dev?  I have searched Django users without
> success.
>
>

Without seeing the code, it's hard to tell. If you could post the relevant
model.py code and the admin.py code (http://dpaste.org/ is your friend)

Does your model have a field called name?

Have you restarted the test or webserver since you added the change?

Cheers
L.






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



-- 
So the future isn't a boot stamping on a human face, forever. It's a person
in a beige business outfit advocating beige policies that nobody wants (but
nobody can quite articulate a coherent alternative to) with a false mandate
obtained by performing rituals of representative democracy that offer as
much actual choice as a Stalinist one-party state. And resistance is
futile, because if you succeed in overthrowing the beige dictatorship, you
will become that which you opposed.

http://www.antipope.org/charlie/blog-static/2013/02/political-failure-modes-and-th.html

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




def __unicode__(self) in models.py is not working

2013-02-12 Thread David
I am working through the tutorial and find that the *def 
__unicode__(self):*command to give an object a readable name in admin is not 
working.  I am 
cutting code from the tutorial.  When I access the detail screen in /admin/ 
all I see is [table name] object and not the name I defined in def 
__unicode__(self): return: self.name

I am working with the 1.6dev release in a 64bit Win7 environment.

Is this a known issue with dev?  I have searched Django users without 
success.

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




Re: One ->Many forms outside admin

2013-02-12 Thread alexandre...@gmail.com
thanks

Segunda-feira, 11 de Fevereiro de 2013 12:02:13 UTC, Jani Tiainen escreveu:
>
> 11.2.2013 13:38, alexan...@gmail.com  kirjoitti: 
> > I think taht is for editing a bunch of equal modelsat the same time... 
> > 
> > I need to edit a 1-many relationship in the same manner admin does. 
> > 
> > thanks 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Django users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> > an email to django-users...@googlegroups.com . 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > Visit this group at http://groups.google.com/group/django-users?hl=en. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>
> Inline formsets to be exact is something that you're looking for: 
>
>
> https://docs.djangoproject.com/en/1.4/topics/forms/modelforms/#inline-formsets
>  
>
> -- 
> Jani Tiainen 
>
> - Well planned is half done and a half done has been sufficient before... 
>

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




Re: Questions about vim

2013-02-12 Thread Antoni Aloy
I have created my own collection of plugins for my django and Python work
with vim: autocomplete, sysntax check, templates, etc. This is mine:
http://code.google.com/p/trespams-vim/ but there are others like
https://github.com/fisadev/fisa-vim-config or
http://sontek.net/blog/detail/turning-vim-into-a-modern-python-ide


2013/2/12 Yussi 

> On 12/02/13 14:52, Ryan Nowakowski wrote:
>
>> On Tue, Feb 12, 2013 at 11:22:54AM +, Yussi wrote:
>>
>>> Hi,
>>> I was wondering if there are any vim users here who managed to get a
>>> productive working environment for django here.
>>>
>>> I looked at the manuals, and set myself up with tags, omni complete,
>>> and syntax error check, but it's far from ideal. omni complete fails
>>> to guess the context correctly most of the time, and is otherwise
>>> lacking what I expect from an ide, namely I would like to be able to
>>> see function headers when typing so I know what arguments to give
>>> it,I would like some short cuts for local variables, I would like
>>> some easy vim templates for things like CharField, DateField etc, I
>>> am still new to django, and i really don't remember enough to free
>>> code everything.
>>>
>>> any other tip of using vim with django would be appreciated.
>>>
>>
>> I have vim configured with ctags and cscope.  Once I have that set up
>> correctly, I use ctags to jump from any use of CharField to the actual
>> Django source code for CharField.  That, of course, shows me the arguments
>> required and the docstring.
>>
>>
> Thanks, I actually had ctags, but rarely used it.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to 
> django-users+unsubscribe@**googlegroups.com
> .
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at 
> http://groups.google.com/**group/django-users?hl=en
> .
> For more options, visit 
> https://groups.google.com/**groups/opt_out
> .
>
>
>


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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




Re: Has the djangoproject.com site been down?

2013-02-12 Thread tOlorun
its just you ...
its loading here ...
Thanks
tOlorun

*Oluwanife@me*


To be filled with the life of Christ Jesus and released into our
destinies,taking
the world for Him.

| M: +2348121631706 | M: +234817907 | M: +23233487811
| E-mail: omnioto...@gmail.com I omnioto...@live.com |
omnioto...@yahoo.co.uk
| Skype: omniotosho


On Tue, Feb 12, 2013 at 5:40 PM, +Emmanuel  wrote:

> Is it just me or is djangoproject.com not loading? Been trying to access
> it for a couple of weeks without success. I've tried different browsers to
> no avail. Am accessing it from Africa.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: Has the djangoproject.com site been down?

2013-02-12 Thread frocco
It is working for me.

On Tuesday, February 12, 2013 11:40:17 AM UTC-5, +Emmanuel wrote:
>
> Is it just me or is djangoproject.com not loading? Been trying to access 
> it for a couple of weeks without success. I've tried different browsers to 
> no avail. Am accessing it from Africa.

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




Has the djangoproject.com site been down?

2013-02-12 Thread +Emmanuel
Is it just me or is djangoproject.com not loading? Been trying to access it 
for a couple of weeks without success. I've tried different browsers to no 
avail. Am accessing it from Africa.

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




Re: How to concatenate a list of Q objects?

2013-02-12 Thread Andreas Karlsson
Even better:
from operator import __or__
reduce(__or__, filters)

Den onsdagen den 7:e april 2010 kl. 20:56:47 UTC+2 skrev Daniel:
>
> Thanks alot guys.  If I can be honest, I'm having a little trouble
> digesting just this one line:
>
> q = q | f if q else f
>
> That line of code only allows (q1 | q2 | q3), right?
>
> It will not allow mixing "AND" as well as "OR" (i.e., q1 & q2 | q3)?
>
> Thanks!
>
> On Apr 7, 1:26 pm, Vinicius Mendes  wrote:
> > On Wed, Apr 7, 2010 at 2:00 PM, Tom Evans  
> wrote:
> > > On Wed, Apr 7, 2010 at 5:39 PM, Daniel  wrote:
> > > > Hi,
> >
> > > > Thank you for your help everyone.  I know that I need to learn python
> > > > better, and I did read those articles.  What is still a bit unclear 
> to
> > > > me, though, is how could I add an "OR" or "AND" separator between Q
> > > > objects?
> >
> > > > So I have a list of qobjects like [qObj1, qObj2, qObj3].
> >
> > > > What I want is something like Sample.objects.filter((qObj1 | qObj2),
> > > > qObj3)
> >
> > > > I know that the default is for all Q objects to be "ANDed" together.
> > > > I think the join operation is not going to work here, nor is
> > > > concatenation, but is there something obvious that I'm missing?
> >
> > > > THANK YOU :>
> >
> > > Documentation on how to combine Q objects:
> >
> > >http://docs.djangoproject.com/en/1.1/topics/db/queries/#complex-looku.
> ..
> >
> > > So you want to loop through them, and 'or' them together..
> >
> > > filters = [ q1, q2, q3, q4, q5 ]
> > > q = None
> > > for f in filters:
> > >  q = q | f if q else f
> > > Foo.objects.filter(q)
> >
> > Refining a little:
> >
> > filters = [q1,q2,q3,q4,q5]
> > q = Q()
> > for f in filters:
> > q |= f
> > Foo.objects.filter(q)
> >
> > Q() is identity for & and |.
> >
> > > 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...@googlegroups.com
> .
> > > To unsubscribe from this group, send email to
> > > django-users...@googlegroups.com <
> django-users%2bunsubscr...@googlegroups.com >
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
> >
> > __
> > Vinícius Mendes
> > Solucione Sistemashttp://solucione.info/
>
>

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




Re: Questions about vim

2013-02-12 Thread Yussi

On 12/02/13 14:52, Ryan Nowakowski wrote:

On Tue, Feb 12, 2013 at 11:22:54AM +, Yussi wrote:

Hi,
I was wondering if there are any vim users here who managed to get a
productive working environment for django here.

I looked at the manuals, and set myself up with tags, omni complete,
and syntax error check, but it's far from ideal. omni complete fails
to guess the context correctly most of the time, and is otherwise
lacking what I expect from an ide, namely I would like to be able to
see function headers when typing so I know what arguments to give
it,I would like some short cuts for local variables, I would like
some easy vim templates for things like CharField, DateField etc, I
am still new to django, and i really don't remember enough to free
code everything.

any other tip of using vim with django would be appreciated.


I have vim configured with ctags and cscope.  Once I have that set up
correctly, I use ctags to jump from any use of CharField to the actual
Django source code for CharField.  That, of course, shows me the arguments
required and the docstring.



Thanks, I actually had ctags, but rarely used it.

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




Re: How do I redirect a logged in customer to https page?

2013-02-12 Thread Bill Freeman
Let me rephrase the issues so that you can tell me if I understand
correctly.

There is information which should not be shown to anonymous (not logged in)
users.  You desire to always use SSL/TLS (https) when showing such
information to logged in users.  Once a user has logged in then virtually
all pages contain such information.  You are concerned that a logged in
user may perform an access where he has manually modified the https to be
http, or, more likely, has used a book mark, or has refreshed another tab
or window of the same browser which was originally loaded before the user
logged in.  In this case, since all of these windows/tabs will share the
same session cookie, request.user.is_authenticated() will be true (thought
request.is_secure() will be False), and secure information will be shown
over an insecure channel.

The simplest answer is to require all accesses (with the possible exception
of favicon.ico and robots.txt) be made by way of https.  This is easily
done in apache using mod_rewrite.  The directives applying to port 80 and
tose to port 443 are easily separated, and all (or nearly all) requests
arriving on port 80 can be redirected to the same path but using https.

But if you must display certain pages via http to anonymous users, you can
use the combination request.user.is_authenticated() and not
request.is_secure() to trigger a redirect in Django, probably from request
middleware.  Make sure that you are using a new enough Django the
request.is_secure() with apache mod_wsgi is reliable (the last bug I know
about was fixed in 2007  -- just be sure to test it with your
apache/mod_wsgi configuration)

More exotic, since mod_rewrite can't tell from the session cookie whether
the user is logged in, would be to add a cookie indicating whether the user
is logged in (probably in response middleware), which mod_write can use in
a condition to force the redirect.  The truly malicious can modify their
cookies, so I would back stop this with the request middlware solution of
the previous paragraph, but when mod_rewrite manages to do the redirect it
will have a smaller performance impact (no setting up of the Django request
object, looking up the session key, etc.).

Bill

On Tue, Feb 12, 2013 at 2:16 AM, Alagappan  wrote:

> Hi,
>
> In my website, I have a few http pages and a few https pages.
>
> The session cookie has been made secure=True and once a customer logs in
> to the site, we keep all pages as https.
>
> But if the customer manually changes the URL to http, Django's
> user.is_authenticated method returns False and hence is shown some content
> that is to be shown for an anonymous user.
>
> Is there a way I can redirect logged in customers to https pages even if
> he/she manually changes the URL. This can either be at the project level or
> in server level.
>
> I am using Apache/mod_wsgi to run my website.
>
> I hope I have worded my query in a clear manner. Please let me know if I
> need to provide further details.
>
> Thanks,
> Alagappan
>
>
>
> --
> Thanks & Regards,
> Alagappan Ramu
> +91 9840 143 620
>
> http://about.me/alagappanr
>
> NIT Trichy  | Global Analytics India Pvt 
> Ltd
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: Django makemessages is marking translated strings as fuzzy

2013-02-12 Thread Ramiro Morales
On Tue, Feb 12, 2013 at 10:08 AM, Mohammad Abbas
 wrote:
> I am having issues with the Django makemessages management command. It seems
> like it is randomly marking messages as fuzzy even though they have already
> been translated. For example
>
> #: templates/profile/edit.html:21
> msgid "Save Changes"
> msgstr "Save Changes DE"
>
> Would become...
>
> #: templates/profile/edit.html:21
> #, fuzzy,
> msgid "Save Changes"
> msgstr "Save Changes DE"
>
> The behaviour is very intermittent and hard to recreate, so debugging hasn't
> been straightforward.
>
> Does anyone have any ideas?

OOps, that'svery strange and awkward. Tools shoudn't be automatically
changing content nor properties of translations written by a human translator.

Unfortunately I have no idea what could be happening.

Please tell us which version of Django, GNU gettext tools and OS you are using.
and keep us posted about if/how you manage to reproduce this.

Have you been able to identify if it happens with literals extracted from
(only, any, all of) Python files?, JS files?, template files?

One hypothesis: Is it possible "Save Changes" also appears as the
singular literal of a singular/plural construct (ungettext() calls or
{% blocktrans %}...{% plural %}...{% endblocktrans %} tags)?

-- 
Ramiro Morales
@ramiromorales

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




Re: Questions about vim

2013-02-12 Thread Ryan Nowakowski
On Tue, Feb 12, 2013 at 11:22:54AM +, Yussi wrote:
> Hi,
> I was wondering if there are any vim users here who managed to get a
> productive working environment for django here.
> 
> I looked at the manuals, and set myself up with tags, omni complete,
> and syntax error check, but it's far from ideal. omni complete fails
> to guess the context correctly most of the time, and is otherwise
> lacking what I expect from an ide, namely I would like to be able to
> see function headers when typing so I know what arguments to give
> it,I would like some short cuts for local variables, I would like
> some easy vim templates for things like CharField, DateField etc, I
> am still new to django, and i really don't remember enough to free
> code everything.
> 
> any other tip of using vim with django would be appreciated.

I have vim configured with ctags and cscope.  Once I have that set up
correctly, I use ctags to jump from any use of CharField to the actual
Django source code for CharField.  That, of course, shows me the arguments
required and the docstring.

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




Re: How to associate a formset with a field in a form

2013-02-12 Thread Sanjay Bhangar
Hey,

I, too, initially found the formsets documentation a bit confusing,
but they're quite straightforward to work with once you figure them
out..

Firstly, you probably want to use inlineformset_factory and not
formset_factory:
https://docs.djangoproject.com/en/dev/ref/forms/models/#django.forms.models.inlineformset_factory

With this, you would do something like:
ingredient_formset_factory = inlineformset_factory(Recipe, Ingredient,
form=IngredientForm)

Now you have your formset "factory" to be able to instantiate, either
an empty formset, with something like:
ingredient_formset = ingredient_formset_factory()

or with data with something like:
ingredient_formset = ingredient_formset_factory(request.POST)

then you can pass the ingredient_formset as context to your view and
render it in your html, inside your parent , probably after you
render your Recipe form, with something like {{ ingredient_formset }}
on your template .. as long as its within the  tag, the POST
data will be sent on form submit, and you can process it in your view.

Another thing you're probably going to want is the ability for your
users to Add additional forms on the page - there's a jquery plugin
for that: 
http://blog.stanisla.us/2009/10/10/jquery-plugin-django-dynamic-formset/

You should also probably read the documentation at
https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#inline-formsets
which covers these things better than my email :-)

All the best,
Sanjay


On Tue, Feb 12, 2013 at 10:28 AM, mmuk2  wrote:
> I'm trying to create a simple "recipe" form with a title and a list of
> ingredients, which allows a user to add additional ingredients to the
> recipe.
>
> I'm struggling, however, to implement this in Django. Particularly how to
> associate a formset with a field in a form. I'm sure it's a simple solution
> and one that's been done many times, but I must be missing something.
>
> I've got a model called Recipe that has a 1:n relationship with Ingredient.
> That means, a Recipe can have many Ingredients, but an Ingredient can only
> belong to 1 Recipe.
>
> models.py:
>
> class Recipe(models.Model):
>
> title = models.CharField(blank=True, null=True, max_length=100)
>
>
> class Ingredient(models.Model):
>
> title = models.CharField(blank=True, null=True, max_length=1000)
> recipe = models.ForeignKey(Recipe)
>
> The next step would be to set up model forms using the above 2 Models, which
> I've done.
>
> forms.py:
>
> class IngredientForm(forms.ModelForm):
> class Meta:
> model = Ingredient
>
> class RecipeForm(forms.ModelForm):
> class Meta:
> model = Recipe
>
> I know I now need to use formset_factory in order to display a list of
> Ingredients. This is where I'm stuck.
>
> views.py
>
> from django.forms.formsets import formset_factory
>
> # This obviously just gives me a Recipe form
> recipe_form = RecipeForm(request.POST or None)
>
> # This gives me a list of Ingredient forms in a formset, which is what I
> want, but I would like it to be associated with a Recipe
> ingredient_formset = formset_factory(IngredientForm)
>
> The above 2 lines of code will give the IngredientForm and RecipeForm as two
> separate forms that I can send to the template. However, there must be a way
> to display the recipe_form so that it displays the ingredient_formset as a
> "field" of a recipe_form. Subsequently, the user should be able to add extra
> ingredients to the recipe.
>
> I've had a read of the django documentation and haven't been able to come
> across anything there. Is there a particular section of the django docs that
> I should be focusing my attention on to get me unstuck? Or is there another
> way I should be approaching this?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

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




Re: Updated Django by Example tutorials

2013-02-12 Thread Vijaya Reddy
Thank you so much

On Monday, February 11, 2013 8:24:57 PM UTC-8, Rainy wrote:
>
> Hi, I've started updating Django by Example tutorials for django version 
> 1.5 and using class-based views.
> I have posted 3 tutorials so far; 3 more will be added soon:
>
> http://lightbird.net/dbe2/
>
> I hope these will prove to be useful.. please let me know of any issues / 
> ways to improve the guide.
>
>  - rainy
>

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




Re: Updated Django by Example tutorials

2013-02-12 Thread frocco
Thank you

On Monday, February 11, 2013 11:24:57 PM UTC-5, Rainy wrote:
>
> Hi, I've started updating Django by Example tutorials for django version 
> 1.5 and using class-based views.
> I have posted 3 tutorials so far; 3 more will be added soon:
>
> http://lightbird.net/dbe2/
>
> I hope these will prove to be useful.. please let me know of any issues / 
> ways to improve the guide.
>
>  - rainy
>

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




Re: E-commerce framework for downloadable content

2013-02-12 Thread Carlos Edo Méndez
Thank you both for your help.

I found Django-Oscar, what do you think of it? Would it be good for a start?

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




Re: chained selectboxes with simpleJson call

2013-02-12 Thread vijay shanker
well override ModelForm's __init__ and if theres a kwargs , then populate 
choices depending upon the value of model_name , as well override def 
clean() to handle model attribute.

class ConditionSetAdminForm(forms.ModelForm):
def __init__(self,*args,**kwargs):
super(ConditionSetAdminForm, self).__init__(*args,**kwargs)
try:
model_name = kwargs['instance'].model_name
app_label,model_class = 
model_name.split('.')[0],model_name.split('.')[1] 
model_class = get_model(app_label=app_label, 
model_name=model_class)
self.fields['model_attribute']  = 
forms.ChoiceField(required=True, label='Model Attribute', choices= 
[(each.name,each.name) for each in model_class._meta.fields])
except:
self.fields['model_attribute']  = 
forms.ChoiceField(required=True, label='Model Attribute', 
choices=get_attributes())
self.fields['model_name']   = forms.ChoiceField(required=True, 
label='Model Name', choices=get_all_models())
class Meta: 
model = ConditionSet
def clean(self):
super(ConditionSetAdminForm,self).clean()
if 'model_attribute' in self._errors:
self.cleaned_data['model_attribute'] = 
self.data['model_attribute']
del self._errors['model_attribute']
return self.cleaned_data

just like that ;)

On Tuesday, February 12, 2013 5:09:51 PM UTC+5:30, vijay shanker wrote:
>
> hey all
>
> I have a model which is as such:
> *in models.py*
>
> class ConditionSet(models.Model):
> model_name  =models.CharField(max_length=
> 50) 
> model_attribute  =models.CharField(max_length=50)
> operator =models.CharField(max_length=50, 
> choices=OPERATORS)
> val=
> models.CharField(max_length=50,null=True,blank=True)
> evaluation  =models.NullBooleanField(null=True, blank=True)
> def __str__(self):
> return self.model_attribute
>
> *in admin.py :*
>
> def get_all_models():
> return [('.'.join([each._meta.app_label,each.__name__]),each.__name__) 
> for each in [each.model_class() for each in 
> ContentType.objects.filter(app_label__in=['products','productoptions','shoppingcart'])
>  
> if each is not None] if each is not None]
>
> def get_attributes():
> model_class = 
> ContentType.objects.filter(app_label__in=['products','productoptions','shoppingcart'])[0].model_class()
> return [ (each.name,each.name) for each in model_class._meta.fields ]
>
> class ConditionSetAdminForm(forms.ModelForm):
> def __init__(self,*args,**kwargs):
> super(ConditionSetAdminForm, self).__init__(*args,**kwargs)
> self.fields['model_name']   = forms.ChoiceField(required=True, 
> label='Model Name', choices=get_all_models())
> self.fields['model_attribute']  = forms.ChoiceField(required=True, 
> label='Model Attribute', choices=get_attributes())
> class Meta: 
> model = ConditionSet
>
> class ConditionSetAdmin(admin.ModelAdmin):
> form = ConditionSetAdminForm
>
> admin.site.register(ConditionSet, ConditionSetAdmin )
>
> model_attribute has an initial set of choices, populated by 
> get_attributes().
> When a user selects model_name in admin, i make a json call to get options 
> and populate model_attribute options , but when i try to save it, i get  
> "select a valid choice. xyz_attribute_name is not one of the available 
> choices."
> I understand the problem is the choices for this field are still the one 
> assigned to it in beginning, how should I fix it ?
>
>

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




Django makemessages is marking translated strings as fuzzy

2013-02-12 Thread Mohammad Abbas
I am having issues with the Django makemessages management command. It 
seems like it is randomly marking messages as fuzzy even though they have 
already been translated. For example

#: templates/profile/edit.html:21
msgid "Save Changes"
msgstr "Save Changes DE"

Would become...

#: templates/profile/edit.html:21
#, fuzzy,
msgid "Save Changes"
msgstr "Save Changes DE"

The behaviour is very intermittent and hard to recreate, so debugging 
hasn't been straightforward.

Does anyone have any ideas?

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




How to associate a formset with a field in a form

2013-02-12 Thread mmuk2
I'm trying to create a simple "recipe" form with a title and a list of 
ingredients, which allows a user to add additional ingredients to the 
recipe.

I'm struggling, however, to implement this in Django. Particularly how to 
associate a formset with a field in a form. I'm sure it's a simple solution 
and one that's been done many times, but I must be missing something.

I've got a model called Recipe that has a 1:n relationship with Ingredient. 
That means, a Recipe can have many Ingredients, but an Ingredient can only 
belong to 1 Recipe.

*models.py:*

class Recipe(models.Model):

title = models.CharField(blank=True, null=True, max_length=100)


class Ingredient(models.Model):

title = models.CharField(blank=True, null=True, max_length=1000)
recipe = models.ForeignKey(Recipe)

The next step would be to set up model forms using the above 2 Models, 
which I've done.

*forms.py:
*
class IngredientForm(forms.ModelForm):
class Meta:
model = Ingredient

class RecipeForm(forms.ModelForm):
class Meta:
model = Recipe

I know I now need to use formset_factory in order to display a list of 
Ingredients. This is where I'm stuck.

*views.py*

from django.forms.formsets import formset_factory

# This obviously just gives me a Recipe form
recipe_form = RecipeForm(request.POST or None)

# This gives me a list of Ingredient forms in a formset, which is what I 
want, but I would like it to be associated with a Recipe
ingredient_formset = formset_factory(IngredientForm)

The above 2 lines of code will give the IngredientForm and RecipeForm as 
two separate forms that I can send to the template. However, there must be 
a way to display the recipe_form so that it displays the ingredient_formset 
as a "field" of a recipe_form. Subsequently, the user should be able to add 
extra ingredients to the recipe.

I've had a read of the django documentation and haven't been able to come 
across anything there. Is there a particular section of the django docs 
that I should be focusing my attention on to get me unstuck? Or is there 
another way I should be approaching this?

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




Django 1.5 AbstractBaseUser with char primary key not JSON serializable

2013-02-12 Thread Kaloian


I am having the following custom user model trying to use the Django 1.5 
AbstractBaseUser:

class Merchant(AbstractBaseUser): 
email = models.EmailField()
company_name = models.CharField(max_length=256)
website = models.URLField()
description = models.TextField(blank=True)
api_key = models.CharField(blank=True, max_length=256, primary_key=True)   

USERNAME_FIELD = 'email' 
REQUIRED_FIELDS = ['company_name','website']


   class Meta:
verbose_name = _('Merchant')
verbose_name_plural = _('Merchants')

   def __unicode__(self):
return self.company_name 


The model works perfectly and database is as expected, but the problem is 
when I try to dumpdata to create fixtures for my tests. 

python manage.py dumpdata --natural --exclude=contenttypes 
--exclude=auth.permission --indent=4 > fixtures/initial_data.json


Then I get the error:

CommandError: Unable to serialize database:  is not JSON 
serializable



Do you have ideas what could be the reason for this. Could it be the charfield 
primary key or something with the abstractbaseuser model?
  
Thanks

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




chained selectboxes with simpleJson call

2013-02-12 Thread vijay shanker
hey all

I have a model which is as such:
*in models.py*

class ConditionSet(models.Model):
model_name  =models.CharField(max_length=
50) 
model_attribute  =models.CharField(max_length=50)
operator =models.CharField(max_length=50, 
choices=OPERATORS)
val=
models.CharField(max_length=50,null=True,blank=True)
evaluation  =models.NullBooleanField(null=True, blank=True)
def __str__(self):
return self.model_attribute

*in admin.py :*

def get_all_models():
return [('.'.join([each._meta.app_label,each.__name__]),each.__name__) 
for each in [each.model_class() for each in 
ContentType.objects.filter(app_label__in=['products','productoptions','shoppingcart'])
 
if each is not None] if each is not None]

def get_attributes():
model_class = 
ContentType.objects.filter(app_label__in=['products','productoptions','shoppingcart'])[0].model_class()
return [ (each.name,each.name) for each in model_class._meta.fields ]

class ConditionSetAdminForm(forms.ModelForm):
def __init__(self,*args,**kwargs):
super(ConditionSetAdminForm, self).__init__(*args,**kwargs)
self.fields['model_name']   = forms.ChoiceField(required=True, 
label='Model Name', choices=get_all_models())
self.fields['model_attribute']  = forms.ChoiceField(required=True, 
label='Model Attribute', choices=get_attributes())
class Meta: 
model = ConditionSet

class ConditionSetAdmin(admin.ModelAdmin):
form = ConditionSetAdminForm

admin.site.register(ConditionSet, ConditionSetAdmin )

model_attribute has an initial set of choices, populated by 
get_attributes().
When a user selects model_name in admin, i make a json call to get options 
and populate model_attribute options , but when i try to save it, i get  
"select a valid choice. xyz_attribute_name is not one of the available 
choices."
I understand the problem is the choices for this field are still the one 
assigned to it in beginning, how should I fix it ?

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




Chained Select Boxes using SimpleJson Call

2013-02-12 Thread vijay shanker
hey all

I have a model which is as such:

*in models.py*

class ConditionSet(models.Model):
model_name  =models.CharField(max_length=50) 
model_attribute  =models.CharField(max_length=50)
operator =models.CharField(max_length=50, 
choices=OPERATORS)
val=
models.CharField(max_length=50,null=True,blank=True)
evaluation  =models.NullBooleanField(null=True, blank=True)
def __str__(self):
return self.model_attribute

*in admin.py :*
def get_all_models():
return [('.'.join([each._meta.app_label,each.__name__]),each.__name__) 
for each in [each.model_class() for each in 
ContentType.objects.filter(app_label__in=['products','productoptions','shoppingcart'])
 
if each is not None] if each is not None]

def get_attributes():
model_class = 
ContentType.objects.filter(app_label__in=['products','productoptions','shoppingcart'])[0].model_class()
return [ (each.name,each.name) for each in model_class._meta.fields ]

class ConditionSetAdminForm(forms.ModelForm):
def __init__(self,*args,**kwargs):
super(ConditionSetAdminForm, self).__init__(*args,**kwargs)
self.fields['model_name']   = forms.ChoiceField(required=True, 
label='Model Name', choices=get_all_models())
self.fields['model_attribute']  = forms.ChoiceField(required=True, 
label='Model Attribute', choices=get_attributes())
class Meta: 
model = ConditionSet

class ConditionSetAdmin(admin.ModelAdmin):
form = ConditionSetAdminForm

admin.site.register(ConditionSet, ConditionSetAdmin )

When model_attribute has an initial set of choices, populated by 
get_attributes().
When a user selects model_name in admin, i make a json call to get options 
and populate them, but i get  "select a valid choice. xyz_attribute_name is 
not one of the available choices."
I understand the problem is the choices for this field are still the one 
assigned to it in beginning, how should I fix it ?








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




Questions about vim

2013-02-12 Thread Yussi

Hi,
I was wondering if there are any vim users here who managed to get a 
productive working environment for django here.


I looked at the manuals, and set myself up with tags, omni complete, and 
syntax error check, but it's far from ideal. omni complete fails to 
guess the context correctly most of the time, and is otherwise lacking 
what I expect from an ide, namely I would like to be able to see 
function headers when typing so I know what arguments to give it,I would 
like some short cuts for local variables, I would like some easy vim 
templates for things like CharField, DateField etc, I am still new to 
django, and i really don't remember enough to free code everything.


any other tip of using vim with django would be appreciated.

thanks,
Yussi

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




Re: Modelform and Ajax (Select a valid choice..... Error)

2013-02-12 Thread vijay shanker
hey siddhartha i have similar problem, i created dynamic option with ajax 
calls and getting the same error
"select a valid choice. xyz is not available choices , how did you solved 
it?"

On Tuesday, December 11, 2012 5:09:48 PM UTC+5:30, siddharth56660 wrote:
>
> Hi, 
>
> I am facing problem in handling modelform and ajax together. 
> The situation is:- 
> I am using modelform to get display the form as ul in the template. 
> I have 3 ChoiceFields (country, state,city). On select of a country 
> from the dropdown, the valid states dropdown gets populated and on 
> select of a state the respective city dropdown gets populated. 
> For achieving the above functionality I am calling an ajax function 
> which returns me the available data of the other dropdown in Json Form 
> {stat_id, stat_name} 
> I am able to populate the data in next dropdown i.e state and city, 
> but when i click submit form it shows "Select a valid choice. 8 is not 
> one of the available choices" 
> 8 happens to be the stat_id in this case. 
> I have gone through google but dint find anything useful. Help is 
> really appreciated. 
>

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