Django Models

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Django Models

göktürk sığırtmaç
Hi, I'm developing app with django. I have users module. My database schema users table and address table. Address table have foreign key from users table. Now how can compose app architecture? Should i new module as address and i should put address model etc. or Should i write address table in users model? Does second choose violate single responsibility principle.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/91e6ab67-868b-4f83-a2da-6a04646a97b0%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Django Models

RAVVE MAALIE
Actually you can refer to one to many relation model.

Its like one user has multiple address
Or
One adress has multiple users.

In models file.
You can make changes.
Like
For 1 user multiple address
Eg:
Class User(models.Model):
            User_name= models.Charfield()
Class address(models.Model):
            Adressss=model.ForeignKey(User, on_delete=models.CASCADE)




On Fri, Aug 9, 2019, 02:36 göktürk sığırtmaç <[hidden email]> wrote:
Hi, I'm developing app with django. I have users module. My database schema users table and address table. Address table have foreign key from users table. Now how can compose app architecture? Should i new module as address and i should put address model etc. or Should i write address table in users model? Does second choose violate single responsibility principle.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/91e6ab67-868b-4f83-a2da-6a04646a97b0%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAAB4E736Xwbzfe-ypFxcsM2jhex-J%2BOUvqbsoYtr%2B01nm2NsxA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Django Models

Adam Johnson-2
Hi!

I think you've found the wrong mailing list for this post. This mailing list is for the development of Django itself, not for support using Django. This means the discussions of bugs and features in Django itself, rather than in your code using it. People on this list are unlikely to answer your support query with their limited time and energy. Read more on the mailing lists at https://www.djangoproject.com/community/

For support, please use the django-users mailing list, or IRC #django on Freenode, or a site like Stack Overflow. There are people out there willing to help on those channels, but they might not respond if you don't ask your question well. Stack Overflow's question guide can help you frame it well: https://stackoverflow.com/help/how-to-ask .

Also if you haven't read it, please take a look at Django's Code of Conduct: https://www.djangoproject.com/conduct/ . These are our "ground rules" for working well as a community, and will help you get the most out of Django and our fantastic community.

As for your question - the Django official tutorial guides you through creating some models with foreign keys, so should serve as a great starting point for you: https://docs.djangoproject.com/en/2.2/intro/tutorial01/ . Also see my blog post https://adamj.eu/tech/2019/03/21/where-to-learn-django-in-2019/ for more learning resources.

Thanks for your understanding,

Adam

On Fri, 9 Aug 2019 at 02:17, RAVVE MAALIE <[hidden email]> wrote:
Actually you can refer to one to many relation model.

Its like one user has multiple address
Or
One adress has multiple users.

In models file.
You can make changes.
Like
For 1 user multiple address
Eg:
Class User(models.Model):
            User_name= models.Charfield()
Class address(models.Model):
            Adressss=model.ForeignKey(User, on_delete=models.CASCADE)




On Fri, Aug 9, 2019, 02:36 göktürk sığırtmaç <[hidden email]> wrote:
Hi, I'm developing app with django. I have users module. My database schema users table and address table. Address table have foreign key from users table. Now how can compose app architecture? Should i new module as address and i should put address model etc. or Should i write address table in users model? Does second choose violate single responsibility principle.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/91e6ab67-868b-4f83-a2da-6a04646a97b0%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAAB4E736Xwbzfe-ypFxcsM2jhex-J%2BOUvqbsoYtr%2B01nm2NsxA%40mail.gmail.com.


--
Adam

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAMyDDM2zhRXHUzddTEKAzbuK8vmPUT17QU0xPy%3DdxCvjrUrCYw%40mail.gmail.com.