bulk_create for multi table inheritance support

2016-03-29 Thread Podrigal, Aron
Hi,

I worked on supporting bulk_insert for multi table inheritance here [1] I
would like to get some feedback.

bulk_create can be used in one of 2 ways

1) If you already have parent records in the database and want to
bulk_insert into the child table only.
2) There isn't any parent records, and need to create them as well.

In the first case, all database backends can support it. It simply requires
the user to set the `parent_ptr` attributes for all child instances, and
then do  bulk_create.
In the second case it gets tricky and it cannot be supported for all
databases for any model as it requires a way to get all the ids from the
inserted parent records. Postgres is the most flexible in that case and
supports bulk_insert for any table and any type of field because it
supports the RETURNING clause so we can always retrieve the ids for the
inserted rows. For sqlite we can only support bulk_create if the model does
not have a parent with an AutoField.
for MySQL I think we can rely on `LAST_INSERT_ID()` which will return the
first ID out of the rows count inserted, so we can than generate a list of
IDs of `range(last_insert_id, last_insert_id + count_rows)`.

Can anyone confirm if we can rely on MySQL last_insert_id to be consistent
and and without gaps for all records inserted at once?

Thanks.

[1]
https://github.com/django/django/compare/master...ar45:allow_bulk_insert_multi_inheritance


-- 
Aron Podrigal
-
'101', '1110010', '110', '1101110'   '101', '110',
'1100100', '1110010', '1101001', '1100111', '111', '1101100'

P: '2b', '31', '33', '34', '37', '34', '35', '38', '36', '30', '39', '39'

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CANJp-yh7SXmC1a3T3RZjdDApdAqo6Op06DsQCqOQ0LhbmVhY5g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: bulk_create for multi table inheritance support

2016-03-29 Thread Anssi Kääriäinen
For MySQL InnoDB tables the behavior is described here:
http://dev.mysql.com/doc/refman/5.1/en/innodb-auto-increment-handling.html,
see "Gaps in auto-increment values for “bulk inserts”" item. So, you
are safe as long as the lock mode is correct, and assuming the lock
mode is the default is OK for Django.

For SQLite there can't be concurrent inserts (tables are locked
exclusively when writing), so you can just check the max id from the
table after insert and calculate the values from that.

There are still all the 3rd party databases (mssql for example), so
even if all core backends can support the multi-table bulk create,
you'll need to take in account that this isn't necessarily the case
for all possible backends.

Personally I think we should just rename the method to fast_create()
and allow it to fall back to single row at time behavior. This way you
could safely call it for any objects on any database and know the
results will be OK. I don't see much point in throwing errors when
batch insert isn't possible. If batch insert isn't possible, the user
needs to insert the values one row at a time in any case.

 - Anssi

On Tue, Mar 29, 2016 at 11:47 AM, Podrigal, Aron
 wrote:
> Hi,
>
> I worked on supporting bulk_insert for multi table inheritance here [1] I
> would like to get some feedback.
>
> bulk_create can be used in one of 2 ways
>
> 1) If you already have parent records in the database and want to
> bulk_insert into the child table only.
> 2) There isn't any parent records, and need to create them as well.
>
> In the first case, all database backends can support it. It simply requires
> the user to set the `parent_ptr` attributes for all child instances, and
> then do  bulk_create.
> In the second case it gets tricky and it cannot be supported for all
> databases for any model as it requires a way to get all the ids from the
> inserted parent records. Postgres is the most flexible in that case and
> supports bulk_insert for any table and any type of field because it supports
> the RETURNING clause so we can always retrieve the ids for the inserted
> rows. For sqlite we can only support bulk_create if the model does not have
> a parent with an AutoField.
> for MySQL I think we can rely on `LAST_INSERT_ID()` which will return the
> first ID out of the rows count inserted, so we can than generate a list of
> IDs of `range(last_insert_id, last_insert_id + count_rows)`.
>
> Can anyone confirm if we can rely on MySQL last_insert_id to be consistent
> and and without gaps for all records inserted at once?
>
> Thanks.
>
> [1]
> https://github.com/django/django/compare/master...ar45:allow_bulk_insert_multi_inheritance
>
>
> --
> Aron Podrigal
> -
> '101', '1110010', '110', '1101110'   '101', '110',
> '1100100', '1110010', '1101001', '1100111', '111', '1101100'
>
> P: '2b', '31', '33', '34', '37', '34', '35', '38', '36', '30', '39', '39'
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/CANJp-yh7SXmC1a3T3RZjdDApdAqo6Op06DsQCqOQ0LhbmVhY5g%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CALMtK1EfyCqE37hbdB%3DvyTvCRmJ6zqspSfng1-kxn1Evwtr_Lg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: relative path in {% extends "...base.html" %} like relative import

