Django 4.2 beta 1 released

2023-02-20 Thread Mariusz Felisiak

Details are available on the Django project weblog:

https://www.djangoproject.com/weblog/2023/feb/20/django-42-beta-1-released/

--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/09920202-2ff3-9bce-6a64-e69ec0b9782c%40gmail.com.


dynamically added INSTALLED_APPS

2023-02-20 Thread Christian González

Hi devs,

I am still evolving my GDAPS plugin system for Django (which works well 
here), and try to overcome some shortcomings of Django that is not 
really easy so solve, like dynamically added INSTALLED_APPS.


Given the need that a plugin that is installed/found via 
setuptools/entry point (like GDAPS, or e.g. Pretix does), it can 
sometimes be necessary that a plugin itself needs another app (like e.g. 
django-money etc.) as "dependency".


Install-wise this is no problem, as it can be added as "dependency" in 
setup.py, setup.cfg or, as in my case, pyproject.toml. But to make the 
main app use that dependency, it must be added to the INSTALLEd_APPS 
list during the setup process.


I solved that problem by adding a helper function that must be called 
after INSTALLED_APPS in settings.py, which dynamically imports the 
plugin class (no models, no views, just the plugin main class itself, 
e.g. "foo_main_app.plugins.dynamically_added_plugin", and searches for 
an INSTALLED_APPS attr in that namespace. If it exists, it is basically 
appended to the main INSTALLED_APPS.


To solve ordering problems, it is a bit more complicated, and the plugin 
gets the chance to reorder the INSTALLED_APPS and insert its own 
dependencies (and itself) to a special index.


But basically the main module of the django (plugin) app is imported, 
and read. This works, but I'd like to ask you if this violates any of 
Django's principles, or if there would be a better approach in the long 
term to create pluggable apps, that just can be installed by pip.


The only reason I post it here (in dev) is that this may be of interest 
too for Django itself at some point in time too. But here I need your 
feedback.


I first wanted to put that information into the AppConfig class - but 
can't be loaded in settings.py - apps aren't loaded.
So, for my taste, plugin information is a bit scattered around 
(AppConfig in apps.py, INSTALLED_APPS and more in __init__.py). It could 
be added declaratively in some yaml file too, but this would feel even 
creepier to me.


Eager to hear your opinion here.

--
Dr. Christian González
https://nerdocs.at

--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/af191009-898a-ed99-7d6a-4f99057674fc%40nerdocs.at.


Re: Fellow Reports - February 2023

2023-02-20 Thread Mariusz Felisiak
Week ending February 19, 2023 

*Triaged: *
   https://code.djangoproject.com/ticket/34332 - Migrations for fields with 
model-referencing defaults break later (needsinfo) 
   https://code.djangoproject.com/ticket/34335 - Spurious error when using 
label_tag of CheckboxSelectMultiple widget (wontfix) 
   https://code.djangoproject.com/ticket/34333 - Migrations tries to add 
constraint before adding a foreign key. (accepted) 
   https://code.djangoproject.com/ticket/34328 - Class-based async-only 
middleware not detected as coroutine in MiddlewareMixin (invalid) 
   https://code.djangoproject.com/ticket/34338 - Allow to customize the 
code attribute of ValidationError raised by BaseConstraint.validate 
(accepted) 
   https://code.djangoproject.com/ticket/34336 - Reverting a migration with 
`replaces = [...]` set does not revert it (needsinfo) 
   https://code.djangoproject.com/ticket/34337 - Documentation for custom 
related managers is contradictory (duplicate) 
   https://code.djangoproject.com/ticket/34339 - Allow overriding 
construct_search(). (wontfix) 
   https://code.djangoproject.com/ticket/34340 - Apparently wrong table 
name? (needsinfo) 
   https://code.djangoproject.com/ticket/34341 - FileSystemFinder harsh 
regarding its input on Windows (invalid) 
   https://code.djangoproject.com/ticket/34322 - ManifestStaticFilesStorage 
crashes on commented JavaScript import statements (duplicate) 
   https://code.djangoproject.com/ticket/34344 - PostGIS Database Backend 
Overrides features_class, ops_class and introspection_class (needsinfo) 
   https://code.djangoproject.com/ticket/34345 - Add system check for 
filter_horizontal/filter_vertical on ManyToManyFields with intermediary 
models.(accepted) 
   https://code.djangoproject.com/ticket/34346 - QuerySet ordered by 
annotation with name used by select_related() field crashes with 
AmbiguousColumn. (accepted) 
   https://code.djangoproject.com/ticket/34348 - Add medium path to the 
settings.py file from the time the project is created (wontfix) 
   https://code.djangoproject.com/ticket/34349 - Formsets' add_fields() 
method fails in some circumstances if the argument index is None. 
(accepted) 
   https://code.djangoproject.com/ticket/34350 - WSGIRequest crashes when 
"wsgi.input" is None. (invalid) 
   https://code.djangoproject.com/ticket/34351 - Slash in constraint name 
results in invalid migration file naming (duplicate) 

*Reviewed/committed: *
   https://github.com/django/django/pull/16548 - Fixed #34316 -- Fixed 
layout of admin password change forms and help texts. 
   https://github.com/django/django/pull/16544 - Fixed #34318 -- Added 
release note for 4bfe8c0eec835b8eaffcda7dc1e3b203751a790a. 
   https://github.com/django/django/pull/16550 - Bumped versions in 
pre-commit and npm configurations. 
   https://github.com/django/django/pull/16551 - Fixed #29994 -- Added 
warning about performance of FileBasedCache with a large number of files. 
   https://github.com/django/django/pull/16511 - Fixed #34280 -- Allowed 
specifying different field values for create operation in 
QuerySet.update_or_create(). 
   https://github.com/django/django/pull/16532 - Fixed #34250 -- Fixed 
renaming model with m2m relation to a model with the same name. 
   https://github.com/django/django/pull/16555 - Bumped grunt-contrib-qunit 
versions in npm configurations. 
   https://github.com/django/django/pull/16553 - Increase coverage. 
   https://github.com/django/django/pull/16545 - Refs #16247 -- Updated 
docs to use default  style and refactored docs to have less emphasis 
on as_* methods. 
   https://github.com/django/django/pull/16557 - Fixed #34320 -- Fixed 
introspection of constraints on truncated column names on Oracle. 
   https://github.com/django/django/pull/16515 - Fixed #34045 -- Improved 
accessibility of selecting items in admin changelist. 
   https://github.com/django/django/pull/16562 - Fixed #34343 -- Moved 
built-in templates to filesystem. 
   https://github.com/django/django/pull/16559 - Fixed #34342, Refs #33735 
-- Fixed test client handling of async streaming responses. 
   https://github.com/django/django/pull/16564 - Fixed #34302 -- Fixed 
SpatialReference.srid for objects without top-level authority. 
   https://github.com/django/django/pull/16565 - Fixed #34347 -- Added 
__all__ to django.contrib.gis.utils. 
   https://github.com/django/django/pull/16572 - Refs #33308 -- Added tests 
for queryset ordered by annotation with nulls_first/nulls_last. 

*Reviewed: *
   https://github.com/django/django/pull/16554 - Fixed #34328 -- Added 
async-only class-based middleware example. 

*Authored: *
   https://github.com/django/django/pull/16561 - Refs #21080, Refs #34322 
-- Added warning to ManifestStaticFilesStorage docs about paths in comments.

Best,
Mariusz

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

Re: dynamically added INSTALLED_APPS

2023-02-20 Thread Jacob Rief
Isn't it a bit dangerous to auto-add a package from PyPI to a running 
Django installation? That module then gains full database access and could 
do all kind of nasty stuff.
Maybe I am a bit naive here, but 3rd party packages sometimes get installed 
incautiously.
– Jacob

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/8c725ee5-3d05-4baf-a1a0-134334cac465n%40googlegroups.com.


Re: Model icons

2023-02-20 Thread Jacob Rief
I agree with Adam Johnson that adding HTML to the model class is a bit too 
coupled.
But I like the idea of Mark Niehues to add them to the ModelAdmin class, 
although I would allow a HTML/SVG snippet rather than a CSS class.

   - How would we then handle 3rd party apps providing their own SVG file 
   to be used as icon?
   - Shouldn't that icon definition be part of the ModelAdmin's Media 
   subclass?  

– Jacob

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/a5e570a9-5cba-442c-abe6-435b320d5579n%40googlegroups.com.


Re: [Ticket #24686] Support for Moving a Model between two Django Apps - Implementation Approach Feedback

2023-02-20 Thread Durval Carvalho


Since my last post, I've discovered that the current implementation 

 
only handles simple ForeignKeys and not more complex cases like 
ManyToManyFields. This is because the current approach generates at least 
one AlterField 

 
with the fields ManyToOneRel and ManyToManyField, which cannot be serialized 

 
at the time of writing operations to the migration files.

I'm still trying to figure out the best approach to tackle this issue. I'm 
unsure whether extending the serializer_factory to support these types of 
fields or creating a new operation (probably "MoveModel") similar to 
RenameModel would be the better solution. I noticed that in the RenameModel 
the operations related to column renaming in the M2M tables are done in the 
database_forwards 

 
method using the _alter_many_to_many 

.

If anyone in the Django community has any suggestions or experience with 
this issue, I would greatly appreciate any input. Thank you!

Em sexta-feira, 17 de fevereiro de 2023 às 16:56:01 UTC-3, Durval Carvalho 
escreveu:

> Hello Django developers,
>
> I'm new to the community and I'm not sure if this is the right place to 
> ask my question, so please let me know if there's a more appropriate 
> channel for this type of discussion.
>
> I would like to ask for feedback on my approach. I have found what I 
> believe to be the best way to move a model from one app to another in 
> Django. It involves four separate operations in at least 3 different 
> migrations:
>
>1. 
>
>Rename table operation: renames the physical table name on the 
>database. This operation should be a SeparateDatabaseAndState operation 
> and 
>only change the database, without changing any state.
>2. 
>
>Create table operation: moves the model code to the new app, and 
>creates a CreateModel only in state, with a SeparateDatabaseAndState 
>operation.
>3. 
>
>Update all foreign keys that point to the moved model.
>4. 
>
>Delete the old model table, but only in state, using a 
>SeparateDatabaseAndState operation.
>
>
> I've implemented this logic in a new method called "generate_moved_models" 
> in MigrationAutodetector. 
> 
>  
>
> This approach didn't break any existing tests, and now I'm focused on 
> writing the text using the moving model feature with other operations.
>
> Thank you all in advance for your feedback on this approach.
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/cada5a80-bb77-4f26-8a14-54f27b6c2d3cn%40googlegroups.com.


Re: Model icons

2023-02-20 Thread Marty
I really like the idea to add just a simple 'icon' attribute. That's quite 
elegant solution. Thanks, Mark! 🙂

On Monday, February 20, 2023 at 2:33:43 PM UTC+1 Jacob Rief wrote:

> I agree with Adam Johnson that adding HTML to the model class is a bit too 
> coupled.
> But I like the idea of Mark Niehues to add them to the ModelAdmin class, 
> although I would allow a HTML/SVG snippet rather than a CSS class.
>
>- How would we then handle 3rd party apps providing their own SVG file 
>to be used as icon?
>- Shouldn't that icon definition be part of the ModelAdmin's Media 
>subclass?  
>
> – Jacob
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/45c143cc-2716-430a-93cf-7c2a938640ccn%40googlegroups.com.


Re: dynamically added INSTALLED_APPS

2023-02-20 Thread Christian González

Am 20.02.23 um 14:23 schrieb Jacob Rief:
Isn't it a bit dangerous to auto-add a package from PyPI to a running 
Django installation? That module then gains full database access and 
could do all kind of nasty stuff.
Maybe I am a bit naive here, but 3rd party packages sometimes get 
installed incautiously.


Hi Jacob,

no, I don't think so. It is generally "dangerous" to run code you don't 
know what it does ;-)

In my case it is even more dangerous to run code I wrote myself, hehe.

But really, if you install ANY package via pip, you have to trust that 
package. So it doesn't matter if you install a Django GDAPS auto-plugin 
package or django-money. you would have to add it manually to your 
settings.py/ INSTALLED_APPS anyway to use it.
GDAPS is intended to enable plugins for a main application - e.g. there 
is medux, and medux.plugins.laboratory - both from the same vendor. 
There is no trust problem when installing your own packages.


Christian

--
Dr. Christian González
https://nerdocs.at

--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/12149f6c-cc96-adb0-76c8-91a704d2828f%40nerdocs.at.