Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Format Django's server display
For debugging, I add print statement to URL Controller. urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^polls/', include('polls.urls')), ] print('urlpatterns: \n', urlpatterns) Server display reads: $ ipython manage.py runserver 8080 Performing system checks... urlpatterns: [<RegexURLResolver <RegexURLPattern list> (admin:admin) ^admin/>, <RegexURLResolver <module 'polls.urls' from '../Documents/Public/Dev/django-tutorial-repo/polls/urls.py'> (None:None) ^polls/>] System check identified no issues (0 silenced). The results I desire is that readable as IPython does in an interactive mode.like, urlpatterns: [<RegexURLResolver <RegexURLPattern list> (admin:admin) ^admin/>, <RegexURLResolver <module 'polls.urls' from '../Documents/Public/Dev/django-tutorial-repo/polls/urls.py'> (None:None) ^polls/>] An IPython automatic format example, In [4]: dir('') Out[4]: ['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__',] Alternatively, I can edit the print statement one by one. How to set the configuration to enable this function? -
Django Python: Only changed Email Address and now failed to send mail with error
I really dont know what happend. I just changed the Adress of EMAIL_HOST_USER = .. and now i cant send an Email any more. The worst is i tried to revert it but even this doesn't work any more. I really don't get it, i must have changed something without noticing. in my settings.py i have the following: EMAIL_HOST = 'smtp.web.de' EMAIL_HOST_USER = 'myadress@web.de' EMAIL_HOST_PASSWORD = 'mypass' EMAIL_PORT = 587 EMAIL_USE_TLS = True EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' and the error appers on this code: send_mail( 'Subject', 'Blah blah blah', 'myadress@web.de', ['to.thisaddress@web.de'], fail_silently=False ) the error which is caused is this: [Errno 10061] Es konnte keine Verbindung hergestellt werden, da der Zielcomputer die Verbindung verweigerte Sry its German but it English it means that there is no connection possible to the target-computer By debugging i realized the following: that auth_password and auth_user is None (see in the picture). I Think that could be the problem but i real have no idea how to fix it. I have really checked my address and password a thousand times an it is corret also the problem cant be the email provider web.de i think because both adresse, before and after i changed it, are from … -
Salesforce rate limits: uploading contact details from web app
I have a Python/Django + JS web app that stores user data in a PostgreSQL database. I want to now add a sign-up/subscribe form that uploads the user's contact details to Salesforce and I'm looking for a robust way to do this. I'm confused about the multiple ways to upload to Salesforce and how there are different API limits I have to worry about. It's difficult to estimate how popular the app is going to be and I don't want to lose contact details or have to show a "sorry, try signing up another time" message. Options I've considered: Use web to lead to upload via JavaScript (limit of 500 uploads per day). Use a Python library that uploads each user at the time of submission. Use Heroku Connect to sync the database to Salesforce (looks expensive and you need to ask for a quote). Add all the user data to a database table and run a scheduled job that uploads each row in batches periodically so if I hit rate limits they'll get uploaded eventually. Most complex to implement. -
Define which fields are shown in a Django forms.ModelForm list
I want to restrict which fields are shown in the list view of a Django forms.ModelForm I can restrict which fields are shown in the update and create forms but can't work out how to do this for the list view of the form. My model looks like this: class Teacher(models.Model): name = models.CharField(max_length=255) email = models.CharField(max_length=30) slug = extension_fields.AutoSlugField(populate_from='name', blank=True) My view code looks like this: class TeacherListView(GroupRequiredMixin, ListView): model = Teacher group_required = [u"school_admin"] login_url = "/login/" My form code looks like this: class TeacherForm(forms.ModelForm): class Meta: model = Teacher fields = ['name', 'email' ] I am trying to hide the slug field from the list view. -
How can the foreign field shows the name instead of its id?
In my models.py, there are two model, the AvailableArea has a foreign field refer to AddressRegion: class AddressRegion(models.Model): name = models.CharField(max_length=8) def __str__(self): return self.name def __unicode__(self): return self.name class AvailableArea(models.Model): name = models.CharField(max_length=8) addressregion = models.ForeignKey(AddressRegion, default=1, related_name='availableareas', on_delete=models.CASCADE) def __str__(self): return self.name def __unicode__(self): return self.name In the serializers.py, I serialize all the fields: class AvailableAreaSerializer(ModelSerializer): """ 可用地区 """ class Meta: model = AvailableArea fields = "__all__" In the views.py: class AddressRegionListAPIView(ListAPIView): serializer_class = AddressRegionSerializer permission_classes = [] queryset = AddressRegion.objects.all() The rest framework data is like this: [ { "id": 13, "name": "福州一区", "addressregion": 3 }, { "id": 14, "name": "西南一区", "addressregion": 4 }, { "id": 15, "name": "西南一区", "addressregion": 3 } ] I want the addressregion not shows the addressregion's id, but shows the addressregion's name. -
how to create fieldset in django
I'm new to django. I want to make a formset with 4 forms (name, lastname, phone, address) that I want to have them in 2 groups called: 'general info' and 'optional info'. How can I use fieldset to do that? and how can I parse it? I read some tutorial but none worked. thanks -
Django: Filtering the Distinct Data
I'm trying to build a messaging app. Here's my model, class Message(models.Model): sender = models.ForeignKey(User, related_name="sender") receiver = models.ForeignKey(User, related_name="receiver") msg_content = models.TextField() created_at = models.DateTimeField(auto_now_add=True) This is what I tried in view, data = Message.objects.filter(Q(sender=request.user) | Q(receiver=request.user)) In the template, {% for abc in data %} {{ abc.receiver }}<br /> {% endfor %} How can I print out the distinct users and re-order them based upon new messages as we see on social media platforms? -
Adding a 'view all' endpoint to restful Django
I have this row in my urls.py: url(r'^rss/(?P<rss_id>\d+)/', views.RSSList.as_view()) I want to be able to server also something like http://example.com/rss Which will show the complete rss list. How can I add it while keeping the id option? -
Importing date from HTML into Django views
I'm fairly new to Django and I am facing a bit of a problem. I have my html template in which I have two html date fields - start_date and end_date. I want to pass the contents of those field into my views.py and then display data for that time period, but I am having trouble making it work. Any help will be greatly appreciated. Relevant code: home.html Select time period: <br> From: <input id = "start_date" type="date" name="From" value="{{data.start_date|date:"d/m/Y"}}"> To: <input id = "end_date" type="date" name="To" value="{{data.end_date|date:"d/m/Y"}}"> <input type = "submit"> {% for data in data.all %} {% if data.profile.user.username == user.username %} <tr> <td>{{data.profile.user.username}}</td> <td>{{data.date}}</td> </tr> {% endif %} {% endfor %} views.py import datetime from datetime import date @login_required def home(request): if request.user.is_authenticated(): user = request.user.username start_date = request.GET.get['start_date'] end_date = request.GET.get['end_date'] data = Data.objects.filter(date__range=[start_date, end_date]) context = { 'data': data, 'cpu_hours_all': cpu_hours_all, } models.py class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE def __str__(self): return self.user.username class Data(models.Model): date = models.DateField(blank=True) profile = models.ForeignKey(Profile , on_delete=models.CASCADE) Thanks in advance! -
Django-Registration override Registration Form
I'm using Django-Registration 2.3 for a project and trying to override the standard RegistrationForm with the following: class MyRegistrationForm(RegistrationForm): captcha = NoReCaptchaField() class Meta: model = User fields = ['first_name', 'last_name', 'username', 'email', 'password1', 'password2'] widgets = { 'first_name' : forms.TextInput(attrs={'class' : 'form-control'}), 'last_name' : forms.TextInput(attrs={'class' : 'form-control'}), 'username' : forms.HiddenInput(), 'email' : forms.EmailInput(attrs={'class' : 'form-control'}), 'password1' : forms.PasswordInput(attrs={'class' : 'form-control'}), 'password2' : forms.PasswordInput(attrs={'class' : 'form-control'}), } I'm then calling this from my urls.py with url(r'^accounts/register/$', RegistrationView.as_view(form_class=MyRegistrationForm), name='registration_register'), In the template the captcha, first_name and last_name fields are rendered using form-control, the username is hidden but the other fields are rendered without the class. What do I need to do? -
django download images in zip file
I use this code in DJANGO framework to can some user download images. this code work fine and download image every time to press download some user. but this code download absolute images I need to zip this images for any user download. def download_image(request, id): product_image=MyModel.objects.get(pk=id) product_image_url = product_image.upload.url wrapper = FileWrapper(open(settings.MEDIA_ROOT+ product_image_url[6:], 'rb')) content_type = mimetypes.guess_type(product_image_url)[0] response = HttpResponse(wrapper, content_type=content_type) response['Content-Disposition'] = "attachment; filename=%s" % product_image_url return response is easy to change this code to download images in zip file ? -
How can I set up Django Crontab in Docker container?
Let's assume that I would like to run custom management command in Django every day at 12 noon. I have in management/commands file myfile.py and I set it up in this way TIME_ZONE = 'UTC' CRONJOBS = [ ('* 12 * * *', 'django.core.management.call_command', ['myfile']), ] I have added django-crontab to the requirements.txt and 'django_crontab' in INSTALLED_APPS. This file should add data to the PostgreSQL database however it doesn't work. Any ideas why? Maybe I should use Celery scheduler instead? -
Get value of RangeType input field in Django forms?
In my django form I wanted a slider type field. So I used NumberInput widget, code below. from django.forms.widgets import NumberInput class RangeInput(NumberInput): input_type = 'range' class MyForm(ModelForm): .... class Meta: model = Application fields = ['amount', 'reason'] widgets = { 'amount' : RangeInput(attrs={'max': 100000, 'min':10000, 'step':5000}), } Above helped me to get a slider in my form. Pic below. Slider is fine but I want to current value of the slider also to be shown. One way is to manually do using Javascript. Does Django gives a more automatic solution for this? Without showing the value of the slider to the user, the slider is virtually useless. -
Restoring of django database taking more time
For Django database backups and restore. I used this tool https://github.com/django-dbbackup/django-dbbackup. It is taking so much time to restore the database. It is taking 3hours of time to restore a 500MB Compressed file. I used the below command. time python manage.py dbrestore -i django_db_production_backup_20171109_0200.dump.gz -z Is there any alternative methods to reduce the time consumption. -
Different allowed_method for different Authentication in tastypie
I am working with tastypie for my API. I want to create a resource which allows multiple types of Authentications (SessionAuthentication and ApiKeyAuthentication). I want to allow get, post, put, delete methods for SessionAuthentication and just get method for ApiKeyAuthentication. I want to keep the same resource to meet my need. Please help. -
Celery add_periodic_task blocks Django running in uwsgi environment
I have written a module that dynamically adds periodic celery tasks based on a list of dictionaries in the projects settings (imported via django.conf.settings). I do that using a function add_tasks that schedules a function to be called with a specific uuid which is given the settings: def add_tasks(celery): for new_task in settings.NEW_TASKS: celery.add_periodic_task( new_task['interval'], my_task.s(new_task['uuid']), name='My Task %s' % new_task['uuid'], ) Like suggested here I use the on_after_configure.connect signal to call the function in my celery.py: app = Celery('immonaut_backend') @app.on_after_configure.connect def setup_periodic_tasks(celery, **kwargs): from add_tasks_module import add_tasks add_tasks(celery) This setup works fine for both celery beat and celery worker but breaks my setup where I use uwsgi to serve my django application. Uwsgi runs smoothly until the first time when the view code sends a task using celery's .delay() method. At that point it seems like celery is initialized in uwsgi but blocks forever in the above code. If I run this manually from the commandline and then interrupt when it blocks, I get the following (shortened) stack trace: Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/kombu/utils/objects.py", line 42, in __get__ return obj.__dict__[self.__name__] KeyError: 'tasks' During handling of the above exception, another exception occurred: Traceback (most recent call last): File … -
python social auth partial `NOT NULL constraint failed: social_auth_partial.timestamp` with django
I have following pipelines at settings.py SOCIAL_AUTH_PIPELINE =( 'social_core.pipeline.social_auth.social_details', 'social_core.pipeline.social_auth.social_uid', 'social_core.pipeline.social_auth.auth_allowed', 'social_core.pipeline.social_auth.social_user', 'social_core.pipeline.user.get_username', 'social_core.pipeline.user.create_user', 'social_core.pipeline.social_auth.associate_user', 'social_core.pipeline.social_auth.load_extra_data', 'social_core.pipeline.user.user_details', 'auth_manager.fb_account_linking.save_number', ) my auth_manager.fb_account_linking.py looks like following: @partial def save_number(strategy, details, user=None, is_new=False, *args, **kwargs): m = MobileNo.objects.filter(user=user) print(len(m)) if not len(m)>0: return redirect('account_kit') I am getting following error: IntegrityError at /auth/oauth/complete/facebook/ NOT NULL constraint failed: social_auth_partial.timestamp Traceback: File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\utils.py" in execute 65. return self.cursor.execute(sql, params) File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\sqlite3\base.py" in execute 328. return Database.Cursor.execute(self, query, params) The above exception (NOT NULL constraint failed: social_auth_partial.timestamp) was the direct cause of the following exception: File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\exception.py" in inner 41. response = get_response(request) File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\base.py" in _get_response 187. response = self.process_exception_by_middleware(e, request) File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\base.py" in _get_response 185. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\views\decorators\cache.py" in _wrapped_view_func 57. response = view_func(request, *args, **kwargs) File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\views\decorators\csrf.py" in wrapped_view 58. return view_func(*args, **kwargs) File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\social_django\utils.py" in wrapper 50. return func(request, backend, *args, **kwargs) File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\social_django\views.py" in complete 28. redirect_name=REDIRECT_FIELD_NAME, *args, **kwargs) File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\social_core\actions.py" in do_complete 41. user = backend.complete(user=user, *args, **kwargs) File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\social_core\backends\base.py" in complete 40. return self.auth_complete(*args, **kwargs) File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\social_core\utils.py" in wrapper 252. return func(*args, **kwargs) File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\social_core\backends\facebook.py" in auth_complete 110. return self.do_auth(access_token, response, *args, **kwargs) File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\social_core\backends\facebook.py" in do_auth 152. return self.strategy.authenticate(*args, **kwargs) File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\social_django\strategy.py" in authenticate 115. … -
Duplicate record issue in python CSV
MY Record show in CSV FILE LIkE THis 12/11/2017 |PK-LHR-20171112164753_15 |HEAD MASSAGE MENS| SPRAY WITH 10 MINERALS revitalizing care 12/11/2017| PK-LHR-20171112164753_15 |HEAD MASSAGE MENS |SPRAY WITH 10 MINERALS revitalizing care I need 12/11/2017 |PK-LHR-20171112164753_15| HEAD MASSAGE MENS |NULL 12/11/2017 |PK-LHR-20171112164753_15| NULL| MENS SPRAY WITH 10 MINERALS revitalizing care | if filtered_record: #print filtered_record.query for row in filtered_record: #print row writer.writerow(row) file_name = 'reports/invoice_reports/' + timezone.now().strftime('%Y_%m_%d_%H_%M_%S.csv') file_path = os.path.join(BASE_DIR, 'static/' + file_name) with open(file_path, 'wb') as f: f.write(response.content) -
ManytoMany Relation and Custom widget in Django
I have two models Categories and Products. A Product can have multiple Categories, a Category can have multiple Products. The Categories have a circular Foreign key, to itself. class Product: categories = models.ManyToManyField(Category) name = models.CharField(max_length=255) class Category: categories = models.ManyToManyField(Category) name = models.CharField(max_length=255) Not all Categories have the same depth level. A Category can have no children and a Category can have multiple grandchildren. What I want to achieve: When a user add/create a Product, only a select-box containing the parents will appear. After the parent is selected, if the parent has children another select will appear with that parent children. Also the possibility to add more categories. When a user what to edit a product the select boxes for what was already chosen should be available. From where I start: I know that to ManyToMany relation corresponds a ModelMultipleChoiceField Field. To a ModelMultipleChoiceField corresponds a SelectMultiple widget. I thought of creating an widget that inherits from SelectMultiple and change the templates manipulating the get_context_data on the Widget. But my problem is that in context I don't have (know to find) the parent relation inside categories. What are my options ? -
How to realize with a serializer, when the admin user request, serialize all the fields, but the normal user request, serialize part fields?
How to realize with a serializer, when the admin user request, serialize all the fields, but the normal user request, serialize part fields in Rest Framework? In my serializers: class UserListSerializer(ModelSerializer): """ user serializer """ account = AccountSerializer(many=False, read_only=True) class Meta: model = User exclude = [ 'password', ] ... class AccountSerializer(ModelSerializer): """ user's accout """ class Meta: model = Account exclude = [ 'total_charge', 'total_consume', ] In the views: class UserListAPIView(ListAPIView): """ the user view """ queryset = User.objects.filter(is_admin=False, is_staff=False, is_superuser=False).exclude(status=4) serializer_class = UserListSerializer filter_backends = [SearchFilter, OrderingFilter] search_fields = ['username', 'qq', 'email'] pagination_class = UserPageNumberPagination class Meta: ordering = ['-id'] My requirement is that when I use normal user request the APIView, I want to exclude the bellow fields: 'total_charge','total_consume' If I use the admin user request the APIView, I want to serialize all the fields. -
Django-Filter | Looping over form fields
I am using django-filter which works as intended. I am however trying to loop over the form fields but the standard django attributes aren't working. The only one that does is {{ form.id_for_label }}. Am I missing something? My template code: <form action="" method="get"> {% for form in forms.form.product_colours %} <div class="form-group"> <input type="checkbox" name="product_colours" id="{{ form.id_for_label }}" value="{{ form.value }}"> <label for="{{ form.id_for_label }}">{{ form.label }}</label> </div> {% endfor %} <input type="submit" /> </form> The reason I don't want to simply use {{ form }} is because it loads the <label> before the <input> whereas I'd need it to work viceversa to fit into my styling. I would prefer not to have to change the styling. In case they are needed, here are my FilterSet and my view: FilterSet: class ProductFilter(django_filters.FilterSet): product_colours = django_filters.ModelMultipleChoiceFilter(name="product_colours", label="Product Colour", widget=forms.CheckboxSelectMultiple, queryset=ProductColour.objects.all(), conjoined=False) class Meta: model = Product fields = ['product_colours'] View: def get_context(self, request): context = super(Page, self).get_context(request) all_products = ProductFilter(request.GET, queryset=Product.objects.live()).qs forms = ProductFilter(request.GET, queryset=Product.objects.live()) paginator = Paginator(all_products, 9) # Show 9 resources per page page = request.GET.get('page') try: products = paginator.page(page) except PageNotAnInteger: products = paginator.page(1) except EmptyPage: products = paginator.page(paginator.num_pages) context['forms'] = forms context['products'] = products return context -
Nested Seriliazers with multiple tables not working
I have the below tables in models.py class ProductLine(models.Model): availability = models.CharField(max_length=20, blank=True, null=True) series = models.CharField(max_length=20, blank=True, null=True) model = models.CharField(max_length=20, blank=True, null=True) class Meta: db_table = "product_line" class DriveType(models.Model): drive_name = models.CharField(max_length=20, blank=True, null=True) product_line = models.ForeignKey(ProductLine, related_name="drive_type") class Requirements(models.Model): performance_unit = models.CharField(max_length=100, blank=True, null=True) drive_type = models.OneToOneField(DriveType,on_delete=models.CASCADE,primary_key=True) class Meta: db_table = "requirements" class WorkloadType(models.Model): workload_type_options = models.CharField(max_length=50, blank=True, null=True) drive_type = models.OneToOneField(DriveType,on_delete=models.CASCADE,primary_key=True) class Meta: db_table = "workload_type" I have below serializers: class WorkloadTypeSerializer(serializers.ModelSerializer): class Meta: model = WorkloadType fields = "__all__" class RequirementsSerializer(serializers.ModelSerializer): class Meta: model = Requirements fields = "__all__" class DriveTypeSerializer(serializers.ModelSerializer): requirements = RequirementsSerializer(many = False, read_only = True) workload_type = WorkloadTypeSerializer(many=False,read_only=True) class Meta: model = DriveType fields = ( "drive_name", "available_drive_type", "capacity", "raid_type", "raid_size", "workload", "workload_percentage", "raid_groups", "compression", "compression_value","requirements","workload_type") class ProductLineSerializer(serializers.ModelSerializer): drive_type = DriveTypeSerializer(many=True, read_only=True) class Meta: model = ProductLine fields = ('availability','series','model','drive_type') In my views I have this: class SnippetDetail(generics.RetrieveUpdateDestroyAPIView): def get_queryset(self): return ProductLine.objects.filter(id=self.kwargs.get("pk")) serializer_class = ProductLineSerializer I am getting output as below : { "availability": "Current", "series": "G1000", "model": "F1500", "drive_type": [ { "drive_name": "drive1", "requirements": { "drive_type": 2, "performance_unit": "by_iops", } } ] } Why I am not able to see WorkLoadType tables data in json where as I am able … -
What approach should I use in mysql database designing that includes more than billion of rows to find particular value using minimum of time?
I have a Django project where I have to solve the following task: client paste the phone number to the search field and application returns full address. If there is no requested address in database, it should be added to another database table of unknown numbers. So, when admin uploads the list of number-address pairs, application should check if everey number exists in database table of unknown numbers. And if exists - it should be removed. This database after some time will contain more than billion rows. My approach is to create two database tables: first - the main table with two columns: "number" and "address". For the column "number" I provide indexation for the faster searching for address. And second one - table with unknown numbers where will be single column "number" which also should be indexed. So, asking for help of experts: do I think right? Or what approach should be the best to solve this task? I can not ask you for deep answer, I just need to which direction I should move on. Thank you very much. I will be happy for any kind of help (comments, links etc). -
How to enable/disable textbox based on selected value of radio button on Django?
I've tried enabling and disabling textbox based on radio button using javascript but it doesn't work. is it possible? Any one can help? Here is template.py <form id="myform" name="myform" action="" method="post"> <td>Radio1</td> <td>{{form.group.1 }}</td> <td>text1</td> <td>{{ form.Text1 }}</td> <td>text2</td> <td>{{ form.Text2 }}</td> <td>Radio2</td> <td>{{form.group.2 }}</td> <td>text1</td> <td>{{ form.Text3 }}</td> <td>text2</td> <td>{{ form.Text4 }}</td> </form> <script> $(document).ready(function(){ $('input[type=radio][name=group]').click(function () { if ($('input[name=group]:checked').val() == "1") { $('#text1').attr("disabled", false); $('#text2').attr("disabled", false); $('#text3').attr("disabled", true); $('#text4').attr("disabled", true); } else if ($('input[name=group]:checked').val() == "2") { $('#text1').attr("disabled", true); $('#text2').attr("disabled", true); $('#text3').attr("disabled", false); $('#text4').attr("disabled", false); } }); </script> form.py text1= forms.CharField(widget=forms.TextInput(attrs={'id':'text1', 'name':'text1'})) text2= forms.CharField(widget=forms.TextInput(attrs={'id':'text2', 'name':'text2'})) text3= forms.CharField(widget=forms.TextInput(attrs={'id':'text3', 'name':'text3'})) text4= forms.CharField(widget=forms.TextInput(attrs={'id':'text4', 'name':'text4'})) group1= forms.ChoiceField(widget=forms.RadioSelect(attrs={'name': 'group', 'id':"group"}), choices=get_payment_choices()) -
Django with Angular 4 app
How can I serve my Angular 4 app from a Django server? I've tried doing an ng build and then render the index.html in a Django view, but the resulting page is blank. What is the best way to achieve this?