Re: Initial data doesn't go complelely in the modelformset

2021-06-13 Thread VISHESH MANGLA
In line 58 you can see me adding "print_report_check":True, my form class PrintReportModelForm(ModelForm): print_report_check = forms.BooleanField(widget=forms.CheckboxInput(), required=False) class Meta: fields = ["PAN_ID", "print_report_check"] model = User

Re: Initial data, tests and migrations

2017-02-22 Thread Tim Graham
I'm not trying to be antagonistic, sorry if I came off that way. I wanted to point out the difficulties that Django encountered trying to provide "integration" tests like django-otp does. As others suggested, if django-otp provided tools to build your own integration tests, that might be a bett

Re: Initial data, tests and migrations

2017-02-22 Thread Melvyn Sopacua
On Wednesday 22 February 2017 15:13:47 'Tom Evans' via Django users wrote: > These tests exercise parts of django_otp that interact with parts of > my code. Successful tests indicate that those two parts interoperate > correctly. The tests are successful when run individually, but fail > when run

Re: Initial data, tests and migrations

2017-02-22 Thread Adam Stein
On Wed, 2017-02-22 at 15:06 +, 'Tom Evans' via Django users wrote: > On Wed, Feb 22, 2017 at 2:41 PM, Adam Stein wrote: > > > > On Wed, 2017-02-22 at 14:22 +, 'Tom Evans' via Django users > > wrote: > > > > The URL you refer to mentions about loading data for apps. Doesn't > > mention >

Re: Initial data, tests and migrations

2017-02-22 Thread Melvyn Sopacua
On Wednesday 22 February 2017 14:22:36 'Tom Evans' via Django users wrote: > On Wed, Feb 22, 2017 at 12:47 AM, Melvyn Sopacua wrote: > > On Tuesday 21 February 2017 19:00:42 'Tom Evans' via Django users wrote: > >> What is the "correct" way of ensuring that these instances exist in > >> > >> th

Re: Initial data, tests and migrations

2017-02-22 Thread 'Tom Evans' via Django users
On Wed, Feb 22, 2017 at 2:40 PM, Tim Graham wrote: > I'm curious if you feel that running django_otp's tests as part of your > project's tests is adding value. I'm curious whether you think I commonly spend my time doing things that I don't think add value... django_otp is simply an example of t

Re: Initial data, tests and migrations

2017-02-22 Thread 'Tom Evans' via Django users
On Wed, Feb 22, 2017 at 2:41 PM, Adam Stein wrote: > On Wed, 2017-02-22 at 14:22 +, 'Tom Evans' via Django users wrote: > > The URL you refer to mentions about loading data for apps. Doesn't mention > anything in regards to tests. Why are fixtures bad for tests? In fact, right > above the "Pro

Re: Initial data, tests and migrations

2017-02-22 Thread Tim Graham
I'm curious if you feel that running django_otp's tests as part of your project's tests is adding value. All third-party apps that I've used (including tests for django.contrib apps*) have moved their tests to a separate directory so that they're not installed along with the application. It's q

Re: Initial data, tests and migrations

2017-02-22 Thread Adam Stein
On Wed, 2017-02-22 at 14:22 +, 'Tom Evans' via Django users wrote: > On Wed, Feb 22, 2017 at 12:47 AM, Melvyn Sopacua > om> wrote: > > > > On Tuesday 21 February 2017 19:00:42 'Tom Evans' via Django users > > wrote: > > > > > > > > > > > > Previously, these instances were loaded from a JS

Re: Initial data, tests and migrations

2017-02-22 Thread 'Tom Evans' via Django users
On Wed, Feb 22, 2017 at 12:47 AM, Melvyn Sopacua wrote: > On Tuesday 21 February 2017 19:00:42 'Tom Evans' via Django users wrote: > > > >> Previously, these instances were loaded from a JSON fixtures file, > > > > And you can still do that. > > > >> which used to be the recommended way. For our o