2016-03-29 Thread Tim Graham
I found a couple previous discussions but no strong arguments against the 
feature so I'll move forward with reviewing the patch.

https://groups.google.com/d/topic/django-users/qX2ThbMk_So/discussion
https://groups.google.com/d/topic/django-users/_dUhA_IWpl8/discussion



On Friday, March 25, 2016 at 10:18:25 AM UTC-4, Vitaly Bogomolov wrote:
>
>
>> Assuming the feature is accepted, at least a ticket and documentation are 
>> needed to finish the patch. See the patch review checklist:
>>
>> https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/submitting-patches/#patch-review-checklist
>>
>
> Documentation:
> https://github.com/django/django/pull/6330/commits/0d49bf63aa8855bb8b61d198d8f08d1547de9dcb
>
> My english not good, so i need help with proof reading and advice
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/3335cdf0-9400-4b4e-afe8-310e1ef0dfef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


I have a problem when linking two urls

2016-03-29 Thread Cristina Elena Stan
Hello!
I make the login page and the register. After the user logs in on the home 
page i have a "create prescription" button and when i press it it says 
ERROR page not found. 
So the only problem i have is that when i press "create prescription" from 
the home page it doesn;t show me the page.
Can someone help me please?



-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/af7e39c1-0a7b-46c7-afe7-1ef85c259fee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: I have a problem when linking two urls

2016-03-29 Thread ludovic coues
Without a bit more of information, it will be kinda hard to help you.
The full text of the error, the content on the template with the
button and the content on the related urls.py file would be a nice
start.


2016-03-29 23:09 GMT+02:00 Cristina Elena Stan
:
> Hello!
> I make the login page and the register. After the user logs in on the home
> page i have a "create prescription" button and when i press it it says ERROR
> page not found.
> So the only problem i have is that when i press "create prescription" from
> the home page it doesn;t show me the page.
> Can someone help me please?
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/af7e39c1-0a7b-46c7-afe7-1ef85c259fee%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 42

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAEuG%2BTa20fp0ZtPhNAecS1Yv%3DpSvTDNdu_mXi3%2BrwGGv9hxRFQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Add HTML5 required attribute on form widgets

2016-03-29 Thread Collin Anderson
Hi All,

I think things are kind of quiet because djangocon.eu is starting tomorrow.

My opinion: In the past we changed things to use html5 types (number,
email, url, etc) and we didn't use a deprecation warning in those cases,
just mentioned it in the release notes. I'm sure it will break some
people's applications, but I think as long as we made it easy to remove the
required attribute it shouldn't be a big problem to not warn first.

Thanks,
Collin


On Mon, Mar 28, 2016 at 5:27 PM, Jon Dufresne 
wrote:

