Re: apprendre Django

2015-01-14 Thread th . granier
je me suis mis a apprendre Django et python3.4 et c'est un regal

Pourquoi Django? parce que c'est framework tres puissant, tres 
logiquesuffisammant complexe pour etre tres interessant et reutilisable
Pourquoi Python? parce que je voulais apprendre un language universel et 
puissant qui me permette de faire aussi de la programmation systemes et 
reseaux

J4aim mis longtemps a etudier et comparer les solutions proposees sur le 
marche "libre"  (Wordpress, Symphonie2, Cakaphp, Joomla, ... et je me 
suis decide pour django car je ne voulais pas en plus apprendre le php que 
je n'utiliserai surement pas par la suite. contrairement a Django)

Bonn nuit

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/971eba03-6cf7-450d-a585-d43faf800553%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


apprendre Django

2015-01-14 Thread th . granier
Bonjour 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/877a7e15-8c8d-4940-9b21-e196cc9f8eda%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: object has no attribute 'new_objects' error when saving related objects

2015-01-14 Thread mateja
Thank you! You're right, I don't even want to be able to edit datapoints, 
just display them in the admin view so they shouldn't be an inline.

On Wednesday, January 14, 2015 at 9:42:57 AM UTC-5, Collin Anderson wrote:
>
> Hi,
>
> You are using an inline which uses a formset under the hood. When a 
> formset gets saved it gets the expected new_objects, but you're not saving 
> the formset.
>
> It might make sense to not use an inline and display the data points by 
> hand.
>
> Collin
>
> On Tuesday, January 13, 2015 at 8:49:54 AM UTC-5, mateja wrote:
>>
>> I am working on a simple application to store sets of collected 
>> datapoints into a dataset. I am using the admin interface to handle CRUD 
>> management of the dataset objects. I would like to be able to add 
>> additional datapoints to an existing dataset instance by importing model 
>> data from a file. The error happens when I save the change form, I get the 
>> error "object has no attribute 'new_objects'"
>>
>> This is what the admin change view looks like: http://imgur.com/gQGXquS
>>
>> I have overridden the admin change view to include a file field that 
>> accepts a CSV file containing datapoint data. When the user clicks the Save 
>> button, the file should upload and the app should import and save 
>> datapoints from the file and associate them with the given dataset. I have 
>> googled around for this error and I have seen where others omitted to call 
>> the save_m2m() function, but I don't think this is what I am trying to do 
>> as I am not using a formset, I am using a file upload.
>>
>> I have overridden the Dataset ModelAdmin save_model function to accept 
>> the file, save the datapoints, and associate them with the given dataset.
>>
>> The code and the full error log is all here: 
>> https://gist.github.com/matejaputic/0e25cd74830033442886
>>
>> Is this the right way to do this? I would appreciate any guidance.
>>
>> Also, why are the existing datapoints being resubmitted? How can I 
>> prevent that from happening?
>>
>> Thank you
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/98b2e9dc-3ecc-4919-a356-c288a9f6b510%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Best Tutorial

2015-01-14 Thread Tobias Dacoir
After doing the official tutorial I also worked through this one: 
http://www.tangowithdjango.com/
Anything else you can find with Google, if you have specific problems there 
are tons of blog posts, video tutorials and so on. 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8bf9ae4f-d3c0-40ff-91cf-8d9fa5c441d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: hello need help to configure django

2015-01-14 Thread Tobias Dacoir
I'm also new to Django but to me it seems that you have not registered any 
App in settings.py.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3c02b1ea-5678-4d08-9966-a5f0f1bcf280%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Which 3rd Party (Social) Auth App should I use?

2015-01-14 Thread Tobias Dacoir
Thanks for the link. That explain's how I can inject my logic and hopefully 
form into the authentication process. Still quite complicated for a 
beginner. 

I did some more reading and apparently I need django-registration-redux for 
local registration (and stuff like password reset) and then a 2nd addon for 
social auth. 

Still I'm not quite sure what the difference between django-allauth and 
django-social-auth is. 

As for your question, I was quite unsure which to chose, so I did a lot of 
reading and asked on this forum. People recommended B), however I haven't 
fully understood why. Intuitively I would have chosen A) by myself, not 
only because it was shown in the online tutorial I read (Tango with Django) 
but also because it seems to be less complex.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/39c66976-7cbd-4dd3-aa96-05ba436bbae7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: hello need help to configure django

