Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
incuding DetailView context in ListView page in the Order history page using Django
Hi Djangonauts, I would like to add some Order details(DetailView) in the Order history page(ListView), See image example below ( I have made the image on photoshop). I was able to get the grey part (order list to show) But I am not able to get the item details to show in this page. If I click View Order Detail it goes to detail page where I can show all this. But I need a small summary in the ListPage too see example below below are my view.py class OrderHistory(LoginRequiredMixin, ListView): model = Order template_name = 'order/order_list.html' def get_context_data(self, **kwargs): context = super(OrderHistory, self).get_context_data() context['order_details'] = Order.objects.filter(emailAddress=self.request.user.email) context['order_items'] = OrderItem.objects.filter(order=self.kwargs.get("order")) return context I even tried # context['order_items'] = OrderItem.objects.filter(order__id=self.kwargs.get("order.id")) Below are my models.py from django.db import models class Order(models.Model): token = models.CharField(max_length=250, blank=True) total = models.DecimalField(max_digits=6, decimal_places=2, verbose_name='USD Order Total') emailAddress = models.EmailField(max_length=100, blank=True, verbose_name='Email Address') created = models.DateTimeField(auto_now_add=True) billingName = models.CharField(max_length=350, blank=True) billingAddress1 = models.CharField(max_length=350, blank=True) billingCity = models.CharField(max_length=100, blank=True) billingZipcode = models.CharField(max_length=10, blank=True) billingCountry = models.CharField(max_length=50, blank=True) class OrderItem(models.Model): product = models.CharField(max_length=250) quantity = models.IntegerField() price = models.DecimalField(max_digits=5, decimal_places=2, verbose_name='USD Price') order = models.ForeignKey(Order, on_delete=models.CASCADE) def sub_total(self): return self.quantity * self.price Below are my templates Its not needed … -
While using Django Social/All Auth - How can I specify what I want to store as a username?
I am using Google social auth as the only way to login to the site, and I want to be able to specify the username that I am storing. Currently, it is just the user's first name, but I'd like it to be their email address, not including the domain. For example, if their email is test@gmail.com, I want test as the username. I have tried it using receivers such as below, but it seems to have no effect: @receiver(pre_save, sender=User) def update_username_from_email(sender, instance, **kwargs): username = instance.email.split("@")[0] instance.username = username -
pdf invoice of multiple items, doesn't cuts page
Image: If items are small, workds fine with a5 paper size Image: When items are more, white space on right adds up Am using XHTML2PDF library in django python, i have tried out: @frame, it works but truncates content even with shrink cant use: pdf:nextpage tag p { margin: 0; -pdf-keep-with-next: true; } and putting table data in paragraph What i want is: When the products size grows, if they fall off page, the page shall break automatically, and rest of products shall be printed to next page (either with header and footer or without) (i.e. td tag data), i can't use pdf:nextpage after 5-6 items as product name might be large that only 2-3 products fall out of page or maybe small that 10 items fit to single page, it read lots of answers none actually worked, though they pretend to solve problem. and i have to use html template only, cant use reportlab tags. HTML: <html> Not actual HTML code, but looks like <style> @page { size: a5 portrait; margin-top: 0; margin-bottom: 0; } table { -pdf-keep-in-frame-mode: shrink;} <style> <body> {% for data in products %} <table><tr><td>{{data.name}}<table><tr><td> <tr><td>{{data.price}}<table><tr><td> <tr><td>{{data.mrp}}<table><tr><td></table> {% endfor %} </body> </html> Python Django API looks … -
PostgreSQL type casting failure in INSERT queries on copied tables
I'm trying to migrate tables in my PostgreSQL DB from one schema to another in my Django project. I removed and recreated my migration scripts to consolidate my DB changes and that part works beautifully. However I am running into issues copying my data. The query INSERT INTO table_name SELECT * FROM other_schema.table_name will work about 1/4 of the time. However, I often get odd TYPE errors like the following: ERROR: column "doc_date" is of type timestamp with time zone but expression is of type integer LINE 2: SELECT * FROM django_apps.db_comments_dbcomment Then I break out my INSERT statement using a CTE and type casting like so: WITH dbComments AS ( SELECT id, created_date, modified_date, doc_date::TIMESTAMP, customer_number, customer_name, db_table, db_table_number, note_processed::BOOLEAN, note_modified::BOOLEAN, comment_id, customer_id, created_by_id, modified_by_id FROM django_apps.db_comments_dbcomment ) INSERT INTO db_comments_dbcomment SELECT * FROM dbComments; However, I still get the following error ERROR: column "note_modified" is of type boolean but expression is of type integer LINE 21: SELECT * FROM dbComments; despite the fact that I've already cast that field to boolean (since I know conversion between BOOLEAN and INTEGER is a problem with glob SELECT statements). If anyone has any ideas how I can force no modification in … -
Django: File not downloading, but opening in browser
I have a Django model that has a file upload field in a model. I want the file to be downloaded when clicked on a webpage, However, when the button is clicked it just opens up in the browser. It seems pretty straight forward w3schools, but I can't get it to work. HTML Page {% if obj.document %} <td><a href="{{ obj.document.url }}" download>File</td> {% else %} Models.py @property def document_url(self): if self.document and hasattr(self.document, 'url'): return self.document.url If I put the {{ obj.document.url }} instead of File I see the path to the file on AWS. Thought? -
ImportError: No module named 'django_select2'
I am trying to deploy my django application on the pythonanywhere. I have have install all the packages that requires for the application. I am also using django_select2 reusable app in my application. Firstly, i activate virtual environment and install the django_select2 by this command. $ pip install django_select2 when i execute below command $ pip freeze cryptography==2.2.2 Django==2.0.7 django-appconf==1.0.2 django-select2==6.1.0 Flask==1.0.2 Flask-JWT==0.3.2 Flask-SQLAlchemy==2.3.2 furl==1.2 idna==2.7 As you see django_select2 is also in the installed list. I also check site-packages inside my virual environment. There is also django_select2 folder. However when i run my app it generates the ImportError: No module named 'django_select2' inside my error.log Here is the part of my error.log 2018-07-14 14:18:53,934: Error running WSGI application 2018-07-14 14:18:53,934: ImportError: No module named 'django_select2' 2018-07-14 14:18:53,934: File "/var/www/harunergul_pythonanywhere_com_wsgi.py", line 22, in <module> 2018-07-14 14:18:53,935: application = get_wsgi_application() 2018-07-14 14:18:53,935: 2018-07-14 14:18:53,935: File "/usr/local/lib/python3.5/dist-packages/django/core/wsgi.py", line 13, in get_wsgi_application 2018-07-14 14:18:53,935: django.setup(set_prefix=False) 2018-07-14 14:18:53,935: 2018-07-14 14:18:53,935: File "/usr/local/lib/python3.5/dist-packages/django/__init__.py", line 27, in setup 2018-07-14 14:18:53,935: apps.populate(settings.INSTALLED_APPS) 2018-07-14 14:18:53,935: 2018-07-14 14:18:53,935: File "/usr/local/lib/python3.5/dist-packages/django/apps/registry.py", line 85, in populate 2018-07-14 14:18:53,936: app_config = AppConfig.create(entry) 2018-07-14 14:18:53,936: 2018-07-14 14:18:53,936: File "/usr/local/lib/python3.5/dist-packages/django/apps/config.py", line 90, in create 2018-07-14 14:18:53,936: module = import_module(entry) Any suggestions? What i have … -
Django sort on paginated results
I am creating a list view in Django 2 using CBV. The pagination is working however I am now trying to add sorting to my pagination. This sorting will work whereby when the user selects a column, it will append a GET query string and then when I render my view, I will order_by the QueryResult. This is working however I am now only fetching 4 entries (my current page) as opposed to the entire set. My problem is that I need it to filter only on the current page results but then return the current page and the rest of the results. This is my current solution: class AccountList(ListView): ordering_dict = { 'pk':'asc', 'is_active':'asc','created':'asc' } template_name = "marketing/comm_list.html" context_object_name = 'comms' paginate_by = 4 def get_queryset(self): type_filter = self.request.GET.get('type', 'all') queryset = Comm.objects.values('pk', 'name', 'is_active', 'created') page_field = self.request.GET.get('page') paginator = Paginator(queryset, 4) try: pages = paginator.page(page_field) except PageNotAnInteger: pages = paginator.page(1) except EmptyPage: pages = paginator.page(paginator.num_pages) start_index = pages.start_index() end_index = pages.end_index() queryset = Comm.objects.values('pk', 'name', 'is_active', 'created').filter(pk__gte=start_index, pk__lte=end_index) order_by_field = self.request.GET.get('order_by') if order_by_field: if self.ordering_dict[order_by_field] == 'asc': self.ordering_dict[order_by_field] = 'desc' else: self.ordering_dict[order_by_field] = 'asc' order_by_field = '-'+order_by_field queryset = queryset.order_by(order_by_field) else: queryset = queryset.order_by('-created') return queryset Any … -
Django CSRF error with AJAX on iOS 8
I am trying to make an AJAX call to a Django function, but have started getting a CSRF Verification failed error in iOS 8. It works with the latest iOS and used to work with iOS 8. This may be related to the recent updates to TLS. My host recently deprecated TLS 1.0 and TLS_RSA_WITH_3DES_EDE_CBC_SHA. I add the CSRF token as a post parameter. If I make the function (server-side) @csrf_exempt then the call works, but I obviously don't want to take away the security. I have only tested this in Safari. I'm using Django 1.5.2. HTML: # this creates an input with the CSRF token as its value <div id = "csrf_token" class = "hidden">{% csrf_token %}</div> Javascript: csrfmiddlewaretoken = $('#csrf_token input').val(); $.ajax({ type: "POST", url: "<my_url>", data: {"csrfmiddlewaretoken":csrfmiddlewaretoken}, success: function(data){ alert("ok"); } ,error: function(xhr, status, error) { alert("error " + xhr.responseText); } }); Is there any solution to this or must I stop supporting iOS 8? I still have some users who use it. -
what does this mean i cant uderstand what r'^$' mean in url(r'^$',views.index,name='index') i created a view index in views.py
i am familiar with regular expression still cannt uderstand what r'^$' actually does -
Django REST Serializer uses wrong Model for serialization
Problem: My serializer uses the wrong Model for serialization. I expected that the serializer uses my ProfileInfo model but it does not. It uses the User model. They have an OneToOneRelationship. I do not know why because I defined in the meta that the serializer should use the ProfileInfo model. So when I try to serialize the username with -> username=serializers.Field(source='user.username') Django shows this error: 'User' object has no attribute 'user'. Can you please explain to me why the wrong model is used ? Thank you for your help. Serializers: class ProfileInfoSerializer(serializers.ModelSerializer): image = serializers.SerializerMethodField() socialMediaLinks = serializers.SerializerMethodField("get_social_media_links") username = serializers.Field(source='user.username') class Meta: model = ProfileInfo fields = ['username', 'description', 'image', 'socialMediaLinks'] def get_image(self, obj): request = self.context.get('request') photo_url = obj.image.url return request.build_absolute_uri(photo_url) class UserInfoSerializer(serializers.ModelSerializer): user = ProfileInfoSerializer() wingman = ProfileInfoSerializer() clan = ClanSerializer() class Meta: model = ProfileInfo fields = ['user', 'clan', 'wingman'] Model: class ProfileInfo(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True) wingman = models.OneToOneField(User, on_delete=None, related_name="wingman", null=True) clan = models.ForeignKey(Clan, on_delete=None) image = models.ImageField(upload_to="", default="", null=True) description = models.CharField(max_length=5000, null=True) Api: class ProfileInfoApi(APIView): def get(self, request, id): profileInfo = ProfileInfo.objects.get(pk=id) serializer = UserInfoSerializer(profileInfo, context={'request': request}) return Response(serializer.data) -
how can config gunicorn and nginx in ubuntu server for django
hi every one i follow this tutorial for config my ubuntu 16.04 serever but it didnt work turly my "/etc/systemd/system/gunicorn.service" file : [Unit] Description=gunicorn daemon After=network.target [Service] User=majid Group=www-data WorkingDirectory=/home/majid/intec ExecStart=/home/majid/my_env/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/majid/intec/intec.sock intec.wsgi:application [Install] WantedBy=multi-user.target and my nginx config is: server { listen 80; intec 54.36.*.*; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /home/majid/intec; } location / { include proxy_params; proxy_pass http://unix:/home/majid/intec/intec.sock; } } my Venv path :'home/majid/my_enve' my project : 'home/majid/intec' setting.py 'path :/home/majid/intec/intec' thanks a lot for your time and your help -
user creation form with custom user model is not authenticated django 2.0
I tried to know what is wrong but i couldn't. I made custom user model and added custom backend when the user is registered through the form a new user is created in the database but the user is not authenticated, and the user is redirected to the login view. here is the custom model: class User(AbstractBaseUser, PermissionsMixin): email = models.EmailField(unique=True, blank=False) slug = models.SlugField(blank=True) name = models.CharField(max_length=100, blank=True) is_active = models.BooleanField(blank=True, default=True) is_admin = models.BooleanField(blank=True, default=False) date_joined = models.DateField(blank=True, auto_now_add=True) objects = UserManager() USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] class Meta: verbose_name = 'user' verbose_name_plural = 'users' def email_user(self, subject, message, from_email=None, **kwargs): send_mail(subject, message, from_email, [self.email], **kwargs) def save(self, *args, **kwargs): if not self.slug: if self.name: self.slug = slugify(self.name + urandom(5).hex()) else: self.slug = slugify(urandom(5).hex()) return super().save(*args, **kwargs) @property def is_superuser(self): return self.is_admin @property def is_staff(self): return self.is_admin the backend: class UserAuthenticationBackend(): def authenticate(self, request, username, password): try: user = get_user_model().objects.get(email=username) if user.check_password(password): return user return None except user.DoesNotExist: return None def get_user(self, user_id): try: user = get_user_model().objects.get(pk=user_id) if user.is_active: return user return None except user.DoesNotExist: return None the registration form: class RegisterationForm(UserCreationForm): password1 = forms.CharField( label="Password", strip=True, widget=forms.PasswordInput, help_text=get_password_help_text(), validators=[ RegexValidator( regex='^(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+*!=]).*$', message='''Password must contain at least … -
The formal abstract concept for model relationships connectors
There are three model relationships class Article(models.Model): headline = models.CharField(max_length=100) publications = models.ManyToManyField(Publication) reporter = models.ForeignKey(Reporter, on_delete=models.CASCADE) copyright = models.OneToOneField(Property) The connecting pivot of many-to-one is abstracted as ForeignKey, but others are called ManyToManyField and OneToOneField which seems not a good abstract concept to reference. How about to mention the three all, should I say "publications", "reporters","copyright" are connecting point? It's frivolous to ask but google searches are not helpful. ForeignKey is a good abstract concept, how about the other two and even mention them three? -
While saving .csv to database error occured:-' list index out of range '
def import_db(request): f=open('product.csv','r') for row in f: row = row.split('!') tmp = AdminProduct.objects.create() tmp.id = row[0] tmp.productname = row[1] tmp.barcode = row[2] tmp.company = row[3] tmp.size = row[4] tmp.price = row[5] tmp.description = row[6] tmp.category = row[7] tmp.subcategory = row[8] tmp.product_tag = row[9] tmp.image = row[10] tmp.save() f.close() This error(list index out of range) occured while saving .csv file into database. -
Nginx + Django + Gunicorn: 502 Bad Gateway upstream prematurely closed connection while reading response header from upstream
I am creating (for the first time) a website. More specifically, the user uploads an image and after some computations the website displays some result. However, sometimes (not always, sometimes just retrying or changing image it works) during this process I get "502 Bad Gateway nginx/1.10.3 (Ubuntu)" Looking at the error I get: [error] 7836#7836: *16 upstream prematurely closed connection while reading response header from upstream, client: 131.175.147.1, server: _, request: "POST / HTTP/1.1", upstream: "http://unix:/home/django/gunicorn.socket:/", host: "165.227.170.231", referrer: "http://165.227.170.231/" I tried this but it did not help much, while I think this is not my case. The settings are: /etc/nginx/sites-available/django : upstream app_server { server unix:/home/django/gunicorn.socket fail_timeout=0; } server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /usr/share/nginx/html; index index.html index.htm; client_max_body_size 4G; server_name _; keepalive_timeout 5; # Your Django project's media files - amend as required location /media { alias /home/django/django_project/django_project/media; } # your Django project's static files - amend as required location /static { alias /home/django/django_project/django_project/static; } # Proxy the static assests for the Django Admin panel location /static/admin { alias /usr/lib/python2.7/dist-packages/django/contrib/admin/static/admin/; } location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_redirect off; proxy_buffering off; proxy_connect_timeout 75s; proxy_read_timeout 300s; proxy_pass http://app_server; } } The /etc/nginx/nginx.conf: … -
Make it to throw errors if no records found using .filter
When I search for a record which does not recorded in database, it return a null In [15]: a = Article.objects.filter(title="hello") In [16]: a Out[16]: <QuerySet []> This mean, it silence if I use try and except try: a = Article.objects.filter(title="strange title") except SyntaxError: print("typo, double check") How to make it report error if no records qualified? -
'_TaggableManager' object has no attribute 'name' for blog posts
I'm having some issues with using the TaggableManager. I'm new at using Django so i did and tutorial which is about building a blog. Now i want to add tags to each blog post. I walked through the taggit installation and they say i need to add a custom display method, but none of this is working. (page 7: https://media.readthedocs.org/pdf/django-taggit/stable/django-taggit.pdf) When i want to open a blog post i get that error: AttributeError at /post/4/ '_TaggableManager' object has no attribute 'name' Request Method: GET Request URL: http://127.0.0.1:8000/post/4/ Django Version: 2.0.6 Exception Type: AttributeError Exception Value:'_TaggableManager' object has no attribute 'name' Exception Location: /usr/local/lib/python3.6/site-packages/django/db/models/manager.py in __str__, line 36 Python Executable: /usr/local/opt/python/bin/python3.6 Python Version: 3.6.5 In the following, you can se my code: models.py from django.db import models from django.contrib import admin from django.utils import timezone from taggit.managers import TaggableManager class Post(models.Model): objects = models.Manager() author = models.ForeignKey('auth.User', on_delete=models.CASCADE) title = models.CharField(max_length=200) text = models.TextField() created_date = models.DateTimeField( default=timezone.now) published_date = models.DateTimeField( blank=True, null=True) tags = TaggableManager() def publish(self): self.published_date = timezone.now() self.save() def __str__(self): return self.title class PostAdmin(admin.ModelAdmin): list_display = ['tag_list'] def get_queryset(self, request): return super(PostAdmin, self).get_queryset(request).prefetch_related('tags') def tag_list(self, obj): return u", ".join(o.name for o in obj.tags.all()) -
Django chain filtering results based on selected manytomany fields
I have the following models: class Country(models.Model): name = models.CharField(max_length=50) class State(models.Model): country = models.ForeignKey(Country, on_delete=models.CASCADE) name = models.CharField(max_length=50, null=False, blank=False) class Species(models.Model): name = models.CharField(max_length=50, null=False, blank=False) country =models.ManyToManyField(Country) state =models.ManyToManyField(State) Let say I added multiple countries into the a form or admin field. Is there a way to filter the results from the state field based on what I have selected in the country field? The closest thing I can find that does something similar is django-smart-select but it does not work for my case. -
Web application on local server - 'UnicodeDecodeError' in Python, Django
When I try to run my web application a can see UnicodeDecodeError. Does anyone see what the problem is? how can I fix it? My Django Version: 2.0.7 Python Version: 3.7.0 C:the_weather\weather\views.py in index from django.shortcuts import render # Create your views here. from django.shortcuts import render def index(request): return render(request, 'weather/index.html') #returns the index.html template ... ▼ Local vars Variable Value request <WSGIRequest: GET '/'> views.py code from django.shortcuts import render # Create your views here. from django.shortcuts import render def index(request): return render(request, 'weather/index.html') #returns the index.html template I tried change my code in views.py on this bellow, but unfortunately it did not work. from django.shortcuts import render def index(request): return render(request, '127.0.0.1:8000/weather/index.html') #returns the index.html template -
Django with nginx static file doesn't load
I ran django server with Debug = True option. Yesterday, I changed it to Debug = False, and then static file doesn't load. /etc/nginx/site-enabled/web : server { server_name my_domain; location / { proxy_pass http://127.0.0.1:8000; proxy_set_header X-Real-IP $remote_addr; } location /static/ { alias /home/ubuntu/project/static/; } } settings.py static setting : STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_URL = '/static/' static directory path is not wrong. I run server with python mange.py runserver 0.0.0.0:8000 -
Modal forms and Django URLs, how to work?
html <form action="{% url 'sp_feedback' %}" method="post"> url url(r'^feedback/$', views.post_feedback, name="sp_feedback"), views: return HttpResponseRedirect("") In using modal forms, how do you, after hitting submit, return to the page? In my current setup, the browser redirects to nothing. I'm completely confused on what to put in the url regular expressions. -
Dynamic Django Models
I want to create Dynamic models. class Subject(models.Model): subject_name=models.CharField(...) class Department(models.Model): name=models.CharField(...) subject=models.ManyToManyField(Subject) Now I want to create models for every unique pair of (Department,Subject). Example- Suppose we have a pair- IT(department),Java(subject) and another pair- IT(department),Python(subject). Model for pair (IT, Java) Date/Attributes | Attribute 1 | Attribute 2 | .... |||||||||||||||||||||||||||||||||||||||||||||||||| 05/08/2018 | Value 1 | Value 2 | .... 12/08/2018 | Value 3 | Value 4 | .... The above is an example table for pair (IT, Java). Now we don't know how many pairs of (department,subject) we have as they would be entered by the admin in admin panel. -
AppRegistryNotReady when setting up celery daemon for askbot
I'm trying to setup instant email notifications for askbot and I have to setup celery in order for this to work. I followed the instruction HERE. After I setup the celery, I'm trying to run celery daemon, and that's where the error kicks in. Basically I'm hitting some kind of infinite loop where celery was trying to work. after I setup celery, if I run python manage.py runserver, the website will run locally without a problem but the instant email function will not work if I run python manage.py celeryd, then the following error code shows up and it loops infinitely. The error code is: "The translation infrastructure cannot be initialized before the " AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import time. The full trackback is: [2018-07-14 00:56:54,359: ERROR/Worker-1] Process Worker-1 Traceback (most recent call last): File "D:\Anaconda3\envs\BHTL\lib\site-packages\billiard-3.3.0.23-py2.7-win-amd64.egg\billiard\process.py", line 292, in _bootstrap self.run() File "D:\Anaconda3\envs\BHTL\lib\site-packages\billiard-3.3.0.23-py2.7-win-amd64.egg\billiard\pool.py", line 292, in run self.after_fork() File "D:\Anaconda3\envs\BHTL\lib\site-packages\billiard-3.3.0.23-py2.7-win-amd64.egg\billiard\pool.py", line 395, in after_fork self.initializer(*self.initargs) File "D:\Anaconda3\envs\BHTL\lib\site-packages\celery-3.1.18-py2.7.egg\celery\concurrency\prefork.py", line 58, in process_initializer app.loader.init_worker() File "D:\Anaconda3\envs\BHTL\lib\site-packages\celery-3.1.18-py2.7.egg\celery\loaders\base.py", line 128, in init_worker self.import_default_modules() File "D:\Anaconda3\envs\BHTL\lib\site-packages\django_celery-3.1.17-py2.7.egg\djcelery\loaders.py", line 140, in import_default_modules super(DjangoLoader, self).import_default_modules() File "D:\Anaconda3\envs\BHTL\lib\site-packages\celery-3.1.18-py2.7.egg\celery\loaders\base.py", line 121, in … -
Condition on django-filter fields for display
Is there any way to apply condition on fields of model while filtering like for example I have a field say 'Bookscount' having integer values and if user opts for value > 5 then django-filter displays all those books having 'Bookscount' > 5 import django_filters as df from .models import Books class BooksListFilter(df.FilterSet): class Meta: model = Books fields = ['Bookscount'] -
How to collect the billing address information in Django Oscar?
How do I collect the billing address information in my Django Oscar Payment details view? So far I have read the code of Django Oscar in github and in the method handle_place_order_submission() here:https://github.com/django-oscar/django-oscar/blob/05049733e5c6152e37f7b99d957fd67d825c78b8/src/oscar/apps/checkout/views.py#L442 ,the code is: def handle_place_order_submission(self, request): return self.submit(**self.build_submission()) they say that I should override this method and then call build_submission. So I had forked my checkout app and then under PaymentDetailsView(). I wrote a function named build_submission and also imported the BillingAddressForm() , from oscar.apps.payment.forms import BillingAddressForm. def build_submission(self, **kwargs): submission = super( PaymentDetailsView, self).build_submission(**kwargs) submission['billing_address'] = BillingAddressForm(self.request.POST) return submission I would build a form in payment_details.html to collect the Billing Address.Now in my HTML should I give all the fields similar to the ones in Shipping Address Form and what should I do when the form is submitted? I already have the Stripe payments gateway integrated in a form, so what it does is:<form action="{% url 'checkout:preview' %}" class="form-stacked" method="POST"> Now how do I validate the form for billing address?I am new to Oscar so an answer with some code might help me understand better. Or is there any other way through which I can collect the Billing address from the user?