> Hi,
>
> I'm working on ticket #22383 to add the HTML5 required attribute to form
> widgets.
>
> The hope is this will add an additional level of validation at the client
> side. The feedback provided to the user is much faster than a server round
> trip.
>
> This is something I've done manually in my own projects. I'll frequently
> add "required" to widget attrs to take advantage of this validation. As I
> already use this frequently, I'm motivated to see it adopted by the Django
> core.
>
> This feature have been discussed in the ticket [1] as well as a previous
> email thread [2].
>
> In the past, there were two discussed concerns:
>
> * Allow a project to opt-out of using the required attribute
> * Add a deprecation warning that new version of Django will include the
> required attribute
>
> Past discussion settled on using the class attribute
> Form.use_required_attribute to decide if a form's widget should render the
> HTML5 required attribute. As this was the previous consensus I have
> implemented a PR [3]. To be on the safe side, this PR also adds the
> deprecation warning.
>
> Upon review, Tim Graham replied with the following:
>
> I fear the deprecation will be quite annoying if every form in a project
>> needs to be modified to silence all warnings.
>> ...
>> I guess I'm not sure if a deprecation path provides more value than
>> making a backwards-incompatible change. For example, if we expect a
>> majority of projects to adopt this change, then a deprecation will require
>> every Django project to silence the warning instead of a subset of users to
>> opt-out.
>>
>
> No problem for me. I'm OK skipping the deprecation path. I don't see it as
> necessary, I was simply trying to accommodate other opinions. I have
> created a second PR which is identical to the first, but without the
> deprecation warning [4].
>
> Also in the review Tim suggested the following:
>
> I wonder if template-based widget rendering (#15667
>> ) might ease this change. A
>> project could provide custom widget templates if they don't want the
>> required attribute (or if they want required='required'.
>>
>
> This is a different approach than previously discussed. I see the merit in
> this suggestion and think it could be a better implementation. With this
> idea, we could avoid adding the Form.use_required_attribute, entirely.
> However, template-based widget is still very much a WIP. I worry waiting on
> that feature may mean this simpler feature may miss a release cycle. Is it
> reasonable to expect the template-based widget rendering to land before the
> next alpha/beta cut?
>
> Tim asked I post these ideas to the mailing to get other opinions and
> feedback on these two points.
>
> Thanks,
> Jon
>
>
> [1] https://code.djangoproject.com/ticket/22383
> [2]
> https://groups.google.com/forum/#!topic/django-developers/obw18wSc4xU/discussion
> [3] https://github.com/django/django/pull/6341
> [4] https://github.com/django/django/pull/6352
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/CADhq2b7z08aYuY_wpzCCkCaEfOAT5uQvh74wsPCJoZT0hF5aGg%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAFO84S4get-fKgr20oy58rnwnZ2stXFqzA5u2xisYwOyLjd7uQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: I have a problem when linking two urls

2016-03-29 Thread Tim Graham
This mailing list is for the development of Django itself. Please use 
django-users for usage questions.

On Tuesday, March 29, 2016 at 5:28:30 PM UTC-4, ludovic coues wrote:
>
> Without a bit more of information, it will be kinda hard to help you. 
> The full text of the error, the content on the template with the 
> button and the content on the related urls.py file would be a nice 
> start. 
>
>
> 2016-03-29 23:09 GMT+02:00 Cristina Elena Stan 
> >: 
> > Hello! 
> > I make the login page and the register. After the user logs in on the 
> home 
> > page i have a "create prescription" button and when i press it it says 
> ERROR 
> > page not found. 
> > So the only problem i have is that when i press "create prescription" 
> from 
> > the home page it doesn;t show me the page. 
> > Can someone help me please? 
> > 
> > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Django developers (Contributions to Django itself)" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to django-develop...@googlegroups.com . 
> > To post to this group, send email to django-d...@googlegroups.com 
> . 
> > Visit this group at https://groups.google.com/group/django-developers. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/django-developers/af7e39c1-0a7b-46c7-afe7-1ef85c259fee%40googlegroups.com.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
>
>
>
> -- 
>
> Cordialement, Coues Ludovic 
> +336 148 743 42 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/6ef00d2f-e65f-499e-85bd-f852adfe7012%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.