How to use same Models for all apps?

29 views
Skip to first unread message

Javier L. Camacaro

unread,
Aug 27, 2022, 7:18:55 PM8/27/22
to Django users
Do i need to repeat the models for each app?, Can I use same model for all the apps in my project?


I'm a new a DJango programmer, sorry for that

Thanks!

Ryan Nowakowski

unread,
Aug 27, 2022, 7:46:13 PM8/27/22
to django...@googlegroups.com
You can use a model from one app in other apps. Simply import it in the apps where you need it.

Lakshyaraj Dash

unread,
Aug 27, 2022, 7:56:11 PM8/27/22
to django...@googlegroups.com
Ya sure you can use the same models throughout your project. If you're i a different app then import statement will be like
from appName.models import tableName
else if you're in the same app
from .models import tableName

Thanks and Regards
Lakshyaraj Dash

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d5d42018-14db-42dc-b682-fce739950eb0n%40googlegroups.com.

Samuel Alie Mansaray

unread,
Aug 27, 2022, 9:03:21 PM8/27/22
to django...@googlegroups.com
Am new in django framework, am get problem with the new version of django by adding apps and import modules.

Javier L. Camacaro

unread,
Aug 29, 2022, 9:00:51 AM8/29/22
to Django users
thanks mansar.. I did it, but I can see the data, I need to recreate data in home page, with a model freate in "Tienda" app, but I cant.

Thanks
Reply all
Reply to author
Forward
0 new messages