Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django: Automatically logged in as Admin after runserver
Good day SO! I am a beginner in Django, and I am facing a small problem but I do not know where to start in Debugging it. After executing 'manage.py runserver', I will be automatically logged in as the Administrator account I created via createsuperuser. How do I fix this issue? Any clue on where I should start looking? Any help will be greatly appreciated, thank you! Will provide any details necessary -
crispy-forms gives error when trying to run on local host
I have been working on this django app for the last few days but have yet to find a solution to make it work. I am trying to deploy it on local host and also on heroku but neither will work as a result of this error. Here is the error messages that I get when trying to run python manage.py runserver ... Watching for file changes with StatReloader Exception in thread django-main-thread: Traceback (most recent call last): File "c:\users\gorma\appdata\local\programs\python\python36- 32\Lib\threading.py", line 916, in _bootstrap_inner self.run() File "c:\users\gorma\appdata\local\programs\python\python36- 32\Lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "C:\Projects\new\apotofgold\ENV\lib\site- packages\django\utils\autoreload.py", line 54, in wrapper fn(*args, **kwargs) File "C:\Projects\new\apotofgold\ENV\lib\site- packages\django\core\management\commands\runserver.py", line 109, in inner_run autoreload.raise_last_exception() File "C:\Projects\new\apotofgold\ENV\lib\site- packages\django\utils\autoreload.py", line 77, in raise_last_exception raise _exception[1] File "C:\Projects\new\apotofgold\ENV\lib\site- packages\django\core\management\__init__.py", line 337, in execute autoreload.check_errors(django.setup)() File "C:\Projects\new\apotofgold\ENV\lib\site- packages\django\utils\autoreload.py", line 54, in wrapper fn(*args, **kwargs) File "C:\Projects\new\apotofgold\ENV\lib\site- packages\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Projects\new\apotofgold\ENV\lib\site- packages\django\apps\registry.py", line 91, in populate app_config = AppConfig.create(entry) File "C:\Projects\new\apotofgold\ENV\lib\site- packages\django\apps\config.py", line 90, in create module = import_module(entry) File "C:\Projects\new\apotofgold\ENV\lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked ModuleNotFoundError: No module … -
Internal Server Error 500 when deploying Django Application to Elastic Beanstalk
I followed meticulously the official AWS guide to deploy a Django App to Elastic Beanstalk (https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html) for a school project. It is working locally, but when I try to deploy it shows a 500 Error message. I went through many adjustments in my code but they don't seem effective. The AWS dashboard shows one warning that says: Environment health has transitioned from OK to Warning. 100% of the requests are failing with HTTP 5xx. Could it be a timezone problem as I am currently in Europe? I tried to change debug mode from true to false, but I don't think that's the problem. the I truly do not understand why it's not working, I never got an error in the execution in the terminal and it always deployed everything correctly. It is just not showing the web page for some reason. '''(base) MacBook-Air-di-Davide:ebdjango davidemerlin$ eb create django-env Creating application version archive "app-190718_165248". Uploading ebdjango/app-190718_165248.zip to S3. This may take a while. Upload Complete. Environment details for: django-env Application name: ebdjango Region: eu-central-1 Deployed Version: app-190718_165248 Environment ID: e-3mxbcch2rm Platform: arn:aws:elasticbeanstalk:eu-central-1::platform/Python 3.6 running on 64bit Amazon Linux/2.8.6 Tier: WebServer-Standard-1.0 CNAME: UNKNOWN Updated: 2019-07-18 14:52:51.893000+00:00 Printing Status: 2019-07-18 14:52:51 INFO createEnvironment is … -
Django admin, multiple inlines, related to parent and each other, cannot save the objects toghether
I am creating devices network management using django admin, (Django==2.2), where for 1 device can be attached multiple mac addresses and for the same device can be attached multiple ips, but at the same time ips are attached to mac asdresses, and I need to chanage/add/view them toghether. For the device view I have no problems, there is all displayed, the problem is at add/change the device, need there also to add/change new mac/ip. ###From models #Device class, without others not important parameters class Devices(models.Model): ... name = models.CharField(max_length=63) ........... def __str__(self): return format(self.name) class Meta: ordering = ('name',) managed = False db_table = 'devices' verbose_name_plural = "Devices" #Macs class class Macs(models.Model): mac = models.CharField(max_length=17, validators=[validate_mac_adress]) device = models.ForeignKey('Devices', related_name="Macs", on_delete=models.CASCADE) ........... def __str__(self): return format(self.mac) class Meta: managed = False db_table = 'macs' #Ips class ip = models.CharField(max_length=15, validators=[validate_ipv4]) device = models.ForeignKey('Devices', related_name="Ips", on_delete=models.CASCADE) mac = models.ForeignKey('Macs', on_delete=models.CASCADE) def __str__(self): return format(self.ip) class Meta: managed = False db_table = 'ips' #form for inline class IpsForm(forms.ModelForm): class Meta: model = Ips exclude = ('mac',) #####from admin.py class MACInline(admin.TabularInline): model = Macs extra = 0 class IPSInline(admin.TabularInline): title = 'IPS' model = Ips form = IpsForm extra = 0 def save(self, … -
how to provide default value to a foreign while creating a new instance
i'm try to make a restaurant ordering system , when someone order multi products he/she be able to select the quantity of products which selected, if all customers are anonymous(there is no registration option) i want to provide default value instead select manually but i get this error ValueError at /orders-product/ Cannot assign "4": "ProductOrder.order" must be a "Ordering" instance. is there any solution , or if someone know a better way to achieve it, i appreciate it models.py class Product(models.Model): name = models.CharField(max_length=50) price = models.PositiveIntegerField(default=1) def __str__(self): return self.name class Ordering(models.Model): id = models.AutoField(primary_key = True) products = models.ManyToManyField(Product,through='ProductOrder') @property def total(self): return self.productorder_set.aggregate( price_sum=Sum(F('quantity') * F('product__price'), output_field=IntegerField()) )['price_sum'] class ProductOrder(models.Model): product = models.ForeignKey(Product, on_delete=models.CASCADE) order = models.ForeignKey(Ordering, on_delete=models.CASCADE,blank=True) quantity = models.IntegerField(default=1) def create_order(sender , instance,**kwargs): instance.ordering.save() #for create new instance from ordering model pre_save.connect(create_order,sender=ProductOrder) views.py class ProductOrderCreate(CreateView): form_class = ProductOrdering model = ProductOrder template_name = 'create_product_order.html' success_url = '/' def form_valid(self,form): form.instance.order = list(Ordering.objects.values_list('pk' , flat=True).reverse().order_by('pk'))[0] return super(ProductOrderCreate,self).form_valid(form) -
how to instantly load a list of options after submitting a value in a django form
I have an easy template, first the user selects a country from a list of countries, then selects a region from a list of regions of the selected country, finally submits and results are shown. The problem is when a country is selected the regions of that country are shown only after the submit button is clicked so the user have to click submit two times, first after selecting a country to see the list of regions, second time to see results after selecting a region. # models.py class Region(models.Model): country_list = [('IT', 'Italy'), ('FR', 'France')] name = models.CharField(max_length=38) country = models.CharField(max_length=2, choices=country_list, default="IT") #views.py def index_w(request): country = request.GET.get('country') region = Region.objects.all() region = region.filter(country=country) regions = request.GET.get('regions') results = Result.objects.all() if regions is not None: results = results.filter(region=regions) return render(request, 'index_uni.html', { 'regions': region, 'country': country }) /*template*/ <form method="get" action="/university/" class="form-area"> <select name="country"> <option value="IT">Italia</option> <option value="FR">France</option> </select> <select name="regions"> {% for region in regions %} <option value="{{region.id}}">{{region.name}}</option> {% endfor %} </select> <input type="submit"> </form> When the page is loaded for the first time and the user selects a value for "country" there's no option for "regions"; after submit is clicked it correctly displays all the regions … -
How can i add custom div tag with class in ckeditor in django
I want to add special class For example, <div class="Open-subtitle"></div> I added this code in styles.js but doesn't show anything { name: 'Open-subtitle', element: 'div', attributes: { 'class': 'post-open-subtitle' } }, What should i do -
Python with Django Import error with RegistrationSupplementBase cannot import name 'ugettext_lazy'
I'm updating a very old Django project and trying to use RegistrationSupplementBase but when importing I get this error message: File "/home/projectmachine/Desktop/project_rebuild/projectname/models.py", line 11, in <module> from registration.supplements.base import RegistrationSupplementBase File "/home/projectmachine/.local/share/virtualenvs/projectname-QrYA9Qp-/lib/python3.6/site-packages/registration/supplements/base.py", line 9, in <module> from django.utils.text import ugettext_lazy as _ ImportError: cannot import name 'ugettext_lazy' I can't figure out what's wrong. It seems like there is an issue with the dependancies installed. I'm using Django 2.2 with django-inspectional-registration 0.6.2 Here is how I am importing the class: from registration.supplements.base import RegistrationSupplementBase -
How to check if decorator is present on view from Middleware
I have a django application that requires that a session is set for quite a bit of functionality, I want to stop worrying about checking if it is set in the views so I am moving it to midddleware, however, I still have a few views that need the be excluded from the middleware. I have decided to decorate the specific views that do not need the middleware, but I am unsure how to check if the decorator is present. Is this possible? So far I have attempted to bind it to the request variable but that is not working. class CheckPropertyMiddleware(object): def __init__(self, get_response): self.get_response = get_response @staticmethod def process_view(request, view_func, args, kwargs): print(request.property_not_important) if not request.session.get('property'): print('property not selected') messages.error(request, 'You need to select a property to use the system.') # return redirect(reverse('home', args=[request.client_url])) else: print('property selected') def __call__(self, request): # Code to be executed for each request before # the view (and later middleware) are called. response = self.get_response(request) # Code to be executed for each request/response after # the view is called. return response def property_not_important(function): @functools.wraps(function) def decorator(request, *args, **kwargs): request.property_not_important = True return function(request, *args, **kwargs) return decorator -
How to Iterate Over a List in Python
I have a simple for loop to iterate over a list of various dates. For each item in the list, I exclude the timezone by taking only the first 10 characters. However, when I pass the object to my template only the first value in the list is being returned for all values. views.py for opportunity in opportunities: temp = opportunity['expectedCloseDate'] time = temp[:10] context { 'time': time } return render(request, 'website', context) template.html <div class="control is-inline-flex"> <input class="input" name="close_date" id="close_date" type="date" value="{{ time }}" disabled> </div> -
Apache crashing from django.contrib class WKBWriter/Reader
I'm running a django application on an apache webserver. This application uses the django.contrib package, specifically django.contrib.gis.geos. Now sometimes this works out well for weeks, only to come crashing down multiple times a day with seemingly no direct correlation to user interaction. The log shows this: Traceback (most recent call last): File "[...]/lib/python3.4/site-packages/django/contrib/gis/ptr.py", line 37, in __del__ NameError: name 'AttributeError' is not defined [...] Exception ignored in: Exception ignored in: Exception ignored in: <bound method _WKBReader.__del__ of <django.contrib.gis.geos.prototypes.io._WKBReader object at 0x7ff4c2f92a58>> I have shortened the huge chain of Exception ignored in:s. After this, apache won't serve any more requests until it is restarted but also still remain active as a daemon. I am not sure which line exactly is responsible for this error. But I found this: https://docs.djangoproject.com/en/2.2/ref/contrib/gis/geos/#creating-a-geometry Under "My logs are filled with GEOS-related errors" it says that this could be avoided by not having any GEOS-Objects created on top level, so I tried to purge those occurrences but it didn't help. Also it seems weird to see NameError: name 'AttributeError' is not defined maybe that can hint to the root of this problem? If you do not know how to instantly solve this, can you give me some … -
save compressed image vs compress image before rendering
I am developing a webapp and need to render images in different sizes, for that I have one option to save images in different sizes and then render whatever needs. It will save time of compression but takes more storage because I need to save 6 different sizes of same image. Another one is compress image before rendering as per size needed, I am not sure but I think it will take more time to process and also takes more memory in ram. Is this make my ram overloaded ?? I want to go with second one but I think its bad. Can anyone tell which method can be more usefull in what case and what can be the technique for this? -
How can I render a plot in Django made on the server via matplotlib?
I'm developing a Django application where I'd like to be able to render a graph that updates when a user checks/unchecks checkbox inputs. I'm having trouble getting the data from the form to my server-side logic, and then rendering the plot (a histogram created via matplotlib) in the view. The data comes from a SQL query in the sqlite database that comes prepackaged in Django. I have verified that the SQL query returns the correct data, and have a script that will create the correct histogram. However, since there are many different options for the user to click to generate the histogram, I'd like to not save each potential histogram as a static file to be served. Ideally, the histogram would update when the user toggles a checkbox. I'm not opposed to using JavaScript/another plotting framework to render the histogram, however I'm not sure how I'd connect that to the database or to the view. Any help would be greatly appreciated! -
How to print this Json Returned object into Html template
output of json object [{"model": "demo.state", "pk": 1, "fields": {"state_name": "Gujarat", "country": 1}}, {"model": "demo.state", "pk": 2, "fields": {"state_name": "Rajsthan", "country": 1}}, {"model": "demo.state", "pk": 3, "fields": {"state_name": "Maharastra", "country": 1}}] I want to print the only state_name value in html template how to print that values in the template using Jquery //ajax code //I just print response using below alert(response) }, error: function(response) { alert("error"); } }); -
Django 2.1 Foreign Key set value based on previous form field value which is submitted to database
iam having a problem to assign my foreign key value to the first form field value. Model Startup is parent and Model Team is Child with a foreign key related to Startup model and the value of startup_name must be assigned to the startup foreign key field. however, the Team Model is a dynamic fields where multi Team members is inserted to the model and foreign key is only one field. i need help to get it right taking in place that am new to django programming forms.py: from .models import * from django import forms class StartupNameForm (forms.ModelForm): class Meta: model = Startup fields = ['startup_name',] models.py: from django.db import models class Startup (models.Model): startup_name=models.CharField('Startup Name', max_length = 100) def save(self , *args , **kwargs) : super ( Startup , self ).save ( *args , **kwargs ) # Call the "real" save() method. team = Team ( Startup = self , startup = self.startup_name ) team.save () def __str__(self) : return self.startup_name class Team (models.Model): name = models.CharField ( 'Name' , max_length = 100 ) position = models.CharField ( 'Position' , max_length = 100 ) startup = models.ForeignKey(Startup, on_delete = models.CASCADE) def __str__(self): return self.name views.py: def str_dashboard(request) : … -
Two Models pointing to One Database Table - Redundant Code [Django 2.1]
I'm working on a Django project that have two models on different apps using the same tables on database. The City and State tables are used in both apps. I want to know which is the best way to apply DRY concepts and use only one model for the two apps access these tables. The two apps are on the project folder and each one has his own models.py with the folowing code for city/state: from django.db import models from django.contrib.auth.models import User,Group from django.db.models.signals import post_save from django.dispatch import receiver class state(models.Model): class Meta: db_table = '"db_property"."state"' created_at = models.DateTimeField(db_column='created_at') updated_at = models.DateTimeField(db_column='updated_at') name = models.CharField(db_column='name',max_length=50) class city(models.Model): class Meta: db_table = '"db_property"."city"' created_at = models.DateTimeField(db_column='created_at') updated_at = models.DateTimeField(db_column='updated_at') name = models.CharField(db_column='name',max_length=50) state = models.ForeignKey(state,on_delete=models.CASCADE) Thanks in advance! -
How to send an object with other variables back to the client using json serialize?
How to add dict a to response and how can I get two objects at the ajax? view def abc(request): cp = Cp.objects.get(id=1) cp = serializers.serialize('json', [cp,]) cp = json.loads(cp) a = {'a': 'a', 'b': 'b'} return HttpResponse(data) js $.ajax({ // success: function(data){ } }) -
DjangoRestFramework: AttributeError: 'str' object has no attribute '_meta'
I traced this error and found that serializer.data is causing the problem. I have used similar code in my other Django apps and they are running perfectly fine. models.py from django.db import models class Category(models.Model): name=models.CharField(max_length=30) def __str__(self): return self.name class Subcategory(models.Model): category=models.ForeignKey(Category,on_delete=models.CASCADE) name=models.CharField(max_length=30) def __str__(self): return self.name class Products(models.Model): Subcategory=models.ForeignKey(Subcategory,on_delete=models.CASCADE) name=models.CharField(max_length=30) def __str__(self): return self.name serializers.py from rest_framework import serializers from .models import Category,Subcategory,Products class CategorySerializer(serializers.ModelSerializer): class Meta: model='Category' fields='__all__' class SubcategorySerializer(serializers.ModelSerializer): class Meta: model='Subcategory' fields='__all__' class ProductsSerializer(serializers.ModelSerializer): class Meta: model='Products' fields='__all__' views.py def post(self,request): action=request.query_params['action'] if action=='add': category_name=request.query_params['category_name'] category=Category(name=category_name) category.save() serializer=CategorySerializer(Category.objects.filter(name=category),many=True) return JsonResponse({"category details":serializer.data}) I went through all the posts on StackOverflow based on this error but none of those could help me resolve it. -
Django trailing slash in page
I have a problem if i add " / " at the end of the url and then the page 404 not found path('<slug:slug>',post_detail,name="post_detail"), Or if i delete " / " in the url then the page 404 not found path('news/',post_index,name="post_index"), I want to work whether have slash or not. -
ImportError: cannot import name 'PostListView' from 'main.views'
hello guys I'm beginner in learning Django, I got this error when I try to import PostListView from .views this project urls: from django.contrib import admin from django.urls import path, include from users import views as user_views from django.contrib.auth import views as auth_views from django.conf import settings from django.conf.urls.static import static urlpatterns = [ path('admin/', admin.site.urls), path('register/', user_views.register, name='register'), path('profile/', user_views.profile, name='profile'), path('/', include('main.urls')), path('login/', auth_views.LoginView.as_view(template_name='users/login.html'), name='login'), path('logout/', auth_views.LogoutView.as_view(template_name='users/logout.html'), name='logout'), ] if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) this is my app main urls: from . import views from django.urls import path from main.views import PostListView urlpatterns = [ path('', PostListView.as_view, name="blog"), path('about/', views.about, name='about'), ] and this is my views: from django.shortcuts import render from .models import Post from django.views.generic import ListView def blog(request): context = { 'posts': Post.objects.all() } return render(request=request, template_name='main/blog.html', context=context) class PostListViews(ListView): model = Post def about(request): return render(request=request, template_name='main/about.html') Thank you in advance :) -
How do I point my Django to my Vue files that are loaded via web pack?
I'm setting up a production server on digital ocean using Django and with MPA Vue. I load the Vue scripts and CSS via a webpack loader and it works fine locally. When I try to deploy it as production I get an error that I cannot 'get' the files of Vue I tried changing the webpack.config.js publicpath to the dir location and eventually changed it back to " " I tried changing the settings.py file's STATIC_URL and STATIC_ROOT to fit the dir's location of the Vue files myIp/:25 GET http://myIp/django_vue_mpa/static/vue/css/chunk-vendors.css net::ERR_ABORTED 404 (Not Found) myIp/:28 GET http://myIp/django_vue_mpa/static/vue/js/vue_app_01.js net::ERR_ABORTED 404 (Not Found) myIp/:27 GET http://myIp/django_vue_mpa/static/vue/css/vue_app_01.css net::ERR_ABORTED 404 (Not Found) myIp/:26 GET http://myIp/django_vue_mpa/static/vue/js/chunk-vendors.js net::ERR_ABORTED 404 (Not Found) myIp/:27 GET http://myIp/django_vue_mpa/static/vue/css/vue_app_01.css net::ERR_ABORTED 404 (Not Found) myIp/:28 GET http://myIp/dj ango_vue_mpa/static/vue/js/vue_app_01.js 404 (Not Found) -
How can i add a date/calender widget to django forms?
I tried following these links and this but it didn't work. the widget doesn't load in the form and the js files gives 404 error in the console while it's accessible from the link. I use crispy forms to render my form. forms.py DateInput = partial(forms.DateInput, {'class': 'datepicker'}) # patient Form class PatientForm(ModelForm): birth_date = forms.DateField(label='Birth Date',widget=DateInput()) class Meta: model = Patient exclude = ['user',] The Template <h2>Add Patient</h2> <form method="POST" action="{% url 'patients:patient_create' %}"> {% csrf_token %} {{ form|crispy }} <button type="submit" class="btn btn-primary" >Add Patients</button> <p></p> </form> </div> {% endblock %} <script> $(document).ready(function() { $('.datepicker').datepicker(); }); </script> The links of js files + CSS <script src=”https://code.jquery.com/jquery-1.12.4.js”></script> <script src=”https://code.jquery.com/ui/1.12.1/jquery-ui.js”></script> <link rel=”stylesheet” href=”//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css”> The errors in the console Not Found: /patients/”https://code.jquery.com/jquery-1.12.4.js” Not Found: /patients/”https://code.jquery.com/ui/1.12.1/jquery-ui.js” [18/Jul/2019 15:29:09] "GET /patients/%E2%80%9Dhttps://code.jquery.com/jquery-1.12.4.js%E2%80%9D HTTP/1.1" 404 6742 [18/Jul/2019 15:29:09] "GET /patients/%E2%80%9Dhttps://code.jquery.com/ui/1.12.1/jquery-ui.js%E2%80%9D HTTP/1.1" 404 6760 Not Found: /patients/”https://code.jquery.com/jquery-1.12.4.js” [18/Jul/2019 15:29:10] "GET /patients/%E2%80%9Dhttps://code.jquery.com/jquery-1.12.4.js%E2%80%9D HTTP/1.1" 404 6742 Not Found: /patients/”https://code.jquery.com/ui/1.12.1/jquery-ui.js” [18/Jul/2019 15:29:10] "GET /patients/%E2%80%9Dhttps://code.jquery.com/ui/1.12.1/jquery-ui.js%E2%80%9D HTTP/1.1" 404 6760 Not Found: /favicon.ico in my code i have many jquery versions can that cause the problem -
how to make dependent foreignkey in model admin (not front side)
I'm new to django.I have to create one Product class and that have two foreignkey product-categories and Attribute.Attribute also have foreignkey of product-categories. I have register this model in wagtail model-admin and create orderable attribute. class Products(ClusterableModel): name = models.CharField(max_length=20) stock = models.IntegerField(blank=True) price = models.FloatField(blank=True) product_type = models.ForeignKey(ProdCategory, on_delete=models.CASCADE) def __str__(self): return "%s"%(self.name) panels = [ FieldPanel('name'), FieldPanel('stock'), FieldPanel('price'), FieldPanel('product_type'), MultiFieldPanel([ InlinePanel('attribute', max_num =3), ], 'All Attributes'), ] class Meta: verbose_name_plural = 'Products' verbose_name = 'Product' from django.contrib.postgres.fields import HStoreField, JSONField class Attribute(Orderable): page = ParentalKey('Products', related_name='attribute') attribute = models.ForeignKey(ProductAttribute, on_delete=models.CASCADE,related_name='+') value = models.CharField(max_length=100) So, when i select category and then attribute can show only that attribute having selected category. Thanks in advance. -
App (Python Django, PostgreSql) is deployed successfully on Heroku, but I'm getting error when trying to open
I have successfully deployed Python/Django app called MyPortfolio in Heroku. But when I am trying to open it gives me an error: ModuleNotFoundError: No module named 'jobs' The project folder is 'MeryPortfolio-project'. The project name is 'MeryPortfolio'. Application name is 'jobs'. So Heroku can't find the module for the application. The case is: I have tried to make local and production settings. Local settings I use when I start the local server. Production settings are used in Heroku with the command: heroku config:set DJANGO_SETTINGS_MODULE=MeryPortfolio-project.MeryPortfolio.settings.production The directories are: 'MeryPortfolio-project' /'MeryPortfolio': _init.py settings.py urls.py wsgi.py /settings: init.py base.py local.py production.py These are logs when I try to open the app (heroku open) $ heroku logs 2019-07-18T12:54:14.328455+00:00 app[web.1]: spew: False 2019-07-18T12:54:14.328457+00:00 app[web.1]: check_config: False 2019-07-18T12:54:14.328459+00:00 app[web.1]: preload_app: True 2019-07-18T12:54:14.328461+00:00 app[web.1]: sendfile: None 2019-07-18T12:54:14.328463+00:00 app[web.1]: reuse_port: False 2019-07-18T12:54:14.328465+00:00 app[web.1]: chdir: /app 2019-07-18T12:54:14.328467+00:00 app[web.1]: daemon: False 2019-07-18T12:54:14.328469+00:00 app[web.1]: raw_env: [] 2019-07-18T12:54:14.328471+00:00 app[web.1]: pidfile: None 2019-07-18T12:54:14.328472+00:00 app[web.1]: worker_tmp_dir: None 2019-07-18T12:54:14.328474+00:00 app[web.1]: user: 36932 2019-07-18T12:54:14.328476+00:00 app[web.1]: group: 36932 2019-07-18T12:54:14.328479+00:00 app[web.1]: umask: 0 2019-07-18T12:54:14.328481+00:00 app[web.1]: initgroups: False 2019-07-18T12:54:14.328483+00:00 app[web.1]: tmp_upload_dir: None 2019-07-18T12:54:14.328485+00:00 app[web.1]: secure_scheme_headers: {'X-FORWARDED-PROTOCOL': 'ssl', 'X-FORWARDED-PROTO': 'https', 'X-FORWARDED-SSL': 'on'} 2019-07-18T12:54:14.328487+00:00 app[web.1]: forwarded_allow_ips: ['*'] 2019-07-18T12:54:14.328489+00:00 app[web.1]: accesslog: - 2019-07-18T12:54:14.328491+00:00 app[web.1]: disable_redirect_access_to_syslog: False 2019-07-18T12:54:14.328494+00:00 app[web.1]: access_log_format: %(h)s %(l)s %(u)s … -
How to multiply succes_url in Django?
How to multiply succes_url in Django view? I tried this but it doesn't work: class ResetPasswordRequestView(FormView): template_name = "registration/password_reset_form.html" form_class = PasswordResetRequestForm def post(self, request, *args, **kwargs): form = self.form_class(request.POST) if form.is_valid(): data = form.cleaned_data["email_or_username"] if self.validate_email_address(data) is True: succes_url = '/reset/password/email/' else: succes_url = '/reset/password/username/'