Giter Club home page Giter Club logo

Comments (6)

bernardopires avatar bernardopires commented on September 22, 2024

Hello,

you can overwrite the method save() from your tenant model. You then call the base save() command, to have your tenant schema created. Afterwards you can save your user normally and it will be on the new tenant.

Cheers,
Bernardo

from django-tenant-schemas.

tsalaet avatar tsalaet commented on September 22, 2024

Thanks Bernardo! I'm gonna try!

from django-tenant-schemas.

tsalaet avatar tsalaet commented on September 22, 2024

Bernardo Sorry!

I'm trying this , but in actual_schema I store the schema that I want to access right?
it's correct?

from django.db import models
from tenant_schemas.models import TenantMixin
from tenant_schemas.test.cases import TenantTestCase
from tenant_schemas.test.client import TenantClient
from tenant_schemas.urlresolvers import reverse,reverse_lazy
from django.contrib.auth.models import User

class Client(TenantMixin):
name = models.CharField(max_length=100)
paid_until = models.DateField()
on_trial = models.BooleanField()
created_on = models.DateField(auto_now_add=True)
auto_create_schema = True
def save(self, _args, *_kwargs):
super(TenantMixin, self).save(_args, *_kwargs)
actual_schema=TenantMixin.schema_name=self.schema_name

from django-tenant-schemas.

bernardopires avatar bernardopires commented on September 22, 2024

Hi Toni,

remember that Client is a tenant by itself. So here's what you can do on
your save method:

def save(self, _args, *_kwargs):
super(Client, self).save(_args, *_kwargs)
with tenant_context(self):
User(username=blabla, ...).save()

2013/3/5 Toni Salaet Larrull [email protected]

Bernardo Sorry!

I'm trying this , but in actual_schema I store the schema that I want to
access right?
it's correct?

from django.db import models
from tenant_schemas.models import TenantMixin
from tenant_schemas.test.cases import TenantTestCase
from tenant_schemas.test.client import TenantClient
from tenant_schemas.urlresolvers import reverse,reverse_lazy
from django.contrib.auth.models import User

class Client(TenantMixin):
name = models.CharField(max_length=100)
paid_until = models.DateField()
on_trial = models.BooleanField()
created_on = models.DateField(auto_now_add=True)
auto_create_schema = True
def save(self, _args, *_kwargs):
super(TenantMixin, self).save(_args, *_kwargs)
actual_schema=TenantMixin.schema_name=self.schema_name


Reply to this email directly or view it on GitHubhttps://github.com//issues/38#issuecomment-14438723
.

Bernardo Pires Carneiro

from django-tenant-schemas.

tsalaet avatar tsalaet commented on September 22, 2024

Bernardo , It's working! thanks for your help.

from django-tenant-schemas.

bernardopires avatar bernardopires commented on September 22, 2024

Great! :)

from django-tenant-schemas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.