Thursday, February 27, 2020

Re: Is it possible to extend the model in another application without explicitly changing firs-one?

It is indeed possible, but I am not sure whether it should be done this way. 

On Thu, Feb 27, 2020 at 11:04 PM Ol P <olp@global-mediator.com> wrote:
I try to figure out if it possible to implement the next scenario:

garage (app-A)
 models
   
class Vehicle(models.Model)
     vin
=models.CharField(max_length=50)
     
...

     
def import_data(self):
       
...
       
# import vehicals


external integration
(app-B)
 models
   
class ExtendedVehicle(Vehicle)
     external_field
=models.CharField(max_length=50)

     
def import_data(self):
        super(ExtendedVehicle, self).import_data()
        self.import_external_field()

     def import_external_field(self):
        ...
        # import external_field


Something like this.


On Thursday, February 27, 2020 at 7:11:20 PM UTC+2, Jin wrote:
One-time class definition is always good choice, I won't do it like that.
But can you share the detailed scenario you are gonna implement?

On Fri, Feb 28, 2020 at 1:03 AM Ol P <o...@global-mediator.com> wrote:
I want to extend model-A from app-B without modification of app-A
For example, add a field or new methods or override existing.

On Thursday, February 27, 2020 at 6:54:37 PM UTC+2, Jin wrote:
Not sure if I understand the question correctly, but are you trying to use model-A in app-B?

On Fri, Feb 28, 2020 at 12:33 AM Ol P <o...@global-mediator.com> wrote:
Imagen we have app-A and app-B with model-A and model-B accordingly.
And we want to extend model-A in app-B.
What should be written in model-B to implement it?

In other words, is it possible to implement the same-table extension?

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/035f39c8-cc71-4ae5-81ed-53f2c0d4aee3%40googlegroups.com.

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9e98c0dc-547c-4b99-8bc3-f31187444f98%40googlegroups.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d3dce9e3-bd95-495e-85b3-a359c21dc95e%40googlegroups.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOX69xrux_rM1vJYHy-6CFYc5fFQPndWK_wn1EMiH%2BY%3DGP9q%2BA%40mail.gmail.com.

No comments:

Post a Comment