Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Can't get form data in view function: Django
I need to submit a string to a view function via a dropdown menu and submit button. in my template I have: <form action="{% url 'exec_task' %}" method="post"> {% csrf_token %} <select id="select_task" form="select_task" name="select_task"> {% for task in available_tasks %} <option id="selected_task" value="{{ task }}">{{ task }}</option> {% endfor %} </select> <input class="button" type="submit" value="Run Selected Task"> </form> in my view function I have: def exec_task(request): if request.method == 'POST': task = request.POST.get('select_task') print(task) getattr(tasks, task)(0) return redirect('management') The print(task) always comes out as None, which generates an error when I try to call it via getattr in the next line. I've read through all the questions and tutorials I can find on this and I don't know what I'm doing wrong, but when I print the request.POST object, all I get is the csrf token. The QueryDict has nothing else in it. Any ideas? -
RunServer seems to be pointing at the wrong file but I don't know why or how to change it
I am trying to run my Python manage.py server and get an error back but the error seems to be pointing at the wrong file, not sure why this is. The file it seems to be pointing at is "Demoproject" when I need it to be pointing at "Slidelytics_site". Is there a path that could be wrong or is there a specific .py file that holds this path that I can adjust? Interesting side note - When I remove the below code from the settings.py file, this error does not occur. Interesting side note - When I remove the below code from the settings.py file, this error does not occur. STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static"), # '/var/www/static/', ] PS C:\Users\trueb\Desktop\Slidelytics_site> python manage.py runserver Performing system checks... Unhandled exception in thread started by .wrapper at 0x03FB7780> Traceback (most recent call last): File "C:\Users\trueb\Desktop\demoproject\venv\lib\site-packages\django-2.1.5-py3.7.egg\django\utils\autoreload.py", line 225, in wrapper fn(*args, **kwargs) File "C:\Users\trueb\Desktop\demoproject\venv\lib\site-packages\django-2.1.5-py3.7.egg\django\core\management\commands\runserver.py", line 117, in inner_run self.check(display_num_errors=True) File "C:\Users\trueb\Desktop\demoproject\venv\lib\site-packages\django-2.1.5-py3.7.egg\django\core\management\base.py", line 379, in check include_deployment_checks=include_deployment_checks, File "C:\Users\trueb\Desktop\demoproject\venv\lib\site-packages\django-2.1.5-py3.7.egg\django\core\management\base.py", line 366, in _run_checks return checks.run_checks(**kwargs) File "C:\Users\trueb\Desktop\demoproject\venv\lib\site-packages\django-2.1.5-py3.7.egg\django\core\checks\registry.py", line 71, in run_checks new_errors = check(app_configs=app_configs) File "C:\Users\trueb\Desktop\demoproject\venv\lib\site-packages\django-2.1.5-py3.7.egg\django\contrib\staticfiles\checks.py", line 9, in check_finders finder_errors = finder.check() File "C:\Users\trueb\Desktop\demoproject\venv\lib\site-packages\django-2.1.5-py3.7.egg\django\contrib\staticfiles\finders.py", line 82, in check if settings.STATIC_ROOT and os.path.abspath(settings.STATIC_ROOT) == os.path.abspath(root): … -
Django, API, reset, wireless, PLC communicate and real time
Hello I new to everything I'm about to explain I had this Unistream PLC, and want this Unistream to communicate a django framework in wireless way, which Django will my read anything my PLC is read and display on django framework in real time; even better I could save the data down to database. I was wondering if anyone had any idea about doing this? If you answer me I'm really apprentice. I hope Django community is big as it claim -
django-autocompelete-light in materialize model select2 search input not working
I am use the django-autocomplete-light whith this css style in materialize . when in modal , the select2 search input not working,help -
How to extract all the commits from a Pull Request from Github API using Django and showing it in an HTML view?
A coworker and me are working in a Django project that have several views, one of them need to show all the commits from a Pull Request made on Github. We were capable to extract the pull requests and show them on the HTML template. However we're not sure how to extract the commits and show them in the template too. We have been using Github API documentation but we can't find a way to make the commits show: https://developer.github.com/v3/repos/commits/ This is the code we have so far, this already show the Pull Requests: This is _git_stats.html <div class="project-details__section scrollbar scrollactivity"> <h2 class="project-details__subhead">Recent PRs</h2> {% for pr in git_stats.pull_requests %} <div class="{% if not forloop.last %}border-bottom pb-2{% endif %} mt-2"> <div class="media"> <div class="media-left mr-2"> <i class="fa fa-github pr-2" style="font-size: 1.7em;"></i> </div> <div class="media-body"> <small>{{ pr.title }}</small> <br> <small>{{ pr.created_at.0 }}</small> <small>{{ pr.created_at.1 }} UTC</small> <small><a href="{{ pr.html_url }}/">{{ pr.html_url }}</a></small> <br> </div> </div> </div> {% endfor %} </div> and this is entities.py: from company.models import GithubRepo from projects.utils.github import github_api_call import datetime class GitStats: def __init__(self, project: GithubRepo): result = github_api_call( f"/repos/{project.full_name}/pulls", {"state": "all"}, request_type="get" ) self.pr_count = result[0]["number"] if len(result) > 0 else 0 def get_created_at(pr): at = … -
Django Dynamic Form Selection
I want to achieve Dynamic form selection using Django Vehicle_Type_Choices = ( (‘car’,’Car’), (‘bike’,’Bike’), (‘auto’,’Auto’), ) vehicle_type = models.CharField(max_length=10,choices=Vehicle_Type_Choices) Now I have 3 different forms (I.e CarForm, BikeForm, AutoForm) for Vehicle specifications based on the type of vehicle selected. Now, I want if the user selects the Choice “Car” above, I want to display the” CarForm” (or) if the user selects “Bike”, then “BikeForm” has to be displayed for further filling of Data. Please Help me to achieve the above scenario . Thanks and regards -
Django ModelForm with ModelChoiceField does not appear to work with arguments
Any help would be greatly appreciated as I am pulling my hair out with this one! I have a Formview that sends over a repair_id and a part_id to a ModelForm. The ModelForm takes this data as input for a ModelChoiceField pulling a set of values. I subclassed the ModelChoiceField as PartMatModelChoiceField in order to concatenate two columns in the label. This all appears to work fine but every time I submit the form things do not submit as valid. If I look at the html output the form values / labels are showing up correctly. If I take one of the values from the ModelChoiceField and submit the form through the shell things show up as valid with no errors. After testing for a while I can see the problem is with the part_mat_nr field. If I switch it back to a ModelChoiceField (no subclass) I have the same problem If I simplify the queryset down to PrdTtBom.objects.filter(item_no__iexact=part_id) I have the same problem If I replace the variable part_id in the simplified queryset with the part_id staticly set. It works. This variable is going through as it is building the list correctly so not sure whats up. Model.py (relevant … -
How to load a local video in Django using webpack?
I can't seem to figure out how to get a video.mp4 to render in a django app from local files using webpack4. everything "compiled succesfully" but the video is not showing. I already tried it without django, just webpack4 and it rendered the video fine, putting in the output: { publicPath: './dist/'}. When i put the same publicPath line with django it compiles but nothing renders, i take the line out and it renders fines but not the video. // here is the output and url-loader for the video in the webpack.config.js output : { path: path.resolve( __dirname, 'dist'), filename: 'js/[name].js', publicPath:'./dist/'}, { test: /\.(mp4|webm)$/, use: { loader: 'url-loader', options: { limit: 100000, name: 'videos/[name].[hash].[ext]' } } }, // here is the index.js in the static/js folder import videoName from '../videos/xyz.mp4' const video = document.createElement('video') video.setAttribute('src', videoName); video.setAttribute('width', 480); video.setAttribute('autoplay', true); video.setAttribute('controls', true); document.body.append(video) // package.json "devDependencies": { "@babel/core": "^7.2.2", "@babel/preset-env": "^7.2.3", "babel-loader": "^8.0.5", "babel-polyfill": "^6.26.0", "css-loader": "^2.1.0", "mini-css-extract-plugin": "^0.5.0", "nodemon": "^1.18.9", "style-loader": "^0.23.1", "url-loader": "^1.1.2", "webpack": "^4.28.4", "webpack-cli": "^3.2.1", "webpack-dev-server": "^3.1.14" }, "dependencies": { "file-loader": "^3.0.1" } } // here is what i have in my settings.py STATIC_URL = 'http://127.0.0.1:8080/' STATICFILES_DIRS = ['dist'] console-screenshot -
Python Django Dynamic Rest API Parameter
I am trying to create a Rest API with Django for collecting web traffic like google analytic did. Is it possible to create an dynamic rest API parameter with POST request something like this http POST localhost:8000/collect/ pr1nm=abc pr2nm=bcd with limit dynamic parameter from 1-200, so we could use pr1nm until pr200nm. So far, I use json data on my request like http POST localhost:8000/collect/ productname="{"products":{ "pr1nm":"abc", "pr2nm":"bcd"}}" the reason why we want to do that because we also need to validate this payload to google analytic measurement protocol (https://ga-dev-tools.appspot.com/hit-builder/) which is need dynamic parameter (https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#pr_nm) any ideas? thanks before! -
django - My form wont save an added M2M object. Why?
My code: class DataSourceCreateView(CreateView): model = DataSource form_class = DataSourceForm template_name = 'engine/datasource_create.html' def get_form_kwargs(self): kwargs = super().get_form_kwargs() kwargs['user'] = self.request.user return kwargs def form_valid(self, form): f = form.save(commit=False) f.creator = self.request.user f.save() dsr_pk = form.cleaned_data['dataset_request'] if dsr_pk != 'noval': print(dsr_pk) dsr = DatasetRequest.objects.get(pk=dsr_pk) f.dataset_requests.add(dsr) print(f) print(f.dataset_requests) f.save() return super(DataSourceCreateView, self).form_valid(form) why isn't my form adding dsr to f.dataset_requests? The form saves and goes on without adding dsr to f.dataset_requests. I made the dataset_request field into a single select field instead of a multiple select field in DataSourceForm. Thanks in advance -
Getting the entries of a ManyToManyField
I'm working with a ManyToManyField and using a ModelMultipleChoice on form, I want to get the entries, but all I get is appname.Extra.none models.py class Extra(models.Model): extra_n = models.CharField(max_length=200) extra_price = models.IntegerField(default=0) def __str__(self): return self.extra_n class Meal(models.Model): restaurant = models.ForeignKey(Restaurant, on_delete=models.PROTECT) category = models.ForeignKey(MealCategory, on_delete=models.PROTECT) name = models.CharField(max_length=500) short_description = models.CharField(max_length=500) image = models.ImageField(upload_to='meal_images/', blank=False) price = models.IntegerField(default=0) extras = models.ManyToManyField(Extra, related_name='extras') def __str__(self): return self.name forms.py class MealForm(forms.ModelForm): extras = forms.ModelMultipleChoiceField(widget=forms.CheckboxSelectMultiple(), queryset=Meal.extras) class Meta: model = Meal exclude = ("restaurant",) views.py def restaurant_meal(request): meals = Meal.objects.filter(restaurant = request.user.restaurant).order_by("-id") return render(request, 'restaurant/meal.html', {"meals": meals}) The output desired is getting the extras added displayed on restaurant_meal view. -
How to Execute Python Custom Commands with Crontab
I have a series of django custom commands that I am attempting to automate via cron-tab, through a cron.py script. class Command(BaseCommand): def add_arguments(self, parser): pass def handle(self, *args, **options): #init cron cron = CronTab(user='dtorr') #add new cron job job = cron.new(command='python /home/dtorr/myproject/pol/sanct/management/commands/congress_dl.py >>/tmp/out.txt 2>&1') job1 = cron.new(command='python /home/dtorr/myproject/pol/sanct/management/commands/congress_extract.py >>/tmp/out.txt 2>&1') #job settings job.minute.every(120) job1.minute.every(120) cron.write() When I check if the cron jobs have loaded using crontab -l in the terminal the commands appear, but don't appear to be executing. Do I need to reference my virtualenv in these commands somehow? What am I missing? These scripts download files, but they do not appear to be executing. I have verified that the commands work otherwise. -
null value in column "user_id" violates not-null constraint Django form
Trying to implement a file upload for a user profile page. I am recieving the following error: null value in column "user_id" violates not-null constraint DETAIL: Failing row contains (35, profile/{now:%Y/%m/YmdHMSext_xg2iZ6M, null, null). I've read that it probably has something to do with the User_ID, I tried passing form.user = request.user, but that didn't work. There are also two nulls, not just one. Models.py class User(AbstractUser): # First Name and Last Name do not cover name patterns # around the globe. name = models.CharField(_('Name of User'), blank=True, max_length=255) #accepted_terms_of_service = models.Booleanfield() def __str__(self): return self.username def get_absolute_url(self): return reverse('users:detail', kwargs={'username': self.username}) # Profile Image def upload_to(instance, filename): now = timezone_now() base, ext = os.path.splitext(filename) ext = ext.lower() return "profile/{now:%Y/%m/%Y%m%d%H%M%S}{ext}" class Profile(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete='CASCADE', related_name='user_profile') school = models.CharField(max_length=30, null=True, blank=True) image = models.ImageField(_("Picture"), upload_to=upload_to, null=True, blank=True) def __str__(self): return self.user.username views.py @login_required def add_image(request): form = ProfileImageForm() #form.user = request.user if request.method == "POST": form = ProfileImageForm(data=request.POST, files=request.FILES) if form.is_valid(): form.save() return redirect('userPage') else: return render(request, "users/user_image_form.html", {"form": form }) forms.py class ProfileImageForm(forms.ModelForm): class Meta: model = Profile fields = ["image"] -
Django Admin: Register multiple admin classes to the same model
Is it possible to register multiple admin classes to the same model? I want to have both PostAdmin and MyPostAdmin register to the Post model. Right now I'm trying to use a proxy model with MyPost, but it's giving me two different models in the admin panel with their separate functionality. admin.py: class PostAdmin(admin.ModelAdmin): prepopulated_fields = {'slug':('title',)} class MyPostAdmin(SummernoteModelAdmin): summernote_fields = ('text', ) admin.site.register(Post, PostAdmin) admin.site.register(MyPost, MyPostAdmin) models.py: class Post(models.Model): title = models.CharField(max_length=250) category = models.IntegerField(choices=category_choices, default=0) description = models.TextField(max_length=250, blank=True, null=True) text = models.TextField() thumbnail = models.ImageField(upload_to=settings.MEDIA_URL) created_date = models.DateTimeField(default=timezone.now) published_date = models.DateTimeField(blank=True, null=True) slug = models.SlugField(unique=True) def publish(self): self.published_date = timezone.now() self.save() def save(self, *args, **kwargs): self.slug = slugify(self.title) super(Post, self).save(*args, **kwargs) def __str__(self): return self.title class MyPost(Post): class Meta: proxy = True -
Why are my Django static files not being served by IIS?
I have a Windows 2016 Server set up with IIS for my Django project. I have already configured my FastCGI settings for the Django website that is on my IIS Manager. Currently, the Django website that I am working with is nothing more than the default one when you run django-admin startproject. When I go to localhost:8000/admin, there is no CSS being displayed. Here is what I have done so far: ran manage.py collectstatic into the main app directory (same one settings.py is in) created a virtual directory on IIS Manager, with alias as "static" and path as the path to the static file that was created when running collectstatic configured the static virtual directory's handler mappings so that, in the ordered view, StaticFile is above my Django handler (so that requests that come into the static directory will be handled by the StaticFile handler as opposed to being processed by the Django Handler, so IIS will serve the static files now). This did not work, so I even tried deleting the Django handler and it still did not work. I followed this guide, and everything was working until this point: http://blog.mattwoodward.com/2016/07/running-django-application-on-windows.html What else can I try? -
How to use generic.ListView without Python interpreting ".L" as a separate syntax?
I'm defining a generic index view in Django, but when calling "generic.ListView" as a parameter, for some reason Python interprets the ".L" from .ListView as something else, and returns a syntax error. It works fine with generic.DetailView, and it's only when an L follows a period that it's interpreted differently. I tried Googling what the .L was, if there had been a change to how .ListView is called, etc. to no avail This is the Index call: def IndexView(generic.ListView): template_name = 'form/index.html' context_object_name = 'latest_entries_list' This is the Detail call, which works just fine: def DetailView(generic.DetailView): model = Info template_name = 'form/detail.html' Thanks! -
Django model inheritance weird or expected behavior?
I'm currently working on a project using django 1.11 and struggled some time trying to find the cause of an error. I don't know if it's a bug or expected behavior and was hoping someone could shed some light into the issue or point me in the right direction. I already searched for similar issues but did not found anything similar. The problem is the following, I have a base model class: class BaseModel(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) created_at = models.DateTimeField(default=timezone.now, editable=False) modified_at = models.DateTimeField(default=timezone.now, editable=False) def save(self, *args, **kwargs): if self.pk: self.modified_at = timezone.now return super(BaseModel, self).save(*args, **kwargs) and it was working fine on every model, until I needed to override the default save behavior on another model: class Agent(BaseModel): TIME_ZONES = [(tz, tz) for tz in pytz.common_timezones] user = models.OneToOneField( User, on_delete=models.CASCADE, related_name='agent', ) time_zone = models.CharField(choices=TIME_ZONES, default=settings.TIME_ZONE, max_length=100) phone = models.CharField(max_length=50, null=True, blank=True) email = models.CharField(max_length=255, null=True, blank=True) def __str__(self): return self.user.username def save(self, *args, **kwargs): self.email = self.user.email return super(Agent, self).save(*args, **kwargs) When I tried to save a new instance of the Agent model to the db doing Agent(user=user).save(), an exception was raised saying expected string or bytes-like object. The exception is not raised if … -
KeyError when setting field specific error on def clean()
I've got a multiple choice field in my form. paymentoption = forms.MultipleChoiceField(required=False, widget=forms.CheckboxSelectMultiple) def __init__(self, *args, **kwargs): super(BasisOfPricingForm, self).__init__(*args, **kwargs) self.fields['paymentoption'].choices = [(t.id, t.title) for t in PaymentOption.objects.all()] def clean(self): cleaned_data = super(BasisOfPricingForm, self).clean() paymentoption = cleaned_data.get('paymentoption') if paymethod1 == 3 and len(paymentoption) == 0: self.add_error('paymentoption', 'You must select at lease one Offline Payment Option if users must pay in person or over the phone.') When the conditions of the error are met, I get a "KeyError" on field ''paymentoption'. -
on change it shows value in alert but shows None when in ajax post request
$('.multiselect_region').change(function(){ var region_list = $(this).val(); var pathname = window.location.pathname; alert(region_list) $.ajax({ url:"{% url 'sanjh:price_per_region' %}", method:"POST", data:{ 'regionList':region_list, 'url':pathname, csrfmiddlewaretoken: '{{ csrf_token }}' }, success:function(data){ console.log(data) }, }) }); It shows clicked value in alert but when i am trying to send it to my django view and trying to retrive the region value with request.POST.get('regionList'), it shows none. but it prints the value of 'url' in this method. class PricePerRegionView(View): def post(self,request): region_list = request.POST.getlist('regionList') #getlist or get,both prints None print('dsssssssssssssssssssssssssssss',region_list) path = request.POST.get('url') print('kkkkkkkkkkkkkkkkkkkkkkkkkkkk',path) # if 'region_details' in r.json(): # print(r.json()['region_details']) return HttpResponse('s') -
How to add bootstrap 4 datepicker in django
I have been trying to add bootstrap 4 datepicker from this tutorial. It works great when I add a new record but problem is when editing the record, the value has not appeared in the field. What I have done is: widgets.py from django.forms import DateTimeInput, DateInput class BootstrapDateTimePickerInput(DateTimeInput): template_name = 'widgets/bootstrap_datetimepicker.html' def get_context(self, name, value, attrs): datetimepicker_id = 'datetimepicker_{name}'.format(name=name) if attrs is None: attrs = dict() attrs['data-target'] = '#{id}'.format(id=datetimepicker_id) attrs['class'] = 'form-control datetimepicker-input' context = super().get_context(name, value, attrs) context['widget']['datetimepicker_id'] = datetimepicker_id return context forms.py class ClaimForm(forms.ModelForm): purchase_date = forms.DateTimeField(input_formats=['%d/%m/%Y %H:%M'], widget=BootstrapDateTimePickerInput()) class Meta(forms.ModelForm): model = Claim fields = ['store', 'expense', 'rewards', 'money_receipt', 'purchase_date'] I want to add the date value into the input field when I edit the form. -
Image thumbnails Django Backblaze B2
I am building a photo viewing and storing website using Django and Backblaze B2 and I have a lot of large (filesize) photo's that I am planning to upload on it. My plan was to use thumbnails for photo browsing, these need to be generated automatically. Photo's are uploaded to Django, which in turn uploads the photo to B2, then it downloads it again, creates a thumbnail and uploads the thumbnail to B2. The downloading of the full-size image step seems unnessecary to me as the file is already uploaded through the Django webserver. Couldn't Django just keep the uploaded photo in memory (or temporary local storage), build a thumbnail and upload both the full-size image and the thumbnail to B2 afterwards? I am using the code below to generate a thumbnail in the save() step of the Photo model and it works. I am just looking for a way to make this more efficient without downloading the full-size image again. I thought about doing this in the PhotoForm with an overridden save() method but I was not able to find how to do this. I also have included the code of the custom B2Storage class. If anyone could give … -
Migrating Django project from production to local SQL server
I have Django project which is working fine in production(using Mysql as Database). I am running Mysql server locally in my PC(using XAMPP) , i have a done appropriate changes in setting.py as shown below. BUT when i try to run "python manage.py migrate MYAPP" i am getting an error as shown below. Also tried different command (same error) --> python manage.py syncdb --> python manage.py makemigrations MYAPP --> python manage.py runserver ..etc., It is not creating any table in SQL backend , any suggestion ? Settings.py DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'MYAPP', 'USER': 'root', 'HOST': '127.0.0.1', 'PORT': '3306', } } ERROR _mysql.connection.query(self, query) django.db.utils.ProgrammingError: (1146, "Table 'MYAPP.role' doesn't exist") -
How to trigger empty value validation in Django functional test?
I am new to Django and I am now reading the "Test-Driven Development with Python' book for learning. However, when I want to test the empty-value validation, the unit test is ok, but the functional test is failed. I am now using Django 2.1, Python 3. I have tried my best to check the reason of the problem but still failed to pass the functional test models.py ... class Item(models.Model): text = models.TextField(default='') list = models.ForeignKey(List, default=None, on_delete=models.CASCADE) views.py ... def new_list(request): list_ = List.objects.create() item = Item.objects.create(text=request.POST['item_text'],list=list_) try: item.full_clean() item.save() except ValidationError: list_.delete() error = "You can't have an empty list item" return render(request, 'home.html', {"error": error}) return redirect(list_) test_views.py (Unit Test-Successful) ... def test_validation_errors_are_sent_back_to_home_page_template(self): response = self.client.post('/lists/new', data={'item_text':''}) self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, 'home.html') expected_error = escape("You can't have an empty list item") self.assertContains(response, expected_error) test_list_item_validation.py (Functional Test-Failed) ... def test_cannot_add_empty_list_items(self): self.browser.get(self.live_server_url) self.browser.find_element_by_id('id_new_item').send_keys(Keys.ENTER) error = self.browser.find_element_by_css_selector('.has-error') self.assertEqual(error.text, "You can't have an empty list item") base.html (All html files extend from this) ... {% if error %} <div class="form-group has-error"> <span class="help-block">{{ error }}</span> </div> {% endif %} I expect that both the unit test and functional test are correct, but the actual result is the unit test is passed but … -
How can I convert the DateTimeField in Django from UTC to enduser's timezone (usually PST) when querying a Django model?
I'm querying a Django model connected to a table in my Postgres database that contains a datetime stored in UTC. My query code looks something like this: query_set = table_object.objects.values() One of the columns in the query set is the datetime value in UTC. The model looks like this: class ops_inbox_view(models.Model): requested_date = models.DateTimeField() other_item = models.CharField(max_length=20) other_item2 = models.CharField(max_length=40) other_item3 = models.CharField(primary_key=True, max_length=10) other_item4 = models.CharField(max_length=50) other_item5 = models.CharField(max_length=50) other_item6 = models.CharField(max_length=50) I want to convert this into PST or robustly in the enduser's local time zone. My current solution is to use pandas with dt.tz_localize and dt.tz_convert after loading the query set into a dataframe but I'm trying to find a solution that is easily manageable in one location of the project file structure of the app. In my settings.py, I have TIME_ZONE set to 'US/Pacific' but because I'm using Pandas, the conversion to PST is not automatically done and will have to change many lines of code in my views.py to make the conversion with pandas. Is there a way to not use Pandas and instead either make the field timezone aware or make the explicit conversion in the query code? Also looking for any other best … -
What type of options apply to the SlugField?
If we see the documentation of Django, we see this; SlugField class SlugField(max_length=50, **options) **options : is a kwargs but Django doesn't show me anything about of what other parameter I can use it. I appreciate if somebody help me. https://docs.djangoproject.com/en/2.1/ref/models/fields/#slugfield