Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Can a radio input send an integer to Django with POST?
I'd like to give three choices which are represented by words but are going to POST numbers: <form method="POST"> {% csrf_token %} <div class="btn-group" data-toggle="buttons"> <label class="btn btn-secondary"> <input type="radio" name="intensity" id="Low" value=1 autocomplete="off"> Pale </label> <label class="btn btn-secondary"> <input type="radio" name="intensity" id="Medium" value=5 autocomplete="off"> Medium </label> <label class="btn btn-secondary"> <input type="radio" name="intensity" id="High" value=9 autocomplete="off"> Deep </label> </div> </form> But then in my view request.POST.get('intensity') is a string. Do I need to manually convert it or there's something I'm missing? ps. I'm not using Django forms and I don't want to use it at the moment. -
How to disable a field in crispy form django
I am using crispy form to let user create a new issue post, but I want user not change 'project' field', so that issues can be put under the right project. I used form.fields['project'].widget.attrs['readonly'] = True ,but this one only has styling disable effect, not really functionally. models.py def new_issue(request, project_id): if request.method == 'POST': form = IssueForm(request.POST) if form.is_valid(): issue = form.save(commit=False) issue.author = request.user issue.save() return redirect('project:issue_tracker:issue_detail',project_id=project_id,issue_id=issue.id) else: form = IssueForm(initial={'project': project_id}) form.fields['project'].widget.attrs['readonly'] = True template = 'issue_tracker/issue/new_issue.html' context = {'form': form,'project_id':project_id} return render(request, template, context) form.py class CommentForm(forms.ModelForm): class Meta: model = Comment fields = ('body',) class IssueForm(forms.ModelForm): class Meta: model = Issue fields = ('title','content','project','status') class NewIssueForm(forms.ModelForm): class Meta: model = Issue fields = ('title','content','project','status') new_issue.html {% extends 'base.html' %} {% load crispy_forms_tags %} {% block content %} <h1>Add New Issue </h1> <form method="POST" class="Issue-form">{% csrf_token %} {{form|crispy}} <button type="submit" class="btn btn-success">Submit</button> </form> {% endblock %} -
Django Rest Framework ViewSet doesn't filter by field
I have a ModelViewSet with SearchFilter and OrderingFilter. Everything works fine, but when I try to filter by one specific field (like localhost:8000:/es/countries/?code=MX), it returns all records even when only one matches the criteria. When I use a generic search, like localhost:8000:/es/countries/?search=MX, it works fine. This is my ViewSet: class CountryViewSet(viewsets.ModelViewSet): permission_classes = (permissions.IsAuthenticated,) queryset = models.Country.objects.all() serializer_class = serializers.CountrySerializer filter_backends = (SearchFilter, OrderingFilter,) search_fields = ('name', 'code', 'calling_code') -
Why do I have TabError: inconsistent use of tabs and spaces in indentation?
I have formated my code with autopep8. Anyway,I still have error File "/home/milenko/fp/fileupload/models.py", line 20 self.date_start_processing = datetime.datetime.now() ^ TabError: inconsistent use of tabs and spaces in indentation My code from django.db import models from django.contrib.auth.models import User from django.utils.translation import ugettext_lazy as _ import datetime class Document(models.Model): uploaded_by = models.ForeignKey('User') date_uploaded = models.DateTimeField(auto_now_add=True) PENDING, PROCESSED, FAILED = 'Pending', 'Processed', 'Failed' STATUSES = ((PENDING, _(PENDING)),(PROCESSED, _(PROCESSED)),(FAILED, _(FAILED)),) status = models.CharField(max_length=64, choices=STATUSES, default=PENDING) processing_description = models.TextField(blank=True, null=True) num_records = models.PositiveIntegerField() date_start_processing = models.DateTimeField(null=True) date_end_processing = models.DateTimeField(null=True) def process(self): self.date_start_processing = datetime.datetime.now() try: docfile = models.FileField(upload_to='documents/%Y/%m/%d') except Exception, e: self._mark_failed(unicode(e)) else: self._mark_processed(num_records) How to format my code properly and save time? -
Custom permissions on Django group form
I've added some custom permissions to my Post model. I've also created a form to add/edit groups with only this custom permissions: class GroupFornm(forms.ModelForm): permissions = forms.MultipleChoiceField(choices=Post._meta.permissions) class Meta: model = Group fields = '__all__' It works because I can see and select only my custom permissions but when I try to save the form I got the error: invalid literal for int() with base 10: 'can_view' What am I doing wrong? It seems that this form field waits for (int, str) pair but documentation says that as usually, (str, str) should work. -
Datetimepicker sends two requests
I have django template, that renders a form: 2 datetimepickers, 2 multiselect dropdown lists & 1 select dropdown list. The dropdown works like a charm, but the datetimepicker are behaving incorrectly. Case: I want to change the date. So: - Click on the datetimepicker and the calendar (no time) displays - Click on the date: - Send new request -Click somewhere else or in other field: - Send the same request as before I'm afraid this could eventually overload the server. How can i avoid that last extra request? Code: Form: class UsageByTypeForm(forms.Form): def __init__(self, data=None, user=None, *args, **kwargs): super().__init__(data=data, *args, **kwargs) if user and user.is_authenticated(): self.setup_mcu_field(user) self.setup_client_field(user) def setup_mcu_field(self, user): user_mcus = user.operated_mcus if len(user_mcus) > 1: mcu_field = self.fields['mcus'] mcu_field.queryset = user_mcus.order_by('name').exclude(mcu_unico_id__isnull=True) mcu_field.initial = mcu_field.queryset else: del self.fields['mcus'] def setup_client_field(self, user): user_clients = user.operated_client_ids client_field = self.fields['clients'] client_field.queryset = Cliente.objects.filter(id__in=user_clients) client_field.initial = client_field.queryset frequency = forms.ChoiceField( label=_('Frequency'), choices=ReportFrequency.values.items(), required=True, widget=forms.Select( attrs={ 'data-placeholder': _('Frequency'), 'data-header': _('Select a frequency'), }), ) mcus = forms.ModelMultipleChoiceField( queryset=MCU.objects.none(), widget=forms.SelectMultiple( attrs={ 'data-actions-box': "true", 'data-header': _('Choose some MCUs'), }), ) clients = forms.ModelMultipleChoiceField( queryset=Cliente.objects.none(), required=False, widget=forms.SelectMultiple( attrs={ 'data-header': _('Choose some clients'), 'data-actions-box': "true", }), ) begin = forms.DateField( initial=get_last_month_range()[0], widget=forms.TextInput( attrs={ 'class': 'form-control', }), ) … -
Combining distinct and annotate over a many to many filter with Django
With Django's ORM, I have a simple Question and Topic model like so: class Topic(models.Model): name = models.CharField(max_length=200) class Question(models.Model): topic_items = models.ManyToManyField(Topic, blank=True) date_asked = models.DateField() Suppose I have four Questions asked each on separate dates, with the fourth sharing two topics 'topic1', 'topic2' If I do the following query with topics_restrict a list of the two topic ids for 'topic1' and 'topic2'... q_filter = Question.objects.filter(topic_items__in=topics_restrict).distinct() Then I get four results (instead of five, which would have resulted without the distinct) Now if I do the following: return q_filter.annotate( total=Count('date_asked') ).values_list('total', flat=True) I get the result [2,1,1,1] instead of [1,1,1,1] - ie, as if the distinct() had never been applied. The only way to get around it is to do... q_filter = Question.objects.filter(pk__in=q_filter.values_list('pk', flat=True)) ... and then annotate on that q_filter. But there has to be a better way? -
During handling of the above exception (authenticate() got an unexpected keyword argument 'email'), another exception occurred:
Now I'm working on a Django project. We are using django-allauth for the user registration. When we set Debug = True, everything was ok. But if we seDebug = False will get During handling of the above exception (authenticate() got an unexpected keyword argument 'email'), another exception occurred: when we try to login with the wrong password. How can I fix that? We are using python3. -
Django multiple annotate clashes
Check out the following code. I am trying to get the area_count annotation for which the correct value is 1. But if I add the data_count annotation to the queryset, area_count gets messed up. >> factors_qs=Factor.objects.annotate( area_count=Count('change__areas'), evaluation_count=Count('factor_datas__evaluation'), ) >> factors_qs.get(pk=1017).area_count >> 1 >> factors_qs=Factor.objects.annotate( data_count=Count('sets__elements__datas'), area_count=Count('change__areas'), evaluation_count=Count('factor_datas__evaluation'), ) >> factors_qs.get(pk=1017).area_count >> 4615 -
Django loaddata fails for unicode
Here's the model: class ListItem(models.Model): # id -- PK dateCreated = models.DateTimeField(auto_now_add=True) dateModified = models.DateTimeField(auto_now_add=True) listId = models.IntegerField(null=False) # required FK => OnixList itemId = models.CharField(max_length=8, null=False) description = models.CharField(max_length=1024) notes = models.CharField(max_length=2048) class Meta: ordering = ('itemId',) And here is the offending item from the fixture file (json): { "model": "myproject.ListItem", "pk": 721, "fields": { "listId": 26, "itemId": "A3", "description": "Statystyka Książek Papierowych, Mówionych I Elektronicznych", "notes": "Polish Statistical Book and E-book Classification", "dateCreated": "2018-05-14 22:05:25", "dateModified": "2018-05-14 22:05:25" } }, ... and here is the command I used to try to load the data: python3 manage.py loaddata listItems.json which resulted in the following error(s): django.db.utils.OperationalError: Problem installing fixture '/Users/sloughin/dev/myproject/fixtures/listItems.json': Could not load myproject.ListItem(pk=721): (1366, "Incorrect string value: '\\xC4\\x85\\xC5\\xBCek...' for column 'description' at row 1") should I be using some flag in the model to indicate that I expect this field to contain unicode data? This is running against a MySQL database on Ubuntu 16.04, and I'm running python 3.6.2 on an iMac (OSX 10.13.5). All my other loaddata operations worked fine. -
Django Registration Redux Custom View not calling register
So I have my custom form called, "UserProfileRegistrationForm" and also my custom view, "MyRegistrationView". The form is displayed correctly, however data inputted into my custom fields don't seem to be saved. The User object is created, but firstname, lastname and the rest is left blank. My problem is that the function register() is not called at all in "MyRegistrationView". There is a question exactly the same as mine, here, but I can't make out how he fixed the issue. Any help is greatly appreciated. View.py class MyRegistrationView(RegistrationView): form_class = UserProfileRegistrationForm def register(self, request, form_class): new_user = super(MyRegistrationView, self).register(request, form_class) new_user.first_name = form_class.cleaned_data['firstName'] new_user.last_name = form_class.cleaned_data['lastName'] print("This is never run!!!") if form_class.cleaned_data['profileImage']: profile_image = form_class.cleaned_data['profileImage'] location = form_class.cleaned_data['location'] bio = form_class.cleaned_data['bio'] user_profile = Profile.objects.create(user=new_user, profile_image=profile_image, location=location, bio=bio) user_profile.save() return new_user Form.py from django import forms from registration.forms import RegistrationFormUniqueEmail from django.contrib.auth.models import User class UserProfileRegistrationForm(RegistrationFormUniqueEmail): firstName = forms.CharField(label=(u'First Name'), help_text='Not required', max_length=30, required=False) lastName = forms.CharField(label=(u'Last Name'), help_text='Not required', max_length=30, required=False) profileImage = forms.ImageField(label='Profile Picture', required=False) location = forms.CharField(label=(u'Location'), help_text='Not required', max_length=30, required=False) bio = forms.CharField(label=(u'Bio'), help_text='Not required', widget=forms.Textarea, max_length=500, required=False) class Meta: model = User fields = ['username', 'firstName', 'lastName', 'email', 'password1', 'password2', 'profileImage', 'location', 'bio'] -
Django : Mezzanine "title_fr" not in list
I'm using Mezzanine, and doing some unit tests on. self.department_page = DepartmentPage.objects.create(title="title department",content="my dep content", publish_date=datetime.today(),department=self.department, status=CONTENT_STATUS_PUBLISHED) Above is part of my setUp, and here is the DepartmentPage model. class DepartmentPage(Page, SubTitled, RichText): """(Department description)""" department = models.ForeignKey('Department', verbose_name=_('department'), related_name="pages", blank=True, null=True, on_delete=models.SET_NULL) weaving_css_class = models.CharField(_('background pattern'), choices=PATTERN_CHOICES, max_length=64, blank=True) class Meta: verbose_name = _('department page') Here is my unit test : response = self.client.get("/title-department/") And, strangely, i've this error : Traceback (most recent call last): File "/srv/lib/mezzanine-organization/organization/network/test/tests.py", line 165, in test_department_display_for_everyone response = self.client.get("/title-department/") File "/usr/local/lib/python3.6/site-packages/django/test/client.py", line 503, in get **extra) File "/usr/local/lib/python3.6/site-packages/django/test/client.py", line 304, in get return self.generic('GET', path, secure=secure, **r) File "/usr/local/lib/python3.6/site-packages/django/test/client.py", line 380, in generic return self.request(**r) File "/usr/local/lib/python3.6/site-packages/django/test/client.py", line 449, in request response = self.handler(environ) File "/usr/local/lib/python3.6/site-packages/django/test/client.py", line 123, in __call__ response = self.get_response(request) File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 230, in get_response response = self.handle_uncaught_exception(request, resolver, sys.exc_info()) File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 296, in handle_uncaught_exception return callback(request, **param_dict) File "/usr/local/lib/python3.6/site-packages/django/utils/decorators.py", line 149, in _wrapped_view response = view_func(request, *args, **kwargs) File "/srv/lib/mezzanine/mezzanine/core/views.py", line 220, in server_error return HttpResponseServerError(t.render(context, request)) File "/usr/local/lib/python3.6/site-packages/django/template/backends/django.py", line 95, in render return self.template.render(context) File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 206, in render return self._render(context) File "/usr/local/lib/python3.6/site-packages/django/test/utils.py", line 92, in instrumented_test_render return self.nodelist.render(context) File "/usr/local/lib/python3.6/site-packages/django/template/base.py", line 992, in render bit … -
How do I add a Query String in djangos post TestCase?
I want to add a querystring in a Django APITestCase of a post function. This is the Code that I use to test post functions without a query string: self.url_pks = dict(cs_pk=self.cs, kf_pk=self.kf) url = 'as-list' self.post_data = dict(model_feature='test') response = self.post(url, **self.url_pks, data=self.post_data, extra={'format': 'json'}) The URL that I would like to test is: /api/cs/7/kf/30/as/?GET=true So how can I include the '?GET=true'-part? -
Heroku returns 500 and no log about it
I have the polls app created with django tutorial, and I have deployet it to heroku server without errors. I am able to connect to my url and goes to /admin app. This module does not use conection to any database. On the other hand, when I goes to /polls the app returns error 500. My database is a postgresql database at heroku, and through SQL client I can connect and throw some SQL statements. I try to read the reason of this error 500 with: heroku logs --tail or heroku logs -t And the output with both statments is: 2018-06-19T16:06:45.796936+00:00 heroku[router]: at=info method=GET path="/" host=myhost request_id=2b2adf06-0eb0-455b-8074-49b95db986c5 fwd="80.94.4.53" dyno=web.1 connect=1ms service=140ms status=500 bytes=387 protocol=https 2018-06-19T16:06:45.796523+00:00 app[web.1]: 10.31.249.159 - - [19/Jun/2018:18:06:45 +0200] "GET / HTTP/1.1" 500 27 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0" How can I debug what is happening? -
Implementing Central Authentication System with angular4 apps using django session authentication
I have three different django projects, ProjectA, ProjectB and ProjectC. ProjectA is django website but other two are only django-rest-framework api based projects and have angular4 apps that consumer these apis respective to their projects. Now I need to combine their Users and some other functionality and need to put into ProjectA. So if a user is logged into ProjectA, and visit angular app of ProjectB or ProjectC and user should already be considered logged in. So this is certain that I need SSO and also I need to replace the token authentication of angular app with session authentication and I am thinking of using Central authentication System CAS but I don't understand how angular4 apps will be served alongside django using its session authentication and consuming its api. because right now all three projects and those two angular apps are deployed on different domains or subdomains. Can you help out here. Also please comment on any security flaws or something -
dajango microsoft server 2012 r2 OperationalEror db.utils 2
[I have a connection to the database mysql, but I can not make this contact on the microsoft server 2012]23 -
are "def post" and "if.request.method == POST " same?
It's newbie question because i am, but are "def post" and "if.request.method == POST " same? i've seen some using def post(self, request): and some using if.request.method == 'POST' they both seem to work (for tasks i've seen) but is there difference? -
Serving content from django
I have a platform with about 30,000 pages. I would like to add content for each page (manually). I wondered what is the best way to do that? I am using django + angular and I dont use django templats. It feels like adding text params to the django model is not the best idea since it will make my DB too heavy. I looked into django-cms but it seems that it based on django templates. -
my router work on django rest frame work 1.11 but this code not working in django rest frame work 2
Trip_router.register(r'places', views.PlaceViewSet, base_name='trips-places')\ .register(r'people', views.PersonInPlaceViewSet, base_name='trips-places-people') this is my error Trip_router.register(r'places', views.PlaceViewSet, base_name='trips-places')\ AttributeError: 'NoneType' object has no attribute 'register' -
Django -- new field: How to set default callable for existing objects
I have a model: class Model(models.Model): price = models.DecimalField(...) There are already Model objects in production database. Now I add price_total field to this model which can't be null. class Model(models.Model): price = models.DecimalField(...) price_total = models.DecimalField(...) I want this price_total to be equal to price right after migration. Something like: price_total = models.DecimalField(default=this_object.price,...) Is it possible to do it somehow? The only thing I know about is: make price_total nullable makemigrations + migrate set price_total equal to price for example through django shell make price_total not nullable makemigration + migrate But this way has multiple disadvantages, you can forgot to do that in production, it has many steps etc... Is there a better way? -
backing up django database with dumpdata
For testing, I would like to be able to save and restore app state. This would seem to be a very common requirement! I find that I have to do python manage.py dumpdata --exclude=contenttypes --exclude=auth > sitedata.json in order for loaddata (after flush) not to complain about uniqueness violations and such. At present this is just a magic incantation for me that I found in online searches. I don't find the explanations comprehensible. I would like to know: first, why I have to exclude auth; second, what contenttypes even is, as well as why I have to exclude it. My concern is not that I can't do what I need to do now, but that I don't understand it and wonder if there are other corners of this procedure waiting to bite me. Thanks for any information or links. -
Django fill table column based on subdict key
I have a dict in the following format: { 'P1': {'A': [1,10], 'B': [4,5], 'C': [8,12]}, 'P2': {'A': [1,10], 'E': [4,5], 'G': [8,12]}, 'P3': {'C': [1,10], 'D': [4,5], 'J': [8,12]} } and an HTML table set-up like this: <table> <thead> <tr> <th></th> </tr> <tr> <th>A</th> <th>B</th> <th>C</th> <th>D</th> <th>E</th> <th>F</th> <th>G</th> <th>H</th> <th>I</th> <th>J</th> </tr> </thead> . . . what I'm trying to do is outputting the P's letter on the correct "cell", basically the data should go in the correct letter. I tried this but failed: {% for k,v in p_dataset.items %} <tr> <td>{{k}}</td> {% for letter, vals in v.items %} <td>{% if letter == 'A' %}{{vals}}{% endif %}</td> <td>{% if letter == 'B' %}{{vals}}{% endif %}</td> <td>{% if letter == 'C' %}{{vals}}{% endif %}</td> <td>{% if letter == 'D' %}{{vals}}{% endif %}</td> <td>{% if letter == 'E' %}{{vals}}{% endif %}</td> <td>{% if letter == 'F' %}{{vals}}{% endif %}</td> <td>{% if letter == 'G' %}{{vals}}{% endif %}</td> <td>{% if letter == 'H' %}{{vals}}{% endif %}</td> <td>{% if letter == 'I' %}{{vals}}{% endif %}</td> <td>{% if letter == 'J' %}{{vals}}{% endif %}</td> {% endfor %} </tr> {% endfor %} but all I got where a lot of exceeding tds, how … -
Proper datetime/timezone handling in Django/DRF
I'm trying to make a proper date handling setup for my web app. I have a model that looks something like this class Entity(models.Model): name = models.CharField(max_length=255) date = models.DateTimeField() User can send a request to my DRF endpoint /api/v1/entity/ to get a list of such entities. Now there is a requirement that user should be able to request all Entity objects for a single day, which is determined by the date parameter. Dates are stored in UTC in the database while users of this app are not in a UTC timezone. User can create an entity with the following date 2018-06-19T01:00:00+02:00, which is stored as 2018-06-18T23:00:00Z in the database. Now if I try to list all entities user has created for 2018-06-19 nothing's returned, but filtering by 2018-06-18 returns one entry. This is the code setup I'm using: http://127.0.0.1:8000/api/v1/entity/?date=2018-06-18. def get_queryset(self): user = self.request.user entities = Entity.objects.filter(owner=user) date = self.request.query_params.get('date') if date: entities = entities.filter(date__date=date) return entities So in this case the appropriate date range would be 2018-06-18T23:00:00Z - 2018-06-19T23:00:00Z. What's the correct approach to fetch all entities for a single day (or a date range) in user's timezone? -
Django: annotate Sum Case When depending on the status of a field
In my application i need to get all transactions per day for the last 30 days. In transactions model i have a currency field and i want to convert the value in euro if the chosen currency is GBP or USD. models.py class Transaction(TimeMixIn): COMPLETED = 1 REJECTED = 2 TRANSACTION_STATUS = ( (COMPLETED, _('Completed')), (REJECTED, _('Rejected')), ) user = models.ForeignKey(CustomUser) status = models.SmallIntegerField(choices=TRANSACTION_STATUS, default=COMPLETED) amount = models.DecimalField(default=0, decimal_places=2, max_digits=7) currency = models.CharField(max_length=3, choices=Core.CURRENCIES, default=Core.CURRENCY_EUR) Until now this is what i've been using: Transaction.objects.filter(created__gte=last_month, status=Transaction.COMPLETED) .extra({"date": "date_trunc('day', created)"}) .values("date").annotate(amount=Sum("amount")) which returns a queryset containing dictionaries with date and amount: <QuerySet [{'date': datetime.datetime(2018, 6, 19, 0, 0, tzinfo=<UTC>), 'amount': Decimal('75.00')}]> and this is what i tried now: queryset = Transaction.objects.filter(created__gte=last_month, status=Transaction.COMPLETED).extra({"date": "date_trunc('day', created)"}).values('date').annotate( amount=Sum(Case(When(currency=Core.CURRENCY_EUR, then='amount'), When(currency=Core.CURRENCY_USD, then=F('amount') * 0.8662), When(currency=Core.CURRENCY_GBP, then=F('amount') * 1.1413), default=0, output_field=FloatField())) ) which is converting gbp or usd to euro but it creates 3 dictionaries with the same day instead of making the sum of them. This is what it returns: <QuerySet [{'date': datetime.datetime(2018, 6, 19, 0, 0, tzinfo=<UTC>), 'amount': 21.655}, {'date': datetime.datetime(2018, 6, 19, 0, 0, tzinfo=<UTC>), 'amount': 28.5325}, {'date': datetime.datetime(2018, 6, 19, 0, 0, tzinfo=<UTC>), 'amount': 25.0}]> and this is what i want: <QuerySet [{'date': … -
Bootstrap 4 Modal only runs once
So for some reason, I created two modals. However, when I open either of them the first time, and then close the modal it will no longer open either of the two when I do t he action that worked the first time. here is my javascript: <script> $(document).ready(function() { $("#accountsTable").tablesorter(); $('#newAccount').on('click', function() { $.ajax({ async:true, url: '/crm/accounts/create_account_modal', success: function(res) { $('.createAccountModalBody'); alert(res); $('#createAccountModal').modal({show:true}); $('.createAccountModalBody').html(res); }}); }); $('tr').on('dblclick', function() { var AccountID = $(this).find('td').first().html(); alert(AccountID); $('.editAccountModalBody').load('/crm/accounts/edit_account/1'); $('#editAccountModal').modal('show'); }); $('#editAccountModal').on('hidden.bs.modal', function () { $(this).removeData('bs.modal'); $(this).empty(); $(this).removeAttr('style'); }); $('#createAccountModal').on('hidden.bs.modal', function () { $(this).removeData('bs.modal'); $(this).empty(); $(this).removeAttr('style'); }); }); $('tr').on('dblclick', function() { var AccountID = $(this).find('td').first().html(); alert(AccountID); $('.editAccountModalBody').load('/crm/accounts/create_account_modal'); $('#editAccountModal').modal('show'); }); </script>