Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django Foreign Key Dropdown Filter
I have a model called Listing which is basically a job listing posted by my users. One of the fields is a Foreign Key called Address (since a user can have multiple addresses). Here is my models.py: class JobListing(models.Model): title = models.CharField(max_length=250) description = models.TextField() customer = models.ForeignKey('CustomerAuth.CustomerProfile') address = models.ForeignKey('CustomerAuth.Address') As it currently stands when a user selects an address from the dropdown it shows everyones address. Is there anyway I can filter it so that only the addresses entered by that user is shown. -
Move Django 1.11 project to wsgi
Please help, I could find error. I'm using django 1.11 and apache (on centos) There is my wsgi.py import os import sys os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings") activate_this = os.path.expanduser("/var/project/project_python35_venv/bin/activate_this.py") execfile(activate_this, dict(__file__=activate_this)) from django.core.wsgi import get_wsgi_application application = get_wsgi_application() my django.conf (of httpd) WSGILazyInitialization On WSGIRestrictEmbedded On WSGIPassAuthorization On WSGIDaemonProcess project user=apache group=apache processes=10 threads=10 maximum-requests=10000 python-path=/var/project/project_python35_venv/lib/python3.5/site-packages python-home=/var/project/project_python35_venv/lib/python3.5 #WSGIProcessGroup project #WSGIApplicationGroup %{GLOBAL} #WSGIPythonHome /var/project/project_python35_venv/lib/python3.5 <VirtualHost *:80> <Directory /var/project/project_python35_venv> Require all granted </Directory> CustomLog /var/log/httpd/project-access.log common ErrorLog /var/log/httpd/project-error.log DocumentRoot /var/project/project/project/ WSGIScriptAlias / /var/project/project/project/wsgi.py Alias /static /var/project/project/project/static/ <Directory /var/project/project/project/static> Require all granted </Directory> <Directory /var/project/project> <Files wsgi.py> Require all granted </Files> </Directory> </VirtualHost> I'm trying all cases, but still got this error on my log of httpd : ImportError: No module named site Thank you all for the help -
django url configuration not able to redirect to specific url when calling urls of one function through urls of another application
I am working with two apps here. The user app create, delete, update, login and register a user. Whereas network app simply check if the session is set through @login_required decorator. My base template is located on the root. i have a login functionality from which i want to call login. I am not able to access user.urls from network.urls any help would be appreciated. This is network.urls from django.conf.urls import url, include from . import views from user import urls as user_urls from user import views as user_views #from django.contrib import admin urlpatterns = [ url(r'^$', views.IndexView.as_view()), url(r'^user/login/', include('user.urls', namespace='user')), url(r'^captcha', include('captcha.urls')), #url(r'^admin/', admin.site.urls), ] and this is user.urls from django.conf.urls import url, include from . import views urlpatterns = [ url(r'^login/', views.LoginView.as_view(), name='login'), url(r'^$', views.IndexView.as_view(), name="index"), #url(r'^register', views.RegisterView.as_view(), name='register') ] now i want to call user login from the base template, which is <body> <div class="container-fluid"> <div class="row"> <div id="top_pane" class="row"> <div class="col-lg-2 text-left" style="padding-left:20px" id="home_logo"><a href="#" style="color:#fff">GS</a></div> <div class="col-lg-8 text-center" id="top_search"> <form class="form-inline"> {%csrf_token%} <input type="text" name="search" placeholder="Search" class="form-control"> <input type="submit" class="btn btn-info" value="Search"> </form> </div> <div class="col-lg-1 text-right" style="padding-right:5px" id="login_logo"> <a href="{%url 'user:login'%}" type="button" class="btn btn-default btn-sm"> <span class="glyphicon glyphicon-log-in"></span> Log in </a> </div> <div class="col-lg-1 … -
'save_model' method + 'save_as = True' // how to change "old" object
I have the following model and i am using 'save_as' in admin.py to enable a “save as new” feature on admin change forms. The goal is that if i use 'save_as' the "old" object should have set the boolean field 'hide' to True. I tried to implement the ModelAdmin method 'save_model' to admin.py but this only changes the value for the "new" object. Is it possible to change the "old" object also? models.py class Person(models.Model): name = models.CharField(max_length=64) hide = models.BooleanField(default=0) admin.py class personAdmin(admin.ModelAdmin): save_as = True def save_model(self, request, obj, form, change): obj.hide = True super(personAdmin, self).save_model(request, obj, form, change) -
Unable to connect using django-mssql to connect to MS SQL Server 2016 with Django 1.11
I'm trying to use django-mssql to connect to MS SQL Server 2016 with Django 1.11 These are my Database settings: DATABASE_ENGINE = 'sqlserver_ado' DATABASE_NAME = 'db' DATABASE_USER = 'sa' DATABASE_PASSWORD = '*********' DATABASE_HOST = 'localhost' } This is the error I get when I try run python manage.py runserver (mywork) C:\Users\Kaushal_K\Python Dev\producttimeline>python manage.py runserver Unhandled exception in thread started by Traceback (most recent call last): File "C:\Users\Kaushal_K\Envs\mywork\lib\site-packages\django\utils\autoreload.py", line 227, in wrapper fn(*args, **kwargs) File "C:\Users\Kaushal_K\Envs\mywork\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run autoreload.raise_last_exception() File "C:\Users\Kaushal_K\Envs\mywork\lib\site-packages\django\utils\autoreload.py", line 250, in raise_last_exception six.reraise(*_exception) File "C:\Users\Kaushal_K\Envs\mywork\lib\site-packages\django\utils\autoreload.py", line 227, in wrapper fn(*args, **kwargs) File "C:\Users\Kaushal_K\Envs\mywork\lib\site-packages\django__init__.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Users\Kaushal_K\Envs\mywork\lib\site-packages\django\apps\registry.py", line 108, in populate app_config.import_models() File "C:\Users\Kaushal_K\Envs\mywork\lib\site-packages\django\apps\config.py", line 202, in import_models self.models_module = import_module(models_module_name) File "c:\python27\Lib\importlib__init__.py", line 37, in import_module import(name) File "C:\Users\Kaushal_K\Envs\mywork\lib\site-packages\django\contrib\auth\models.py", line 4, in from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager File "C:\Users\Kaushal_K\Envs\mywork\lib\site-packages\django\contrib\auth\base_user.py", line 52, in class AbstractBaseUser(models.Model): File "C:\Users\Kaushal_K\Envs\mywork\lib\site-packages\django\db\models\base.py", line 124, in new new_class.add_to_class('_meta', Options(meta, app_label)) File "C:\Users\Kaushal_K\Envs\mywork\lib\site-packages\django\db\models\base.py", line 330, in add_to_class value.contribute_to_class(cls, name) File "C:\Users\Kaushal_K\Envs\mywork\lib\site-packages\django\db\models\options.py", line 214, in contribute_to_class self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) File "C:\Users\Kaushal_K\Envs\mywork\lib\site-packages\django\db__init__.py", line 33, in getattr return getattr(connections[DEFAULT_DB_ALIAS], item) File "C:\Users\Kaushal_K\Envs\mywork\lib\site-packages\django\db\utils.py", line 212, in getitem conn = backend.DatabaseWrapper(db, alias) File "C:\Users\Kaushal_K\Envs\mywork\lib\site-packages\sqlserver_ado\base.py", line 184, in init super(DatabaseWrapper, self).init(*args, **kwargs) File "C:\Users\Kaushal_K\Envs\mywork\lib\site-packages\django\db\backends\base\base.py", line … -
Django Q AND lookup
So I'm trying to implement an AJAX search form in my project. My model contains a Recipe class and an Ingredient class connected by foreign key to the Recipe so that each recipe can have several ingredients. I have a recipe entry in my db titled omelet that has 2 ingredients - egg and milk. My query looks like so: for title_ing in search_text: recipe_list_search = recipe_list_search & (Q(ingredients__ingredient__icontains=title_ing)) When searching for each ingredient separately I get the correct return, for example, my output for egg: egg (AND: ('ingredients__ingredient__icontains', 'egg')) <QuerySet [<Recipe: Eggs>, <Recipe: omlet>, <Recipe: Pan Egg>]> or milk: milk (AND: ('ingredients__ingredient__icontains', 'milk')) <QuerySet [<Recipe: sdfsd>, <Recipe: omlet>]> however, when searching for two ingredients I get the following output: egg milk (AND: ('ingredients__ingredient__icontains', 'egg')) (AND: ('ingredients__ingredient__icontains', 'egg'),('ingredients__ingredient__icontains', 'milk')) <QuerySet []> Any idea why that happens? code for my model: class Ingredient(models.Model): recipe = models.ForeignKey("Recipe", verbose_name=_("Recipe"), related_name="ingredients", on_delete=models.CASCADE) quantity = models.CharField(_("Quantity"), max_length=10, blank=True, null=True) unit = models.CharField(_("Unit"), choices=fields.UNITS, blank=True, null=True, max_length=20) ingredient = models.CharField(_("Ingredient"), max_length=100) note = models.CharField(_("Note"), max_length=200, blank=True, null=True) def __str__(self): _ingredient = '%s' % self.ingredient if self.unit: _ingredient = '%s %s' % (self.get_unit_display(), _ingredient) if self.quantity: _ingredient = '%s %s' % (self.quantity, _ingredient) #python anywhere doesnt register … -
Saving Mezzanine's Displayables is way slower than saving Models
So, I recently heard about Mezzanine and wanted to give it a shot, specially since the Search Engine looks like just what I need. From the documentation, I find out that my model has to subclass mezzanine.core.models.Displayable; easy peasy. Last night I left my database population script running and I now see it hasn't finished, it's taking about 25 seconds per model insert. This is a table that now has about 4200 elements; I remember it inserting about 100 elements/second at the beginning. Incidentally, I just tried running the script with my models inheriting from django.core.models.Model; it inserts about 100 elements / second and finishes in about 58 seconds (shy under 6000 elements are to be inserted). So, herein lies the question: is this normal? did I forget to set up something? I couldn't find any performance warnings or pointers on Mezzanine's documentation; searching around didn't help either. I must add, I am running this against a PostgreSQL database (not SQLite!) and that bulk_create is not an option either, because Mezzanine expects the model's save method to be called (didn't see that documented either!). -
Wagtail/Django internationalization Language select
I am having a bit of a dilema with Wagtail internationalization. my url.py looks like this urlpatterns = [ url(r'^django-admin/', include(admin.site.urls)), url(r'^admin/', include(wagtailadmin_urls)), url(r'^documents/', include(wagtaildocs_urls)), #url(r'^search/$', search_views.search, name='search'), # For anything not caught by a more specific rule above, hand over to # Wagtail's page serving mechanism. This should be the last pattern in # the list: url(r'', include(wagtail_urls)), # Alternatively, if you want Wagtail pages to be served from a subpath # of your site, rather than the site root: # url(r'^pages/', renders(wagtail_urls)), url(r'^i18n/', include('django.conf.urls.i18n')), ] urlpatterns += i18n_patterns( # These URLs will have /<language_code>/ appended to the beginning url(r'^search/$', search_views.search, name='search'), url(r'', include(wagtail_urls)), ) base settings file looks like this MIDDLEWARE = [ 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware', 'wagtail.wagtailcore.middleware.SiteMiddleware', 'wagtail.wagtailredirects.middleware.RedirectMiddleware', ] Then my menu template looks like this <form action="{% url 'set_language' %}" method="post">{% csrf_token %} <input name="next" type="hidden" value="{{ request.get_full_path|slice:'3:' }}" /> <select name="language" onclick="Bonjour"> {% get_current_language as LANGUAGE_CODE %} {% get_available_languages as LANGUAGES %} {% get_language_info_list for LANGUAGES as languages %} {% for language in languages %} <option value="{{ language.code }}"{% if language.code == LANGUAGE_CODE %} selected="selected"{% endif %}> {{ language.name_local }} ({{ language.code }}) </option> {% endfor %} </select> <input type="submit" … -
django form clean data some field missing
In the following Django form: class UserForm(forms.ModelForm): username = ... password = ... password2 = ... class Meta: model = User fields = ['username', 'password'] def clean_password(self): print(self.cleaned_data) return password def clean_password2(self): print(self.cleaned_data) return password2 The self.cleaned_data in the first method contains only two fields: username and password. However, the one in the second method has all three fields. Is that normal? If yes, why is that? Does Django insert fields one after another? -
Why I got django OperationalError: no such table: live_person while I had this table inside my models file?
I couldn't understand the reason of this error message: OperationalError: no such table while in the picture the model file have this table -
NoReverseMatch in Django [Newbie]
I've been trying to figure this out for a while now but I feel like I don't know the framework well enough to debug this myself. Basically I'm creating a little blog style site and I'm trying to create a list of posts which can link to the page to read the post itself. I have a for loop in my template: templates/home.py <h1>Home Page</h1> <p>welcome to the ven home page, {{ username }}!</p> <a href="{% url 'users:logout' %}">Click here to log out</a> <br> <a href="{% url 'posts:create' %}">Click here to create a post</a> <h2>Posts:</h2> {% for post in posts %} <div> <hr> <a href="{% url 'posts:show' id=post.id %}"><h4>{{post.title}}</h4></a> <p>{{post.body}}</p> <p><i>{{post.tags}}</i></p> </div> {% endfor%} It's the line <a href="{% url 'posts:show' id=post.id %}"><h4>{{post.title}}</h4></a> which is causing the problem. I'm getting the error Reverse for 'show' with keyword arguments '{'id': 1}' not found. 1 pattern(s) tried: ['posts/(?P<post_id>\\d+)/view/$'] here is my urls file url(r'^$', views.CreateFormView.as_view(), name='create'), url(r'^(?P<post_id>\d+)/view/$', views.show_post, name='show') The create method link works fine and here is the view which loads the template: def home(request): if not request.user.is_authenticated: return redirect('users:login') posts = Post.objects.all() username = request.user.username return render(request, 'ven/home.html', {'username': username, 'posts': posts}) If more information is needed then let me … -
Using arguments passed as context in forms
I have a view which passes a context to a template like this context = { 'items': items, } items is a collection/list of items. In my template, I list all of these items and create a form with a button for each of them. Now I want to be able to do something with each of them and the form looks something like this: <form action= "{% url 'app:page' %}" method="POST"> {% csrf_token %} <input type="hidden" name="something" value="{{item.id}}"/> <button type="submit">ButtonCaption</button> </form> I want to get the information, which item id has been chosen to the view for the page. I'd normally do it with forms.Form, but in this case I rely on something chosen in the template. How do I get the {{item.id}} to my view? -
Django, view email fetched by imaplib on my webpage
I'm trying to create a mail client using Django. I am fetching the body of the emails from my inbox this way using imaplib: def get_email_body(username, password, imap, email_id): USERNAME = username PASSWORD = password IMAP = imap mail = imaplib.IMAP4_SSL(IMAP) mail.login(USERNAME, PASSWORD) try: mail.select("inbox") result, data = mail.search(None, "ALL") ids = data[0] id_list = ids.split() current_email_id = int(id_list[-1]) - int(email_id) result, data = mail.fetch(str(current_email_id), "(RFC822)") raw_email = data[0][1].decode("utf-8") return raw_email except Exception as ex: print(ex) How can i display my emails from this form: multipart email to this form: beautiful gmail email I would be thankful if you give me at least directions to study the problem. Thank you! -
Changing from Django form to ReactJS
Currently I have a django sign up form rendered with a django template. I'm starting to switch to ReactJS so I wanted to change that form to a Modal window rendered with react. The modal will replace the form so it will contain a form in its body containing the same input fields as the django form, before starting i need to know if the modal will work the same as the form or do I need to do some changes like binding it to the django view. -
django : raspberry pi LED using javascript
I'm developing my own WEB using Django web frame. I'm trying to turn Raspberry pi LED on only using Javascript. var gpio = require("pi-gpio"); gpio.open(16, "output", function(err){ gpio.write(16, 1, function(){ gpio.close(16); }); }); <script src='../static/bundle.js'></script> I downloaded browserify to use require module in my browser SO, I made by typing 'npm run build' in terminal. But, I got this error Uncaught TypeError: fs.readFileSync is not a function at Object.5.child_process(bundle.js:436) at s (bundle.js:1) at bundle.js:1 at Object.1.pi-gpio (bundle.js:2) at s (bundle.js:1) at e (bundle.js:1) at bundle.js:1 -
Why is the str() used in this situation?
These are the codes from django.db.models.fields __all__ = [str(x) for x in ( 'AutoField', 'BLANK_CHOICE_DASH', 'BigAutoField', 'BigIntegerField', 'BinaryField', 'BooleanField', 'CharField', 'CommaSeparatedIntegerField', 'DateField', 'DateTimeField', 'DecimalField', 'DurationField', 'EmailField', 'Empty', 'Field', 'FieldDoesNotExist', 'FilePathField', 'FloatField', 'GenericIPAddressField', 'IPAddressField', 'IntegerField', 'NOT_PROVIDED', 'NullBooleanField', 'PositiveIntegerField', 'PositiveSmallIntegerField', 'SlugField', 'SmallIntegerField', 'TextField', 'TimeField', 'URLField', 'UUIDField', )] I think str(x) for x in (...) and x for x in (...) are the same in this situation. Why is the str() used? -
ManyToMany admin field with filter
I was trying to get a filter feature for my admin, otherwise it is tough to find the value the data-entry would need to find. Something like this: what i wanted I found that in demo.django-blog-zinnia.com/admin/zinnia/entry/add/ (the login info for the site is user: demo, pass: demo) -
JsonResponse is not returning data back to server in django
There is problem in my code, nothing is getting returned to server. class GetIMData(CSRFExemptView): def post(self, request): json_data = json.loads(request.POST['payload']) JsonResponse({'data':json_data}) requests.post(response_url, data) return -
Django - How to create a simple confirmation view?
I'm trying to create a View in which the user is asked to confirm an action of updating a value of an instance. I want the View to only have a submit button. What I want is similar to a DeleteView except what I want is to update a value of a record instead of deleting the record. I have tried using Class based UpdateView, but it requires that I specify a fields parameter in which I must specify at least one field and I do not want to show any field, just the submit button. This is what my template now looks like: <h4>Complete {{ item.name }}?</h4> <form method='POST' class="gia-form"> {% csrf_token %} {{ form.as_p }} <input type="submit" class="button" value="Complete Item"> <a href="{% url 'items:home' %}">Cancel</a> </form> Url for the view: url(r'^action/complete-item/(?P<pk>\d+)/$', views.CompleteItemView.as_view(), name='complete'), My UpdateView: class CompleteItemView(UpdateView): model = models.Item template_name = 'items/complete_item.html' fields = ("status",) def form_valid(self, form): form.instance.status = 'completed' return super().form_valid(form) Above I have chosen to show the status field, and this is what I'm trying to get rid of in an elegant way as I just want to show the confirm button without any fields. -
populate form field with current values
I have a form for creating and updating the rental space. For creating, it is working ok but for updating the form is shown empty. Rather it should show the current value in the fields. How can i now populate the field with current values when updating? Here is what i have done url(r'^rents(?:/(?P<token>[0-9a-z]+))?', Rent.as_view(), name="rent"), class RentSerializer(serializers.ModelSerializer): owner = serializers.SerializerMethodField() class Meta: model = Rental read_only = ('id', 'token', 'created_on', 'modified_on', 'slug', ) fields = ('__all__') def get_owner(self, obj): return str(obj.owner) def create(self, validated_data): #same as update just change to .create() def update(self, instance, validated_data): instance = super(RentSerializer, self).update(instance, validated_data) return instance views.py class Rent(APIView): """ List all the rents if token is not provided else a token specific rent """ serializer_class = RentSerializer def get(self, request, token=None, format=None): reply={} try: rents = Rental.objects.filter(owner=request.user) if token: rent = rents.get(token=token) reply['data'] = self.serializer_class(rent).data else: reply['data'] = self.serializer_class(rents, many=True).data except Rental.DoesNotExist: return error.RequestedResourceNotFound().as_response() except: return error.UnknownError().as_response() else: return Response(reply, status.HTTP_200_OK) def post(self, request, token=None, format=None): rent = None # if token is None, its a list new rent if not token is None: try: rent = Rental.objects.filter(owner=request.user).get(token=token) except Rental.DoesNotExist: return error.RequestedResourceNotFound().as_response() except: return error.UnknownError().as_response() serialized_data = self.serializer_class(instance=rent, data=request.data, partial=True) if serialized_data.is_valid(): … -
django admin missing style when deploying on heroku
I recently deployed an app to heroku. I get my app running however the admin page is missing the styles. I searched on the internet and found that doing python manage.py collectstatic works but it did not work to me. I have also configured the static files in settings.py. What have i missed? Here is what i have done settings.py STATIC_ROOT = os.path.join(BASE_DIR, "static_collected") STATICFILES_DIRS = (os.path.join(BASE_DIR, "static"), ) STATIC_URL = '/static/' MEDIA_URL = "/media/" MEDIA_ROOT = os.path.join(BASE_DIR,"media") urls.py(of main project) if settings.DEBUG: urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) I did collectstatic and static_collected folder was created in the root folder. And then pushed the changes using git push heroku master but still not working. Do i have to do any more? -
dependencies reference nonexistent parent node error in Django
So, I am learning Django using Django By Example book. I moved to a new chapter where I needed to make a new project and app. This is what I did. djnago-admin startproject myshop cd to myshop directory django-admin startapp shop python manage.py migrate I am unable to migrate with the follwing error. django.db.migrations.exceptions.NodeNotFoundError: Migration django.db.migrations.exceptions.NodeNotFoundError: Migration auth.0009_user_following dependencies reference nonexistent parent node (u'account', u'0002_contact') I did make Contact model in account app in my last project. How is the new project related to the old one? Please help me resolve this problem. Thanks. -
How to pass slug as url in Django
I am trying to pass slug in the Url, but I am unable to do so. The slug is in the form like if have a text:- text: - This is Stackoverflow slug:- this-is-stackoverflow but I am unable to achieve this. my url i am trying is:- url(r'^email/edit/(?P<email_template_id>[\w-]+)/$', email_managment.email_send, name='email-edit') my views is like that:- @login_required @csrf_exempt def email_send(request,email_template_id): try: form = emailTemplates(request.POST or None) edit_email_end = 'add' email_template_obj = {} if request.method == 'POST': if form.is_valid(): subject = request.POST.get('subject') lowercase = subject.lower() slug = lowercase.replace(" ","-") print slug content = request.POST.get('content') if email_template_id is None or email_template_id == '': add_email_template_entry = EmailTemplates(subject=subject, content=content,slug=slug) add_email_template_entry.save(using="cms") messages.success(request, 'Successfully added to the email template page') elif email_template_id: email_template_obj = EmailTemplates.objects.using("cms").get(id=email_template_id) email_template_obj.subject = subject email_template_obj.content = content email_template_obj.slug = slug email_template_obj.save(using="cms") messages.success(request, 'Successfully update to the email templates') return redirect('cms:email-list') if email_template_id is not None: edit_email_end = 'edit' email_template_obj = EmailTemplates.objects.using("cms").get(id=email_template_id) return render(request, 'templates/email_managment/add_email.html',{ 'edit_email_end': edit_email_end,'email_template_obj':email_template_obj}) except Exception as e: print e raise Http404 the error which is comming is invalid literal for int() with base 10: 'hello-took-of-fools' Please ignore gramatical mistakes if there any. Thanks in advance -
Django FormWizard - How to change next form depends on the selection in previous form?
The first page is the category selection. I want to change next page's form depends which category was selected in previous page. For example, if we select category A in first page, next page will show form A. First page {% block content %} <p>Select Category</p> <p>Step {{ wizard.steps.step1 }} of {{ wizard.steps.count }}</p> <form action="" method="post" id="select_category_form" novalidate>{% csrf_token %} {{ wizard.management_form }} <input type="radio" value="a">a **next page's form will be form a** <input type="radio" value="b">b **next page's form will be form b** <input type="submit" value="submit"> </form> {% endblock %} Next page {% block head %} {{ wizard.form.media }} {% endblock %} {% block content %} <p>Step {{ wizard.steps.step1 }} of {{ wizard.steps.count }}</p> {% for field in form %} <p>{{ field.label }}:{{ field.value }}</p> {% endfor %} <form action="" method="post" novalidate>{% csrf_token %} {{ wizard.management_form }} <input type="submit" value="submit"/> </form> {% endblock %} views.py TEMPLATES = {'0': 'classifieds/post_select_category.html', '1': 'classifieds/post_new.html'} class PostWizard(SessionWizardView): form_list = [I don't know what should I do here] def get_template_names(self): return [TEMPLATES[self.steps.current]] def done(self, form_list, **kwargs): return redirect('post_detail') I have 3 forms. SelectCategoryForm: This is for first page. JobsPostForm and RealEstatePostForm: These forms are for second page. Depends on selecting category in first page, … -
How to update packages after upgrading Django?
I'm using Django 1.8.4 and currently in the process of upgrading it to 1.11.1 I have many packages and dependencies installed inside a virtual environment, and I'm not sure how should I check/update them. How can I easily check what should be updated? How can I check which packages are not supported yet with the latest Django? Should I do it manually or is there a tool that helps handle large number of packages? Thanks,