Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
why does django add each character to the list
Given a variable task = 'abc' we update the session variable as follows: request.session['tasks'] = [task] this works but seems like we are adding a list to a list. If we try the following: request.session['tasks'] = task our session variable becomes ['a','b','c'] instead of ['abc'] could someone explain why the second approach doesn't work? -
How to create a view for nested comments in Django rest framework?
I want to have a nested comment system for my project. I have product model so I want to clients can comment on my products. I have my product and comment models and serializers and I related comments to products in product serializer so I can show product comments. what should i do to clients can write their comment for products??? the comments must be nested. this is my code: #models class Comment(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) product = models.ForeignKey(Product, on_delete=models.CASCADE, related_name='comments') parent = models.ForeignKey('self', on_delete=models.CASCADE, null=True,blank=True, related_name='replys') body = models.TextField() created = models.DateTimeField(auto_now_add=True) def __str__(self): return f'{self.user} - {self.body[:30]}' class Meta: ordering = ('-created',) #serializers: class CommentSerializer(serializers.ModelSerializer): class Meta: model = Comment fields = ['id', 'user', 'product', 'parent', 'body', 'created'] class ProductSerializer(serializers.ModelSerializer): comments = CommentSerializer(many=True, read_only=True) class Meta: model = Product fields = ['id', 'category', 'name', 'slug', 'image_1', 'image_2', 'image_3', 'image_4', 'image_5', 'description', 'price', 'available', 'created', 'updated', 'comments'] lookup_field = 'slug' extra_kwargs = { 'url': {'lookup_field': 'slug'} } #views: class Home(generics.ListAPIView): queryset = Product.objects.filter(available=True) serializer_class = ProductSerializer permission_classes = (permissions.AllowAny,) filter_backends = [filters.SearchFilter] search_fields = ['name', 'category__name', 'description'] class RetrieveProductView(generics.RetrieveAPIView): queryset = Product.objects.all() serializer_class = ProductSerializer permission_classes = (permissions.AllowAny,) lookup_field = 'slug' -
How do I reinstall the db.sqlite3 file in django
I am a beginner with django and I accidentally deleted the db.sqlite3 file in my django project. I made a new django project but the db.sqlite3 file was not in it. I also uninstalled and reinstalled django and project but the db.sqlite3 file still wasn't there in the project. What do I do. Thank you. -
How can send variable data from one function to another function in Django
Is this possible to send variable data of one function into another function in Django? Note:- both functions received request as an argument and render in return for example:- in views.py def func1(request): user = 'username' email = 'email' context = {'user':user,'email':email} render return(request,'template.html', ,context) def func2(request): #want to received user and email value in this function render return(request,'template.html') -
Trix rendering html tags such as div and br tags in Django
I am using Trix as a rich text editor in Django, however i run into a problem, when going to save the data, If i type, Hey trix check, it will return trix check backk and it also adds br tags as well, if you want to check it can be seen on www.brogrow.in Can anyone help on it? For login you can use - Username - new & password - Nov@2020 -
CharField of Form not showing up in Django Project
I have created Comment Model for my Project but the CharField is not showing in the LocalHost for some reason. The submit button is working but there is no field to place text. I am trying to know why the CharField is not showing and how to show it in the website? Here is the models.py class Comment(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) post = models.ForeignKey(Post, on_delete=models.CASCADE) body = models.TextField(max_length=300) def __str__(self): return f"{self.post}-{self.user}-Comment No.{self.pk}" Here is the views: class Comment_create(CreateView): model = Comment fields = ['body'] template_name = 'blog/post_detail.html' form = CommentModelForm def form_valid(self, form): post = get_object_or_404(Post, slug=self.kwargs['slug']) form.instance.user = self.request.user form.instance.post = post return super().form_valid(form) def form_invalid(self, form): return HttpResponseRedirect(self.get_success_url()) def get_success_url(self): return reverse('blog:post-detail', kwargs=dict(slug=self.kwargs['slug'])) Here is the forms.py class CommentModelForm(forms.ModelForm): body = forms.CharField(label='', widget=forms.TextInput(attrs={'placeholder': 'Add a comment...'})) class Meta: model = Comment fields = ('body',) Here is the urls.py path('blogs/<slug:slug>/comment/', Comment_create.as_view(), name='comment-post'), Here is the template: <div class="container-fluid mt-2"> <div class="form-group row"> <form action="{% url 'blog:comment-post' post.slug %}" method="post" class="comment-form" action="."> {% csrf_token %} {{ form }} <input type="submit" value="Submit" class="btn btn-outline-success"> </form> </div> </div> -
How to get the windows username with Django web page
How can I get the Windows username of the person running my Django web page? I don't know if and how it matters, but I should note that my site is internal to my company but it's not under my company's domain. Do they need to be on the same domain for security reasons? Thanks. -
ImportError : cannon import name 'path' | django
I'm trying to learn Django and when I tried to run it for the first time, that's the error that I had. PS C:\Users\Alnis\Documents\CS20\lecture3> python manage.py runserver Performing system checks... Unhandled exception in thread started by <function wrapper at 0x0000000004067EB8> Traceback (most recent call last): File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 228, in wrapper fn(*args, **kwargs) File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 124, in inner_run self.check(display_num_errors=True) File "C:\Python27\lib\site-packages\django\core\management\base.py", line 359, in check include_deployment_checks=include_deployment_checks, File "C:\Python27\lib\site-packages\django\core\management\base.py", line 346, in _run_checks return checks.run_checks(**kwargs) File "C:\Python27\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks new_errors = check(app_configs=app_configs) File "C:\Python27\lib\site-packages\django\core\checks\urls.py", line 16, in check_url_config return check_resolver(resolver) File "C:\Python27\lib\site-packages\django\core\checks\urls.py", line 26, in check_resolver return check_method() File "C:\Python27\lib\site-packages\django\urls\resolvers.py", line 256, in check for pattern in self.url_patterns: File "C:\Python27\lib\site-packages\django\utils\functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "C:\Python27\lib\site-packages\django\urls\resolvers.py", line 407, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "C:\Python27\lib\site-packages\django\utils\functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "C:\Python27\lib\site-packages\django\urls\resolvers.py", line 400, in urlconf_module return import_module(self.urlconf_name) File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module __import__(name) File "C:\Users\Alnis\Documents\CS20\lecture3\lecture3\urls.py", line 17, in <module> from django.urls import path ImportError: cannot import name path I tried to update django, but that did nothing. Can somebody help me please ? -
Resize bokeh plot from CustomJS
Resize bokeh plot from CustomJS. window.setXYDimension = function (width, height) { fig.plot_width = width; fig.plot_height = height; console.log({fig}); fig.reset(); //reset doesn't exist fig.resize(); //resize doesn't exist fig.layout(); //layout doesn't exist }; Any help is appreciated. -
Why is my Django Server Responding with a List of nulls to a POST?
I am implementing a multi-file upload. The file upload works so far, i.e. I can select multiple files and send them to my server via postman. In the Django admin panel the files are displayed correctly. But even if the files are sent to the server and saved, the server's response is a list of nulls. The length of this list depends on the size of the last file. That is, the larger the file, the more nulls are displayed (see figure). Normally I would expect the server to answer with the created data. How can I actually achieve that the server answers me with the data it created and not with a list of nulls. Model: class Photo(models.Model): image = models.FileField(upload_to='audio_stories/') Serializer: class FileListSerializer (serializers.Serializer): image = serializers.ListField( child=serializers.FileField( max_length=1000, allow_empty_file=False, ) ) def create(self, validated_data): image=validated_data.pop('image') for img in image: print(img) photo=Photo.objects.create(image=img,) print(photo) return photo View: class PhotoViewSet(viewsets.ModelViewSet): serializer_class = FileListSerializer parser_classes = (MultiPartParser, FormParser,) http_method_names = ['post', 'head'] queryset=Photo.objects.all() -
How to add ruby to my python django app on heroku?
I am trying to deploy a python with django on heroku and use ruby with bundler. I am following this tutorial to add the nginx buildpack : https://elements.heroku.com/buildpacks/hq-mobile/v3-nginx-buildpack I managed to set the config var for ruby bundler using this: heroku config:add GEM_PATH=vendor/bundle/1.8 The problem is when the app is deployed I get this error: bin/start-nginx: line 37: bundle: command not found -
Django Import-export TypeError: clean() got an unexpected keyword argument 'row'
When importing csv files it deliver the following error. I think this is related to the date widget? This is an example of my csv: " , ICE, France, EST Current, HD, 4.59, EUR, GROSS, 01/01/08, , test" Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/import_export/resources.py", line 662, in import_row self.import_obj(instance, row, dry_run) File "/usr/local/lib/python3.6/site-packages/import_export/resources.py", line 516, in import_obj self.import_field(field, obj, data) File "/usr/local/lib/python3.6/site-packages/import_export/resources.py", line 499, in import_field field.save(obj, data, is_m2m) File "/usr/local/lib/python3.6/site-packages/import_export/fields.py", line 110, in save cleaned = self.clean(data) File "/usr/local/lib/python3.6/site-packages/import_export/fields.py", line 66, in clean value = self.widget.clean(value, row=data) TypeError: clean() got an unexpected keyword argument 'row' Resource is build like this As I said, I can't be sure what is the widget that is raising this error. That's why I paste all the Class here: (I know is too long) class retailResource(ModelResource): client = fields.Field( column_name='client', attribute='client', widget=widgets.ForeignKeyWidget(Client, 'name') ) country = fields.Field( column_name='country', attribute='country', widget=widgets.ForeignKeyWidget(Country, 'name') ) catalogue_type = fields.Field( column_name='catalogue_type', attribute='catalogue_type', widget=widgets.ForeignKeyWidget(CatalogueType, 'name') ) currency_in_report = fields.Field( column_name='currency_in_report', attribute='currency_in_report', widget=widgets.ForeignKeyWidget(Currency, 'iso3_code') ) start_date = fields.Field( attribute='start_date', widget=fields.Field( attribute='start_date', column_name='start_date', widget=widgets.DateWidget('%d/%m/%Y')) ) end_date = fields.Field( attribute='end_date', widget=widgets.DateWidget('%d/%m/%Y') ) class Meta(): model = RetailPrice fields = ('id','client', 'country', 'catalogue_type','quality','gross_retail_price', 'currency_in_report','reported_as','start_date','end_date','comments',) export_order = ['id','client', 'country', 'catalogue_type','quality','gross_retail_price', 'currency_in_report','reported_as','start_date','end_date','comments'] import_id_fields = ('id',) … -
AttributeError 'int' object has no attribute 'get'
I am getting an error that says: AttributeError at /series/ 'int' object has no attribute 'get' I don't know why and what is causing this error My models.py class Series(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, default=None) SeriesName = models.CharField(max_length=70, default="") NoEpisodes = models.PositiveIntegerField(default=0) EpisodesWatched = models.PositiveIntegerField(null=True, blank=True, default=0) CoverImage = models.ImageField(null=True, blank=True) class Meta: verbose_name_plural = "Series" My views.py: def seriesview(request): form = SeriesForm(request.POST or None) if request.method == 'POST': form = SeriesForm(request.POST) if form.is_valid(): # error raised here print("Form is valid") return render(request, 'series.html', {'form': form}) My forms.py: class SeriesForm(forms.ModelForm): class Meta: model = Series fields = ('SeriesName', 'NoEpisodes', 'EpisodesWatched', 'CoverImage') labels = { "SeriesName": "Series Name:", "NoEpisodes": "Number of episodes:", "EpisodesWatched": "Episodes watched:", "CoverImage": "Add a cover image:", } def __init__(self, *args, **kwargs): super(SeriesForm, self).__init__(*args, **kwargs) for visible in self.visible_fields(): if visible.field.widget.input_type == 'file': visible.field.widget.attrs['class'] = 'form-control-file' continue visible.field.widget.attrs['class'] = 'form-control' def clean(self): episodes = self.cleaned_data['NoEpisodes'] episodeswatched = self.cleaned_data['EpisodesWatched'] if episodeswatched > episodes or episodes < episodeswatched: raise forms.ValidationError('Error creating series, Episodes watched can\'t be greater than number of episodes') return episodeswatched and one line is highlighted by django when I get the error: if form.is_valid(): # this line is in views.py If you need any other information comment … -
ImportError: cannot import name '...' from partially initialized module '...' (most likely due to a circular import)
I'm upgrading an aplication from django 1.11.25 (python 2.6) to django 3.1.3 (python 3.8.5) and, when I run manage.py makemigrations, I receive this messasge: File "/home/eduardo/projdevs/upgrade-intra/corporate/models/section.py", line 9, in from authentication.models import get_sentinel ImportError: cannot import name 'get_sentinel' from partially initialized module 'authentication.models' (most likely due to a circular import) (/home/eduardo/projdevs/upgrade-intra/authentication/models.py) My models are: authentication / models.py class UserProfile(models.Model): user = models.OneToOneField( 'User', on_delete=models.CASCADE, unique=True, db_index=True ) ... phone = models.ForeignKey('corporate.Phone', on_delete=models.SET_NULL, ...) room = models.ForeignKey('corporate.Room', on_delete=models.SET_NULL, ...) section = models.ForeignKey('corporate.Section', on_delete=models.SET_NULL, ...) objects = models.Manager() ... class CustomUserManager(UserManager): def __init__(self, type=None): super(CustomUserManager, self).__init__() self.type = type def get_queryset(self): qs = super(CustomUserManager, self).get_queryset() if self.type: qs = qs.filter(type=self.type).order_by('first_name', 'last_name') return qs def get_this_types(self, types): qs = super(CustomUserManager, self).get_queryset() qs = qs.filter(type__in=types).order_by('first_name', 'last_name') return qs def get_all_excluding(self, types): qs = super(CustomUserManager, self).get_queryset() qs = qs.filter(~models.Q(type__in=types)).order_by('first_name', 'last_name') return qs class User(AbstractUser): type = models.PositiveIntegerField('...', default=SPECIAL_USER) username = models.CharField('...', max_length=256, unique=True) first_name = models.CharField('...', max_length=40, blank=True) last_name = models.CharField('...', max_length=80, blank=True) date_joined = models.DateTimeField('...', default=timezone.now) previous_login = models.DateTimeField('...', default=timezone.now) objects = CustomUserManager() ... def get_profile(self): if self.type == INTERNAL_USER: ... return None def get_or_create_profile(self): profile = self.get_profile() if not profile and self.type == INTERNAL_USER: ... return profile def update(self, changes): ... class ExternalUserProxy(User): … -
Put the website icon on each image uploaded
In my Django application users can upload images to be displayed on the website. I need a way to mark these images with the website icon upon upload but I can't seem to think of any way. Thanks in advance! -
How to safely use django-ckeditor with Django Rest Framework?
I've successfully implemented django-ckeditor with Django REST Framework and React, but I'm pretty sure that the way I've done it is not secure. I've created an art blog, where each art piece has a rich-text description. Here's a basic example of one of my models with a rich-text field: from ckeditor.fields import RichTextField class Artist(models.Model): biography = RichTextField(blank=True, null=False) ... So, if saved his biography as "He was a nice guy!", then DRF serializes that as: <p>He was a <em><strong>nice guy!</strong></em></p> In my React app, I render it with: <div dangerouslySetInnerHTML={{__html: artist.biography}} /> But, as the name implies, the React documentation says that this is generally risky. This is a personal blog, so I'm not worried about other users injecting code into posts. However, I'm sure that someday I'll want to provide a rich-text editor for my users. Is there a way to implement CKEditor with Django rest framework that doesn't require me to use dangerouslySetInnerHTML? If not, how can I safely implement a rich-text editor, and still use it with DRF? -
Django React js: ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
I'm creating a web app using React in the frontend and Django in the backend. I used this blog to integrate react with backend. However I get a strange error called ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine I searched the internet a lot found this question, did what the answer says but the problem persists. I don't think the database has something to do with my issue, because the pure django pages work fine but only react powered page throw this error. I found a question that is closest to mine, this one, but the question is unanswered, and apparently the problem is with loading some media page, but I just want to load <h1>Hello World!</h1>. Here's full traceback Traceback (most recent call last): File "c:\users\ilqar\appdata\local\programs\python\python38-32\lib\socketserver.py", line 650, in process_request_thread self.finish_request(request, client_address) File "c:\users\ilqar\appdata\local\programs\python\python38-32\lib\socketserver.py", line 360, in finish_request self.RequestHandlerClass(request, client_address, self) File "c:\users\ilqar\appdata\local\programs\python\python38-32\lib\socketserver.py", line 720, in __init__ self.handle() File "C:\Users\Ilqar\.virtualenvs\django-react-reddit-XsnOy92e\lib\site-packages\django\core\servers\basehttp.py", line 174, in handle self.handle_one_request() File "C:\Users\Ilqar\.virtualenvs\django-react-reddit-XsnOy92e\lib\site-packages\django\core\servers\basehttp.py", line 182, in handle_one_request self.raw_requestline = self.rfile.readline(65537) File "c:\users\ilqar\appdata\local\programs\python\python38-32\lib\socket.py", line 669, in readinto return self._sock.recv_into(b) ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine By the way, I … -
Get current user in djangocms plugins (CMSPluginBase)
I want to create a plugin whose content is different depending on the user who opens the page. I tried : @plugin_pool.register_plugin # register the plugin class RubriquePluginPublisher(CMSPluginBase): """ RubriquePluginPublisher : CMSPluginBase """ model = RubriquePluginModel # model where plugin data are saved module = "Rubrique" name = "Rubrique plugin" # name of the plugin in the interface render_template = "commission/rubrique_plugin.html" def render(self, context, instance, placeholder): context.update({'instance': instance}) query_set = Article.objects.filter(rubriques=instance.rubrique).filter(contact=self.request.user) page = context['request'].GET.get('page_{}'.format(instance.rubrique.name)) or 1 paginator, page, queryset, is_paginated = self.paginate_queryset(page, query_set, 3) context.update({'paginator': paginator, 'page_obj': page, 'is_paginated': is_paginated, 'articles': queryset }) return context But self.request doesn't exist in class CMSPluginBase. How can I access the current user? -
Filter rows from joined table
I´m struggling with an issue that seems simple but I cannot find the solution: I have a simple model to upload multiple photos to an item. Class Item: name: string Class Photo: item = ForeignKey(Item) image: ImageFile default: Boolean I want to get all the Items from the REST API but only with the default photo. Righ now I have: Class ItemViewSet(viewsets.ModelViewSet): queryset=Item,objects.all() serializer_class=ItemSerializer Class PhotoSerializer(serializers.ModelSerializer): class Meta: model = Photo fields = ['image', 'default'] Class ItemSerializer(serializers.ModelSerializer): photos=PhotoSerializer(source='photo_set', many=True) class Meta: model = Item fields = ['id', 'name', 'photos'] The problem is that I get all the photos of the Item. I don't know how to filter the Photos table to retrieve only the photos with default=True. It cannot be so difficult. Any help?? Appreciate it very much. Dalton -
Django Query contentType data for rating and review
I have a models for trip and anotehr models for rating: class Trip(models.Model): name = CharField(max_length=500) rating = GenericRelation(Ratings, related_query_name='trips') class Rating(models.Model): value = models.IntegerField() comment = models.TextField() created_on = models.DateTimeField(_("Created on"), auto_now_add=True) and this is how i am populating the trip = Trip.objects.first() ct = ContentType.objects.get_for_model(trip) rating = Ratings.objects.create( value = data['value'], comment = data['comment'], content_type = ct, content_object = trip, ) But the problem is when I query the data for rating like this: trip = Trip.objects.first() review = trip.rating.all() for r in review: print(r.created_at) it through me following error: AttributeErrorTraceback (most recent call last) <ipython-input-10-632676dd4f8f> in <module> 3 review = trip.rating.all() 4 for r in review: ----> 5 print(r.created_at) AttributeError: 'Ratings' object has no attribute 'created_at' But when i query in same way for comment: trip = Trip.objects.first() review = trip.rating.all() for r in review: print(r.commnet) It really works, also it returning value and created_by too like this r.value and r.created_by But the question is whats wrong with created_at? also when i add new fields like test_test = models.CharFeled..blab bla fields, they are not getting and fireing same error like such attribute not exist. my question is why comment and value are returning and why other are … -
Is it possible to pass a Django id inside an HTML element, to a jQuery function?
I am displaying a list of blog posts in a for loop, each has a comment form with send button underneath it. I need to let Django know which specific post has been clicked on so have added {{post.id}} to the button element's id. How do I then pass this information to jQuery? Is it possible to do something like this? <button id="addComBtn{{post.id}}...>Send</button> $('#addComBtn //post.id here').click(function() { ... }); Or is there a better way? -
Trouble integrating mysqlclient and django on windows
I've already tried: pip3 install mysqlclient This raised the error: It was not possible to include the file: 'mysql.h': No such file or directory Then I've tried: pip3 install mysqlclient-1.4.6-cp39-cp39-win_amd64.whl Which raised no errors. Then when I tried again: pip3 install mysqlclient It said: Requirement already satisfied: mysqlclient in c:\path\to\venv\lib\site-packages (1.4.6) Then when I type: python3 manage.py migrate No output is given and no modification is done to the database file. But whenever I try, as the django tutorial sugests: python3 manage.py makemigrations polls The following error raises: django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient? I am using a windows x64 enviroment and running codes on Windows PowerShell into a python3.9 virtual enviroment. Those are the packages and respective versions installed: Package Version ----------- ------- asgiref 3.3.1 Django 3.1.3 mysqlclient 1.4.6 pip 20.2.4 pytz 2020.4 setuptools 49.2.1 sqlparse 0.4.1 -
how to fix error: value too long for type character varying(20)
I'm trying to create an object in my view but this error raises: "value too long for type character varying(20)". I googled alot but i couldnt find an answer for this problem. (please let me know if there is) It happened when i add this column to my model: api_url = models.URLField() After i added this to the model, i ran the makemigrations/migrate without any problem. But when i load my view where i'm creating this new object, the error raises. What i tried: i've set the max_length=255 changed the "api_url" to CharField and TextField added a string "https://example.com" instead of the_url variable. unfortunately, the above didn't work so i'm not sure how to fix this issue. The weird thing about this, is that i did the exact same changes to my local project with a SQLite database, and it doesnt give me that error. So i think this has something to do with the PostgreSQL database. The objects.create() in my view where the error raises: Order.objects.create(ordernumber=ordernumber, order_id=id, full_name=full_name, email=email, price=price, created_at=created_at, status=status, paid=paid, paymethod=paymethod, address_line_1=address_line_1, address_line_2=address_line_2, zipcode=zipcode, city=city, telephone=telephone, country_code=country_code, services=service, total_tax=total_tax, price_excl_tax=price - total_tax, api_url=the_url) note: all the data is coming from a API call and i double … -
ObtainAuthToken view keep asking me about username
I've cereated custom user model. And I want to get teken for my user. I'm sending request with login and password. In response I'm getting "username": [ "This field is required." ] It's weird because in mmy user model this field is replaced by login field. What Am i doing wrong ? My User Model class CustomUser(AbstractBaseUser): login = models.CharField(max_length = 20, primary_key = True) password = models.CharField(max_length = 20) name = models.CharField(max_length = 20) surname = models.CharField(max_length = 20) city = models.ForeignKey(City,on_delete=models.CASCADE, null = True) is_patient = models.BooleanField(default=True) # Required for the AbstractBaseUser class date_joined = models.DateTimeField(verbose_name='date joined', auto_now_add=True) last_login = models.DateTimeField(verbose_name ='last login', auto_now=True) is_admin = models.BooleanField(default=False) is_active = models.BooleanField(default=True) is_staff = models.BooleanField(default=False) is_superuser = models.BooleanField(default=False) USERNAME_FIELD = 'login' REQUIRED_FIELDS = ['password'] objects = CustomUserManager() def __str__(self): return self.login # Required for the AbstractBaseUser class def has_perm(self, perm, obj=None): return self.is_admin def has_module_perms(self, app_label): return True I have added to settings.py this line AUTH_USER_MODEL = 'asystentWebApp.CustomUser' My view class AuthToken(ObtainAuthToken): def post(self, request, *args, **kwargs): serializer = self.serializer_class(data=request.data, context={'request': request}) serializer.is_valid(raise_exception=True) user = serializer.validated_data['user'] token, created = Token.objects.get_or_create(user=user) return Response({ 'token': token.key, 'login' : user.login }) -
How can Django and Django Rest Framework be used to create complex applications
How can a complex app like dropbox, Zoom, or Google Search be created using Django or Django-rest-framework. I understand how something like a blog, a LMS, a e-store, or something simple would work, but how about a complex file storage app, video conference, or search engine be created?