2015-01-14 Thread Ulisses Cruz
Hello, 
I'm new to Django but maybe this can help you:

https://docs.djangoproject.com/en/1.7/intro/tutorial01/

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6339ba10-d9b6-44dd-acd2-328da0a373a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Best Tutorial

2015-01-14 Thread Ulisses Cruz
Hello,
I'm getting started in Django and I would like to now what books ou 
tutorials 
can help me in this stage.

I would like one that is up to date with django 1.7.

Also, I've been reading the official documentation, but any other hint 
would be
apreciated.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/44194acc-cc95-478d-aeb2-1e01cb17cc1f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: hello need help to configure django

2015-01-14 Thread Ulisses Cruz
Hello,
I'm new to django, but maybe this can help you:

https://docs.djangoproject.com/en/1.7/intro/tutorial01/

quarta-feira, 14 de Janeiro de 2015 às 01:13:53 UTC-1, zsandrusha escreveu:
>
> I had worked site @ webfaction hosting but i loose old domain names and 
> trying to configure new domain name, here what i see on screenshot:
> http://joxi.ru/Y2LyjZecxPeOA6
>
> realy need urgent help
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0289eba3-f5c4-49dd-a3c8-e48f60294e4c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Integration with Legacy DB

2015-01-14 Thread Sells, Fred
Although I have not tried it, the docs are pretty clear about how to sync a 
django model to an existing legacy DB (sqlserver08 in this case).

But is there a way to sync to a select statement with multi-table joins without 
first creating a View?

I know that creating a view would be easiest, but I’ve got some policy/security 
issues in my organization that require jumping through additional hoops and am 
hoping there is some Django “magic” to solve this.

Thanks,

Fred.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/DCD75728F460F14586086EA606E830820133E90ADA%40ACEVXCHMBX1001.ADVENTISTCORP.NET.
For more options, visit https://groups.google.com/d/optout.


Re: Which 3rd Party (Social) Auth App should I use?

2015-01-14 Thread Viktor Voronin
Hi Tobias, 

Did check the pipeline logic at 
python-social-oauth? 
http://python-social-auth.readthedocs.org/en/latest/pipeline.html#authentication-pipeline
There is an ability to inject your custom logic into authenticating process.

And why did you decide to take B way? Or why did you reject A?

On Wednesday, January 14, 2015 at 12:37:44 PM UTC+2, Tobias Dacoir wrote:
>
> I'm trying to integrate Social Auth to my Webapp. As I have to store a lot 
> of additional information for each User I had two choices:
>
> A) Create a UserProfile with a OneToOne Relationship to User
> B) Overwrite the default User class by inhereting from Abstract User
>
> Currently I chose to go with B) as was also recommended. Now I have found 
> three Addons that seem to be popular:
>
> - django-registration-redux
> - django social-auth
> - django-allauth
>
> I found some tutorial for all three of those (can post links to them if 
> anyone wants) however, all tutorial just make use a regular user model. I 
> have not been able to find a solution / example on how to connect to a 
> custom UserProfile for example. I have tested django-allauth using my 
> overwritten User Model and I was able to log in using Facebook, however I 
> have no idea how to automatically include my custom properties in a sign-up 
> form (as there is essentially no sign up, just log in via facebook).
>
> What I'd like to do is the following: 
>
> - Allow users to register at my site
> - During registration not only ask for username, email and password but 
> additional required fields like language settings (so extend default form)
> - Allow Sign-Up / Login through OAuth (Facebook and Google at least) but 
> still have the user fill out those required fields.
>
> Can someone please tell me which 3rd Party App to use and maybe point me 
> to a tutorial / example that adds additional user properties during 
> registration?
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0ff04723-1382-4514-ad4b-830f0ab5d32d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Running Django Test Suite with pytest

