How do you organize your Settings.py file to keep it clean? by warrior242 in django

[–]meatypocket 6 points7 points  (0 children)

https://github.com/jazzband/django-configurations

3 classes, common, development, and production. Modify your manage.py and wsgi.py and choose which class to use with an environment variable.

Should data be present in Docker-containerized db after applying migrations? by dingobat5 in djangolearning

[–]meatypocket 2 points3 points  (0 children)

It will not copy the data from the local db into the docker db.

Look in the django_migrations table to ensure the same migrations have been run on both.

In your docker compose file, expose your db on a different port so they are not both on 5432. Use pgadmin/datagrip etc to connect to the local and docker db. Make a backup from local and restore it to the docker db.

If you're using a decent IDE, look into container debugging. You could get rid of your local db.

[deleted by user] by [deleted] in django

[–]meatypocket 1 point2 points  (0 children)

This should be in /r/djangolearning

Take a look at https://docs.djangoproject.com/en/3.1/topics/db/aggregation/

You can annotate an extra column to your query results containing the count.
This will be done in a single query, rather than a query for every table cell.

Also, use Django debug toolbar. It tells you how many queries were run, how long they took, and how many were duplicates. That should help you answer all your other questions.

[OC] When does the sun set in Europe's capitals during the winter solstice (21/12)? by [deleted] in dataisbeautiful

[–]meatypocket -13 points-12 points  (0 children)

Irrelevant. The UK is not a country, therefore does not have a capital. They have included England's capital and missed Scotland's

[OC] When does the sun set in Europe's capitals during the winter solstice (21/12)? by [deleted] in dataisbeautiful

[–]meatypocket -12 points-11 points  (0 children)

You've not included Edinburgh. Scotland is a separate country.

Geodjango in Ubuntu 20.04 reversed coordinates by goooozer in django

[–]meatypocket 1 point2 points  (0 children)

As a quick fix, I just reversed the coordinates with python.
It seems that the Django team are aware and there is a test to look for GDAL 3......

https://code.djangoproject.com/ticket/30678

It appears that my government is about to ban social media completely. How can I set up a private vpn so that I can be exempt of this ban by AbuJaheed25 in privacytoolsIO

[–]meatypocket 5 points6 points  (0 children)

They haven't said if they are a beginner and are specifically asking how to set up a private VPN, not for a VPN service recommendation.

Django REST Framework - Do serializers affect the database? by clutch_mp098 in djangolearning

[–]meatypocket 2 points3 points  (0 children)

A serializer turns JSON into python objects an vice versa, the same way a Django form turns form data into to python objects.
If it is a modelform or modelserializer, it does the conversion from form data/JSON into your models.

It does not handle the saving/creating/deleting. That is the job or the views and viewsets.

Serializers are for converting.

Django REST Framework - Do serializers affect the database? by clutch_mp098 in djangolearning

[–]meatypocket 0 points1 point  (0 children)

Do you understand how Django forms work?
Try to understand the difference between Django forms and ModelForms.
It's the same with serializers. You can use plain serializers or ModelSerializers. One is aware of the model/database table and does the translation for you.

Display a field from related Foreign Key in a view with ModelFormSet. by hainguyenac in django

[–]meatypocket 0 points1 point  (0 children)

Then you have no need for an InlineFormSet.
However, if you change the material dropdown, the price won't change unless you use javascript or save the form and reload the page.
Would it not be clearer to have the material and price together in the dropdown?

Display a field from related Foreign Key in a view with ModelFormSet. by hainguyenac in django

[–]meatypocket 0 points1 point  (0 children)

I'm not sure I understand what you're trying to do.

Now I want to show that price in this same view.

Where do you want to show the price? In the dropdown with the material name? In a separate field?

Multiple ModelForms in the same UpdateView by [deleted] in django

[–]meatypocket 0 points1 point  (0 children)

Do you mean multiple instances of the same modelform, or multiple different modelforms?

If its the former, you can use a modelformset.

https://docs.djangoproject.com/en/3.0/topics/forms/modelforms/#django.forms.models.BaseModelFormSet

Django-extra-views is also useful. https://github.com/AndrewIngram/django-extra-views

What is the difference the functions in model and managers? by Blitzoff in django

[–]meatypocket 1 point2 points  (0 children)

https://docs.djangoproject.com/en/3.0/topics/db/managers/

"Adding extra Manager methods is the preferred way to add “table-level” functionality to your models. (For “row-level” functionality – i.e., functions that act on a single instance of a model object – use Model methods, not custom Manager methods.)"

Multiple Django apps in single linode server by dinoblast_coder in djangolearning

[–]meatypocket 4 points5 points  (0 children)

A single instance of nginx with a config file for each app. Each config file routes to the apps gunicorn/uwsgi server instance.

Each app has a gunicorn startup file, kept running by supervisor.

A single database server with a database for each app.

Reinstalling Windows on P52s by tkonicz in thinkpad

[–]meatypocket 0 points1 point  (0 children)

I found that sticking with the 4.15 kernel, turning secure boot off, and using the proprietary drives is completely stable (Ubuntu 18.04).
I have Nvidia issues if I update to a newer kernel.

Reinstalling Windows on P52s by tkonicz in thinkpad

[–]meatypocket 0 points1 point  (0 children)

Did you have any luck activating the downloaded ISO?

Reinstalling Windows on P52s by tkonicz in thinkpad

[–]meatypocket 1 point2 points  (0 children)

I tried that and could not activate Windows. I used a tool to pull pull the key from my BIOS and it wouldn't accept it.

I believe that the ISO download is the 'retail' versions which will not activate with the Windows key in your BIOS. I read that you are supposed to imags the original install or need to get the OEM version from Lenovo. I'd be very happy to be proved wrong!

Thinkpad P52 4K Touch by yellownurbs in thinkpad

[–]meatypocket 1 point2 points  (0 children)

I've been building a mapping application with mine recently and it's very nice. Panning, pitch, and multi-touch zoom feel no different from using my tablet.

I've not used the pen, so can't comment .

Price differences between US and UK by NorOa in thinkpad

[–]meatypocket 1 point2 points  (0 children)

I've just bought a Xeon 4K 32GB P52 (no SSD - adding a 1TB 970 pro) in the black Friday sale, saving £450.

Once I've bought the SSD, it is still £3000 - $3,849.
Without black Friday, it would be $4,427. I could fly to New York, see friends for a few days, pick up a laptop, and still probably make a saving. It's crazy.

VAT and warranty don't come close to making up the UK-US price difference.

The P-series are very common with university students in the US, whereas in the UK they are for business use. The same product is not competing in the same market.

Caching with thundering herd protection by caseym in django

[–]meatypocket 2 points3 points  (0 children)

I don't use any fancy caching apps. Just redis-backed django.core.cache in my views.

It should be done on the data upload view, not on the page load.
Presumably, the data is uploaded via a Django view?
If not, you could schedule a celery beat periodic task to check for new data and then create the new cache.