Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
UnboundLocalError at / local variable 'Profile' referenced before assignment?
How to solve this issue of UnboundLocalError at /profile/ local variable 'context' referenced before assignment. I am seeing it to be okay? When I remove Payment_method dropdown menu,, it works but why it is not working with dropdown menu? models.py Paymet_choices = ( ('easypaisa','EasyPaisa Number'), ('jazzcash', 'Jazzcash Number'), ) class Profile(models.Model): payment_method = models.CharField(max_length=6, choices=Paymet_choices) forms.py class ProfileUpdateForm(forms.ModelForm): class Meta: model = Profile fields = ['image','Payment_method','Detail'] views.py def profile(request): if request.method == 'POST': u_form = UserUpdateForm(request.POST, instance=request.user) p_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.profile) if u_form.is_valid() and p_form.is_valid(): u_form.save() p_form.save() messages.success(request, f'Your account has been updated!') return redirect('profile') else: u_form = UserUpdateForm(instance=request.user) p_form = ProfileUpdateForm(instance=request.user.profile) context = { 'u_form': u_form, 'p_form': p_form } return render(request, 'users/profile.html', context) -
Django model translation
What is the best way to have model fields translated in Django? I've thought about adding extra fields to the model (one field for language) or creating another model with all texts in every language, is there a recommended way to achieve that? Thank you very much -
How to override a package method in Django?
I'm trying to override a parent class method that I've installed via pip. But, the problem is that I'm not sure how my overridden class will be called so that it will use my method instead of parent class method. This is the method I'm trying to override: class OIDCAuthenticationBackend(ModelBackend): def verify_claims(self, claims): """Verify the provided claims to decide if authentication should be allowed.""" # Verify claims required by default configuration scopes = self.get_settings('OIDC_RP_SCOPES', 'openid email') if 'email' in scopes.split(): return 'email' in claims LOGGER.warning('Custom OIDC_RP_SCOPES defined. ' 'You need to override `verify_claims` for custom claims verification.') return True And my overridden method is : models.py from mozilla_django_oidc.auth import OIDCAuthenticationBackend class MyOIDCAB(OIDCAuthenticationBackend): def verify_claims(self, claims): return True I've written this on models.py according to some docs I read for overriding but I'm not sure where should I actually write this. then trying to call it from my view functions like this: views.py from myapp import MyOIDCAB but then I got this error: from myapp import MyOIDCAB ImportError: cannot import name 'MyOIDCAB' I'm not sure I'm calling it in the right way or wrong? My project structure is: myproject myapp templates manage.py -
how to fix error: literal for int() with base 10: b'12 21:00:00'
i have a search form that allow user to search for records stored in the database. the problem is once the user submit the form the system display the below error: ValueError at /folder/search/ invalid literal for int() with base 10: b'12 21:00:00' Request Method: GET Request URL: http://127.0.0.1:8000/folder/search/?q=3342 Django Version: 2.1.3 Exception Type: ValueError Exception Value: invalid literal for int() with base 10: b'12 21:00:00' Exception Location: C:\Users\LT GM\AppData\Local\Programs\Python\Python37\lib\sqlite3\dbapi2.py in convert_date, line 64 Python Executable: C:\Users\LT GM\AppData\Local\Programs\Python\Python37\python.exe Python Version: 3.7.1 fullTraceback Environment: Request Method: GET Request URL: http://127.0.0.1:8000/folder/search/?q=3342 Django Version: 2.1.3 Python Version: 3.7.1 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'blog', 'widget_tweaks', 'import_export'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware'] Traceback: File "C:\Users\LT GM\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\handlers\exception.py" in inner 34. response = get_response(request) File "C:\Users\LT GM\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\handlers\base.py" in _get_response 126. response = self.process_exception_by_middleware(e, request) File "C:\Users\LT GM\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\handlers\base.py" in _get_response 124. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\LT GM\Desktop\ABenvironment\myABenv\ABdatabase\views.py" in searchFolder 252. ListID = list(FilterQuery) File "C:\Users\LT GM\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\query.py" in iter 268. self._fetch_all() File "C:\Users\LT GM\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\query.py" in _fetch_all 1186. self._result_cache = list(self._iterable_class(self)) File "C:\Users\LT GM\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\query.py" in iter 54. results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size) File "C:\Users\LT GM\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\sql\compiler.py" in execute_sql 1065. cursor.execute(sql, params) File "C:\Users\LT GM\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\utils.py" in execute 100. return super().execute(sql, params) File "C:\Users\LT … -
Django sessions: How to include session ID in every log record?
I would like to include session ID (at least portion of it) in every log entry in Django. This would help me group together logs for each user session in case several users are interacting with my Django API at the same time. I know I can retrieve session ID from Request object (when it exists) but I would have to do so for every logger.info() across the whole framework. Instead it would be much better to have Request somehow available in settings.py so that I can prepend the ID to my formatter's format string inside LOGGING config. This would ensure that the session ID is included in every log entry and I would not need to think about it in every view or serializer, etc. But I haven't found a way how to make Request or Session available in settings.py. -
Django - update dictionary with missing date values, set to 0
So to display a small bargraph using Django and Chart.js I constructed the following query on my model. views.py class BookingsView(TemplateView): template_name = 'orders/bookings.html' def get_context_data(self, **kwargs): today = datetime.date.today() seven_days = today + datetime.timedelta(days=7) bookings = dict(Booking.objects.filter(start_date__range = [today, seven_days]) \ .order_by('start_date') \ .values_list('start_date') \ .annotate(Count('id'))) # Trying to add 0 for the missing start_date within the range for start_date in (seven_days): if start_date not in bookings: bookings.update({start_date : 0}) context['booking_list'] = bookings This led me to the following result; { datetime.date(2019, 8, 6): 12, datetime.date(2019, 8, 7): 12, datetime.date(2019, 8, 9): 4, datetime.date(2019, 8, 10): 7, datetime.date(2019, 8, 12): 7 } To use the data in a chart I would like to add the missing start_dates into the dictionary but I'm not entirely sure how to do this. So I want to update the dictionary with a value "0" for the 8th and 11th of August. I tried to add the for statement but I got the error; "'datetime.date' object is not iterable" -
Why does Form submit data by POST only once in a while and then it shows an empty POST dict?
I have a simple form which asks the user to confirm Delete by clicking on Yes or No . The Yes/No (radio buttons with hidden inputs) are attached to a function which immediately submits the form on click of either of the buttons via POST. The Problem is that on submit , the POST data is shown empty , and page redirects to home page without any action . I am building it on Django 2.2. I tried changing the radio buttons to text inputs and then assigning values to them on click of Yes/No and submit the form . That too shows an empty POST Data . But yes , once in a while it works , but then it doesn't . <form method='POST' action="/{{user}}/{{del_id}}/delete"> {% csrf_token %} <h2>Confirm Delete ?</h2> <h3> {{to_delete}} </h3> <img src="" alt="" class="thumb-square"> <br> <br> <p class="center-text">This won't be recovered</p> <label id='no' data-value='Yes' class="danger-btn" onclick="submitForm(this.id)">Yes</label> <input type="text" name='Yes' id='Yes' hidden> <label id='yes' data-value='No' class="success-btn" onclick="submitForm(this.id)">No</label> <input type="text" name='No' id='No' hidden> <input type="submit" value="Delete" id='submit' hidden> </form> JavaScript <script> function submitForm(elem) { console.log(elem); var x = document.getElementById(elem); console.log(x); document.getElementById(elem).value = x.getAttribute('value'); document.getElementById('submit').click(); } </script> I want that the request.POST['Yes'] should have a value of 'Yes' … -
Django: How to prompt user during migration?
I'm writing a migration that converts a ForeignKeyField to a ManyToManyField. Part of this migration involves data migration. Migrating forwards is easy and requires no user interaction. Migrating backwards however ideally requires the user to pick which of the m2m to become the foreign key (ie there's a recognition of data loss). Additionally. the user performing the migration might want to be given a python shell so they can poke around and look at objects before answering the question. And some users might not care, and might not want to be prompted at all. (ie they use the --no-input argument during migration) Does django have a built in mechanism to do all this? I can't find anything, but at the back of my mind it seems like something I've seen somewhere. -
How to Streaming in django - javascript for audio files
first , sorry my english skill :( i want to audio file Streaming in django-javascript Once the user enters the text, they will need to create and stream audio files from it. So when users stream, does the file exist on the django server? Or how? I am curious about the way users are provided. -
How to display django message after uploading an image in form?
I created a simple django html page which enables a user to upload an image. If the image format is either PNG, JPG, JPEG or SVG, it should display a message called "Image uploaded successfully" and save the file in the directory. But, if it's any other format apart from this, it should give a message: "Unsuccessful, please upload either in PNG, JPG, SVG or JPEG". How do I display the message? I tried using the SuccessMessageMixin but it displays the message for both success and failure uploads. Please do help. You can view my current code below: models.py: from django.db import models import os from PIL import Image from datetime import date import datetime def get_directory_path(instance, filename): file_extension = os.path.splitext(filename) today = date.today() t = datetime.datetime.now() day, month, year = today.day, today.month, today.year hour, minutes, seconds = t.hour, t.minute, t.second if file_extension[1] in ['.jpg','.png','.jpeg','.svg']: filename = str(day) + str(month) + str(year) + str(hour) + str(minutes) + str(seconds) + '.png' dir = 'media' else: dir = 'others' path = '{0}/{1}'.format(dir, filename) return path # Create your models here. class Image(models.Model): image = models.FileField(upload_to = get_directory_path, default = 'media/sample.png') created_date = models.DateTimeField(auto_now = True) def __str__(self): return str(self.id) views.py: from django.shortcuts … -
join() argument must be str or bytes, not 'dict' in Django while making a form with Multi-Table inheritance
I am trying to create a form for a model that inherits from the Django auth.User class I got this issue. is there a better way to achieve it? #models.py class Teacher(User): tutor = models.OneToOneField(User, on_delete=models.CASCADE, parent_link=True) department = models.CharField(max_length=100) contact_no = models.BigIntegerField() def __str__(self): return "%s %s" % (self.tutor.first_name, self.tutor.last_name) #Forms.py class TeacherForm(forms.ModelForm): class Meta: model = Teacher fields = ('username', 'first_name', 'last_name', 'email', 'contact_no', 'department') Django Version: 2.2.3 Exception Type: TypeError Exception Value: join() argument must be str or bytes, not 'dict' -
Select a valid choice. ["objects"] is not one of the available choices. in Djngo
I'm going to create a form where the user can select any number of objects from the options.(MultipleChoiceField) Here are my files: OBJECT_CHOICES = ( ('1','object1'), ('2','object2'), ('3','object3'), ) # Models.py Class ObjectModel(models.Model): objects = models.CharField(max_length=250, choices=DAY_CHOICES) # Forms.py class ObjectsForm(ModelForm): objects = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple, choices=OBJECT_CHOICES) class Meta: model = ObjectModel fields = '__all__' When I click on the submit button (for example select object 1 and 2), I get this error: Select a valid choice. ['1', '2'] is not one of the available choices.- -
LinkedIn Auth v.20 extra data setting in settings.py LinkedIn
I am trying to let users log in with LinkedIn but I couldn't find the clear documentation on field selectors and extra data settings for lite profile not basic profile. Here is in settings.py. SOCIAL_AUTH_LINKEDIN_OAUTH2_SCOPE = ['r_liteprofile', 'r_emailaddress'] SOCIAL_AUTH_LINKEDIN_OAUTH2_FIELD_SELECTORS = ['email-address', 'first-name', 'last-name', 'picture-url'] SOCIAL_AUTH_LINKEDIN_OAUTH2_EXTRA_DATA = [ ('id', 'id'), ('first-name', 'first_name'), ('last-name', 'last_name'), ('email-address', 'email_address'), ('picture-url', 'picture_url'), ] Are these correct? Is there a good reference site for this? -
Is there a way to separate "addtocart" and "buynow" from the same form?
I'm making a e-commerce website, right now I have a buy now button, when pressed will add item to cart and redirect to "cart" page, I want to have a "addtocart" botton which will add the product to card but won't redirect under the same function. Please help me carts/modes.py def buy_now(request, slug): request.session.set_expiry(120000) try: the_id = request.session['cart_id'] except: new_cart = Cart() new_cart.save() request.session['cart_id'] = new_cart.id the_id = new_cart.id cart = Cart.objects.get(id=the_id) try : product = Product_info.objects.get(slug=slug) except Product_info.DoesNotExist: pass product_var = [] if request.method == 'POST': qty = request.POST['qty'] for item in request.POST: key = item val = request.POST[key] print(key,val) try: v = Variation.objects.get(product = product,cat__iexact=key,title__iexact=val) product_var.append(v) except: pass cart_item = CartItem.objects.create(cart = cart,product = product) if len(product_var) > 0: cart_item.variations.add(*product_var) cart_item.quantity = qty cart_item.save() return HttpResponseRedirect(reverse("cart")) return HttpResponseRedirect(reverse("cart")) template.html <form class="form pull-right" method='POST' action="{% url 'buy_now' product.slug %}"> {% csrf_token %} {% if product.variation_set.all %} {% if product.variation_set.models %} <select class = "form-control" name='model'> {% for item in product.variation_set.models %} <option value ="{{ item.title }}">{{ item.title }}</option> {% endfor %} </select> {% endif %} {% if product.variation_set.sizes %} <select class = "form-control" name='size'> {% for item in product.variation_set.sizes %} <option value ="{{ item.title }}">{{ item.title }}</option> {% endfor … -
DRF: How to limit fields in nested serializer based on field-permissions?
I'm trying to limit the fields list in serializers based on user permissions. I have a generic routine that does it for all serializers. It's working on the parent serializer, but not on a nested serializer. I have a client model, and a client profile (referred to as "contacts") as shown below. The client profile model is an extension of the user model (one-to-one relationship). class Client(AddressPhoneModelMixin, DateFieldsModelMixin, models.Model): name = models.CharField(max_length=100) status = models.CharField(max_length=25) class Meta: permissions = ( # Object-level ('view_all_clients', 'Can view all clients'), ('change_all_clients', 'Can change all clients'), # Field-level ('view_client_id', 'Can view client ID'), ('view_client_name', 'Can view client name'), ...others omitted... ) class ClientProfile(models.Model): user = models.OneToOneField( User, on_delete=models.CASCADE, blank=True, null=True, ) client = models.ForeignKey( Client, on_delete=models.PROTECT, related_name='contacts', ) receive_invoices = models.BooleanField(default=False) My object-level permission logic is in the list view: class ClientList(ListAPIView): permission_classes = (IsAuthenticated,) serializer_class = ClientSerializer def get_queryset(self): user = self.request.user queryset = None if user.has_perm('view_client') or user.has_perm('clients.view_all_clients'): queryset = Client.objects.all().exclude(status__in=['deleted', 'archived']) if user.has_perm('view_client'): # View only "assigned" clients if user.type == 'client': # See if user is a "contact". queryset = queryset.distinct().filter(contacts__user=self.request.user) else: # See if user is assigned to projects for the client(s). queryset = queryset.distinct().filter(projects__project_users__user=self.request.user) if queryset is None: … -
Django + Postgres: A string literal cannot contain NUL (0x00) characters
I'm syncing a large amount of data and I'm getting this error back: A string literal cannot contain NUL (0x00) characters. Obviously this is a postgres problem, but I'm not quite sure how to solve it. Is there a way to strip null characters out at the Django model level? I have a large set of fields that I'm syncing. -
Django - Not full parsing json nested response within template in for loop
I am trying to parse my nested json output: { "links": { "self": "04h.net:1766/api/v1" }, "data": [ { "type": "part", "id": "BS_SSL", "attributes": { "commut": "YES", "origin": "UTIL", "prot": [ "PESITSSL" ], "rauth": "*", "sap": [ "19" ], "sauth": "*", "syst": "UNIX", "tcp": [ { "type": "tcp", "id": "1", "attributes": { "cnxin": "2", "retryw": "7", "host": [ "bs.net" ], "verify": "0" } } ] }, "links": { "self": "04h.net:1766/api/v11" } }, { "type": "part", "id": "9M_SSL", "attributes": { "commut": "YES", "origin": "UTIL", "prot": [ "PESITSSL" ], "rauth": "*", "sap": [ "19" ], "sauth": "*", "syst": "UNIX", "tcp": [ { "type": "tcp", "id": "1", "attributes": { "cnxin": "2", "retryw": "7", "host": [ "9m.net" ], "verify": "0" } } ] }, "links": { "self": "04h.net:1766/api/v12" } }, i need to edit (bold, underline, italic) keys, values and subkeys and subvalues and so on and so on, i had raw response rendered (like the one i linked up here) but its not enough anymore. with template {% if response %} {% for key, value in response.items %} <b>{{ key }}:</b> {% for key2, value2 in value.items %} {{ value2 }} <br> {% endfor %} {% endfor %} {% else %} <p>No IDs are … -
GeoDjango, distance filter based on database column taking into account the radius of both the seeker and the one he is looking for
I need to find objects taking into account the radius of both the seeker and the one he is looking for. How i can do this? At now i can filter from seeker side: n_range = Obj.objects.filter(location__distance_lt=( obj.location, Distance(mi=obj.radius) ) ) This is my model: class Obj(models.Model): RADIUS_CHOICES = [ (1, "1 km round"), (2, "2 km round"), (3, "3 km round"), ] radius = models.PositiveIntegerField( default=RADIUS_CHOICES[0][0], choices=RADIUS_CHOICES ) location = models.PointField(null=True, blank=True) It is necessary that in the end result there should be only those objects that fall into the radius of the seeker, and at the same time, the seeker must fall into the radius of those whom he seeks -
How to use highstock with django
I can't use Highstock correctly. I'm trying to display candle stick chart with using django and highstock. My code transfer some ohlcv data from django backend to html frontend in json format. And Highstock displays chart but not correctly. I read highstock official documents but I can't understand many options because of I'm newbie(not only python and java script even programing). Please look at my code and a result. I'd like to teach me. models.py from django.db import models class OandaChartData(models.Model): exchange_name = models.CharField(max_length=50) pair = models.CharField(max_length=10) open_time = models.DateTimeField() open_value = models.FloatField() high_value = models.FloatField() low_value = models.FloatField() close_value = models.FloatField() volume = models.FloatField() write_time = models.DateTimeField(null=True) views.py from django.shortcuts import render from .models import OandaChartData from django.core import serializers import json from datetime import timezone def highstock_view(request): record_list = [] records = OandaChartData.objects.all().order_by("id")[0:43200] for record in records: open_time = record.open_time.replace(tzinfo=timezone.utc).timestamp() * 1000 open_value = record.open_value high_value = record.high_value low_value = record.low_value close_value = record.close_value volume = record.volume record_list_tmp = [open_time, open_value, high_value, low_value, close_value, volume] record_list.append(record_list_tmp) record_json = json.dumps(record_list) return render(request, 'scraping/highstock_view.html', {'record_json':record_json}) HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>HighStockView</title> </head> <body> <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> <script src="https://code.highcharts.com/stock/highstock.js"></script> <script src="https://code.highcharts.com/stock/modules/exporting.js"></script> <div id="container" style="height: 400px; min-width: 310px"></div> <script> let … -
How to store SVG files in Django model?
I've got a simple Django template that allows a user to input an image from the system. It should accept only JPEG, JPG, PNG and SVG files. The first three seems to work well. However, SVG doesnt get uploaded. Instead, it sends an error message stating: 'Upload a valid image. The file you uploaded was either not an image or a corrupted image' How do I store a SVG file into my database model? You can view my current code below: models.py from django.db import models import os from PIL import Image from datetime import date import datetime def get_directory_path(instance, filename): file_extension = os.path.splitext(filename) today = date.today() t = datetime.datetime.now() day, month, year = today.day, today.month, today.year hour, minutes, seconds = t.hour, t.minute, t.second if file_extension[1] in ['.jpg','.png','.jpeg','.svg']: filename = str(day) + str(month) + str(year) + str(hour) + str(minutes) + str(seconds) + '.png' dir = 'media' else: dir = 'others' path = '{0}/{1}'.format(dir, filename) return path # Create your models here. class Image(models.Model): image = models.ImageField(upload_to = get_directory_path, default = 'media/sample.png') created_date = models.DateTimeField(auto_now = True) def __str__(self): return str(self.id) forms.py: from django import forms from myapp.models import Image class ImageForm(forms.ModelForm): """Image upload form""" class Meta: model = Image exclude … -
how to fix this exception in django code?
i have a search form that allow the user to search for stored records in the database where the user enter the number and the function will get the user input from the URL. the problem is that is always display the below error: ValueError: invalid literal for int() with base 10: b'12 21:00:00' i don't know what it mean and how to fix it. views.py def searchFolder(request): query = request.GET.get('q') try: print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>", len(query)) print("search for :",query) FilterQuery = Folder.objects.filter(Q(FolderNum__icontains = query)) print("FilterQuery============================", FilterQuery) ListID = list(FilterQuery) if query == "": messages.error(request,"Search field is empty!") print("Search field is empty!!!!!!!!!!!!!!!!") return redirect('create_folder_test') elif ListID == []: messages.error(request,"Record not found/does not exist!") print("Record does not exist!!!!!!!!!!!!!!!!") return redirect('create_folder_test') else: return render(request, 'blog/update2.html', {'FilterRecords': ListID}) except Exception as e: messages.error(request,"ValueError") print("Value Error!!!!!!!!!!!!!!!!",e) return redirect('create_folder_test') -
Is there 3rd party software for storing and displaying, but not processing payment information?
My business (travel agency) must accept payment from a customer, then broker the payment directly to the travel provider (say, a cruise line). The providers do not have API's, and it is not customary (nor financially viable) to actually process the payment to our own merchant account. This means customers supply us with card information which we have to store, queue to accounting, then remit the payment to the supplier. We are currently producing an in-house proprietary software package for the business. We need to have this functionality, but we would like to issue private keys to only a handful of local machines capable of decrypting the data to plain text. The back end is powered by Django and most of the modules it supports are to a VUE.JS front-end application. Is there an established approach for doing this? Are there any 3rd party providers we could off load this to? All of the 3rd parties I see are only for processing the payment, not to view it later in plain text to remit to an entirely different vendor. None of the major travel providers accept payment cooperation with Stripe or any such 3rd party. -
How to call a function before a django app start?
In my django project i have to check if a database/table exist before starting application, i don't know how is better insert the code for check. I try to add in views.py into login function a try except block but i was try to find an elegant and more effective solution. Thanks in advance -
Usage permissions for AppHooks in DjangoCMS
I'm registering a new custom AppHook in DjangoCMS (v.3.5.3): @apphook_pool.register class CustomAppHook(CMSApp): name = _("CustomAppHook") def get_urls(self, page=None, language=None, **kwargs): return ["customapp.urls"] I want to hide this app hook in the dropdown menu in the extended page settings. Only superusers should see and use it. To exclude the "extended page settings" for other users/groups is no option here... Is there another decorator to use? There exists the permissions = True attribute in the CMSApp class. But this says: "if set to true, apphook inherits permissions from the current page". Not excactly what I want/need. -
Django : Fetch application User Model for multiple application from Central Database
Django : I have 6 applications which are already live but they have their own user database table and Model(All have different field names and they have their own extra column.Now I have to go and add user in every application. I have one Idea that I can create cron job which syncs data to current database from central database, but still I have to maintain all local database. Can I use something like singleton class and remove applications user database and sync user object once from central database and use that? I am new to django and I would welcome any suggestions or any implementation sample.