2015-01-14 Thread Jozef knaperek
Hello,

I'd like to know if anybody has tried to run Django's own tests via pytest.

Django does have its own, quite extensive runtests.py script which is
intended for testing Django codebase. I need to execute the test suite
with py.test though (in order to make use of some pytest plugin). Any
suggestions? Thanks!

Jozef

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54B68876.6000303%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Desired: Field behavior like AutoField + unique_with

2015-01-14 Thread Matt Cooper
Got it - thank you! This community is great :)

On Tuesday, January 13, 2015 at 11:31:19 PM UTC-8, Jani Tiainen wrote:
>
> Because sequence number was running number per "tenant" (in my case it 
> was invoice type) that started from zero (0) at the beginning of the 
> every year. 
>
> You could use max+1 as well but you should be aware that there is a 
> slim chance that there is race condition and you may end up having two 
> entities with the same max number - that though would raise error when 
> trying to save into database. 
>
> By having explicitly pessimistic locking (select_for_update) for a row 
> with tenant + sequence value you can guarantee that no other request 
> can change the value while you're reading it. 
>
> To make that easier you can create custom manager that can retrieve 
> updated sequence values automagically, so your call would look like 
> something like: 
>
> Tenant.sequence.get_value(tenant, sequence) 
>
>
> On Tue, 13 Jan 2015 06:37:21 -0800 (PST) 
> Matt Cooper > wrote: 
>
> > Thanks Jani, good to hear someone has gone down this road before. 
> > Since you did it in code, is there a reason you kept a sequence value 
> > on Tenant rather than using 
> > Widget.objects.aggregate(Max(Widget.sequence_value)) ? I ask because 
> > for my app, Widget is actually just one of several cases where I need 
> > this pattern. If I could keep all the book-keeping on the model with 
> > the constraint, that seems cleaner to me. But, of course, I'm not 
> > willing to pay a huge performance or corruption penalty just for 
> > vague ideological purity :) 
> > 
> > Thanks again! 
> > ~matt 
> > 
> > On Tuesday, January 13, 2015 at 5:07:21 AM UTC-8, Jani Tiainen wrote: 
> > > 
> > > I've done something similiar. 
> > > 
> > > Only way to do that is that you need to upkeep that tenant 
> > > sequence_id manually, 
> > > 
> > > So doing something like: 
> > > 
> > > class Tenant(models.Model): 
> > > name = models.CharField(max_length=50) 
> > > sequence_value = models.IntegerField() 
> > > 
> > > and in a code: 
> > > 
> > > tenant = Tenant.object.get(id=tenant_id).select_for_update()  # 
> > > Pessimistic locking 
> > > tenant.sequence_value = tenant.sequence_value + 1 
> > > tenant.save() 
> > > 
> > > widget = Widget(owner=tenant,sequence_value=tenant.sequence_value) 
> > > widget.save() 
> > > 
> > > That should do the trick. Another option could be using table 
> > > triggers to automate 
> > > that within a database table trigger(s). 
> > > 
> > > On Mon, 12 Jan 2015 21:26:54 -0800 (PST) 
> > > Matt Cooper > wrote: 
> > > 
> > > > I'm building a multi-tenant application with a data model that 
> > > simplifies 
> > > > to: 
> > > > 
> > > > class Tenant(models.Model): 
> > > > name = models.CharField(max_length=50) 
> > > > 
> > > > class Widget(models.Model): 
> > > > owner = models.ForeignKey(Tenant) 
> > > > sequence_id =  
> > > > 
> > > > 
> > > > I want Widget.sequence_id to work like an AutoField (that is, 
> > > automatically 
> > > > give me something unique and generally incrementing by 1) but 
> > > > scoped to 
> > > a 
> > > > single Widget.owner. So for instance, when Tenant A creates 3 
> > > > widgets, 
> > > they 
> > > > would get sequence_ids 1, 2, and 3. Then Tenant B comes along and 
> > > creates 2 
> > > > widgets; those widgets get sequence_ids 1 and 2. The tenant/user 
> > > > gets no control over the number, but it's something she'll see in 
> > > > the UI. AutoNumber is out because from the perspective of a 
> > > > single tenant, they should have sequential widget IDs. 
> > > > GUIDs/UUIDs are out because it needs 
> > > to 
> > > > be human-readable. 
> > > > 
> > > > I looked through docs on AutoField and unique_together. I turned 
> > > > StackOverflow upside down and only found this 
> > > > <
> http://stackoverflow.com/questions/18072586/django-autofield-increment>, 
> > > 
> > > > which isn't quite what I want. I didn't see anything on 
> > > djangopackages.com 
> > > > that would solve my problem, though I could have missed it. 
> > > > 
> > > > Basically, has anyone done something like this before and have a 
> > > suggested 
> > > > pattern? 
> > > > 
> > > > Thanks! 
> > > > ~matt 
> > > > 
> > > > -- 
> > > > 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. 
> > > > To view this discussion on the web visit 
> > > 
> https://groups.google.com/d/msgid/django-users/37fd32e7-28dd-4c10-8451-b0d705a3e52e%40googlegroups.com.
>  
>
> > > 
> > > > For more options, visit https://groups.google.com/d/optout. 
> > > 
> > 
> > -- 
> > You received this message because you are subscribed to 