Re: Initial data, tests and migrations

2017-02-21 Thread Melvyn Sopacua
On Tuesday 21 February 2017 19:00:42 'Tom Evans' via Django users wrote: > Previously, these instances were loaded from a JSON fixtures file, And you can still do that. > which used to be the recommended way. For our own tests, we simply > load these fixtures in the setUp portion of the test; ob

Re: Initial data with migrations vs fixtures

2016-12-01 Thread Tim Graham
Calling loaddata in a migration will work until you modify the model's fields. You can read more on Trac: https://code.djangoproject.com/ticket/24778 On Thursday, December 1, 2016 at 12:09:49 PM UTC-5, Tom Evans wrote: > > Hi all > > We're moving a project over to the latest release (well, we'r

Re: Initial data for dynamic field

2011-12-23 Thread Martin Tiršel
On Fri, 23 Dec 2011 09:42:37 +0100, Mengu wrote: you need to set "initial" attribute of TypedChoiceField. Thanks, I knew about the initial only on form instance and not on field :) On Dec 23, 10:34 am, Martin Tiršel wrote: Hello, I have: class SomeForm(forms.Form): ... def __

Re: Initial data for dynamic field

2011-12-23 Thread Mengu
you need to set "initial" attribute of TypedChoiceField. On Dec 23, 10:34 am, Martin Tiršel wrote: > Hello, > > I have: > > class SomeForm(forms.Form): >      ... > >      def __init__(self, *args, **kwargs): >          ... >          super(SomeForm, self).__init__(*args, **kwargs) >          ...

Re: initial data to Formset causing problem

2011-11-10 Thread Bill Freeman
Have you called form.is_valid() somewhere that you're not showing? On Wed, Nov 9, 2011 at 7:15 AM, Asif Jamadar wrote: > I’m assigning initial data to the field of each formset dynamically. But > when I’m trying to save that initial data it’s throwing “Key Error” in > cleaned data. Any solution?

Re: Initial data for ManyToMany field

2011-09-16 Thread Danfi
this initial can be a queryset or a list, but the list must use its primary key like sform = SymptomeForm(initial={'parent':[1,2]}) On 9月7日, 上午4时30分, Thomas49 wrote: > Hello, > > I have two models, and the second contains a ManyToMany relationship: > > class TypeMedical(models.Model): >... >

Re: Initial data for ManyToMany field

2011-09-06 Thread Tomas Neme
> Look into formsets. It's what the admin inlines use. that is class TypeMedicalForm(forms.ModelForm): class Meta: model = TypeMedical TypeMedicalFormSet=formset_factory(TypeMedicalForm) take a look at the django docs for more details -- "The whole of Japan is pure invention. There is no

Re: Initial data for ManyToMany field

2011-09-06 Thread Tomas Neme
Look into formsets. It's what the admin inlines use. On Tue, Sep 6, 2011 at 5:40 PM, Nan wrote: > > Because SymptomeForm is a ModelForm, it will initialize its "parent" > field as a ModelMultipleChoiceField, which I believe must be > initialized with a queryset instead of a list. > > On Sep 6, 4

Re: Initial data for ManyToMany field

2011-09-06 Thread Nan
Because SymptomeForm is a ModelForm, it will initialize its "parent" field as a ModelMultipleChoiceField, which I believe must be initialized with a queryset instead of a list. On Sep 6, 4:30 pm, Thomas49 wrote: > Hello, > > I have two models, and the second contains a ManyToMany relationship: >

Re: Initial Data SQL not sticking?

2011-03-27 Thread fdo
Hmm, I see your commit; Did you get a confirmation message from your database that the commit worked? Perhaps you could try inserting the data via a python script. import sqlite3 # create/connect to a permanent file database con = sqlite3.connect("pyfitness2.db") # establish the cursor, needed to

Re: Initial data in forms

