Django Models

58 views
Skip to first unread message

göktürk sığırtmaç

unread,
Aug 8, 2019, 8:37:00 PM8/8/19
to Django developers (Contributions to Django itself)
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.

RAVVE MAALIE

unread,
Aug 8, 2019, 9:20:23 PM8/8/19
to django-d...@googlegroups.com
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ç <s.gok...@gmail.com> 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 django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/91e6ab67-868b-4f83-a2da-6a04646a97b0%40googlegroups.com.

Adam Johnson

unread,
Aug 9, 2019, 3:32:53 AM8/9/19
to django-d...@googlegroups.com
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



--
Adam
Reply all
Reply to author
Forward
0 new messages