Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Deploy Django app on a server is giving me 404 with static files
I'm trying to deploy a Djagon app to a production server, but is not working, even if I seet DEBUGvariable to True. For what I understand, Heroku is collecting the static files, so should work. remote: -----> $ python manage.py collectstatic --noinput remote: 119 static files copied to '/tmp/build_80f75579ac26656d613f32473cdc0923/staticfiles', 12 unmodified. production.py from wall_web_interface.settings.common import * DEBUG = False ALLOWED_HOSTS = ['*'] STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') settings = dynaconf.DjangoDynaconf(__name__) common.py """ Django settings for wall_web_interface project. Generated by 'Django-admin startproject' using Django 2.2.5. For more information on this file, see https://docs.djangoproject.com/en/2.2/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/2.2/ref/settings/ """ import os import dynaconf # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = "dkjdkjdkjdkdjkdjdi8383383j" # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = ['*'] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'bootstrap4', 'sass_processor', 'images.apps.ImagesConfig', ] 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', ] ROOT_URLCONF = 'wall_web_interface.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, … -
Django: template needs to return per-item result based on who you are
As my template loops through a list of Forum objects provided by the View, I need to present a value ("number of posts ...") that will depend on who the user is – and of course, if he is anonymous. So, I basically need to call a function, from the template, whose arguments are "the current Forum object" and "the current request – thus giving me access to the user." In order to return the appropriate integer as seen by this user. How do I do that, the Django way? -
How to stop django to automatically active users while using UserRegisterForm
views.py from django.shortcuts import render, redirect from django.contrib import messages from django.contrib.auth.decorators import login_required from .forms import UserRegisterForm, UserUpdateForm, ProfileUpdateForm def register(request): if request.method == 'POST': form = UserRegisterForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') messages.success(request, f'Your account has been created! You are now able to log in') return redirect('login') else: form = UserRegisterForm() return render(request, 'users/register.html', {'form': form}) using RegisterForm for Registration form django automatically activate user.I want to add signup email confirmation before activating user. -
null value in column "ProjectName_id" violates not-null constraint
need help on null value in column "ProjectName_id" violates not-null constraint, im new to django i want my ProjectName_id (Foreignkey) is the same id that user choose in my majordetails = ProjectNameInviToBid.objects.get(id=sid) please help me... my model views class ProjectNameInviToBid(models.Model): ProjectName = models.CharField(max_length=255, verbose_name='Project Name', null=True) DateCreated = models.DateField(auto_now=True) class InviToBid(models.Model): today = date.today() ProjectName = models.ForeignKey('ProjectNameInviToBid', on_delete=models.CASCADE) NameOfFile = models.CharField(max_length=255, verbose_name='Name of File') my views.py def project_name_details(request, sid): majordetails = ProjectNameInviToBid.objects.get(id=sid) if request.method == 'POST': form = invitoBidForm(request.POST, request.FILES) if form.is_valid(): majordetails = InviToBid.ProjectName form.save() messages.success(request, 'File has been Uploaded') else: form = invitoBidForm() args = { 'majordetails': majordetails, 'form': form } return render(request,'content/invitoBid/bacadmininvitoBid.html', args) -
Django send_mail not working and returns 0 errors
My code executes fine from my localhost. However, when I try and run my django program from an ubuntu 16.04 server it doesn't work. I tried running the program in the shell and it doesn't return any errors. When I check my inbox I don't receive an email from the "from" address. I've tried sending the email to different addresses. I've also tried sending it using TLS instead of SSL. I also tried using smtplib to send the email instead of using django's send_mail. Here is my code I'm using to send the email send_mail('subject','my message','from_email@gmail.com',['to_email@xxxx.com'],fail_silently=False) Here is my settings.py file EMAIL_HOST = 'smtp.gmail.com' EMAIL_HOST_USER = 'from_email@gmail.com' EMAIL_HOST_PASSWORD = '*******' EMAIL_PORT = 465 -
A pythonic way to get a list filtered by a Django table
I need to filter a list like this: A = ['a','b','c','c','d','e'] and I have a Django model T that contains a field unique which I know if the element is the same or not. Lets say T(id, name_unique,...others_fields). Lets say T has id, name... (1, 'b',...) (2, 'c',...) (3, 'f',...) (4, 'g',...) and alot rows more I need a way (pythonic) to get a list A filtered by distinct and non repeated from name_unique, so the output should be A' = ['a', 'd', 'e'] -
Server Error (500) when logging into admin panel
After deploying my project I have my project in /svr and when i go to login to my admin panel I get Server Error (500) I'm guessing this is because the permissions on my database are not correct. I tried running chown www-data db.sqlite3 but I'm still getting this error. -
This problem "duplicate key value violates unique constraint" has been real pain on my ass for nearly a week
I am trying to create a video blog where users will be able to create their own account and profile. I have also added email verification with for registration. But the problem is when I try to register a new user from Django 2.2.5 development server I get this error ( "duplicate key value violates unique constraint" "account_profile_mobile_number_key" DETAIL: Key (mobile_number)=() already exists. ) repeatedly. I thought if I delete the database this might solve the problem. I deleted the database and create another one. Then I have been able to create a user but again that problem occurred. I delete the database again. This way I have tried so many times but couldn't able to solve the problem. I googled for the solution and got lot of answers but they are very tough for me to understand as I am just in the learning process. I am using Python 3.6, Django 2.2.5, Postgresql 11 on Ubuntu 18.04. Guys could you please see my codes and show me the easiest way to solve the problem? Thanks in advance! Here is the Traceback IntegrityError at /account/register/ duplicate key value violates unique constraint "account_profile_mobile_number_key" DETAIL: Key (mobile_number)=() already exists. Request Method: POST … -
Can django integration zerorpc?
I'm intending to use rpc in my django project.And I found zerorpc is a beautiful lib for rpc.So I want to intrgration django with zerorpc. What is the best practice? And how to start the zerorpc server in production?Thanks! -
Server TTFB takes too long on Chrome
It seems on some pages on the localserver, it takes upward of 40secs on the TTFB as shown by Chrome's Network > Timing. On other pages, it takes 8 seconds. I am running Django's localserver and preparing to lunch the site soon, so I'd like to know: 1) Is it something peculiar to Django's local server? 2) Why is there such a difference in loading time between different pages on the TTFB (Time spent waiting for the initial response, also known as the Time To First Byte) 3) Does this go away once it is lunched on a real server or should I dig for some serious problem in the code base? -
How to fix the "The requested URL was not found on this server" apache2 + django + ec2?
I'm doing the deploy of a website built with django and python2.7 on an EC2 instance and using apache2. I've being following some tutorials and none of them worked for me. I currently installed the apache, configured it to see the project and even configured the permissions. The project directory: | |-ubuntu | |- jendalma |--apps |--media |--promotions |--sellerlogin |--templates |--frobshop | |---frobshop | |---setting.py |---wsgi.py |---urls.py |---static 000-default.conf - apache <VirtualHost *:80> ServerAdmin <jendalma@gmail.com> WSGIScriptAlias / /home/ubuntu/jendalmaShop/frobshop/frobshop/wsgi.py Alias /static/ /home/ubuntu/jendalmaShop/frobshop/frobshop/static/ Alias /media/ /home/ubuntu/jendalmaShop/frobshop/media/ <Location "/static/"> Options -Indexes AllowOverride none Require all granted </Location> <Location "/media/"> AllowOverride none Require all granted </Location> <Location "/"> AllowOverride none Require all granted </Location> <Directory "/home/ubuntu/jendalmaShop/frobshop/frobshop/wsgi.py"> <Files wsgi.py> Require all granted </Files> </Directory> </VirtualHost> urls: js_info_dict = { 'packages': ('stores',), } admin.autodiscover() urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^i18n/', include('django.conf.urls.i18n')), # Stores extension url(r'^stores/', stores_app.urls), url(r'^dashboard/stores/', dashboard_app.urls), # PayPal extension url(r'^checkout/paypal/', include('paypal.express.urls')), # Datacash extension url(r'^dashboard/datacash/', datacash_app.urls), url(r'^dashboard/login/$', DashAccountAuthView.as_view(), name='login'), url(r'^dashboard/register/$', DashAccountRegistrationView.as_view(), name='register'), url(r'^dashboard/methods/shipping/$', methods), url(r'^dashboard/methods/shipping/change/$', change_method), url(r'^currencies/', include('currencies.urls')), url(r'^customer/', include('sellerlogin.urls')), url(r'', application.urls), ] if settings.DEBUG: import debug_toolbar urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) urlpatterns += [ url(r'^__debug__/', include(debug_toolbar.urls)), ] admin.site.site_header = "Jendalma Express Admin" admin.site.site_title = "Jendalma Express Admin" admin.site.index_title = "Welcome to Jendalma Express" The … -
Annotate queryset with count of instances related to it in another queryset
I have three related models like so: Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE ) city = models.ForeignKey(City, on_delete=models.SET_NULL, null=True) Product(models.Model): owner = models.ForeignKey(User, on_delete=models.CASCADE) price = models.FloatField() geo_location = models.PointField(srid=4326, null=True, blank=True) City(models.Model): name = models.CharField(max_length=75) geom = models.MultiPolygonField(srid=4326) the related city can be retrieved from the geo_location field if specified example : city = City.objects.get(geom__contains=someproduct.geo_location) or from the owner's profile : city = someproduct.owner.profile.city lets suppose i have a these queries: all_cities = City.objects.all() products = Product.objects.filter(price__lt=2500) what i want to achieve is products_count attribute on each instance of the all_cities queryset from products queryset maybe a loop would solve this but don't know how to implement it and there might be another solution using Subquery and OuterRef -
how to serve webp from a variable in a static tag wagtail 2.5
I made a carousel orderable. each instance has an image and char field for the webp file name through the picture element. The webp image loads perfect when I hard code the srcset instead of using a {{variable}}. Problem is that keeps the admin backend from being dynamic and leaves me hard coding every pic on the site or just the pages I want to rank for on google. Ive read a bunch of other posts but im still stuck. is there any way to serve webp filename cleanly from the backend? I have read. load static file with variable name in django django 1.5 - How to use variables inside static tag This one was the closest to solving my problem but falls short. https://snakeycode.wordpress.com/2015/02/20/variables-in-django-static-tags/ carousel orderable fields carousel_image = models.ForeignKey("wagtailimages.Image", on_delete=models.SET_NULL,related_name="+",) webp = models.CharField(max_length=100, blank=True, null=True) home template carousel {% for loop_cycle in self.carousel_images.all %} {% image loop_cycle.carousel_image max-750x500 as img %} <picture> <source srcset="{% static '{{loop_cycle.webp}}'%}" type="image/webp" > <img src="{% static '{{img.url}}'%}" alt="{{ img.alt }}"> </picture> As this works perfect when I hard code but then whats the point of having a carousel with an orderable that is next-gen image friendly? Thank you for reading Im going … -
How do I pass a variable from views to a base html template using Django
I have a floatbar with contact details that shows only when the website is opened on a mobile screen. However, there are pages where I do not want them to appear, and I figured I can pass this through context in the respective view classes. What I need to figure out is how do I access this in my base template where this floatbar is called. I did read a bit about context processors, but I am not sure if I can change the value of the variable being passed. I would like to be able to access the variable in base html, but also change the value stored within views.py -
How to deploy django app on hosting service
I'm new to web development. I bought the web hosting start-up package from Siteground to host my graphic design portfolio website. It's a simple Django app that is a one-page portfolio with a contact form using Django's sendEmail through gmail service. I've never deployed a Django app, let alone my own website. I've only made and deployed a Wordpress website which is pretty self-explanatory. I understand how to upload my website to the server through FTP, but I have no idea how to configure the Django app for deployment (aside the brief explanation in their docs) or how to connect the app to my server to run on the domain. I think I'm supposed to configure something in wsgi, but I don't really understand how that works and I can't find support anywhere on deploying a Django app on Siteground (or something like it) even though they have python support. I connected to Sitegrounds' SSH to follow some tutorials on Django deployment, but even though it's Unix I can't use (or don't understand how to) sudo apt-get to follow the tutorials. Here is my settings.py: import os with open('cfsite/key.txt') as f: SECRET_KEY = f.read().strip() # Build paths inside the project … -
How to access foreign key nested fields in template
I have these models: class Board(models.Model): # Board in chassis# name = models.CharField(max_length = 20) SMT = models.CharField(max_length = 20) HM = models.CharField(max_length = 20) class Chassis(models.Model): #chassis information# name = models.CharField(primary_key=True,max_length = 10) board = models.ManyToManyField(Board) fa = models.CharField(max_length = 20) class DocDetials(models.Model): #document details chassis = models.ForeignKey(Chassis,related_name="details",on_delete=models.SET_NULL, null=True) boards = models.TextField(max_length = 50, blank=True, null = True) fields for 'Boards' and 'Chassis' are already defined manually in 'admin' site. What I want to do is to choose from those fields to fill-out my form which is connected to 'DocDetails' model. my form used on my views is using the model 'DocDetails'. I would like to access chassis.name, chassis.board (all items) and chassis.fa fields in my template, so I can display them in my html page. so far I can only access chassis.name by doing: {{ form.chassis.value }} but I cannot access other fields typing similar template tags. is there a way to do this? -
Why will my profile pictures not show up Django
So I am creating a small website, and I want users to be able to upload profile pictures to their page. However, I ran into a problem, and the image won't render. I have the actual process for the user to upload a profile picture, and it saves to a directory, but it won't load in the HTML document I have looked online for answers, but have found none. I have tried renaming fields in the models.py file because I thought that it might be an issue where I need a certain field name. None of these worked Here is the relevant UserProfileInfo model in models.py class UserProfileInfo(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) first_name = models.CharField(max_length=50,blank=True,null=True) #models.OneToOneField(User,'on_delete')# last_name = models.CharField(max_length=50,blank=True,null=True) #models.OneToOneField(User,'on_delete')# bio = models.CharField(max_length=150) image = models.ImageField(upload_to='profile_pics',default='default.png') joined_date = models.DateTimeField(blank=True,null=True,default=timezone.now) verified = models.BooleanField(default=False) def __str__(self): return self.user.username def save(self, *args, **kwargs): super().save(*args, **kwargs) img = Image.open(self.image.path) if img.height > 300 or img.width > 300: output_size = (300, 300) img.thumbnail(output_size) img.save(self.image.path) Here is the views.py file for the user registration def register(request): registered = False if request.method == 'POST': user_form = UserForm(data=request.POST) profile_form = UserProfileInfoForms(data=request.POST) if user_form.is_valid and profile_form.is_valid(): user = user_form.save() user.set_password(user.password) user.save() profile = profile_form.save(commit=False) profile.user = user if 'image' … -
How to in Django get a data from the dropdown
How to get the value from the queryset? MODEL: class LOCATION(models.Model): name = models.CharField(max_length=4, default=None, blank=True, unique=True, error_messages={'unique':"Already in Used"}) class Site(models.Model): code = models.ForeignKey(LOCATION,on_delete=models.SET_NULL, null=True) FORM: class location_Form(forms.ModelForm): class Meta: model = LOCATION fields = '__all__' field_classes = { 'json_field': JSONFormField, } class site_Form(forms.ModelForm): class Meta: model = Site fields = '__all__' field_classes = { 'json_field': JSONFormField, } VIEW def SITEview(request): template_name = 'site.html' code_name = LOCATION.objects.all() form = site_Form(request.POST or None) if request.method == 'POST': dc_pk_list = request.POST.getlist('code', None) selected_dc_query = LOCATION.objects.filter(pk__in=dc_pk_list) selected_dc = [i for i in selected_dc_query] print(selected_dc) RESULTS: How to get a just a value? from the below result: [<location: CHE>] just need CHE how to get the a text value only? -
How to make a ManyToMany serialization to be able to create a object in the POST request?
I'm trying to create a serialize to handle a ManyToMany relation, but it's not working. I have read the documentation and I probably doing something wrong. Also I have read the answers here. Here are my models. class Author(models.Model): name = models.CharField(verbose_name="Name", max_length=255) class Book(models.Model): author = models.ForeignKey( Author, related_name="id_author", blank=True, null=True, on_delete=models.PROTECT) price = models.FloatField(verbose_name="Price") class FiscalDocument(models.Model): seller = models.ForeignKey( User, related_name="user_id", on_delete=models.PROTECT) book = models.ManyToManyField(Book) My serializer: class AuthorSerializer(serializers.ModelSerializer): class Meta: model = Author fields = ('id', 'name') class BookSerializer(serializers.ModelSerializer): class Meta: model = Book fields = ('id', 'author', 'price') def to_representation(self, instance): response = super().to_representation(instance) response['author'] = AuthorSerializer(instance.author).data return response class FiscalDocumentSerializer(serializers.ModelSerializer): book = BookSerializer() class Meta: model = FiscalDocument fields = ('id', 'seller', 'book') def create(self, validated_data): book_data = validated_data.pop('book') fiscal_document = FiscalDocument.objects.create(**validated_data) Book.objects.create(FiscalDocument=FiscalDocument,**medicine_data) return fiscal_document When I try to access the endpoint of the FiscalDocument, django-rest-framework is throwing an error: Got AttributeError when attempting to get a value for field price on serializer BookSerializer. The serializer field might be named incorrectly and not match any attribute or key on the ManyRelatedManager instance. Original exception text was: ManyRelatedManager object has no attribute price. If anyone can help XD. -
"Unknown column in having clause" when using a SimpleFilter on Django admin
I'm using a simple filter to filter model results on Django Admin. Even though all the queries are tested and working well, the code keeps throwing an error. I think it may be a bug. OperationalError at /calibracion_de_instrumentos/instrumentos/ (1054, "Unknown column 'instrumentos.fecha_compra' in 'having clause'") As you may read, it says "Unknown column in having clause". If i execute qs.filter(tiempo_para_vencimiento__gte=timedelta(3) while debugging the method queryset in the Filter, it works fine... This is part of my admin.py class DiasVencimientoFilter(admin.SimpleListFilter): title = ('Por tiempo para vencimiento') # Parameter for the filter that will be used in the URL query. parameter_name = 'tiempo_para_vencimiento' def lookups(self, request, model_admin): qs = model_admin.get_queryset(request) if qs.filter(tiempo_para_vencimiento__lte=timedelta(0)).first() is not None: yield ('vencido', ('Vencido')) elif qs.filter(tiempo_para_vencimiento__gte=timedelta(3), tiempo_para_vencimiento__lte=timedelta(7)).first() is not None: yield ('menosDe3', ('Una semana')) elif qs.filter(tiempo_para_vencimiento__gte=timedelta(7), tiempo_para_vencimiento__lte=timedelta(14)).first() is not None: yield ('menosDe7', ('Dos semanas')) elif qs.filter(tiempo_para_vencimiento__gte=timedelta(14), tiempo_para_vencimiento__lte=timedelta(31)).first() is not None: yield ('menosDe14', ('Un mes')) return qs def queryset(self, request, queryset): if self.value() == 'vencido': return queryset.filter(tiempo_para_vencimiento__lte=timedelta(0)) elif self.value() == 'menosDe3': return queryset.filter(tiempo_para_vencimiento__gte=timedelta(3), tiempo_para_vencimiento__lte=timedelta(7)) elif self.value() == 'menosDe7': return queryset.filter(tiempo_para_vencimiento__gte=timedelta(7), tiempo_para_vencimiento__lte=timedelta(14)) elif self.value() == 'menosDe14': return queryset.filter(tiempo_para_vencimiento__gte=timedelta(14), tiempo_para_vencimiento__lte=timedelta(31)) # return queryset.filter(tiempo_para_vencimiento__lt=timedelta(0)) # return Instrumentos.get_all_data(Instrumentos.objects).filter(tiempo_para_vencimiento__lte=timedelta(0)) return queryset class AdminInstrumentos(admin.ModelAdmin): list_display = ... list_display_links = ... list_filter = (... , DiasVencimientoFilter) … -
DRF tries updating read-only fields
I have a Django model (derived from the CleanerVersion Versionable model) which I am serializing using DRF and I want several fields set to read only (they are created by a series of functions and are therefore set as properties), however when I try to update the record, the read-only fields are included in the validated_data, and are also included in the procedure which sets the attribute and the value during the update(). My model.py class Athlete(Versionable): ... @property def photo_status(self): if(self.photo!=None): return True return False ... For my serializer.py I tried different approaches: Setting the serializer field to read-only class AthleteSerializerSerializer(serializers.ModelSerializer):: ... photo_status= serializers.BooleanField(read_only=True) ... class Meta: model = Athlete fields = '__all__' ... Excluding the field class AthleteSerializer(serializers.ModelSerializer):: ... class Meta: model = Athlete exclude = ['photo_status'] ... Added the extra kwargs class AthleteSerializerSerializer(serializers.ModelSerializer):: ... class Meta: model = Athlete fields='__all__' extra_kwargs = { 'photo_status': {'read_only': True}, } ... and no matter what, when I run: serializer = AthleteSerializer(Athlete.objects.current.get(identity=a.identity),data=request.data.get("athlete")) serializer.is_valid() serializer.save() I get the following error message setattr(instance, attr, value) AttributeError: can't set attribute I set several different properties to read only, as well as a few field (e.g. CleanerVersion automatically updates the id and identity fields so … -
Dealing with varying child levels in Django models
So I've got a database that has an incomplete hierarchy and I'm not quite sure how to deal with it. For example, I want to measure the mass of species.. Each family can have multiple geneses. Each genus can have multiple species. However, not ALL species have a sub-species (with sub-species being the lowest level). In other words, the endpoint of the hierarchy could be subspecies OR species. The solution I have come up with doesn't seem to follow good principles. class mass(model.Models): name = models.CharField(max_length=100) value = models.NumericField() family = models.ForeignKey(family) genus = models.ForeignKey(genus) species = models.ForeignKey(species) subspecies = models.ForeignKey(subspecies) # Could be a blank field class family(model.Models): name = models.CharField(max_length=100) class genus(model.Models): name = models.CharField(max_length=100) family = models.ForeignKey(family) class species(model.Models): name = models.CharField(max_length=100) genus = models.ForeignKey(genus) class subspecies(model.Models): name = models.CharField(max_length=100) species = models.ForeignKey(species) -
how to use VueJs components in Django using django webpack loader?
I followed this tutorial and integrated Django and VueJs using django-webpack-loader?and now the main.js output from django-webpack-loader is loading to my index.html this is my project directory structure assets bundles app.js js components Demo.vue index.js db.sqlite3 manage.py myapp myproject node_modules package.json package-lock.json requirements.txt templates webpack.config.js webpack-stats.json my Demo.vue component has been imported to the index.js and using webpack.config.js file all necessary file has been bundled together to app.js my question is what is the next step? for example if I have some VueJs components and want to use them in some of my templates how should I do that?should I create components in the component directory and bundle them all? if this is the case how should I choose to use or not use a component in a specific template? and how should I use Django template tags to insert dynamic data? or I should write my components in another way? I know there is multiple questions here, but I couldn't find a good reference to answer my questions so any help would be appreciated -
s it possible to use request object outside of views or other way to get current user information
I want to operate some filter with user based. So I need logged user information in my admin.py or other file. But I don't understand how it possible to get current loged user id or other information. Any one help me? Example Code... @register(Category) class CategoryAdmin(admin.ModelAdmin): ordering = ['priority'] if **user.is_superuser**: #do something here.... list_display = ('name', 'slug', 'priority', 'report', 'read_counter') else: list_display = ('name', 'slug') -
django.template.exceptions.TemplateDoesNotExist: home.html
django project was working fine! home page and other pages were rendering no problems. I creating products app/ component page and accidentally named "templates" template so i renamed template to "templates" and that when i started have issues. I ran terminal commands: python manage.py makemigrations python manage.py migrate python collectstatic Nothing is working! I am getting an error message: django.template.exceptions.TemplateDoesNotExist: home.html