2011-02-17 Thread YomGuy
Sorry I'm tired. Got it ! collection = MediaCollection.objects.get(public_id=public_id) form = MediaCollectionForm(instance=collection) 2011/2/18 YomGuy > Hi ! > > I need to get initial data in a form. > Do I have to use a formset or is there any method to fill a form coming > from a model item

Re: Initial data in a many to many field

2010-03-25 Thread mjlissner
I wasn't using ProfileForm(instance = userProfile) because I didn't realize I could. Wow, that makes things easier and neater. Thanks so much. On Mar 25, 11:57 am, Nuno Maltez wrote: > >On Thu, Mar 25, 2010 at 2:00 AM, mjlissner wrote: > > I'll make things more concrete. I have the following in

Re: Initial data in a many to many field

2010-03-25 Thread Nuno Maltez
>On Thu, Mar 25, 2010 at 2:00 AM, mjlissner wrote: > I'll make things more concrete. I have the following in my model > (which is made into a ModelForm): > class UserProfile(models.Model): >    barmembership = models.ManyToManyField(BarMembership, >        verbose_name="the bar memberships held by

Re: Initial data fixtures and auto_now_add=True

2010-02-02 Thread Andrew Turner
On Feb 2, 1:45 pm, Russell Keith-Magee wrote: > Correct. I'm guessing that the same thing is happening - the default > value is being used because the fixture doesn't specify a value. Feel > free to update the ticket so the auto_now case isn't forgotten. Done ;) Kind regards, Andrew -- You rec

Re: Initial data fixtures and auto_now_add=True

2010-02-02 Thread Russell Keith-Magee
On Tue, Feb 2, 2010 at 9:41 PM, Andrew Turner wrote: > On Feb 2, 1:29 pm, Russell Keith-Magee wrote: >> The cause of the problem is your initial fixture. Django doesn't >> listen to auto_now_add or auto_now fields on fixture loading - fixture >> objects are saved in "raw" mode, so it is assumed t

Re: Initial data fixtures and auto_now_add=True

2010-02-02 Thread Andrew Turner
On Feb 2, 1:29 pm, Russell Keith-Magee wrote: > The cause of the problem is your initial fixture. Django doesn't > listen to auto_now_add or auto_now fields on fixture loading - fixture > objects are saved in "raw" mode, so it is assumed that the fixture > should have data for all the fields. In t

Re: Initial data fixtures and auto_now_add=True

2010-02-02 Thread Russell Keith-Magee
On Tue, Feb 2, 2010 at 5:12 PM, Andrew Turner wrote: > On Feb 2, 8:07 am, Russell Keith-Magee wrote: >> It is possible you've found a bug, but in order to verify that, we >> need a minimal example that reproduces the problem - that is, the >> simplest possible model and fixture combination that f

Re: Initial data fixtures and auto_now_add=True

2010-02-02 Thread Andrew Turner
On Feb 2, 8:07 am, Russell Keith-Magee wrote: > It is possible you've found a bug, but in order to verify that, we > need a minimal example that reproduces the problem - that is, the > simplest possible model and fixture combination that fails on the > second syncdb like you describe. Thanks for

Re: Initial data fixtures and auto_now_add=True

2010-02-02 Thread Russell Keith-Magee
On Tue, Feb 2, 2010 at 3:58 PM, Andrew Turner wrote: > On Jan 19, 1:36 pm, Andrew Turner wrote: >> I have an initial_data.json file which provides some, er, initial data >> whenever I run syncdb. One of my models has a DateTimeField with >> auto_now_add=True. The data is loaded first time round,

Re: Initial data fixtures and auto_now_add=True

2010-02-01 Thread Andrew Turner
On Jan 19, 1:36 pm, Andrew Turner wrote: > I have an initial_data.json file which provides some, er, initial data > whenever I run syncdb. One of my models has a DateTimeField with > auto_now_add=True. The data is loaded first time round, but on > subsequent syncdbs, I get "IntegrityError: posts_e

