Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

246
Visualizações
Sharing Django user model between two apps in the same project

I see some similar questions, but they don't appear to be the same or have answers.

I am practicing with Django and trying to make a simple dutch auction project. Initially I thought that the idea would be to create two distinct apps, a buyer app and a seller app, and just have them share databases (or three apps, a commonApp a buyerApp and a sellerApp). However, the more I dig into this the more complicated it seems - I feel like Django isn't really meant to have different apps that are designed around sharing all of their data from one set of tables (maybe I'm wrong?), loosely based on what I've found about having to modify the way Migrations work to accommodate this.

So idea #2, just make one app that separates out the functionality by carefully managing the views, but keeping just one set of models since pretty much all of the data I can think of (the users, the products, etc.) are shared anyway. This seems like it has the advantage of letting Django do all of the data management without my having to sweat about the database design. However, I worry that maybe managing the views will get to be overly complicated.

Maybe there is an idea #3 that makes sense for this sort of project, one that I haven't considered because I am a newb, maybe one that tells me that Django isn't even the right tool for this job...

I tried programming idea #1 and it quickly became spaghetti and only worked when things were very small. I am currently working on idea #2 and so far I think it's going OK, but I'm having trouble conceptualizing how to separate stuff in views, but this could very well just be my lack of experience.

So my question is: is there an obvious resource for this sort of information that I'm missing? If so, could you please point me that way?

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Inside your Django project:

manage.py startapp sellers
manage.py startapp buyers
manage.py startapp common

Add these three apps to settings.py. Depending on your Django's version it can be just 'sellers', 'buyers', 'common' or 'seller.apps.SellerConfig' and so on.

Write your models in common/models.py, and any other logic related to both apps.

Then, in your seller or buyers views:

from common.models import * # or a particular model

Hope this helps.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda