Giter Club home page Giter Club logo

django-composite-foreignkey's People

Contributors

adamstep avatar andrey-skvortsov avatar james-emerton avatar ornoone avatar selcuk avatar shun-liang avatar surgo avatar vstoykov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-composite-foreignkey's Issues

License question - GPLv3?

I wonder, the license choice for GPLv3 is atypical for Python apps. It means I cannot use the library is a different Open Source project because that project needs to stay MPL2, and can't be converted into GPLv3.

Is there is strong choice for picking this license, or more a matter for habit? In the latter case, I'd hope you can replace this license with something more permissive (e.g. MPL2 or BSD). Having a GPL licensed library is also a hard sale for corporate clients.

Have a problem with migrations: AttributeError: 'ForeignObjectRel' object has no attribute 'through'

(.env) ivan@ivan-X555LF:/extra1/biz-tek/cms-medical$ ./manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, menu, posts, sessions, users, versioning
Running migrations:
  Applying posts.0018_auto_20180504_0306...Traceback (most recent call last):
  File "./manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/extra1/biz-tek/.env/lib/python3.5/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "/extra1/biz-tek/.env/lib/python3.5/site-packages/django/core/management/__init__.py", line 365, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/extra1/biz-tek/.env/lib/python3.5/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/extra1/biz-tek/.env/lib/python3.5/site-packages/django/core/management/base.py", line 335, in execute
    output = self.handle(*args, **options)
  File "/extra1/biz-tek/.env/lib/python3.5/site-packages/django/core/management/commands/migrate.py", line 200, in handle
    fake_initial=fake_initial,
  File "/extra1/biz-tek/.env/lib/python3.5/site-packages/django/db/migrations/executor.py", line 117, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/extra1/biz-tek/.env/lib/python3.5/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/extra1/biz-tek/.env/lib/python3.5/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/extra1/biz-tek/.env/lib/python3.5/site-packages/django/db/migrations/migration.py", line 122, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/extra1/biz-tek/.env/lib/python3.5/site-packages/django/db/migrations/operations/fields.py", line 216, in database_forwards
    schema_editor.alter_field(from_model, from_field, to_field)
  File "/extra1/biz-tek/.env/lib/python3.5/site-packages/django/db/backends/base/schema.py", line 491, in alter_field
    old_field.remote_field.through and new_field.remote_field.through and
AttributeError: 'ForeignObjectRel' object has no attribute 'through'

Migration's SQL empty

I added the following CompositeForeignKey to my models and when running sqlmigrate to see the SQL generated by that migration the output is blank.

host_taxonomy = CompositeForeignKey(PrimhosttaxMsw05, on_delete=models.SET_NULL, related_name='primate', to_fields={'taxcode_id': 'taxcode_id', 'hostreportedname': 'hostreportedname'}, null=True)

Operating System: Ubuntu 16.04
Local Setup: Django 1.8.18 and python 3.5.2
Steps to reproduce:

  1. Add CompositeForeignKey to one of your models.
  2. python manage.py makemigrations {app}
  3. python sqlmigrate {app} {migration num}

Expected result: The SQL needed to create a composite foreignkey is printed to the screen
Actual Result: sqlmigrate prints nothing at all.

The reason this is a problem is because my ForeignKey is not created at the database level.

Unable to delete items with a composite foreign key in Django 4.x

>>> a = Appointment.objects.get(pk=13)
>>> a
<Appointment: 2022-07-27 23:10:00+00:00, 2022-07-27 23:20:00+00:00>
>>> a.delete()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/aaron/.virtualenvs/testproj/lib/python3.10/site-packages/django/db/models/base.py", line 1131, in delete
    collector.collect([self], keep_parents=keep_parents)
  File "/home/aaron/.virtualenvs/testproj/lib/python3.10/site-packages/django/db/models/deletion.py", line 350, in collect
    on_delete(self, field, sub_objs, self.using)
  File "/home/aaron/.virtualenvs/testproj/lib/python3.10/site-packages/compositefk/fields.py", line 59, in wrapper
    del collector.field_updates[self.model][(self, None)]
TypeError: list indices must be integers or slices, not tuple
>>> 

How to migrate this to django 4?

Not an expert in django,

is there any simple way how to write the same in django 4? I suppose there is some other native way.

makemigrations always generating field change

With Django 1.11 and Python 2.7 every time I automatically create migrations a change to the CompositeForeignKey is being generated. After some research this seems to be caused by the on_delete attribute being wrapped in a decorator, meaning the on_delete value is never equal.

foreign date

Is it possible to have CompositeForeignKey based on date range. On foreign table i have date from and to and on this table i have date. This date have to match as well.

latest version of dango

I had to comment out virtual only for the latest version of dango

def contribute_to_class(self, cls, name, virtual_only=False):
        super(ForeignObject, self).contribute_to_class(cls, name,
                                                       #virtual_only=virtual_only
        )
        setattr(cls, self.name, CompositeForwardManyToOneDescriptor(self))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.