Re: initial data for formset

2009-05-27 Thread adrian
Thanks. I've set extra=0 and added an element to the list, and now the last form on the page is half-initialized - the date is set but the time is not! What could cause that?? On May 26, 9:20 pm, Sam Chuparkoff wrote: > On Tue, 2009-05-26 at 17:27 -0700, adrian wrote: > > This code creates a f

Re: initial data for formset

2009-05-26 Thread Sam Chuparkoff
On Tue, 2009-05-26 at 17:27 -0700, adrian wrote: > This code creates a formset and populates fields with copies of > date and start_time. > The problem is, if num_events is X then it creates X forms but it only > populates X-1 (it leaves the last one uninitialized). My question > is why, and h

Re: initial data ignored for Form with __init__

2007-11-13 Thread Joseph Kocherhans
On 11/13/07, Ken <[EMAIL PROTECTED]> wrote: > > I'm using 0.96. I define the following form > > class TForm(forms.Form): > admin = forms.ChoiceField() > x = forms.IntegerField() > > def __init__(self, data=None, **kwargs): > super(TForm, self).__init__(data, kwargs) >

Re: initial data 'manage.py' question

2007-10-30 Thread Russell Keith-Magee
On 10/30/07, cjl <[EMAIL PROTECTED]> wrote: > > If I then add additional data to 'account.sql', is there a way to re- > load this updated initial data? Not through manage.py. You could always just pipe account.sql into your sql prompt - essentially, that's all Django is doing anyway. > Should I

Re: initial data + cut up models.py = trouble?

2007-05-21 Thread Russell Keith-Magee
On 5/21/07, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote: > > hey everyone, > > I successfully cut up my models.py into different files, so now I have: ... > to make things simpler. In all my models I have: > > class Meta: > app_label = 'myapp' > > Now I have one problem: my init

Re: Initial Data for Django Classes?

2007-04-25 Thread Russell Keith-Magee
On 4/26/07, Greg Taylor <[EMAIL PROTECTED]> wrote: > Greetings, > > I was wondering if there's a way to include initial data for Django classes. > I noticed that there is a way to do so via a 'sql' subdirectory under your > own models, but didn't see any indication if there was a way to do this fo

Re: Initial Data for Django Classes?

2007-04-25 Thread [EMAIL PROTECTED]
You can use fixtures. In your application folder, create a "fixtures" folder and in that folder create a "initial_data.json" file. Populate it like this: [ { "pk": 1, "model": "application.Contact", "fields": { "name": "Vincent" } } ] And when you run syncdb, the data w

Re: Initial Data for Django Classes?

2007-04-25 Thread [EMAIL PROTECTED]
Sorry for the double reply, I didn't think my first mail went through. I'll definitely check this out, it looks like it'll do the trick nicely. Thanks! On Apr 25, 11:13 am, Horst Gutmann <[EMAIL PROTECTED]> wrote: > Greg Taylor wrote: > > Greetings, > > > I was wondering if there's a way to incl

Re: Initial Data for Django Classes?

2007-04-25 Thread Horst Gutmann
Greg Taylor wrote: > Greetings, > > I was wondering if there's a way to include initial data for Django > classes. I noticed that there is a way to do so via a 'sql' > subdirectory under your own models, but didn't see any indication if > there was a way to do this for base Django classes. >

Re: Initial data for Flatpages?

2007-03-07 Thread Russell Keith-Magee
On 3/4/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > I am looking for some way to add initial Flatpages data to my app. I > am open to either SQL or Django ORM. The pattern of /sql/ > .sql doesn't seem to apply to Flatpages. How can I do > this? In the current Django trunk, you can also

Re: Initial data for Flatpages?

2007-03-04 Thread [EMAIL PROTECTED]
Thanks, this is perfect. On Mar 4, 2:01 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Sun, 2007-03-04 at 01:01 +, [EMAIL PROTECTED] wrote: > > I am looking for some way to add initial Flatpages data to my app. I > > am open to either SQL or Django ORM. The pattern of /sql/ > > .sql

