Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django Site with Country Map
I have a site-project that needs to be done in Django. I have to a country for example the map of Germany and on that map, when the user is moving the mouse over a region like Bavaria to show him the cities of that region. While clicking on a city, i need some page/list to be displayed with population, some authorities numbers etc. Can someone pls advise. I found something made in JavaScript that has what i want, without the clicking event for each region/city etc. https://leafletjs.com/examples/choropleth/ Thank you in advance for your answer! -
Setting up pymysql to work with django as MySQLdb
I wish to get PyMySQL to work with Django, pytest and pytest-django. I understand that in order to get pymysql to expose itself as the mysqldb module django works with, I should place the following snippet at the beginning of my code. import pymysql pymysql.install_as_MySQLdb() I made several attempts to call above function at different locations throughout my code but none seem to be detected by pytest early enough. This includes placing the snippet inside conftest.py:pytest_configure, in my django project's manage.py file, etc. Neither worked. The reason I'm switching from mysqlclient to PyMySQL is that mysqlclient doesn't seem to be functioning with travis.org once I include the following in .travis.yml: addons: mariadb: '10.0' In order to use MariaDB instead of vanilla MySQL. Getting travis to work with the python mysqlclient package will also solve my problem, however I could not get that done either. For reference, this is a travis job for the PR, in case I missed something important out. -
Django CharField w/Choices, model instance needed
Need to turn a CharField into a ChoiceField in the admin. Choices come from external API based on a model instance param. Since I need the model instance, I put the code in a ModelForm __ init __ method. This does not turn the CharField into a ChoiceField: class OfferAdminForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(OfferAdminForm, self).__init__(*args, **kwargs) if hasattr(self, 'instance'): CHOICES = ( ('A', 'Choice A'), ('B', 'Choice B'), ) category_id = forms.ChoiceField(choices = CHOICES) Putting the CHOICES and category_id assignment outside of the init works fine. I think I'm hitting some sort of race condition, but not sure how to go about fixing it. -
how to connect java apps into database that manage by django framework that I deploy in pythonanywhere?
I make a java apps in netbeans that scrape data from website and save it into database. It all working, but after im running python manage.py migrate in pythonanywhere console for easily being manage by django admin panel, my data not entering the database. I'm a rookie, so i cant understand much what explanation that have been provided in https://www.journaldev.com/235/java-mysql-ssh-jsch-jdbc . Can someone explain how to connect my java apps to django via SSH because i think that is the problem now. -
Restructure default hierarchy of Django proyect, moving all apps into a folder
I am trying to move all the apps that I have in my Django application to a folder call apps: The structure that i have right now is: miApp -accounts #App folder -participation #App folder -administration #App folder -miapp --wsgi.py --urls.py --settings ---development.py ---production.py ---__init__.py -static And I would like to have something like this miApp -apps #New folder for the apps --accounts #App folder --reputation #App folder --participation #App folder --administration #App folder -miApp --wsgi.py --urls.py --settings ---common.py #Common settings for develpment and production ---development.py ---production.py ---__init__.py -static ... I tried already to move them all to the same folder, I did the following change in miApp.urls path('', views.inicio, name='inicio'), path('admin/', admin.site.urls), path('cuentas/', include('apps.accounts.urls')), path('participation/', include('apps.participation.urls')), path('administracion/', include('apps.administration.urls')), And also this, in the settings of common.py DJANGO_APPS = ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.sites' ] THIRD_PARTIES = [# Django AllAuth 'allauth', 'allauth.account', 'allauth.socialaccount', 'allauth.socialaccount.providers.facebook', 'allauth.socialaccount.providers.google', 'allauth.socialaccount.providers.twitter', # Django guardian 'guardian', #Django meta 'meta', # Django push notifications 'push_notifications', ] MI_APP_APPS = [# MyVoto Instaled apps 'apps.accounts.apps.AccountsConfig', 'apps.participation.apps.ParticipationConfig', 'apps.administration.apps.AdministrationConfig'] INSTALLED_APPS = DJANGO_APPS + THIRD_PARTIES + MI_APP_APPS And I am getting the following error: Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x107afa488> Traceback (most recent call last): File … -
Django Celery Beats Email raise ValueError("unhandled type %s" % type(wire))
I am trying to send an Email using django celery to schedule the task. I am calling an email function that works when called by itself. However, when called from the celery beats scheduler I get the error: raise ValueError("unhandled type %s" % type(wire)) ValueError: unhandled type The exact error is shown below. Anyone know what I am doing wrong? The function is a send_email from django. I am also using django-results-backend, rabbit and celery-beats Traceback (most recent call last): File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\site-packages\djcelery_email\tasks.py", line 41, in send_emails conn.open() File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\site-packages\django\core\mail\backends\smtp.py", line 63, in open self.connection = self.connection_class(self.host, self.port, **connection_params) File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\smtplib.py", line 251, in __init__ (code, msg) = self.connect(host, port) File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\smtplib.py", line 336, in connect self.sock = self._get_socket(host, port, self.timeout) File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\smtplib.py", line 307, in _get_socket self.source_address) File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\site-packages\eventlet\green\socket.py", line 44, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\site-packages\eventlet\support\greendns.py", line 513, in getaddrinfo qname, addrs = _getaddrinfo_lookup(host, family, flags) File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\site-packages\eventlet\support\greendns.py", line 477, in _getaddrinfo_lookup answer = resolve(host, qfamily, False) File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\site-packages\eventlet\support\greendns.py", line 424, in resolve return _proxy.query(name, rdtype, raise_on_no_answer=raises) File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\site-packages\eventlet\support\greendns.py", line 382, in query return end() File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\site-packages\eventlet\support\greendns.py", line 361, in end raise result[1] File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\site-packages\eventlet\support\greendns.py", line 342, in step a = fun(*args, **kwargs) File … -
Importing the views from my app in the project
So im just starting with Django framework and i cannot explain myself why i can't import the views from my app, im watching one course online and im doing the exact same thing but it won't work, anyone help?Here is screenshot -
Django saving new record to a table with multiple foreign keys
So i basically have a model called Designations that derives foreign keys from 3 other models (curricula, role and staff) and i am trying to save a new record into the Designations model, the code below shows the Designations and Staffs model. However, for the Curriculum and role models i will not be showing as you can assume PK 1 in Curriula and role models will be used as data in the curriculum and role fields in Designation model class Designations(models.Model): designation_id = models.AutoField(primary_key=True) curriculum = models.ForeignKey(Curricula, on_delete=models.CASCADE) role = models.ForeignKey(Roles, on_delete=models.CASCADE) staff = models.ForeignKey(Staffs, on_delete=models.CASCADE) class Meta: db_table = "arc_designations" unique_together = ('curriculum', 'role', 'staff') verbose_name_plural = "Designations" ordering = ['designation_id'] def __str__(self): return '%s of %s %s (%s)' % (self.role.role_name, self.curriculum.course_period.course.course_abbreviation, self.curriculum.module_period.module.module_abbreviation, self.staff.staff_full_name) class Staffs(models.Model): staff_id = models.AutoField(primary_key=True) admission_number = models.CharField(max_length=5, unique=True, help_text="Enter 5 digits", validators=[numeric_only, MinLengthValidator(5)]) staff_full_name = models.CharField(max_length=70, help_text="Enter staff's full name", validators=[letters_only]) created_by = UserForeignKey(auto_user_add=True, editable=False, related_name="staff_created_by", db_column="created_by") created_at = models.DateTimeField(auto_now_add=True, editable=False) updated_by = UserForeignKey(auto_user=True, editable=False, related_name="staff_updated_by", db_column="updated_by") updated_at = models.DateTimeField(auto_now=True, editable=False) roles = models.ManyToManyField(Roles, through='Designations') class Meta: db_table = "arc_staffs" verbose_name_plural = "Staffs" ordering = ['staff_id'] def __str__(self): return '%s (S%s)' % (self.staff_full_name, self.admission_number) I have made a forms.py to get the admission_number(field in … -
AUTH_USER_MODEL refers to model '%s' that has not been installed"
I'm using a CustomUser in my model. This is the User Manager. class UserManager(BaseUserManager): def create_user(self, email, username, password=None, is_staff=False, is_superuser=False, is_active=False, is_bot=False, is_mobile_verified=False, is_online=True, is_logged_in=True): logger = logging.getLogger(__name__) logger.info("REGULAR user created!") if not email: raise ValueError('Email is required') if not username: raise ValueError('Username is required.') email = self.normalize_email(email) user = self.model(email=email, username=username, is_staff=is_staff, is_superuser=is_superuser, is_active=is_active, is_bot=is_bot, is_mobile_verified=is_mobile_verified, is_online=is_online, is_logged_in=is_logged_in) user.set_password(password) user.save(using=self._db) return user def create_superuser(self, email, username, password): logger = logging.getLogger(__name__) logger.info("SUPER user created!") return self.create_user(email, username, password=password, is_staff=True, is_superuser=True, is_active=True, is_bot=False, is_mobile_verified=False, is_online=True, is_logged_in=True) This is my definition of the custom user model. class User(AbstractBaseUser, PermissionsMixin): email = models.EmailField(unique=True, max_length=255) mobile = PhoneNumberField(null=True) username = models.CharField(null=False, unique=True, max_length=255) full_name = models.CharField(max_length=255, blank=True, null=True) birthday = models.DateField(null=True) gender = models.CharField(max_length=255, null=True) is_staff = models.BooleanField(default=False) is_superuser = models.BooleanField(default=False) is_active = models.BooleanField(default=False) is_mobile_verified = models.BooleanField(default=False) is_online = models.BooleanField(default=False) is_logged_in = models.BooleanField(default=True) is_bot = models.BooleanField(default=False) location = models.ForeignKey(Location, on_delete=models.SET_NULL, null=True) USERNAME_FIELD = 'email' REQUIRED_FIELDS = ['username'] #objects = UserManager() get_user_model().objects.create_user(...) If I uncomment the line objects = UserManager() then I can run the server but the super users created from the admin backend can't log in. If I use get_user_model() the code breaks and I get the following error "AUTH_USER_MODEL refers to … -
Name not defined error in python django
import csv import io import re from django.http import HttpResponse from django.shortcuts import render from django.views import generic from ...forms import CsvUploadForm import pandas as pd class CsvImportView(generic.base.View): def getemailcolumn(self, sample): for key, val in sample: print(key, val) if re.match("^.+@([?)[a-zA-Z0-9-.]+.([a-zA-Z]{2,3}|[0-9]{1,3})(]?)$", val[0]) is not None: return key return None def get(self, request): ... def post(self, request): form = CsvUploadForm(request.POST, request.FILES) if form.is_valid(): fieldnames = ['first_name', 'email', 'last_name'] csv = pd.read_csv(request.FILES['csv']) sample =csv.head(); emailColumn = getemailcolumn(sample) return HttpResponse(sample) else: ... ... when the post method is getting executed, i am getting a name not defined error name 'getemailcolumn' is not defined what am i missing? -
AttributeError: module 'blog.views' has no attribute 'post_detail'
urls: from django.conf.urls import url from . import views urlpatterns = [ url(r'^$', views.post_list, name='post_list'), url(r'^post/(?P<pk>\d+)/$', views.post_detail, name='post_detail'), ] views: from django.shortcuts import render, get_object_or_404 from django.utils import timezone from .models import Post from . import urls def post_list(request): posts = Post.objects.filter(published_date__lte=timezone.now()).order_by('published_date') return render(request, 'blog/post_list.html' , {'posts': posts}) def post_detail(request, pk): post = get_object_or_404(Post, pk=pk) return render(request, 'blog/post_detail.html', {'post': post}) Even though 'post_detail' attribute has been included,still I get the error that it's not included. Can someone please help? -
Sending data in django without creating forms
There is already a subscribe field in my html page. I don't want to create another django form. how can I send data from here? Subscribe -
auth.views.Loginview shows "__init__() got an unexpected keyword argument 'request' "
I am trying to use django inbuilt LoginView but it showed an error, " init() got an unexpected keyword argument 'request' " batchbook/user/urls.py from django.urls import path from django.contrib.auth.views import LoginView, LogoutView from django.shortcuts import reverse from .forms import LoginForm app_name = 'user' urlpatterns = [ path('login', LoginView.as_view( authentication_form=LoginForm, success_url='/', template_name='user/login.html', ), name='login'), path('logout', LogoutView.as_view( template_name='user/logout.html' ), name='logout'), ] batchbook/batchbook/urls.py urlpatterns = [ path('admin/', admin.site.urls), path('user/', include(auth_urls)), re_path('^$', TemplateView.as_view( template_name='site/index.html'), name='index'), ] traceback -
Heroku / Django failing to load GDAL library
I'm trying to import the GDAL library in a Django project, and while my application loads successfully locally, and builds successfully when deploying to Heroku, it crashes once the web server starts. Using the buildpack https://github.com/TrailStash/heroku-geo-buildpack heroku[web.1]: Starting process with command `gunicorn feed.wsgi` app[web.1]: [2018-07-15 13:24:39 +0000] [4] [INFO] Starting gunicorn 19.9.0 app[web.1]: [2018-07-15 13:24:39 +0000] [4] [INFO] Listening at: http://0.0.0.0:55791 (4) app[web.1]: [2018-07-15 13:24:39 +0000] [4] [INFO] Using worker: sync app[web.1]: [2018-07-15 13:24:39 +0000] [8] [INFO] Booting worker with pid: 8 app[web.1]: [2018-07-15 13:24:39 +0000] [9] [INFO] Booting worker with pid: 9 app[web.1]: [2018-07-15 13:24:40 +0000] [9] [ERROR] Exception in worker process app[web.1]: Traceback (most recent call last): app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker app[web.1]: worker.init_process() app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 129, in init_process app[web.1]: self.load_wsgi() app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi app[web.1]: self.wsgi = self.app.wsgi() app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi app[web.1]: self.callable = self.load() app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load app[web.1]: return self.load_wsgiapp() app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp app[web.1]: return util.import_app(self.app_uri) app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 350, in import_app app[web.1]: __import__(module) app[web.1]: File "/app/feed/wsgi.py", line 16, in <module> app[web.1]: application = get_wsgi_application() app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application app[web.1]: django.setup(set_prefix=False) app[web.1]: File … -
Django Rest Framework Serializer Relations: How to get a list of only the latest track?
I'm following this documentation here. I'm trying to wrap my head around being able to query the Album object and have it only return the latest track versus returning all the tracks. Below is a modified version of the documentation models and serializers. Models class AlbumOwner(models.Model): username = models.CharField(max_length=100) class Album(models.Model): album_name = models.CharField(max_length=100) owner = models.ForeignKey(AlbumOwner, related_name='owner', on_delete=models.CASCADE) class Track(models.Model): album = models.ForeignKey(Album, related_name='tracks', on_delete=models.CASCADE) title = models.CharField(max_length=100) created_at = models.DateTimeField(auto_now_add=True) class Meta: get_latest_by = 'created_at' Serializers class TrackSerializer(serializers.ModelSerializer): class Meta: model = Track fields = ('title', 'created_at') class AlbumSerializer(serializers.ModelSerializer): tracks = TrackSerializer(many=True, read_only=True) class Meta: model = Album fields = ('album_name', 'tracks') The query I am currently using is below, "o" represents the owner: albums = Album.objects.filter(owner=o) serializer = AlbumSerializer(albums) serializer.data Serializer.data will return a response similar to this: [{ 'album_name': 'The Grey Album', 'tracks': [ {'title': 'Public Service Announcement', "created_at": "2018-06-15T06:22:35.680291Z"}, {'title': 'What More Can I Say', "created_at": "2014-07-15T06:22:35.680291Z"}, {'title': 'Encore', "created_at": "2016-07-15T06:22:35.680291Z"} ], },{ 'album_name': 'The Blue Album', 'tracks': [ {'title': 'PSA', "created_at": "2002-07-15T06:22:35.680291Z"}, {'title': 'WMCIS', '"created_at": "2003-07-15T06:22:35.680291Z"}, {'title': 'E', "created_at": "2005-07-15T06:22:35.680291Z"} ], }, ] The response I want is where only tracks of the latest date are returned: [{ 'album_name': 'The Grey Album', 'tracks': [ … -
What is the best way to clean all Python on my MacOs
Good afternoon, I had some issues with my Python and Django how can I clean everything and install back after. ps: I install all tags -
Django. Скачивание ранее загруженного файла с сервера
Хочу, чтобы у пользователя была возможность скачать файл с сервера загруженный ранее. Мой views.py class GoodsListView(PageNumberView, ListView, SortMixin, CategoryListMixin): model = Good template_name = "goods_index.html" paginate_by = 2 cat = None def get(self, request, *args, **kwargs): if self.kwargs["pk"] == None: self.cat = Category.objects.first() else: self.cat = Category.objects.get(pk = self.kwargs["pk"]) return super(GoodsListView, self).get(request, *args, **kwargs) def get_context_data(self, **kwargs): context = super(GoodsListView, self).get_context_data(**kwargs) context["category"] = self.cat return context def get_file(self, request, *args, **kwargs): filename = self.kwargs.get('filename', None) content_type = 'image/jpeg' file_path = os.path.join(settings.MEDIA_ROOT, filename) response = HttpResponse(FileWrapper(file(file_path)), content_type=content_type) response['Content-Disposition'] = 'attachment; filename=%s' % ( filename.encode('utf-8') if isinstance(filename, unicode) else filename, ) response['Content-Length'] = os.path.getsize(file_path) return response Мой urls.py url(r'^uploads/(?P<path>.*)$', GoodsListView.get_file, name = "download"), Часть моего шаблона: <td class="centered"><a href="/uploads/goods/list/pp2-3.jpg">Скачать файл</a></td> При переходе по ссылке на скачивание получаю ошибку: get_file() missing 1 required positional argument: 'request' -
Unable to load media files in nginx
I just deployed a django application on digitalocean and I'm having problems with nginx as it's not serving media files uploaded by users. Here's my nginx configuration: upstream app_server { server unix:/home/sayc/run/gunicorn.sock fail_timeout=0; } server { listen 80; server_name www.shelteratyourcrossroads.com; keepalive_timeout 5; client_max_body_size 4G; access_log /home/sayc/logs/nginx-access.log; error_log /home/sayc/logs/nginx-error.log; location /static/ { alias /home/sayc/staticfiles/; } # checks for static file, if not found proxy to app location / { try_files $uri @proxy_to_app; } location @proxy_to_app { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://app_server; } } Here are some settings in settings.py: STATIC_URL = '/static/' STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'staticfiles') STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static'), ] # Media MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media/') # CKEditor Configuration CKEDITOR_JQUERY_URL = 'https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js' CKEDITOR_UPLOAD_PATH = 'uploads/' CKEDITOR_IMAGE_BACKEND = 'pillow' CKEDITOR_CONFIGS = { 'default' : { 'toolbar' : None, } } models.py: class Post(models.Model): ... image = models.ImageField(upload_to='posts/%Y/%m/%d', blank=True) ... class Profile(models.Model): ... image = models.ImageField(upload_to='users/%Y/%m/%d', null=True, blank=True) ... The image fields in each of the classes in models.py file above means there are two subfolders in my media directory - media/posts and media/users. Also, there's another subfolder, media/uploads - this was added by the CKEDITOR_UPLOAD_PATH setting. This makes three. I hope this … -
"pip install mysqlclient" requires microsoft visual c++ error
I do installed "Microsoft Visual C++ 14.0", But while running "pip install mysqlclient" it shows as shown in the screenshot,...please can anyone help. Thanks in advance. pip install mysqlclient requires MS Visual C++ 14.0 -
return a nested list of one model
I have a lookups table that contains course categories and subcategories separate: { "id": 138, "lookup": "CRS_CTGRY", "attr1": "Arts and Humanities", "attr2": "الفنون والعلوم الإنسانية", "attr3": null, "attr4": null, "attr5": null, "editable": 1 }, { "id": 155, "lookup": "CRS_SB_CTGRY", "attr1": "Photography", "attr2": "النصوير", "attr3": "138", "attr4": null, "attr5": null, "editable": 1 }, The relation between them is that attr3 = id_of_the_category && attr1 = CRS_SB_CTGRY I want to merge them together in one list like: {"id":138," "lookup":"CRS_CTRGY", "name":"Arts and Humanities", "subcategories":{"id": 154, "lookup": "CRS_SB_CTGRY", "attr1": "Music", "attr2": "الموسيقي", "attr3": "138", "attr4": null, "attr5": null, "editable": 1 }} This is my models.py: class Lookups(models.Model): lookup = models.CharField(max_length=45) attr1 = models.CharField(max_length=100) attr2 = models.CharField(max_length=100, blank=True, null=True) attr3 = models.CharField(max_length=100, blank=True, null=True) attr4 = models.CharField(max_length=100, blank=True, null=True) attr5 = models.CharField(max_length=100, blank=True, null=True) editable = models.IntegerField(blank=True, null=True) class Meta: managed = True db_table = 'lookups' unique_together = (('lookup', 'attr1', 'attr2', 'attr3', 'attr4', 'attr5'),) How can i do it? and where to put the code? in the serializers class? -
I want to make admin dashboard in django
I want to make admin dashboard in django. i am little bit confuse between for all link should i reload the whole site or page(eg. Header/Footer/Sidebar) or i'll make a div and load page specific content on it. Which Way is Better?? -
Django template: How to get date and time from SplitDateTimeWidget separately?
Can't figure out how to render date and time fields of SplitDateTimeWidget separately. This renders both fields: {{ form.datetime_field }} But what if I want to use them on different places? I tried: {{ form.datetime_field_0 }} <hr> {{ form.datetime_field_1 }} Which didn't render anything. How can I access those fields separately? -
Django admin page outside admin
This might be a simple Django question, but I hope I can get som advice. The following code in admin.py class ExarbeteMomentInline(admin.TabularInline): model = ExarbeteMoment extra=0 class ExarbeteStudent(admin.TabularInline): model = ExarbeteStudent extra=0 class ExamensarbeteAdmin(admin.ModelAdmin): list_display = ('title', 'start_date', 'end_date', 'company') inlines = [ExarbeteMomentInline, ExarbeteStudent] admin.site.register(Examensarbete,ExamensarbeteAdmin) produces what I want, in the admin panel. But I want a version of it outside the admin panel, so that regular users can enter data. How can I modify the code in a minimal way to get essentially the same page outside the admin region? Thanks, in advance. -
Remove inline styles from text
I'm using Trumbowyg which is a javascript text editor. My problem is, when I paste text from another site into the editor, it adopts the style of the text from that site. How can I prevent this? My editor is rendered in my Django template like this: {{ post.content }} Is there a template tag I can use to remove HTML? Because the external styling is inline styles, e.g. <span style='font-family: Arial;font-size:30px' etc..? -
How to run Django server on MacOs
When i try to run the server it doesn't work at all: python3 manage.py runserver Traceback (most recent call last): File "manage.py", line 8, in <module> from django.core.management import execute_from_command_line ModuleNotFoundError: No module named 'django' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "manage.py", line 14, in <module> ) from exc ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?