Re: ImportError: No module named check_constraints

2015-01-14 Thread Collin Anderson
Hi,

Yes, a full traceback would be helpful, if you can get it. If it's a 
manage.py commany, you may need to use --traceback.

Collin

On Tuesday, January 13, 2015 at 5:38:47 AM UTC-5, Jenefa Jeyaraj wrote:
>
> ImportError: No module named check_constraints
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7626b728-5342-4f64-8bd9-3110f1d9cd30%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: object has no attribute 'new_objects' error when saving related objects

2015-01-14 Thread Collin Anderson
Hi,

You are using an inline which uses a formset under the hood. When a formset 
gets saved it gets the expected new_objects, but you're not saving the 
formset.

It might make sense to not use an inline and display the data points by 
hand.

Collin

On Tuesday, January 13, 2015 at 8:49:54 AM UTC-5, mateja wrote:
>
> I am working on a simple application to store sets of collected datapoints 
> into a dataset. I am using the admin interface to handle CRUD management of 
> the dataset objects. I would like to be able to add additional datapoints 
> to an existing dataset instance by importing model data from a file. The 
> error happens when I save the change form, I get the error "object has no 
> attribute 'new_objects'"
>
> This is what the admin change view looks like: http://imgur.com/gQGXquS
>
> I have overridden the admin change view to include a file field that 
> accepts a CSV file containing datapoint data. When the user clicks the Save 
> button, the file should upload and the app should import and save 
> datapoints from the file and associate them with the given dataset. I have 
> googled around for this error and I have seen where others omitted to call 
> the save_m2m() function, but I don't think this is what I am trying to do 
> as I am not using a formset, I am using a file upload.
>
> I have overridden the Dataset ModelAdmin save_model function to accept the 
> file, save the datapoints, and associate them with the given dataset.
>
> The code and the full error log is all here: 
> https://gist.github.com/matejaputic/0e25cd74830033442886
>
> Is this the right way to do this? I would appreciate any guidance.
>
> Also, why are the existing datapoints being resubmitted? How can I prevent 
> that from happening?
>
> Thank you
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/59f8ab4f-0da7-47d1-a84b-1d84a76165b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ChoiceInline field giving name error

2015-01-14 Thread Vinayak Kaniyarakkal


