Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
saving an instance of a model with auto_now_add in Django returns error message Column 'xxx' cannot be null
I must be doing something very wrong or this error doesn't make any sense to me. I have an object Location: class Location(models.Model): class Meta: db_table = 'location' location_id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) name = models.CharField(max_length=200) state = models.CharField(max_length=200) country = models.CharField(max_length=200) apt_number = models.CharField(max_length=200, null=True, blank=True) street_address = models.CharField(max_length=200) city = models.CharField(max_length=200) zip_code = models.IntegerField() created = DateTimeField(auto_now_add=True) here this is my code for inserting a new or updating an existing location record: class LocationList(generics.ListCreateAPIView): queryset = Location.objects.all() serializer_class = LocationSerializer def post(self, request, *args, **kwargs): location_dict = request.data if 'location_id' not in location_dict: okStatus = status.HTTP_201_CREATED else: okStatus = status.HTTP_200_OK location = Location(**location_dict) location.save() return Response(LocationSerializer(location).data, status=okStatus) Inserts work fine, but everytime an update happens, I get the error "Column 'created' cannot be null". My online research seems to point me to the fact that this was a bug which has been long fixed. I expect the update to pass since the 'created' field was set to auto_now_add, which means Django should set that field once upon insert and leave it on any subsequent update. I do not know why Django is trying to set that column to null on update. I am using MySQL as database. -
Registered Models not showing in Django Admin
So I boogered up a migrate and decided it would be easier to go with a db reset. So I removed the migrations folder, as well as the database. I then recreated the database, ran python manage.py migrate, createsuperuser, and went ahead and logged into the admin panel - but to my surprise the models that I have registered no longer show up in the panel. They were there before this whole thing. Can anyone give me some insight? I'm sure I've missed something small and stupid. The file structure, outside of the migrations folder, has been untouched. Models.py from django.db import models from django.core.validators import RegexValidator class DetailsModel(models.Model): distance = models.SmallIntegerField() rate = models.DecimalField(max_digits=5, decimal_places=2) class PhoneModel(models.Model): phone_regex = RegexValidator(regex=r'^\+?1?\d{9,15}$', message="Phone number must be entered in the format: '+999999999'. Up to 15 digits allowed.") phone_number = models.CharField(validators=[phone_regex], max_length=15, blank=True) # validators should be a list class TravelModel(models.Model): mileageRate = models.DecimalField(max_digits=4, decimal_places=3) def __str__(self): return '%s' % (self.mileageRate) class CompanyModel(models.Model): name = models.CharField(max_length=255) details = models.ForeignKey(DetailsModel, on_delete=models.CASCADE) def __str__(self): return '%s' % (self.name) class SiteModel(models.Model): company = models.ForeignKey(CompanyModel, on_delete=models.CASCADE) street1 = models.CharField(max_length=255) street2 = models.CharField(max_length=255) city = models.CharField(max_length=50) state = models.CharField(max_length=2) zipcode = models.IntegerField() country = models.CharField(max_length=50) class PersonModel(models.Model): firstName … -
django: are the view parameters "sticky"?
I have this url matcher: url(r"^(.*)$", views.process) and this view: def process(request, path, context={}): print(context) context["test"] = "test" return HttpResponse("") At first I get context={} as expected, but as I reload the page, I get the process view called with context={"test": "test"}. Does this mean if I make changes to view parameters, it remains sticky? Or is this because of some middleware? -
Is there a more Django way to convert underscore string into Django model?
I wrote my own helper function that will convert a underscore string and return the Django model Django version 1.11 from django.apps import apps def _underscore_string_to_model(in_str, app_name, delim="_"): chunks = in_str.split(delim) chunks[0:] = [_.title() for _ in chunks[0:]] return apps.get_model(app_name, "".join(chunks)) Is there an existing function or library that already does this? I have been looking around but there appears to be none hence i wrote my own. I am happy to keep using this but prefer to re-use existing if possible -
Does Django hit the database when I access an object's attributes?
Background info to follow because the question is fairly straightforward. class Question(models.Model): name=... etc. Does the following code query the database? question_name = question.name My view takes a set of questions and user responses and scores a worksheet. My goal is to execute all of the scoring without going back to the database. Then saving the result of my comparisons (a dictionary) using a background task where it's ok if it takes a little longer. Trying to eliminate any unnecessary database hits. -
How to correctly let a Javascript file in static folder inject an HTML file in the same static folder?
I'm in a very confusing situation... kinda like INCEPTION movie... I'm using an private charting library in a Django 1.10 project. I'll show the file structure of this Django project with the charting library files. These library files came in a structure that I kept under the static folder in Django, excpet by the index.html I put in template folder to be able make some loginc with it. I'll show below how the project files and mark the charting library files with "*". /project settings.py urls.py /static /tdviewer /charting_library* /static* /js* spin.min.js* tv-chart.18168320bd5edaac1e75.html* charting_library.min.js* /tdviewer /templates /tdviewer index.html * urls.py view.py This is /project/settings.py STATIC_URL = '/static/' STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static"), ] This is /project/urls.py urlpatterns = [ url(r'^tdviewer/', include('tdviewer.urls')), url(r'^admin/', admin.site.urls), ] This is /tdviewer/urls.py urlpatterns = [ # /tdviewer/ url(r'^$', views.index, name='index'), ] This is /tdviewer/views.py #/index def index(request): template = loader.get_template('tdviewer/index.html') context = { } response = HttpResponse(template.render(context, request)) return response The library index.html located at /tdviewer/templates/tdviewer/index.html is an example in how to use it and I put it in the template app because I'll need to do some code on server side. This HTML calls the the libraby's javascript in the tag: <!DOCTYPE HTML> {% … -
How to include templates of external libraries?
I'm trying to use django-openinghours template in my template with {% include openinghours/edit_base.html %} but I get TemplateNotFound. django-openinghours was installed using pip into the virtualenv. Any thought appreciated. -
PrimaryKeyRelatedField fields prints ids of foreign table but need values
PrimaryKeyRelatedField fields prints ids of foreign table but api demands to return values. Is there any customized way to get the values class Album(models.Model): album_name = models.CharField(max_length=100) artist = models.CharField(max_length=100) class Track(models.Model): album = models.ForeignKey(Album, related_name='tracks') order = models.IntegerField() title = models.CharField(max_length=100) duration = models.IntegerField() class Meta: unique_together = ('album', 'order') order_by = 'order class AlbumSerializer(serializers.ModelSerializer): tracks = serializers.PrimaryKeyRelatedField(many=True, read_only=True) class Meta: model = Album fields = ('album_name', 'artist', 'tracks') Results : { 'album_name': 'The Roots', 'artist': 'Undun', 'tracks': [ 89, 90, 91, ... ] } Is there any way to get output in the below format: { 'album_name': 'The Roots', 'artist': 'Undun', 'tracks': [ {'order': 1, 'title': 'Public Service Announcement', 'duration': 245}, {'order': 2, 'title': 'What More Can I Say', 'duration': 264}, {'order': 3, 'title': 'Encore', 'duration': 159}, ] } -
Passing a pickled object in Django's HttpRequest
I'm currently attempting to move an sklearn model object from server side to client side. I'm new to django so I'm struggling mightily. Option one is to jsonify all the model parameters, pass them through and reconstruct a fresh model object with those parameters. However, in my attempts to both simplify, and learn a bit about django, I've been trying to pass a pickled object and failing. I originally tried something simple like: result = pickle.dumps({'test':'test'}, pickle.HIGHEST_PROTOCOL) return HttpResponse(pkl) When I got it from the front end API, if I did a simple pickle.loads(api_res) I get a type instance error. When I do: pickle.loads(api_res.read()) It gives me an EOF error. I know there's the potential to also just pickle.dump instead of the string version, but I'm having trouble with djangos content-type etc. I just seem to get gibberish on the way out. The unfortunate icing on the cake is that, it's apparently difficult to find instances of people serializing objects and returning them with django, because almost all the results are about serializing/pickling the django objects themselves. Any help/links would be appreciated. -
Django: ImportError: No module named 'corsheaders'
During my first Django project i encountered a strange problem: ImportError: No module named 'corsheaders'. I have installed django-cors-headers in my virtual enviroment using pip3 install django-cors-headers but with on success. pip3 freeze shows package django-cors-headers as installed, but whenever i run uwsgi it shows exception traceback in log: Traceback (most recent call last): File "./login/wsgi.py", line 16, in <module> application = get_wsgi_application() File "/home/pawel/pythonApp/myappenv/lib/python3.5/site- packages/django/core/wsgi.py", line 13, in get_wsgi_application django.setup(set_prefix=False) File "/home/pawel/pythonApp/myappenv/lib/python3.5/site- packages/django/__init__.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "/home/pawel/pythonApp/myappenv/lib/python3.5/site- packages/django/apps/registry.py", line 85, in populate app_config = AppConfig.create(entry) File "/home/pawel/pythonApp/myappenv/lib/python3.5/site- packages/django/apps/config.py", line 94, in create module = import_module(entry) File "/home/pawel/pythonApp/myappenv/lib/python3.5/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ImportError: No module named 'corsheaders' unable to load app 0 (mountpoint='') (callable not found or import error) I tried installing different corsheaders versions, but with no success either. I am running Django 1.11.7 and Python 3.5.2. Any help would be appreciated. -
Celery not processing tasks from RabbitMQ
I have a Celery 4.1 worker configured to process tasks from a queue called "longjobs", using RabbitMQ as my messaging backend. My Celery configuration and workers are managed through a Django 1.11 project. Nothing throws any errors, but tasks launched from my Django application are never picked up by my worker. My celery.py file looks like: from __future__ import absolute_import import os import sys from celery import Celery from celery._state import _set_current_app import django app = Celery('myproject') app.config_from_object('django.conf:settings', namespace='CELERY') _set_current_app(app) os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings.settings') sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../myproject'))) django.setup() from django.conf import settings app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) My Django Celery settings are: CELERY_IGNORE_RESULT = False CELERY_TRACK_STARTED = True CELERY_IMPORTS = ( 'myproject.myapp.tasks', ) CELERY_RESULT_BACKEND = 'amqp' CELERY_ACCEPT_CONTENT = ['pickle', 'json', 'msgpack', 'yaml'] CELERY_TASK_SERIALIZER = 'pickle' CELERY_RESULT_SERIALIZER = 'pickle' CELERY_RESULT_PERSISTENT = True CELERY_ALWAYS_EAGER = False CELERY_ROUTES = { 'mytask': {'queue': 'longjobs'}, } CELERY_WORKER_PREFETCH_MULTIPLIER = CELERYD_PREFETCH_MULTIPLIER = 1 CELERY_SEND_TASK_ERROR_EMAILS = True CELERY_ACKS_LATE = True CELERY_TASK_RESULT_EXPIRES = 360000 And I launch my worker with: celery worker -A myproject -l info -n longjobs@%h -Q longjobs and in its log file, I see: [2017-11-09 16:51:03,218: INFO/MainProcess] Connected to amqp://guest:**@127.0.0.1:5672/myproject [2017-11-09 16:51:03,655: INFO/MainProcess] mingle: searching for neighbors [2017-11-09 16:51:05,441: INFO/MainProcess] mingle: all alone [2017-11-09 16:51:06,162: INFO/MainProcess] longjobs@localhost ready. indicating that the … -
How can I create an object and associate a User with M2M fields
I have a problem that I haven't been able to find a good post on how to best achieve so I'd hope I could get a pointer on how I could do this. I need a way to create groups via my api endpoint if they do not exist, and associate (.add()) the user with that requested, and now created object. A group in my case is a to_location, from_location, advertised_train_identity and a weekday in iso format. I have bulletpointed a more detailed version down below. Only allow: GET, POST, DELETE methods. This is the flow I have visualized in my mind: Client sends a request with a list of group objects. Since many=True in serializer, list will be split up into object chunks and feed separatly into the serializer. If group object already exists, I need an instance of it so I can associate the requesting user (request.user) with the already existing object. If it does not exist, create the group as per request, and add the requesting user onto it. As for the DELETE: query the instance of the group object, if requesting is the only currently added user to the group object - then unsubscribe, and delete … -
Django 1.11 order by field on related model duplicate results workaround
In Django 1.11 I have a parent and child model (one to many relationship) simplified below: class Conversation(models.Model): name = models.CharField(max_length=150) class Comment(models.Model): comment_text = models.TextField() submitted_date = models.DateTimeField() conversation = models.ForeignKey(Conversation, on_delete=models.CASCADE) class Meta: ordering = ['-submitted_date'] A conversation can have many comments. Now what I want to do is order conversations by which one has the most recent comments. I attempted to add this to the Conversation model: class Meta: ordering = ['-comment__submitted_date'] And this sort of works, but it returns duplicates in the queryset - this duplicate behavior is well documented in Django and why it happens - https://docs.djangoproject.com/en/1.11/ref/models/querysets/#order-by - but it doesn't say anything about how to work around it. I'm looking for a way to work around this limitation. The overall goal is: have conversations sorted by most recent comment (submitted_date). I've tried multiple variations, but it either doesn't sort at all, or it returns duplicates (which isn't useful to me). distinct() won't work either, which is also documented in the link. I could add an 'updated_at' or similar field to Conversation, and update that whenever a comment is created/updated, but that feels really hacky and unclean to me, and I'd rather avoid it if … -
I can't get the data from the database by using _set.all on Django. Where am I doing it wrong?
This is the related part of the models.py: from django.db import models class Author(models.Model): author_name = models.CharField(max_length=50) def __str__(self): return self.author_name class Book(models.Model): author = models.ForeignKey(Author, on_delete=models.CASCADE) book_title = models.CharField(max_length=250) book_image = models.ImageField(max_length=1000) book_link = models.URLField() def __str__(self): return self.book_title And this is the related part of the template in which I'm trying to get the information: <ul> {% for book in author.book_set.all %} <li><a href="{{ book.book_link }}">{{ book.book_title }}</a></li> {% endfor %} </ul> I've also checked if the information is available in the database, and it looks like everyting's okay. This is the only part I'm having trouble. -
Show values in dropdown list in Django
I want to add documents about different parts of my facility in my Django app. So, I have the following models in my models.py: class Parts(models.Model): Name = models.CharField(max_length=50) class Docs(models.Model): Date = models.DateField(default=date.today) Type = models.CharField(max_length=50) Part = models.ForeignKey(Parts) Link = models.FileField(upload_to='Docs/%Y/%m/%d') forms.py: class DocsForm(ModelForm): class Meta: model = Docs fields = ['Date', 'Type', 'Part', 'Link'] class PartsForm(ModelForm): class Meta: model = Parts fields = ['Name'] views.py: def adddocs(request): if request.method == 'POST': f = DocsForm(request.POST, request.FILES) if f.is_valid(): f.save() return HttpResponseRedirect('') else: form = DocsForm() return render( request, 'adddocs.html', {'form': form} and the following fragment in my template: <form action="{% url 'adddocs' %}" method="post" enctype="multipart/form-data"> {% csrf_token %} <p> {{form.Date}} </p> <p> {{form.Type}} </p> <p> {{form.Part}} </p> <p> {{form.Link}} </p> <p><input type="submit" value="Add" /></p> </form> And everything works fine except one problem. Now I have two parts of my facility, for example 'tubes' and 'storage'. But if I want to choose them in dropdown list, I see the following variants in my browser: Parts Object Parts Object What should I change to see names of parts like this tubes storage ? -
Create a report in Django using a jaspersoft (jrxml) file
I am looking for a way to produce a report in pdf format using my jrxml file (jasepersoft) in Django. I saw this example on github: https://github.com/jadsonbr/pyreport#processing. How can I integrate this example into my django template? Is there a much simpler way to run my jrxml file in Django? Thank you -
when I update a field of a model, all the other fields are deleted
if I update f1, f2 is deleted and if update f2, f1 is deleted ... how do i keep varing the fields that are not changed? sorry for my horrible English views.py def edit_iscrizioni(request, corso_id): corsi = Corso.objects.filter( pk=corso_id) fasca = Corso.objects.get( pk=corso_id) tabella= Iscrizione.objects.filter(user=request.user) iscrizione=get_object_or_404(Iscrizione, pk=tabella) if request.method == "POST": form = IscrizioneForm(request.POST, instance= iscrizione) if form.is_valid(): iscrizione = form.save(commit=False) iscrizione.user = request.user iscrizione.published_date = timezone.now() if fasca.progressivo: if fasca.f1: iscrizione.corso1_id= corso_id if fasca.f2: iscrizione.corso2_id= corso_id form.save() return redirect('privata') else: form = IscrizioneForm(instance= iscrizione) return render(request, 'corsi/edit.html', {'form':form, 'corsi':corsi}) model.py class Corso(models.Model): titolo = models.CharField(max_length=100) progressivo= models.BooleanField(default=False) f1= models.BooleanField(default=False) f2= models.BooleanField(default=False) class Iscrizione(models.Model): user = models.ForeignKey('auth.User') corso1= models.ForeignKey('Corso', blank=True, null=True, related_name="corso1") corso2= models.ForeignKey('Corso', blank=True, null=True, related_name="corso2") -
Django Cookiecutter : package folder not found
I have created a Django Project usin the cookiecutter project. On this project I have installed django-simple-poll. All is going fine, not error message; the poll Model appears in the admin. But, there is not folder for the 'poll' app in my project. I presume that installing the package should create a folder for this new app with template subfolder and all the usual stuff. Am I missing something? -
'Your models have changes that are not yet reflected in a migration.' error
I'm trying to deploy https://github.com/codingforentrepreneurs/eCommerce.git/ on heroku and I get this error- Your models have changes that are not yet reflected in a migration, and so won't be applied. Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them. How can I fix it? -
Django-Wagtail - How to select the "Choose A Page" panel when adding a model to the content panels?
I'm not sure if I'm being really thick here but I am struggling to find this panel in the list of available panels. At first I thought it was the PageChooserPanel but it isn't. This is what I'm looking for: This panel is available when inserting links into the RichTextField. It's perfect for my needs but I can't seem to find it anywhere else. I'm trying to create a field whereby the editor can select either an existing page or link to an external URL. The URL will then feed into a ref="{{ page.my_url }}" in my template. -
Django.db.utils.DataError: value too long for type character varying (3)
Not sure why I'm getting this error as none of my fields are set to limit 3 except one, which I know will never exceed 3. I'm able to run python manage.py makemigrations without any issue, but once I migrate the error pops up. My model looks like this: class Player(models.Model): player_id = models.PositiveIntegerField() player_name = models.CharField(max_length=60) team_id = models.PositiveIntegerField() team_abbreviation = models.CharField(max_length=3) age = models.PositiveIntegerField() gp = models.PositiveIntegerField() w = models.PositiveIntegerField() l = models.PositiveIntegerField() w_pct = models.DecimalField(max_digits=4, decimal_places=3) min = models.DecimalField(max_digits=4, decimal_places=3) fgm = models.DecimalField(max_digits=4, decimal_places=3) fga = models.DecimalField(max_digits=4, decimal_places=3) fg_pct = models.DecimalField(max_digits=4, decimal_places=3) fg3m = models.DecimalField(max_digits=4, decimal_places=3) fg3a = models.DecimalField(max_digits=4, decimal_places=3) fg3_pct = models.DecimalField(max_digits=4, decimal_places=3) ftm = models.DecimalField(max_digits=4, decimal_places=3) fta = models.DecimalField(max_digits=4, decimal_places=3) ft_pct = models.DecimalField(max_digits=4, decimal_places=3) oreb = models.DecimalField(max_digits=4, decimal_places=3) dreb = models.DecimalField(max_digits=4, decimal_places=3) reb = models.DecimalField(max_digits=4, decimal_places=3) ast = models.DecimalField(max_digits=4, decimal_places=3) tov = models.DecimalField(max_digits=4, decimal_places=3) stl = models.DecimalField(max_digits=4, decimal_places=3) blk = models.DecimalField(max_digits=4, decimal_places=3) blka = models.DecimalField(max_digits=4, decimal_places=3) pf = models.DecimalField(max_digits=4, decimal_places=3) pfd = models.DecimalField(max_digits=4, decimal_places=3) pts = models.DecimalField(max_digits=4, decimal_places=3) plus_minus = models.DecimalField(max_digits=4, decimal_places=3) nba_fantasy_pts = models.DecimalField(max_digits=4, decimal_places=3) dd2 = models.DecimalField(max_digits=4, decimal_places=3) td3 = models.DecimalField(max_digits=4, decimal_places=3) gp_rank = models.PositiveIntegerField() w_rank = models.PositiveIntegerField() l_rank = models.PositiveIntegerField() w_pct_rank = models.PositiveIntegerField() min_rank = models.PositiveIntegerField() fgm_rank = models.PositiveIntegerField() fga_rank = models.PositiveIntegerField() … -
How to use Django Proxy Models from remote database
I have a Django app running on a remote server, let's call that app "masterapp". On that remote server, it is actually included in settings.INSTALLED_APPS as "toppath.middlepath.masterapp" (obviously I am changing the names to protect the innocent). This app of course has a models.py file toppath/middlepath/masterapp/models.py. I also have a second Django app running on a different server, let's call this app "childapp" and suppose it is in package "foo.bar.childapp". The settings.INSTALLED_APPS lists "foo.bar.childapp" as one of the installed apps. Now suppose that in childapp, I need to use models and data from masterapp. Specifically, I need to use the django.auth.User model, and masterapp also has some custom models that have a ForeignKey to user. Furthermore, the custom models have reverse relationships like this: class CustomThing(Model): user = models.ForeignKey(User, null=False, related_name='custom_things') name = models.CharField(max_length=255, null=False, blank=False) def __unicode__(self): return self.name class Meta: db_table = 'masterproject_custom_things' verbose_name_plural = 'Custom Things' ordering = ['name'] Here I should be able to get a user's custom things using user.custom_things.all(). What I want to do is: 1. Get access to both User and CustomThing models from masterapp and use them in childapp. Remember masterapp runs on one server with one MYSQL DB and childapp runs … -
Model bijection
I am working with the following sitation in Django. (I know the design is bad, I am working with a legacy database and cannot change the underlying tables and relationships). Class User(models.Model): user_id = models.IntegerField(db_column="UserID", primary_key=True) userdetail1 = models.CharField(db_column="UserDetail1") userdetail2 = models.CharField(db_column="UserDetail2") Class UserDetail3(models.Model): user_id = models.IntegerField(db_column="UserID", primary_key=True) userdetail3 = models.CharField(db_column="UserDetail3") Class Event(models.Model): event_id = models.IntegerField(db_column="EventID", primary_key=True) user = models.ForeignKey(User, db_column="UserID") E.g., Userdetail3 does not just have a one-to-one relationship, but a bijective relationship with the User model. I want a list of all the events objects, but I want to annotate the event objects with the details of the user which generated that event. This works great for userdetail1 and userdetail2. I do it like this: class EventSerializer(serializers.Serializer): event_id = serializers.IntegerField() userdetail1 = serializers.CharField() userdetail2 = serializers.CharField() class EventList(generics.ListAPIView): serializer_class = EventSerializer def get_queryset(self): qs = models.Event.all() qs.annotate(userdetail1=F('user__userdetail1') qs.annotate(userdetail2=F('user__userdetail2') return qs But I am not sure how I can also annotate with userdetail3. Any ideas? -
Django with PostgreSQL 10?
Does Django support PostgreSQL 10 at the moment? I tried to use pgadmin3 with the psql V10 and found, it breaks pdagmin3. Somebody has opened a ticket on django project which may be in discussion. Is there any known breaking changes in v10 compared to v9.6 for Django? (because it breaks in pgadmin3)? let me know thanks. -
WebSocket connection to 'ws://xxx' failed: Error during WebSocket handshake: Unexpected response code: 200
I am working on a django project, which includes communication functions via channels. It runs smoothly on my own MacOS (accessed via 127.0.0.1). So I move it to Ubuntu server and use Apache2 to deploy it. I have linked wsgi.py to the website configuration file. The wsgi.py links correctly to the settings.py where I set up channels correctly. Then I "service apache2 restart" to get the website running. When I open the website, all the static files are loaded correctly. But the function of discussion forum is not working. In the browser console, it says "WebSocket connection to 'ws://xxx' failed: Error during WebSocket handshake: Unexpected response code: 200". Please help! Thanks.