Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Pythonanywhere Database Configurations
I have a remote database server in godaddy. I want to use that for database connectivity for my Django Project. Because, I want to access the data stored in pythonanywhere database and it is said that, it is accessible unless you have the SSH keys which is provided only if you have paid account. Is there a way to configure the settings.py database values to access it remotely from a java program? Thank you! -
this cannot be nulll django..?
my email should be ended with "ac.uk" so i put this one in form class MyUserCreationForm(UserCreationForm): def clean_email(self): if not self.cleaned_data['email'].endswith('ac.uk'): raise forms.ValidationError('You need to use ac ID') UserCreationForm class UserCreationForm(forms.ModelForm): password1 = forms.CharField(label='Password', widget=forms.PasswordInput(attrs={'placeholder': 'Password'}) ) password2 = forms.CharField(label='Password confirmation', widget=forms.PasswordInput(attrs={'placeholder': 'Password confirmation'})) class Meta: model = MyUser def __init__(self, auto_id='%s', *args, **kwargs): super(Meta, self).__init__(*args, **kwargs) self.fields['Mother_language'].choices = ('','Please choose ') + models.Language_list self.fields['Mother_language'].choices = ('','Please choose ') + models.Language_list widgets = { 'email': forms.TextInput(attrs={'size':30,'placeholder': 'Email'}), 'username': forms.TextInput(attrs={'size':30,'placeholder': 'UserName'}), 'status_message': forms.TextInput(attrs={'height':50,'placeholder': 'Write your message'}), } fields = ('email','username','Mother_language','Nationality','Wish_language','Profile_image','status_message') and my view. def register(request): registered = False if request.method == 'POST': user_form = MyUserCreationForm(data=request.POST) if user_form.is_valid(): user = user_form.save() user.save() if 'Profile_image' in request.FILES: user.Profile_image = request.FILES['Profile_image'] user.save() registered = True else: print(user_form.errors) else: user_form = MyUserCreationForm() return render(request, 'LanguageExchange/register.html', {'user_form': user_form, 'registered': registered}) when I remove MyUserCreationForm, it is working, but when i do, it is not... and also, it said this field cannot be null.... plz help me. -
Why can't I import User model in django?
I am building a django web app with a custom user model which extends the AbstractBaseUser. In one of my models I need to use this custom user model: from accounts.models import User class History(models.Model): user = models.ForeignKey(User) job = models.ForeignKey(Job) When I try to run the python manage.py makemigrations command this error message is outputted: ImportError: cannot import name User In my settings.py I do the following to let django know that there is a custom user model: AUTH_USER_MODEL = "accounts.User" I am puzzled as to what I am doing wrong. Surely there must be a way to import this model that I do not know of. How do I fix this? Thank you in advance. -
Multiple formsets on the same page in Django
So I have several connected models. I need to have several formsets which the user can dynamically add (via add more button) all on the same page. So if a person's has more than 1 job, they'd click the "add more" button and another workingexperience form would appear underneath it. You get the idea. class Resume(models.Model): user = models.OneToOneField(User) image = models.ImageField() name = models.CharField(max_length=200) class WorkingExperience(models.Model): resume = models.ForeignKey(Resume) position = models.CharField(max_length=40) company = models.CharField(max_length=70) class Education(models.Model): field_of_study = models.CharField(max_length=40) currently_studying = models.BooleanField() resume = models.ForeignKey(Resume) class Skill(models.Model): name = models.CharField(max_length=30) resume = models.ForeignKey(ZonaCV) class Language(models.Model): name = models.CharField(max_length=20) level = models.CharField(choices=language_levels, max_length=3) resume = models.ForeignKey(Resume) I'm using modelforms and inlineformset_factory together with MultiModelForm from django-betterforms. (just normal modelforms above this) class ZonaCVMultiForm(MultiModelForm): form_classes = OrderedDict(( ('resume', ResumeForm), ('workexp', WorkExpFormset), ('eduform', EduFormset), ('skillsform', SkillFormset), ('langform', LanguageFormset), ... )) I've used django-dynamic-formset (jquery), because I've used it in the past(for one formset). Now I seem to have a hit a wall (over a week) and can't seem to go anywhere. What my template looks like: {% block content %} <form action="" method="post">{% csrf_token %} <div id="resume">{{ form.resume}}</div> <div id="workexp">{{ form.workexp}}</div> <div id="eduform">{{ form.eduform}}</div> <div id="skillsform"> {{ form.skillsform}}</div> <div id="langform">{{ form.langform}}</div> … -
Subtract or add datetime fields which are returned from djangomodel
After searching, I could not find an answer to my problem. I have this model: class Subtask(models.Model): Created_subtask_date = models.DateTimeField(default=timezone.now, null=True) subflag = models.BigIntegerField(default=0, null=True) def __str__(self): return str(self.Created_subtask_date) As you can see this object returns a string which is the created date of the subtask. My problem is how can I substract or add two objects (two datetimes) of this model. For example if I have subtask1 which is equal with the date of this task. Then I have another object (eg subask 2) which has another date. I tried to convert them to integer but with no success. Any help is highly appreciated -
Django Web App Integration with Salesforce via Heroku Connect
I'm working on integrating Salesforce with my Django web app via Heroku Connect. I'm using Postgres for my database. I've set up Heroku Connect so that my Salesforce tables are replicating to Postgres correctly: However, I'm not sure how to access the "salesforce" schema in code. (E.g. in views.py file). I've taken a look at this tutorial to set up my settings.py file but I'm still unsure of the syntax needed to access and update the "salesforce" schema in code. Can someone point me in the right direction please? -
Django duplicate signal receiver
According to the docs, a signal might be connected multiple times to a receiver, even when the user code connects the signal only once. To prevent this, one must supply a dispatch_uid argument to the connect method of the signal. To connect signals and receivers, one can use the receiver decorator, which does not supply dispatch_uid when calling connect. My question is, can a signal be connected multiple times when using the receiver decorator? My guess is it can, since the user code will be run twice regardless of whether it's calling the connect method or defining a decorated function. -
rendering ordered dic in django template
I have an ordereddic in python which I can access to its element in python using the following code: for value in orderedDict: for val in orderedDict[value]: print(orderedDict[value][val]) Now I am trying to render it via django templates. First I used this code and it works. <body> {% for value in orderedDict %} <tr><td> {{ value }} </td></tr> {% endfor %} </body> but when I going to access nested values, I can not get any results. <body> {% for value in orderedDict %} {% for val in orderedDict[value] %} #I tried orderedDict.value too but doesn't work. <tr><td> orderedDict[value][val] </td></tr> {% endfor %} {% endfor %} </body> Can you help me how can fix this problem? -
Replace Django Request/Response with Send/Receive messages by Celery Workers?
I'm having issues while building an API Gateway for a micro-services architecture app. Due to security's risk of child services and avoiding complex tasks when building API Gateway, I've decided to use message queue architecture for communication between services, not use Django HTTP request anymore. So how can I make Celery Workers get the existed messages I've sent from another instances? Below are the only document I've found but it seems not enough for my issues. http://celery.readthedocs.io/en/latest/userguide/extending.html May workers from a instance get messages stored from result backend of another instance? Regards. -
Django multiple checkbox form with raw quesyset
I have two model: class items(models.Model): type = models.CharField() model = models.CharField() class cart(models.Model): client = models.ForeignKey(client, on_delete=models.CASCADE) type = models.CharField() What I want to do is to create a form that show all the items' type not already into the cart for a client. I need a multiple checkbox (and possibly an header checkbox for "select all") I made this form manually but there is a way to make it using django form? I tried with this code but I'm not sure that this is the best solution. How can I add a "select all" checkbox? form.py class AddItemsForm(Form): def __init__(self, *args, **kwargs): self.client_id = kwargs.pop('client_id') super(AddItemsForm, self).__init__(*args, **kwargs) pl = items.objects.raw("SELECT * FROM app_items WHERE type NOT IN (SELECT type FROM app_cart WHERE client_id = %s)" % self.client_id) b = [] for p in pl: b.append([p.type, p.type]) self.fields["choices"] = MultipleChoiceField( choices = b, widget = CheckboxSelectMultiple, ) self.fields['choices'].label = '' view.py: def pricelist_addcountries_form(request, client_id): if request.method == 'POST': form = AddItemsForm(request.POST) if form.is_valid(): ... return redirect(reverse('app:index')) else: form = AddItemsForm(client_id=client_id) return render(request, 'app/form.html', {'form': form}) thanks in advance! -
Django display log in admin interface
I'm experimenting with Django and I created a simple model with a name. The name refers to a logger with the same name. I want to display all logs of this logger in the admin interface. How can I do this? Thanks in advance -
Edit UserProfile information in Django
Problem description: UserProfile form doesn't save any data. I am creating a new User and automatically create a UserProfile object for him (so I'm extending UserProfile), so I can go to admin page and fill all the fields . But when I'm trying to do it from client side, my form just doesn't catch the data. Also the strangest moment is that I can change username and email using UserChangeForm, so I'm trying to do the same for UserProfileObject. models.py: class UserProfile(models.Model): user = models.OneToOneField(User) image = models.ImageField(upload_to='profile_image', blank=True) title = models.CharField(max_length=100, default = '') first_name = models.CharField(max_length=200, default = '') last_name = models.CharField(max_length=200, default = '') subject = models.ManyToManyField('Subject', related_name='tutor_type', default = '', help_text="Select a subject") AREA_STATUS = ( ('Jerusalem', 'Jerusalem'), ('Tel Aviv', 'Tel Aviv'), ('Haifa', 'Haifa'), ('Eilat', 'Eilat') ) area = models.CharField(max_length=200, choices=AREA_STATUS, blank=True, default='', help_text='Tutor area') # Foreign Key used because tutor can only have one area, but area can have multiple tutors # Author as a string rather than object because it hasn't been declared yet in file. description = models.TextField(max_length=4000, help_text="Enter a brief description about yourself") charge = models.IntegerField(default = '0') # ManyToManyField used because Subject can contain many tutors. Tutors can cover many subjects. … -
Ask the user to choose one or multiple dictionary keys with django forms
I have a view which generates a dictionary in the following format: dict = {key1:[id,site], key2:[id,site], key3:[id,site]} I want a form which shows the keys to the user and saves on my db the one he clicks on. I thought that I might do this redirecting him to an url mysite/selection/id where that's the id of the selected key (in other words dict['selected_key'][0]) Doing this in this view (mysite/selection/id) I can register the user selection (getting the id from the url and the rest from the id) but there must be a way to automatically save the key, id and name to my database without the need of this extra view mysite/selection/id right? Also, I can't manage to render the dictionary keys in my django template. So far I have: start.html <h3>What do you want to track?</h3> {% for key in dict %} <form method="post" action="{% url 'selection' id %}" enctype="multipart/form-data"> {% csrf_token %} <input type="submit" value={{url}} /> </form> {% endfor%} And my form is: class SelectionForm(forms.ModelForm): class Meta: model = Selection fields = ['key', 'id', 'name'] widgets = { 'key': forms.ChoiceField(), 'name': forms.HiddenInput(), 'id': forms.HiddenInput(), } I thought that the ChoiceField might be correct in this case, but probably … -
Sharing content with all users in Django
I have base of website and register and login form. I want to make website, whose users would be able to upload pictures so other users can see them. For now i am only aware of option that lets user upload picture, but only the user himself can see it. I have been looking for anwser for long time but no right answer. If im not clear i am happy to explain once more. I would appreciate help -
How to pass form id if there are several forms on page and no submit buttons Django 1.10?
I have a page with list of questions. Each of them has radio button form with "Yes", "Maybe", "No" kind of choices. This form's submits by making a choice. http://prntscr.com/embo1m I can't understand how to connect question id with it's form. How to get it in it's view with response? models.py class Answer(models.Model): user = models.ForeignKey(User) apartment = models.ForeignKey(Apartment) question = models.ForeignKey(Question) choice = models.IntegerField(default=2) def __str__(self): return str(self.choice) views.py def questions_list(request, apartment_pk): if request.method == 'POST': form = AnswerForm(request.POST or None) if form.is_valid(): print(form.cleaned_data) else: context = {} context['apartment'] = get_object_or_404(Apartment, pk=apartment_pk) context['questions'] = get_list_or_404(Question) context['answer_form'] = AnswerForm context['username'] = auth.get_user(request).username return render(request, 'main/questions.html', context) forms.py class AnswerForm(ModelForm): choice = ChoiceField(label='', widget=RadioSelect, choices=ANSWERS) question_id = CharField(widget=HiddenInput(), required=False) class Meta: model = Answer fields = ('choice', 'question_id') template <h1>{{ apartment.title }}</h1> {% for question in questions %} <h3>{{ question.title }}</h3> <form id="{{ question.id }}" name="question_{{ question.id }}" action="/apartments/{{ apartment.id }}/" method="post"> {% csrf_token %} {% for radio in answer_form.choice %} <label><input name="choice" type="radio" value="{{ radio.choice_value }}" onchange="question_{{ question.id }}.submit()">{{ radio.choice_label }}</label> {% endfor %} {{ answer_form.hidden_field }} </form> {% endfor %} -
How do I make the values saved from a CheckboxSelectMultiple populate my edit form in Django?
I'm trying to create a working edit view. Creating the user profile works perfectly. I can see the saved checkbox values in the admin, but when I go to edit the form, everything renders correctly except the checkboxes. These are empty as if no values had been saved. If I select new values and submit the edit form, the new values are saved correctly, so my problem is just getting the saved values to appear as checkmarks. My form is: class ProfileUserForm(forms.ModelForm): class Meta: model = ProfileUser fields = ('field1', 'field2','field3','field4', 'chosencategories') chosencategories = forms.ModelMultipleChoiceField( widget=forms.CheckboxSelectMultiple, queryset=Category.objects.all(), to_field_name="name") Based on these Models: class ProfileUser(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL) field1 = models.CharField(max_length=155, blank=True) field2 = models.CharField(max_length=155, blank=True) field3 = models.DateField(blank=True) field4 = models.CharField(max_length=255, blank=True) chosencategories=models.ManyToManyField(Category, blank=True, null=True, related_name='categorieschosen') def __str__(self): return self.user.username class Category(models.Model): name=models.CharField(max_length=100, choices=CATEGORIES) class Meta: verbose_name_plural = "categories" def __str__(self): return self.name Here is my edit view at present: @login_required def edit_user_profile(request, username): user = request.user userprofile = ProfileUser.objects.get_or_create(user=user)[0] if request.method == 'POST': profile_form = ProfileUserForm(request.POST, instance=userprofile) if profile_form.is_valid(): updated_user_profile=profile_form.save(commit=False) updated_user_profile.user = user updated_user_profile.save() profile_form.save_m2m() return HttpResponseRedirect(reverse('accounts:userprofile', kwargs={'username': user.username})) messages.success(request, ('Your profile was successfully updated!')) else: messages.error(request, ('Please correct the error below.')) else: profile_form = ProfileUserForm(instance=userprofile) return render(request, 'accounts/edit_user_profile.html', … -
Django - performance practice to assign request.user to variable in view
Probably, it is the silliest question here, but I have a view with lots of request.user like: def my_view(request): some_stuff1 = request.user.param1 some_staff2 = request.user.param2 if request.user.param3 > request.user.param4: // another stuff with request.user So, the question is, will it be better for performance to make something like user = request.user somewhere in the beginning of view? Where is the tag for stupid questions? -
Duplicate F Objects from database
Currently, I am in the process taking my data out of the database to do simple addition, Views.py `def final(request): questions = Question.objects.annotate( s=F('question1') + F('question2') + F('question3') + F('question4') + F('question5') + F('question6') + F( 'question7') + F('question8') + F('question9') + F('question10')) for q in questions: print(q.s) return render(request, 'music/final.html', {'questions': questions, 'rows': Question.objects.all()})` Currently, if I have one object in the database (which would be a name, alongside answers to the 10 questions the user was asked from between 1-4) I would want it to look like above, But as more entries are put into the database it comes showing the same answer multiple times (example below) I'm not sure why this is happening, and I feel it's because my F statement is also pulled all the objects from the database along from my Question.object.all statement. -
Request to local host using Electron
How do I go about making a HTTP GET request to localhost using electron? I have a database that was created using Django and I just need to get information from an API that holds the information from this database? I am also using WebStorm as an IDE. Thanks for the help ! -
django how to distinguish user's email ?
I want to user register their email's end "ac.uk". if it is not, they got some messages. i do not know how to handle.. plz help me.. if not request.FILES['email'].endswith("ac.uk"): bring MultiValueDictKeyError at /LanguageExchange/. this is my view. def register(request): registered = False if request.method == 'POST': user_form = UserCreationForm(data=request.POST) if user_form.is_valid(): if not request.FILES['email'].endswith("ac.uk"): messages.warning(request, 'You need to use ac ID', extra_tags='alert') return redirect('/LanguageExchange/') else: user = user_form.save() user.save() if 'Profile_image' in request.FILES: user.Profile_image = request.FILES['Profile_image' user.save() registered = True else: print(user_form.errors) else: user_form = UserCreationForm() return render(request, 'LanguageExchange/register.html', {'user_form': UserCreationForm, 'registered': registered}) -
What is the correct way to reference nested django apps in ManytoManyFields
I'm trying to update an old django app from 1.1.x to 1.8 LTS, which has involved updating paths, as I apps move apps around. However, I'm unable to generate migrations for one app, and I can't see how to reference a namespaced app model correctly (assuming that's the problem) If I've moved files from PROJECT/news/models to PROJECT/site_name/news/models, how should I be referencing these models in in foreign keys or ManyToManyFields? My app I have a projects app I want to make migrations for. Projects in some_org/projects, and listed in installed apps like so: INSTALLED_APPS = ( 'some_org.maps', 'some_org.library', 'some_org.extras', 'some_org.news', 'some_org.projects', 'some_org.members', 'some_org.comments', ) All the apps with the namespace are within the some_org directory. Here's an abridged view of the models file in the projects app: # some_org/projects/models.py from some_org.library import Paper class Project(models.Model): name = models.CharField(max_length=30) def get_children(self): return ProjectPage.objects.filter(level=1, publish=True, project=self) def has_library(self): return Paper.objects.filter(projects=self).count() > 0 Calling ./manage.py makemigrations library, gives me this error: ValueError: Lookup failed for model referenced by field library.Paper.projects: projects.Project When I look in the Paper model, it looks like this: class Paper(models.Model): # snip # NewsLinkSubject, Projects et al used to in an app on # the project root, like `./app_name/models.py`, … -
working with annotate django
What I want to do is pull all the teams that have more than 12 players on it. I am told i need to use .annotate with a count to get it done. I am looking at https://docs.djangoproject.com/en/1.10/topics/db/aggregation/ but dont understand how to do a query on that and put it into html. I am assuming pull a query and then do html to make it do the right count. the question for the assignmnt is ...show all teams that have had 12 or more players, past and present. (HINT: Look up the Django annotate function.) views.py from django.shortcuts import render, redirect from .models import League, Team, Player from . import team_maker def index(request): context = { "leagues": League.objects.all(), "teams": Team.objects.all(), "players": Player.objects.all(), "baseball" : League.objects.filter(sport__contains="Baseball"), "women" : League.objects.filter(name__contains="Womens'"), "ice" : League.objects.filter(sport__contains="ice"), "nofootball" : League.objects.exclude(sport__contains="football"), "conferences" : League.objects.filter(name__contains="conference"), "atlantic": League.objects.filter(name__contains="Atlantic"), "teamdallas": Team.objects.filter(location__contains="Dallas"), "raptor": Team.objects.filter(team_name__contains="Raptor"), "cityloc": Team.objects.filter(location__contains="city"), "startT": Team.objects.filter(team_name__startswith="T"), "abc": Team.objects.order_by('location'), "cba": Team.objects.order_by('location').reverse(), "cooper": Player.objects.filter(last_name="Cooper"), "joshua": Player.objects.filter(first_name="Joshua"), "nocooper": Player.objects.filter(last_name="Cooper").exclude(first_name="Joshua"), "wyatt": Player.objects.filter(first_name="Alexander")|Player.objects.filter(first_name="Wyatt"), "atlanticsoccer" : Team.objects.filter(league__name__contains='atlantic', league__sport__contains="soccer"), "bostonp" : Player.objects.filter(curr_team__team_name__contains='Penguins'), "icbc" : Player.objects.filter(curr_team__league__name__contains='International Collegiate Baseball '), "footballlopez" : Player.objects.filter(curr_team__league__name__contains="American Conference of Amateur Football", last_name__contains="lopez"), "footballplayer" : Player.objects.filter(curr_team__league__sport__contains="football"), "sophia" : Team.objects.filter(curr_players__first_name__contains='sophia'), "sophiale" :League.objects.filter(teams__curr_players__first_name__contains='sophia'), "notrough" :Player.objects.filter(last_name__contains='Flores').exclude(curr_team__team_name__contains='rough'), "sevans" :Team.objects.filter(all_players__first_name__contains='Samuel'), "Tiger" :Player.objects.filter(all_teams__team_name__contains='Tiger'), "vikings":Player.objects.filter(all_teams__team_name__contains='vikings'), "jgray":Team.objects.filter(all_players__first_name__contains='Jacob').exclude(team_name__contains='colts'), "joshua":Player.objects.filter(all_teams__league__name__contains='Atlantic Federation of … -
AWS S3 Boto usage with Django gives a security token query parameter with the object link
I am using AWS Boto to handle file uploads and downloads in my Django app. The server on which the application is running has an attached role to it giving full s3 access and full access to that bucket as well. When I upload a file on my app, on the frontend it comes as {http://xyz.s3.amazonaws.com/content/8d632aa1e9e821cfb5648d198d02397c99ba1a47ac8810c2a.jpeg?x-amz-security-token=FQoDYXdzEF8aDN3BTE58ol4F0GNncyK5A%2BjnaijqccanrQK5Q/3qfurJtJOB4Pdm9A0P2ni0d5DfRTTLgmZR%2B5miwzO6nseZF4QUmOiiNfM3RVZmxr9vyEdqeVcPPtDFXnpUB%2BKOLTjsFvYoX68q7lNJ1sBIK3dZJeCVOa67H4keeTU3c2gC0s61wbjuZL38Ozbs242wEJ6PEf9T4dsg%2B2095C9s/qD6wgsdsdsdsdsds9zjGIexET1UsrBTb8HoNV0LN3oWL/h53bu72zBm78ywQC/hWPmGXw5qFfJXaZVWG8QK9pSfghHV9iJcxDbCbbsGqETmRGlQL05Ap2rU1tzN2hbrabYstVKmvSCHNNY7SpmIMqeklyhpHWvP7kZXJkVYIKQ/h3%2B3Zl53Snn%2BoOjb8PnJU1WNI4sOaslTUzeSPuttCRn0qUNxea0U5b//aE%2BcbQYv3OH5syZ%2BCCf3lFPuoO47SF6/W3ib/Uz7T9OnkwSheV6VR0ePF9omvtL2S9TixM/ZkXLhTahNtryUgWjrh3YA0EbPQe4Pn/IokyVaikISpgMqqAS/e/Juq3bwdvJNlw5/2WPOeuAbovfRX82Seqnetao0Ezkb5XSjFvr/GBQ%3D%3D?w=536&h=500} I want to remove this since when I click on it the browser, it does not open the file and says access enter image description here Though the file is there in S3 and I can open it in the console. Please help me. Is it that AWS Boto 2 doesn't support AWS IAM roles? When I explicitly provide AWS access and secret keys in .boto file, this works perfectly fine. I read through this but did not help and we already have CUSTOM variable set in base.py. Using django-storages and the s3 boto backend: x-amz-security-token is appended which I do not want Also, it's here https://www.bountysource.com/issues/35651947-index-urls-are-generated-with-x-amz-security-token-and-don-t-work Please read the issues in the links I have provided too. -
pass parameter in django template URL tag
I am trying to pass a parameter to a django URL in the template. The URL is configured as: url(r'^reviewrecord/(?P<pk>\d+)/$', views.MyView, name='reviewrecord') Now, I am calling this from a ajax block in a javascripyt function. The javascript function is declared as: function EditDialog(pk) { $.ajax( { url: "{% url 'reviewrecord' pk=pk %}", type: "POST", data: postData, }); } Doing this results in: Reverse for 'reviewrecord' with arguments '()' and keyword arguments '{u'pk': ''}' not found. 2 pattern(s) tried: ['reviewrecord/$', 'reviewrecord/(?P<pk>\\d+)/$'] However, I have verified that if I hard-code the pk value, it works. So, replacing the url paranmeter with something like: url: "{% url 'reviewrecord' pk=5 %}", This works. So, I am somehow unable to refer to the passed pk value in the JS function in the URL tag. -
How to have multiple types of users in separated tables?
I'm building a project in which I'll have 3 types of users. Super Admin Teacher Student Teacher and Student will be in a table called Class, each Class will have one teacher and several Student. As far as I know(Very limited), Django only provide one user table for all kinds of users, But I don't know how to go on, because I will need separated tables to keep the data organized and without redudance, in addition to relate with other tables. Is there any kind of solution to solve this problem ?