Re: Initial data for Flatpages?

2007-03-03 Thread Malcolm Tredinnick
On Sun, 2007-03-04 at 01:01 +, [EMAIL PROTECTED] wrote: > I am looking for some way to add initial Flatpages data to my app. I > am open to either SQL or Django ORM. The pattern of /sql/ > .sql doesn't seem to apply to Flatpages. How can I do > this? Try this: http://www.bright-green.com/b

Re: Initial data for a Select widget in newforms

2007-01-27 Thread Denis Frère
On Jan 27, 9:23 am, "canen" <[EMAIL PROTECTED]> wrote: > my_field = ChoiceField(choices=[(1, 1), (2, 2)], initial=1) > doesn't work? Yes, thank you. For information, here is more details. I have a view function called bill_clone to build a new bill form prepopulated with the values from a prev

Re: Initial data for a Select widget in newforms

2007-01-27 Thread canen
my_field = ChoiceField(choices=[(1, 1), (2, 2)], initial=1) doesn't work? On Jan 26, 7:04 pm, "Denis Frère" <[EMAIL PROTECTED]> wrote: > Hi all, > > I'm discovering newforms. > > It works pretty well, but I can't manage to give an initial selection > in a ChoiceField (Select widget). > I tried to

Re: Initial data for models splitted across multiple files

2006-11-30 Thread Mikko Suniala
On Thu, 30 Nov 2006, Russell Keith-Magee wrote: > Sounds like a bug in the way that manage.py discovers the module in which > the sql files are located. This is entirely possible, as the 'split models > across files' approach isn't the common use case for Django models. Ok. Since the recipe seems

Re: Initial data for models splitted across multiple files

2006-11-29 Thread Russell Keith-Magee
On 11/29/06, Mikko Suniala <[EMAIL PROTECTED]> wrote: > > > I did a quick search but found nothing about this issue. I have splitted > my models across multiple files as described in > http://code.djangoproject.com/wiki/CookBookSplitModelsToFiles. The manager > action "sqlinitialdata" did not seem

Re: Initial data for sites framework?

2006-06-04 Thread Jorge Gajon
Hi, This is not exactly what you are asking for, but you can modify your own local copy of Django. The file to modify is: trunk/django/contrib/sites/management.py Change the line that looks like this: s = Site(domain="example.com", name="example.com") Cheers, Jorge On 6/4/06, [EMAIL PROTE

Re: initial data

2005-09-24 Thread Matt
to clarify for those as slow as I am... the "models' Python model names" refers to the plural names of your modul class names. rewriting the example to (hopefully) make this more clear: class Poll(meta.Model): ... class Choice(meta.Model): ... will look for the following files: apps/

Re: initial data

2005-09-01 Thread Sebastien Fievet
Great. Nice shot !

Re: initial data

2005-09-01 Thread Adrian Holovaty
On 9/1/05, Rachel Willmer <[EMAIL PROTECTED]> wrote: > is there a django way to set up the tables with the initial data I > want? or should I just do this using a postgres script? Yes, there is a way to do this, although it's currently not documented. Just create an "sql" directory within your ap

Re: initial data

2005-09-01 Thread Bryan L. Fordham
On Thu, Sep 01, 2005 at 07:33:56AM -0400, Jason F. McBrayer wrote: > > On Thu, 2005-09-01 at 10:15 +0100, Rachel Willmer wrote: > > is there a django way to set up the tables with the initial data I > > want? or should I just do this using a postgres script? > > You could either do it with a pos

Re: initial data

2005-09-01 Thread Jason F. McBrayer
On Thu, 2005-09-01 at 10:15 +0100, Rachel Willmer wrote: > is there a django way to set up the tables with the initial data I > want? or should I just do this using a postgres script? You could either do it with a postgres script, or you could write a python script that imports your models, insta