On Wednesday, 14 January 2015 18:33:59 UTC+5:30, sanjeet kaur wrote:
>
> Hi, 
>   I am working on django ap in which I have two apps in a single project 
> but while using inline option, I get the error 
>
> NameError: name 'ChoiceInline' is not defined
>  
> I have searched this error and all say that 'l' in StackedInline and 
> ChoiceInline should not be capitalized. I have corrected this but still 
> getting the same error.
> I have attached the screenshots of models.py and admin.py
>

1. Define expense admin after ChoiceInline.
2. "inlines = [ChoiceInline]" should come in expenseAdmin, not in 
ChoiceInline.
 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8e50d099-f8f3-486c-8178-c4648de1ee34%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Many-To-Many Relationship changes not accessible in Model.save() ?

2015-01-14 Thread Collin Anderson
Hi,

The admin first calls obj.save(), then it saves the related data.

You could try putting your logic in ModeAdmin.save_related()
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_related

Collin

On Monday, January 12, 2015 at 5:00:54 PM UTC-5, Tobias Dacoir wrote:
>
> Thanks for the links. It might be related to that bug. In my scripts I 
> added another save() and then it works of course and as for the Admin 
> Panel, until I have a solution I put a message into the help text that 
> users have to click 'save and continue' first and then 'save' afterwards. 
> Then it's fine as well. Phew at least the workaround was quickly 
> implemented, still I spend at least 1 hour on figuring out what's going 
> wrong. 
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1a648722-0981-4f38-a2dc-3529225dba85%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: modelformset question - interspersing extra forms among existing forms

2015-01-14 Thread Collin Anderson
Hi Richard,

Yes, my way is pretty hacky. The proper way is to get the instance from the 
form.save() method like you mentioned.

Collin

On Monday, January 12, 2015 at 10:58:46 AM UTC-5, Richard Brockie wrote:
>
> Hello again Collin,
>
> I am using your example as the basis for another similar set of forms and 
> I spotted something subtle that passed me by the first time through.
>
> Namely, that to save the data, you are calling the model.save() method, 
> rather than the form.save() method that is generally shown in the 
> documentation examples.
>
> I've tried both, and they both work. From the documentation I was 
> expecting that this line:
>
> forms = [EntryForm(request.POST, instance=e, prefix=e.category.pk) 
> for e in entries]
>
> would be one-way, in that the POST and instances would combine in the 
> forms and form.save() would be the method that should be used. It appears 
> however that the POST data also end up in the instances.
>
> I wasn't expecting that, but it appears to work. Is there a preferred or 
> standard method that I should think about using?
>
> R.
>
> On Sunday, January 4, 2015 at 11:41:36 AM UTC-8, Collin Anderson wrote:
>>
>> Hi,
>>
>> If the field on the model is already blank=True, then you don't need that.
>>
>> Also, I realized my (completely untested :) code doesn't exactly match 
>> the behavior you want, but I hope it's a good enough start. You may need to 
>> store a reference to the original race_number to decide if you need to 
>> .save() or not.
>>
>> Collin
>>
>> On Friday, January 2, 2015 9:42:47 PM UTC-5, Richard Brockie wrote:
>>>
>>> Hi Collin,
>>>
>>> Thanks very much for the advice. I'll be getting to this part of my 
>>> development in the next few days and will report back when I have things 
>>> working.
>>>
>>> One question in the meantime - what does this line do given that my 
>>> model will already explicitly not require the race_number?
>>>
>>> race_number = Entry._meta.get_field('race_number').formfield(required=
>>> False)
>>>
>>> Wishing everyone a prosperous New Year.
>>> R.
>>>
>>>
>>> On Thursday, January 1, 2015 3:31:45 PM UTC-8, Collin Anderson wrote:

 Hi,

 Your case is complicated enough that I'd actually recommend not using 
 formsets here and processing a list of plain ModelForms yourself in the 
 view. I bet formsets will ending out getting in your way.

 Here's a some messy code:

 class EntryForm(forms.ModelForm):
 race_number = Entry._meta.get_field('race_number').formfield(
 required=False)
 class Meta:
 model = Entry
 fields = ['race_number']

 def the_view(request, athlete_id):
 athlete = get_object_or_404(Athlete, id=athlete_id)
 existing = {e.category_id: e for e in athlete.entry_set.all()}
 entries = []
 for category in Category.objects.order_by('particular'):
 entries.append(existing.get(category.pk, Entry(athlete=athlete, 
 category=category)))
 if request.method = 'POST':
 forms = [EntryForm(request.POST, instance=e, prefix=e.category.
 pk) for e in entries]
 if all([f.is_valid() for f in forms]):  # be sure to call 
 is_valid() on every form
 for entry in entries:
 if entry.race_number:
 entry.save()
 if entry.pk and not entry.race_number:
 entry.delete()
 else:
 forms = [EntryForm(instance=e, prefix=e.category.pk) for e in 
 entries]
 return render(request, 'template.html', {'athlete': athlete, 
 'forms': forms})

 {% for form in forms %}
 Category: {{ form.instance.category }}
 {{ form }}
 {% endfor %}

 Collin

 On Monday, December 29, 2014 6:07:19 PM UTC-5, Richard Brockie wrote:
