Did you try what  David Nugent suggested? Did it worked?

On Thursday, July 27, 2023 at 6:31:33 PM UTC+8 David Nugent wrote:

> Database Router is the trick for this. Django calls this function to 
> determine which database the transaction will use based on the type of 
> operation requested, so you can separate which database is selected for 
> reads, writes and migrations.
>
> Regards,
> David
>
> On Wed, Jul 26, 2023 at 1:11 PM Muhammad Juwaini Abdul Rahman <
> [email protected]> wrote:
>
>> Hi all,
>>
>> I have two different databases as below:
>>
>> DATABASES = {
>> 'tvet': {
>> 'ENGINE': 'django.db.backends.sqlite3',
>> 'NAME': BASE_DIR / 'db.sqlite3',
>> },
>> 'default': {
>> 'ENGINE': 'django.db.backends.mysql',
>> 'NAME': 'jpk',
>> 'USER': 'jpkuser',
>> 'PASSWORD': 'jpkpassword',
>> 'HOST': 'localhost', # Or an IP Address that your DB is hosted on
>> 'PORT': '3306',
>> }
>> }
>>
>> When I want to create a CreateView, I am unable to save it.
>>
>> This is my CreateView:
>>
>> class BiodataCreateView(CreateView):
>> template_name = 'bio_create.html'
>>
>> # model = Biodata.objects.using('tvet').all()
>> def get_queryset(self):
>> return Biodata.objects.using('tvet').all()
>>
>> fields = 'name', 'hobby'
>>
>> def get_success_url(self):
>> return reverse('biodata-list')
>>
>> Any idea on how to do it?
>>
>> -- 
>>
> 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 [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/4985efd7-437c-432e-86c8-9a902430513fn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/4985efd7-437c-432e-86c8-9a902430513fn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ef988bc0-20e3-4e9b-90e5-b7d1d8abf5b3n%40googlegroups.com.

Reply via email to