Reverse function fails for a single app

2023-11-24 Thread Derek
o_modeltwo_changelist' is not a valid view function or pattern name. /home/derek/miniconda3/envs/tp32/lib/python3.9/site-packages/django/urls/resolvers.py:677: NoReverseMatch During normal use, the app behaves fine and any other tests not requiring reverse all work OK. What could cause the

Re: How to solve primary key error in django?

2023-01-09 Thread Derek
Also understand that using '0' for a primary key is NOT recommended by MySQL; look at: https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sqlmode_no_auto_value_on_zero This has bitten me before when migrating data from other types of DBMS. On Thursday, 5 January 2023 at 12:09:35 UTC+2 prash

Re: Fwd: Delivery Status Notification (Failure)

2022-09-18 Thread Derek
I agree with previous posts. It might also be worthwhile to simplify your code to avoid unneeded variables: details=Details( name=requests.POST.get('name'), roof_age=requests.POST.get('roof_age'), email=requests.POST.get('email'), phone=r

Re: Negative Stock Prevention

2022-08-30 Thread Derek
As a start, the logic checks for the model should not be in views.py but rather with the model object (in models.py). You can extend the save() method, for example, and add the checks there. See: * https://docs.djangoproject.com/en/4.1/ref/models/instances/#saving-objects * https://docs.djang

Re: How to generate a table in pdf?

2022-06-26 Thread Derek
https://xhtml2pdf.readthedocs.io/en/latest/usage.html is what you need. On Friday, 24 June 2022 at 16:08:10 UTC+2 kvnk...@gmail.com wrote: > > > > > *Hi family, I created a salary calculation application.As I already > display the list of employees, I now have to download it using a function >

Re: Json Object type field in Model in Django

2022-06-10 Thread Derek
Creating: https://docs.djangoproject.com/en/4.0/ref/models/fields/#jsonfield Querying: https://docs.djangoproject.com/en/4.0/topics/db/queries/#querying-jsonfield On Thursday, 9 June 2022 at 15:00:31 UTC+2 vmuk...@gmail.com wrote: > Hii Community, > > can we add a field in model that stores j

Re: create_question not define error. NameError.

2022-05-03 Thread Derek
What steps did you follow to get here? What does your code look like that creates this error? (Its probably better to post actual code snippets as text rather than screenshots.) On Monday, 2 May 2022 at 15:02:44 UTC+2 mdanz...@gmail.com wrote: > Anyone is here for help? > > On Friday, 29 Apri

Re: Help! I begginer...

2022-04-29 Thread Derek
You may need to update the version of Django you're running; the current source code (https://github.com/django/django/blob/main/django/db/models/sql/query.py) shows this import: from collections.abc import Iterator, Mapping Hope that helps. On Tuesday, 26 April 2022 at 18:34:34 UTC+2 rikrdop

Re: simple command line ./manage.py shell puzzle

2022-04-24 Thread Derek
Actually, there does seem to be some further issue: echo "import datetime; [datetime.date(2022,4,e) for e in [1,2]]" > test.py Also triggers an error when used in the Django shell, but works when run as a normal Python script: python test.py On Monday, 25 April 2022 at 07:44:0

Re: simple command line ./manage.py shell puzzle

2022-04-24 Thread Derek
It fails because the second datetime in your test script is taken to be a variable and it is not one you have already defined; hence the error: "NameError: name 'datetime' is not defined". Try this instead: echo "import datetime ; [e*e for e in [1,2]]" > test On Thursday, 21 April 2022 at 19:0

Re: Django

2022-04-22 Thread Derek
from app2.models import ThatModel (assuming both apps are part of the same project) On Thursday, 21 April 2022 at 21:47:18 UTC+2 farid...@gmail.com wrote: > Please how do I import a model from another app. Thanks, please someone > should help me out > -- You received this message because you

Re: Fetching Data Between Models

2022-04-21 Thread Derek
You've already posted the same question: https://groups.google.com/g/django-users/c/f7ZH2pcZp0s On Wednesday, 20 April 2022 at 16:44:19 UTC+2 techg...@gmail.com wrote: > I have a model Staff and LeaveReportStaff, I wanted to get leave_balance > between Total_Leave_Days and leave_days. I already

Re: Calculations Between Models

2022-04-20 Thread Derek
Not sure what the "@aproperty" are here for, but in your views.py file, you could do this calculation, passing in the ID of the staff record: from .models import Staff, LeaveReportStaff def get_leave_balance(staff_id): total_leave_days = Staff.objects.get(pk=staff_id) leave_reports = Lea

Re: Logging: set default values for custom keys in custom formatters OR choose formatter based on logger

2022-04-11 Thread Derek
Re issue (1): https://github.com/django/django/blob/main/django/utils/log.py#L31 shows how Django uses its own JSON format in `settings.py` to set a link to its (local) own custom class `ServerFormatter`, which in turn inherits from Python's logging.Formatter. So it should be possible to creat

Re: xlsx file data pasing into array to pgadmin using python

2022-03-15 Thread Derek
If you are working purely at database level, perhaps best to ask on a PostgreSQL Mailing List? On Monday, 14 March 2022 at 16:27:02 UTC+2 boddulur...@gmail.com wrote: > database function how to write data saave into table in array data -- You received this message because you are subscribed to

Re: How to create dynamic models in django??

2022-03-10 Thread Derek
I'm not quite sure how these requirements have arisen as you have not provided any context as to the actual user or business needs. In my experience, most businesses and science organisations understand very clearly what kinds of data they need to store and what they need to do with that dat

Re: collectstatic files chown'ed by root

2022-02-15 Thread Derek
rocess, but it comes down to file permissions in Docker not being independent of those in the host; and there is a LOT of reading around that if you want to dig into it. IMO, its not a "workaround" if you just actually do need to work with multiple permissions at different points in

Re: Django versus competitors survey

2022-02-12 Thread Derek
ners-guide-to-concurrency-and-parallelism-in-python On Thursday, 10 February 2022 at 18:35:47 UTC+2 michae...@gmail.com wrote: > On Wednesday, February 9, 2022 at 8:39:01 AM UTC-5 Derek wrote: > >> Hi Michael >> >> I think you may be be comparing apples and oranges and

Re: Django versus competitors survey

2022-02-09 Thread Derek
Hi Michael I think you may be be comparing apples and oranges and this could be because it seems you're more of a software user than a software builder. Django is used to build web-based applications, primarily those with a database backend. One such type of application is a CMS (other types c

Re: Barcode

2022-02-02 Thread Derek
We implemented bar coding on the back end - e.g., to generate a PDF which the client then prints. One library you can use for this is: https://pypi.org/project/treepoem/ On Wednesday, 2 February 2022 at 02:05:56 UTC+2 andres@uaiinpebi-cric.edu.co wrote: > Does anyone have experience with

Re: Database design

2022-01-23 Thread Derek
The best approach is for the Django/DB devs to create these fields (and forms) in advance for the users to enter data. If you want users to add "key/pair" type data which is not known in advance, look to adding a JSON column to your table; see: https://www.postgresql.org/docs/14/datatype-json.ht

Re: Django reportViewer

2021-12-15 Thread Derek
This seems to be referring to a Microsoft app (https://www.thereportviewer.com/) that has nothing to do with Django. You can, of course, use Django to build a web page that looks similar to this, assuming you have access to the underlying database. On Tuesday, 14 December 2021 at 16:01:39 UTC+2

Re: Re-write an application from Turbogear to Django.

2021-11-27 Thread Derek
Agreed. You could also consider keeping Dojo and upgrading to the current version. On Thursday, 25 November 2021 at 19:41:52 UTC+2 sutharl...@gmail.com wrote: > I would have chosen the first option, since we can have some relationships > in the database and once all the apis are ready. We can e

Re: Mouse movement detection and processing from client UI

2021-10-27 Thread Derek
I am not sure about the others, but certainly for map clicks you'll need JavaScript e.g. https://docs.mapbox.com/mapbox-gl-js/example/popup-on-click/ Of course, the page itself, with JS code links, snippets and supporting data can be generated via Django in the normal way. HTH On Wednesday, 2

Re: Quick question for web hosting production

2021-10-12 Thread Derek
Here's a similar question on StackOverflow: https://stackoverflow.com/questions/65141036/deploy-react-and-django-with-nginx-and-docker On Friday, 8 October 2021 at 16:17:27 UTC+2 patz...@gmail.com wrote: > I want to ask a quick question guys that, is it possible to host 2 apps in > one cloud s

Re: Listing and Searching fields in another table

2021-10-06 Thread Derek
Obviously you will be searching in related table. So if you have models.py like: class Author(models.Model): first_name = models.CharField(max_length=100) last_name = models.CharField(max_length=100) class Book(models.Model): title = models.CharField(max_length=200) author = mod

Reverse look fails when importing from the admin for an app

2021-10-03 Thread Derek
#x27;admin:myapp_mymodel_changelist')) i.e. if I comment out the import line the code works, otherwise it fails. Any ideas on why Django is failing when importing from the app's admin? Thanks Derek -- You received this message because you are subscribed to the Google Groups "Djang

Re: How can add multiple forms according to input enter number or with click add more button

2021-09-26 Thread Derek
Have a look at https://django-formtools.readthedocs.io/en/latest/ This includes the ability to skip steps based on information already supplied - https://django-formtools.readthedocs.io/en/latest/wizard.html#conditionally-view-skip-specific-steps On Thursday, 23 September 2021 at 20:37:03 UTC+2

Re: UML to Django models

2021-08-26 Thread Derek
There is not sufficient data in that image to create models. You don't know the field types, for example. Once you have those, it should not be too hard e.g.: from django.db import models class Product(models.Model): product_id = models.AutoField() name = models.CharField( max_length=2

Re: Django admin filters + select2 + loading many options asynchronously

2021-08-05 Thread Derek
Alternatively, there is : https://pypi.org/project/django-admin-autocomplete-filter/ (My own issue with that one s that does not necessarily match any custom styling, but that is probably not a problem for most.) On Friday, 6 August 2021 at 07:53:35 UTC+2 Derek wrote: > You mean like ht

Re: Django admin filters + select2 + loading many options asynchronously

2021-08-05 Thread Derek
You mean like https://pypi.org/project/django-autocomplete-light/ ? On Wednesday, 4 August 2021 at 20:45:16 UTC+2 Federico Capoano wrote: > Hi everyone, > > when adding adming filters by foreign key in the admin, sometimes the > possible values are too many to load. > > So I am thinking, why not

Re: Conmect two docker container

2021-08-01 Thread Derek
Docker has a short tutorial on their website: https://docs.docker.com/samples/django/ On Sunday, 1 August 2021 at 04:48:54 UTC+2 parampal...@gmail.com wrote: > I have two docker container one is postgresql > > > > > And second one is django container > how i connect this two container > > So

Re: complex math calculation from query set

2021-07-21 Thread Derek
Ignore the "'distance': distance" in the return - that should not be there. On Wednesday, 21 July 2021 at 15:55:08 UTC+2 Derek wrote: > See: > https://stackoverflow.com/questions/54412377/adding-values-to-django-queryset > > > VIEW > > def po

Re: complex math calculation from query set

2021-07-21 Thread Derek
See: https://stackoverflow.com/questions/54412377/adding-values-to-django-queryset VIEW def position_view(request): packet_data = TncData.objects.exclude(lat=0).order_by('-dt_heard')[:100] for packet in packet_data: *# my complex math calculation* *packet.distance = "#

Re: Looking for help to add quantity field in my food ordering project

2021-07-16 Thread Derek
>From your Order model, it seems that all the user would need to do is supply the value of "count" representing multiples of one item in a single order. On Thursday, 15 July 2021 at 15:35:37 UTC+2 tiwar...@gmail.com wrote: > Hello community! > I hope you all are in best health. I've been workin

Re: Real-time dashboard method after delivering restapi from outside

2021-06-15 Thread Derek
At a guess, I'd say you will need Django Channels - many blogs and tutorials out there, but here is one good worked example: https://blog.logrocket.com/django-channels-and-websockets/ On Monday, 14 June 2021 at 15:32:51 UTC+2 lkh...@gmail.com wrote: > It is currently returning after receiving a

Re: [Solved] SVG widget for the Admin

2021-06-07 Thread Derek
Dewhirst wrote: > Thanks Derek - it is now working as follows ... > > > class Chemical(models.Model): > ... > ddstructure = models.TextField(null=True, blank=True, verbose_name="2D > structure") > ... > > > class Svg_AdminTextareaWidget(AdminTexta

Re: SVG widget for the Admin

2021-06-04 Thread Derek
rpose. If you want to see it as "read only" in the form, but shown as SVG, perhaps you need a custom model template (https://docs.djangoproject.com/en/dev/ref/contrib/admin/#templates-which-may-be-overridden-per-app-or-model) Derek On Thursday, 3 June 2021 at 08:22:57 UTC+2 Mike Dewhir

Re: SVG widget for the Admin

2021-06-02 Thread Derek
Hi Mike OK, if you have more specific feedback I will try to respond. I doubt you need a specific template as the SVG should be displayable by a modern browser using Django's built-in options. On Thursday, 3 June 2021 at 01:10:07 UTC+2 Mike Dewhirst wrote: > Derek > > I pre

Re: SVG widget for the Admin

2021-06-02 Thread Derek
#modifying-a-change-list-using-list_display (Please note that to show HTML strings, you need to use the format_html() method. Ignore mt previous reference to "allow_tags" as this is deprecated.) Derek On Wednesday, 2 June 2021 at 10:05:11 UTC+2 Mike Dewhirst wrote: > On 1/06/2021 11:44 pm,

Re: SVG widget for the Admin

2021-06-01 Thread Derek
Field() def _the_svg(self): return """%s""" % self.svg_text _the_svg.allow_tags = True I am not sure about editing visually, however - I would expect that would require a specialised widget. HTH Derek On Tuesday, 1 June 2021 at 03:28:59 UTC+2 Mi

Re: how to input list [] dynamic in python

2021-05-31 Thread Derek
This does look a programming exercise in a class... if you ask these questions in future, be warned people here will probably ask to see your attempt at writing code first (otherwise you are not really learning to be a programmer). But, OK, it seemed interesting to me,so here is one approach:

Re: Business logic constants

2021-05-30 Thread Derek
There are many types of constants. We have a 'utils' directory (at same level as 'apps') and under that 'constants' sub-directory - with different files for different types of constants that are generally applicable across all apps. But because we have lots of client-specific constants and codi

Re: Chrome book vs Django application development

2021-05-23 Thread Derek
Perhaps install Linux and work from there? https://www.howtogeek.com/363331/how-to-set-up-and-use-linux-apps-on-chrome-os/ It may be that PostgreSQL is too demanding and can be avoided for development purposes; rather use sqlite. It could also be worth considering to switching to cloud-based CI

Re: After user click on like button page should not refresh(redirect) and update count of likes

2021-05-05 Thread Derek
You'll need to use javascript for this - have a look at https://data-flair.training/blogs/ajax-in-django/ for an example. On Wednesday, 5 May 2021 at 05:30:59 UTC+2 sali...@rohteksolutions.com wrote: > When user click to like a post the web page should not refresh(redirect) > and count of the

Re: Admin layout getting too bulky - what to do?

2021-05-05 Thread Derek
Mike Dewhirst wrote: > Derek > > My phone doesn't do interspersed responses well, so my apologies for top > posting. > > The record to which I refer is any one of those in any list page. > > After clicking one, if that record has any 1:1, 1:n or n:m related > records,

Re: Admin layout getting too bulky - what to do?

2021-05-03 Thread Derek
ar of links should change to the named headings on that page. When a heading is clicked the page should relocate itself so that heading is at the top" at all, sorry. Maybe a follow-up post with a picture (== 1000 words)? Derek On Monday, 3 May 2021 at 08:57:25 UTC+2 Mike Dewhirst wrote:

Re: Loading csv data in database

2021-04-30 Thread Derek
Someone has an example of doing just this: https://arshovon.com/blog/django-custom-command/ On Thursday, 29 April 2021 at 19:39:36 UTC+2 Ryan Nowakowski wrote: > Typically you would write a custom management command for this kind of > thing: > > https://docs.djangoproject.com/en/3.2/howto/cust

Re: How to save a result of multiplication

2021-04-25 Thread Derek
I think you have used the wrong name - "saveit" instead of "save" - also have a look at the example in the docs: https://docs.djangoproject.com/en/3.2/topics/db/models/#overriding-predefined-model-methods and see which parameters are needed for it. On Saturday, 24 April 2021 at 20:50:15 UTC+2 enc

Re: Validate group of fields

2021-04-25 Thread Derek
The docs cover this use case: https://docs.djangoproject.com/en/3.2/ref/forms/validation/#cleaning-and-validating-fields-that-depend-on-each-other On Saturday, 24 April 2021 at 19:57:50 UTC+2 robert...@gmail.com wrote: > > > Hello guys! > > I've 3 fields, but I need validate it as a group, Ej: >

Re: how to get only the 'title' attribute value from following data in django

2021-04-22 Thread Derek
I'd use: querye = Product.objects.filter(id=sell_id).values('title') title = querye[0]['title'] # get the title for the first Product But if you're sure there is one (and only one) product matching the 'sell_id', you can use: querye = Product.objects.get(id=sell_id) title = querye.title HTH

Re: Unique and null

2021-04-07 Thread Derek
Are you using MySQL? https://stackoverflow.com/questions/371/does-mysql-ignore-null-values-on-unique-constraints On Wednesday, 7 April 2021 at 08:07:35 UTC+2 Mike Dewhirst wrote: > I have just made a CharField unique and Django detects duplicates nicely > but seems to ignore multiple insta

Re: License management system Refrence

2021-04-06 Thread Derek
e (https://pypi.org/project/django-limits/) can ensure they do not exceed their allowed number. 4. For generation of an ID to help track products (I assume you mean like goods that are being sold), have a look at the UUIDField - https://www.geeksforgeeks.org/uuidfield-django-models/ HTH

Re: Regarding auto-generating a map with measurements

2021-04-06 Thread Derek
We have done something similar, but for a rectangular layout you may be able to also use a simple HTML table, or a series of nested "div"s (with appropriate styling). On Tuesday, 6 April 2021 at 01:42:17 UTC+2 sammym...@gmail.com wrote: > This was of great help, thanks! > > > On Mon, Apr 5, 2

Re: Deploy Django website internally within company network

2021-04-06 Thread Derek
Our IT dept. will typically set up a virtual machine, with you as admin, into which you can install your own software. Provided it will not be visible outside the company's firewall, this is usually not an issue for them. On Thursday, 1 April 2021 at 15:14:13 UTC+2 Ryan Nowakowski wrote: > I t

Re: How to get only month name and total

2021-04-06 Thread Derek
Have a look at the last answer in this SO question: https://stackoverflow.com/questions/8414584/how-to-get-month-of-a-date-in-a-django-queryset/43505881 On Sunday, 4 April 2021 at 07:32:41 UTC+2 azharul.t...@gmail.com wrote: > Hello , > I am trying to get only month name and count number from *Q

Re: Django asychronous for millions of users

2021-03-31 Thread Derek
I agree with Lars. You have said very little about your actual situation; my concern would be that if someone was appointed to develop a web-based system that was expected to scale that big and that fast I would expect (in fact, if I was the project funder I would *demand*) that you already have

Django reverse lookup fails during unit testing

2021-03-16 Thread Derek
.NoReverseMatch: Reverse for 'locales_site_changelist' not found. 'locales_site_changelist' is not a valid view function or pattern name. Is there some simple reason why reverse lookup does not work when testing? (I actually need to use it in a client post request.) Thanks Dere

Re: Django vs Spring decision

2021-03-02 Thread Derek
You''ll probably not get a unbiased opinion. Devs who work with Java as their primary language are going to pick Spring; and the opposite in the case of Python. If you already have much Java experience and don't want to start learning Python, then rather go on with Spring. Some comments over a

Re: Show FK as input instead of drop down in admin

2021-01-31 Thread Derek
Another option if you want to show actual data, but only a portion, is to use an incremental lookup via an app such https://django-autocomplete-light.readthedocs.io/en/master/ - this works in the Admin as well. On Saturday, 30 January 2021 at 20:58:00 UTC+2 Ryan Nowakowski wrote: > On Wed, Jan

Re: How can I segment a roads?

2021-01-06 Thread Derek
This is a spatial query problem, not a Django one. Suggestion: use PostgreSQL and PostGIS and look at this: https://gis.stackexchange.com/questions/107277/getting-points-along-line-at-defined-distance-using-postgis/203551 HTH Derek On Tuesday, 5 January 2021 at 16:12:59 UTC+2 jfa...@inerza.com

Re: Handle timeseries, how to model ?

2020-12-14 Thread Derek
/django-postgres-large-time-series https://medium.com/smart-digital-garden/timescaledb-and-django-5f2640b28ef1 https://pypi.org/project/django-timescaledb/ https://docs.timescale.com/latest/using-timescaledb Derek On Sunday, 13 December 2020 at 18:35:58 UTC+2 Franck DG wrote: > Hello, >

Re: I cannot output the value of the foreign key via jsonresponse serealize

2020-12-07 Thread Derek
You may want to try some of the approaches given in this StackOverflow: https://stackoverflow.com/questions/15453072/django-serializers-to-json-custom-json-output-format On Sunday, 6 December 2020 at 19:02:31 UTC+2 wwran...@gmail.com wrote: > Hi mates, > > I want to get json serialized the name

Re: Can't create custom user model

2020-11-24 Thread Derek
And this: https://stackoverflow.com/help/minimal-reproducible-example On Monday, 23 November 2020 at 15:59:50 UTC+2 Kasper Laudrup wrote: > On 11/23/20 9:05 AM, Charles Freeman wrote: > > Hey everyone I can't create a custom user model. Every time I try to > > create super user I end up with an

Re: Need help about display machine state?

2020-11-22 Thread Derek
I am not sure the Django mailing list is the best place to get advice on Flask? I did have a quick look - my advice would be to create a Docker deployment (ideally with a pre-built image on DockerHub) to allow quick/fast testing. On Sunday, 22 November 2020 at 02:43:38 UTC+2 graves@gmail.co

Re: Integrating GeoDjango with Esri API

2020-11-22 Thread Derek
Some other (possibly useful) links are: * https://www.youtube.com/watch?v=1-7KUHLTqjs - edit data with QGIS instead of GeoDjango * https://stackoverflow.com/questions/19160349/geodjango-geoserver-openlayers-for-dynamic-mapping - replace "geosever" with "arcmap" and the same principles apply *

Using smart_selects in the admin for a ChainedManyToMany?

2020-11-18 Thread Derek
multi-select box (i.e. just a long list of unfiltered milestones). What needs to change in the above code to create a working smart_selects version? Thanks Derek -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from

Re: How to print sequence number in python

2020-11-15 Thread Derek
You can also use range; >>> for i in range(0, 5): ... print(i + 1) ... 1 2 3 4 5 >>> or in reverse: >>> for i in range(5, 0, -1): ... print(i) ... 5 4 3 2 1 >>> On Saturday, 14 November 2020 at 21:26:04 UTC+2 vicker...@gmail.com wrote: > Python has the enumerate function for these s

Re: Numeric field widget with built-in units

2020-11-13 Thread Derek
Django Suit uses an "enclosed" widget - https://django-suit.readthedocs.io/en/develop/widgets.html#enclosedinput ; see also https://getbootstrap.com/docs/4.5/components/input-group/ On Friday, 13 November 2020 at 05:11:24 UTC+2 Mike Dewhirst wrote: > Does anyone know of a number field widget w

Re: Dropdown

2020-11-09 Thread Derek
Look at Django's select widgets: https://docs.djangoproject.com/en/3.1/ref/forms/widgets/#select If you want a dynamic search type of widget, you'll need a javascript-based approach; for example: https://django-autocomplete-light.readthedocs.io/en/master/ On Thursday, 5 November 2020 at 16:06:

Re: Fetching data from database

2020-10-29 Thread Derek
Have a look at: https://www.guru99.com/python-mysql-example.html and then: https://www.mysqltutorial.org/python-mysql-insert/ https://www.mysqltutorial.org/python-mysql-update/ Not too hard for a beginner. On Wednesday, 28 October 2020 at 20:43:02 UTC+2 kiran...@gmail.com wrote: > Hi everyone,

Re: Regd:- Generating PDF from HTML with image

2020-10-27 Thread Derek
You can try : https://pypi.org/project/xhtml2pdf/ On Tuesday, 27 October 2020 at 11:37:22 UTC+2 senthil...@gmail.com wrote: > Hi Everyone, > > Hope you are doing well > > We need help to generate the PDF from the HTML tag with images. Let us > know if any package available to do this requirement

Re: DJANGO forms: Improve the presentation of the elements

2020-10-26 Thread Derek
What you want to achieve (labels to the side) is the same example shown in the Django-crispy-forms README: https://github.com/django-crispy-forms/django-crispy-forms On Sunday, 25 October 2020 at 19:46:54 UTC+2 wwran...@gmail.com wrote: > Hi guys, > > Is there any way to improve the distribut

Re: Randomly Generate a "Certificate of Completion"

2020-10-22 Thread Derek
You'd need to have a profile for each user, so you can track if they reach the URL (true/false) and then use their email or internal ID or a generated UUID for the certificate (you could store this extra code as well if needed). For generating a certificate, I'd use a PDF format; this would cre

Re: Periodic Execution of django functions or tasks

2020-10-20 Thread Derek
Ryan's suggestion is a very good one. If you don't need Django-specific commands, you can even write a stand-alone Python script which accesses your database to do the work. An alternative to cron that we use, on occasion, is https://pypi.org/project/APScheduler/ which runs in a container (a P

Re: Template styles.

2020-10-18 Thread Derek
You can also consider using django-crispy-forms; they have a Bootstrap styling option: https://django-crispy-forms.readthedocs.io/en/latest/layouts.html#bootstrap-layout-objects and also: https://django-crispy-forms.readthedocs.io/en/latest/install.html#template-packs (for other styling options

Re: Add user to Group after purchase

2020-10-01 Thread Derek
se pdb to see if the postsave_handler function is reached. On Thursday, 1 October 2020 at 01:04:55 UTC+2 Lightning Bit wrote: > Thanks Derek! > > I tried using the signals but it is not working. This is how my signals > and models looks: > > Signals.py: > from django.contrib.auth.models i

Re: Add user to Group after purchase

2020-09-29 Thread Derek
You need to use a "post save" signal; see: https://docs.djangoproject.com/en/3.1/ref/signals/#post-save On Tuesday, 29 September 2020 at 06:23:19 UTC+2 Lightning Bit wrote: > Hi All, > > How would one add a user to a certain Backend group in the Django > Administration after a user purchases a

Re: Need the create statements for my Django models

2020-08-11 Thread Derek
"I was recently porting a legacy DB to Django by using the inspectdb command" - is there any reason why you cannot just stop here? Why do you think the "inspectdb" would fail? I would just go on creating the app and if any issues arise, I'd look at the specific model and see if it is because

Django test runner not respecting unittest.TestCase?

2020-08-10 Thread Derek DeHart
For one of my functional tests, I decided to use unittest.TestCase instead of a Django test class because it was convenient when cleaning up the test to have direct access to my local development database in the test itself. Running the test in isolation like so passes as I'd expect: $ python

Re: Admin list sorting problem

2020-07-30 Thread Derek
Apologies for lack of proof reading; the example code should be: def _name(self): return '%s' % self.name _name.admin_order_field = 'sort_name' On Friday, 31 July 2020 08:21:45 UTC+2, Derek wrote: > > I've had to do something similar to handle sp

Re: Admin list sorting problem

2020-07-30 Thread Derek
ame(self): return '%s' % self.name _name.admin_order_field = 'display_name' In the Admin, only show "_name" and not "sort_name" or "name". HTH Derek On Thursday, 30 July 2020 08:51:01 UTC+2, Mike Dewhirst wrote: > > I have looked closely

Re: Intensive access and modification of database table

2020-07-19 Thread Derek
s..."). You can use product ID as the key, linked to a pair of "current DB available; current total In-carts" values. This would make lookups quick and you only need DB access/change when, as you say, an actual transaction is concluded. This is just a possibility; and one of many

Re: My first question

2020-07-19 Thread Derek
This would make a great blog post! And in future, we can all refer directly to it, when someone asks a similar question. On Saturday, 18 July 2020 16:13:53 UTC+2, Liu Zheng wrote: > > Hi. Doesn't sound like a Django question, but I assume you came across > this question when writing Django code

Re: Suggestions Front tool

2020-07-08 Thread Derek
cribed (but not because of the GUI aspect). On Wednesday, 8 July 2020 13:59:46 UTC+2, kishore wrote: > > Hi Derek, > > thanks a lot for the suggestion, but i would not get good GUI in terms of > theme, buttons, and give the colors for specific verdicts. > and in future i might hav

Re: Suggestions Front tool

2020-07-07 Thread Derek
You are better off using Django for what is it designed for - web-based systems - and rather use other Python alternatives for desktop-based GUIs e.g. pyQT (see various resources such as https://blog.resellerclub.com/the-6-best-python-gui-frameworks-for-developers/ ) On Tuesday, 7 July 2020 14

Re: Getting exception while importing data though Django Admin

2020-06-25 Thread Derek
This seems to be an error raised by a third-party library; you'd probably get a quicker / better response by contacting their devs. On Thursday, 25 June 2020 00:25:18 UTC+2, Sasi Tiru wrote: > > Exception: > > \lib\site-packages\import_export\resources.py", line 581, in import_data > raise Im

Re: Need Dashboard in Django Admin only

2020-05-31 Thread Derek
PS - Should be "Django REST Framework" ( https://github.com/encode/django-rest-framework ) PPS - Please don't use pie charts, especially 3D, for your visuals ( https://www.businessinsider.com/pie-charts-are-the-worst-2013-6?IR=T ) On Sunday, 31 May 2020 17:05:16 UTC+2, Derek w

Re: Need Dashboard in Django Admin only

2020-05-31 Thread Derek
There are numerous ways to design a front-end dashboard; this a highly contested domain on the web! Just some examples, using Django + various other tech are: * https://www.highcharts.com/blog/tutorials/create-a-dashboard-using-highcharts-and-django/ * https://dreisbach.us/articles/building-d

Re: function model which generate a code for model field

2020-05-29 Thread Derek
I would not assume what "previous" means. Rather use post_save to get the actual ID of the current recording. On Friday, 29 May 2020 12:43:19 UTC+2, Anselme SERI wrote: > > Hello Derek, > Is it possible to retrieve the id of the previous recording from this > functio

Re: function model which generate a code for model field

2020-05-28 Thread Derek
The suggested code will not work because, at this point, the "id" has not yet been generated by the database (unlike the other data which is typically entered by the user). You will need to move this code to a post_save signal function - https://docs.djangoproject.com/en/3.0/ref/signals/#post-s

Re: Can we use python related api's on the Django templates ?

2020-05-27 Thread Derek
While you cannot use Python operators and functions directly in the templates, you can write your own "wrappers" around those you need: https://docs.djangoproject.com/en/3.0/howto/custom-template-tags/ On Wednesday, 27 May 2020 15:57:34 UTC+2, Daniel Roseman wrote: > > On Wednesday, 27 May 2020

Re: Regarding redering data in html templates

2020-05-27 Thread Derek
Lots of examples out there, but here is one: https://www.gun.io/blog/how-to-list-items-in-a-dictionary-in-a-django-template For working with static files (such as CSS or images), have a look at: https://scotch.io/tutorials/working-with-django-templates-static-files On Monday, 25 May 2020 17:06:

Re: function model which generate a code for model field

2020-05-26 Thread Derek
Its not clear what you mean by "last"; do you mean a record that already exists in the database and has a ID value - or do you want the ID of the current record? Either way, the code field should not be resetting the '0' to a '1' as this is then misrepresenting the actual data. PS The logic to

Re: JSON file

2020-05-24 Thread Derek
I am not sure about the field names part, but you could probably create that manually very easily. For the data section, you need a list of lists, which you can get from code like: import json data_ready_for_json = list(mail_item_count_deliveries_perDate.objects.values_list('countDeliveries','

Re: Database audit fields in Django

2020-05-24 Thread Derek
There are many things available "by default" in other frameworks; but Django has chose to keep the core focused on doing key things well (I won't say "simple"). For everything else, the plugin/app approach can be used to support your project's specific needs. So "auditing" is actually a comple

Re: HOW TO PROTECT SOURCE CODE DEPLOYED TO A REMOTE SERVER

2020-05-21 Thread Derek
No; a container is not going to hep with this - see: https://stackoverflow.com/questions/51574618/preventing-access-to-code-inside-of-a-docker-container (they specifically mention Python in the answer). On Wednesday, 20 May 2020 17:20:24 UTC+2, James Shen wrote: > > try to deploy using a container

Re: HOW TO PROTECT SOURCE CODE DEPLOYED TO A REMOTE SERVER

2020-05-19 Thread Derek
Yes - short answer is you cannot really "protect" Python code directly (see: https://python-compiler.com/post/how-to-distribute-python-program ) Long answer - don't sell your code to anyone that you do not trust with it. Obviously, there is a legal route, but there is also the "name and shame

Re: Django Model

2020-05-14 Thread Derek
>>> from django.apps import apps >>> apps.all_models['app_name'] So if your app is called, for example, products, then: >>> apps.all_models['products'] Will create a dictionary with all the model classes from that app. On Thursday, 14 May 2020 14:03:40 UTC+2, muazzem_ hossain wrote: > > how to

Re: Can I use a JS Framework to display small JS tasks in a Django project?

2020-05-13 Thread Derek
Its not clear why you need JS at all. The app can load content from directories on the server side (back-end) and write these to a DB. Django could then load these from the DB and show in the normal way. Page generation can be done via normal views (Django/Python code). (PS Both react and ang

  1   2   3   4   5   6   7   8   9   10   >