>
> Hi,
>
> I have the following pseudo model that I will use as the basis of a 
> modelformset:
>
> class Entry:
> athlete = ForeignKey(athlete)
> category = ForeignKey(category)
> race_number = IntegerField
>
> I have a page that displays each athlete's details so the choice of 
> athlete has already been made. I want to add a formset that allows a user 
> to specify a race_number for each of the possible categories available.
>
> An obvious way would be for there to be one Entry for each 
> athlete/category, but in practise this will result in a large entry table 
> that is only ~10% actual data, with the rest being superfluous rows. I'd 
> prefer to avoid this.
>
> Let's assume that an athlete is already entered in 2 categories out of 
> a possible 10. The queryset will return the 2 existing entries, and I can 
> use extra=8 to add in the other possibilities. However, I am not yet 
> done. 
> I want to do the following and would like advice on how to accomplish 
> this:
>

Re: do migrations (Django 1.7+) handle production data?

2015-01-14 Thread Markus Holtermann
Hey Abraham,

to be more specific, when you used South and ran "manage.py
datamigration" [1] you got an empty migration file with a forwards and
backwards method where you had to fill out the blanks and tell South
what to do, e.g. to create a certain object in the database.

With Django's migration system you get the same with running "manage.py
makemigrations --empty". Django will generate an empty migration file
that you can fill with the operations to run.

Django offers "migrations.RunPython" to run arbitrary Python code, and
"migrations.RunSQL" do perform raw SQL queries. (For documentation
please see the links Russell send earlier).

Best

/Markus

[1] http://south.readthedocs.org/en/latest/commands.html#datamigration

On 01/14/2015 01:43 PM, James Bennett wrote:
> On Wed, Jan 14, 2015 at 6:34 AM, Abraham Varricatt <
> abraham.varric...@googlemail.com> wrote:
> 
> To be more specific, the document you link clearly mentions that "Django
>> can’t automatically generate data migrations for you"
>>
>>
>> And this is what puzzles me. If it isn't automated and is something that
>> needs to be done manually, what's so great about it's inclusion in Django
>> 1.7?
>>
> 
> Django cannot read your mind to figure out what specific changes to your
> data you'd like to have happen. So writing the logic of the data migration
> is up to you.
> 
> Django *can* usually deduce the necessary schema changes from examining
> what the models looked like before and after. And that's the difference.
> 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54B66F6C.1000607%40markusholtermann.eu.
For more options, visit https://groups.google.com/d/optout.


Re: ChoiceInline field giving name error

2015-01-14 Thread Kamal Kaur
On Wed, Jan 14, 2015 at 6:33 PM, sanjeet kaur  wrote:
> NameError: name 'ChoiceInline' is not defined


Have you tried this?

http://stackoverflow.com/questions/22768262/nameerror-not-defined

-- 
Kamaljeet Kaur

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAP8Q%2Bxi6cTFS_aKSUUCCdbRtu60wThL%2B4AVLyODuDP2K%2BCS_Cg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: do migrations (Django 1.7+) handle production data?

2015-01-14 Thread James Bennett
On Wed, Jan 14, 2015 at 6:34 AM, Abraham Varricatt <
abraham.varric...@googlemail.com> wrote:

To be more specific, the document you link clearly mentions that "Django
> can’t automatically generate data migrations for you"
>
>
> And this is what puzzles me. If it isn't automated and is something that
> needs to be done manually, what's so great about it's inclusion in Django
> 1.7?
>

Django cannot read your mind to figure out what specific changes to your
data you'd like to have happen. So writing the logic of the data migration
is up to you.

Django *can* usually deduce the necessary schema changes from examining
what the models looked like before and after. And that's the difference.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAL13Cg88m0rV_H7HCQPgsXtUeyrJ7qShnu0KFt55Z%2B7uTuhP-A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: do migrations (Django 1.7+) handle production data?

2015-01-14 Thread Abraham Varricatt
To be more specific, the document you link clearly mentions that "Django 
can’t automatically generate data migrations for you"

And this is what puzzles me. If it isn't automated and is something that 
needs to be done manually, what's so great about it's inclusion in Django 
1.7?

Slowly discovering django,
Abraham V.


On Wednesday, January 14, 2015 at 12:56:45 PM UTC+5:30, Russell Keith-Magee 
wrote:
>
>
> On Wed, Jan 14, 2015 at 3:03 PM, Abraham Varricatt <
> abraham@googlemail.com > wrote:
>
>> Hello everyone,
>>
>> One of the biggest features introduced in Django 1.7 are migrations. They 
>> can broadly be classified into 2 types - 
>> * schema migrations
>> * data migrations
>>
>> Schema migrations deal with changes to the database schema. eg - changing 
>> max_digits of a DecimalField.
>> Data migrations revolve around the actual data in your database and are 
>> not automatically taken care of.
>>
>> My question is; 
>>
>> Why is there so much praise for the Django (1.7) migrations feature if it 
>> can't handle data? Yes, I can understand the convenience of schema 
>> migrations, but without it being accompanied by data migrations, what's the 
>> point? (I'm assuming that this is something run on a production 
>> environment. For test/development environments, the data can arguably be 
>> worthless)
>>
>  
> What gave you the impression that Django's migrations doesn't handle data? 
> There's a section in the Migration topic guide in Django's documentation 
> entitled "Data Migrations":
>
> https://docs.djangoproject.com/en/1.7/topics/migrations/#data-migrations
>
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e537c1bb-2516-43b1-9da6-52392ad81352%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Which 3rd Party (Social) Auth App should I use?

2015-01-14 Thread Tobias Dacoir
I'm trying to integrate Social Auth to my Webapp. As I have to store a lot 
of additional information for each User I had two choices:

A) Create a UserProfile with a OneToOne Relationship to User
B) Overwrite the default User class by inhereting from Abstract User

Currently I chose to go with B) as was also recommended. Now I have found 
three Addons that seem to be popular:

- django-registration-redux
- django social-auth
- django-allauth

I found some tutorial for all three of those (can post links to them if 
anyone wants) however, all tutorial just make use a regular user model. I 
have not been able to find a solution / example on how to connect to a 
custom UserProfile for example. I have tested django-allauth using my 
overwritten User Model and I was able to log in using Facebook, however I 
have no idea how to automatically include my custom properties in a sign-up 
form (as there is essentially no sign up, just log in via facebook).

What I'd like to do is the following: 

- Allow users to register at my site
- During registration not only ask for username, email and password but 
additional required fields like language settings (so extend default form)
- Allow Sign-Up / Login through OAuth (Facebook and Google at least) but 
still have the user fill out those required fields.

Can someone please tell me which 3rd Party App to use and maybe point me to 
a tutorial / example that adds additional user properties during 
registration?

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/27571248-a38a-4c08-890d-273146444953%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.