Re: Registration form in template

2024-03-19 Thread Clive Bruton
If you want to override what the form is showing, then you can build your own template and only include the elements that you wish to show. Rather than use: {{ form }} use: {{ form.field_name }} or break it down further, like: {{ form.field_name.html_name }} etc

Re: Custom User models

2023-11-27 Thread Clive Bruton
I am taking it that there is more than one "school"? If so, surely it's is just a many-to-many relationship. On 27 Nov 2023, at 09:33, Okkert Joubert wrote: Good morning all, I made a custom user model for a school, it is currently working with djoser authentication, now what I want to

Re: bonjour tout le monde Je suis confronte a cette erreur depuis 2 jours....besoins d'aide svp

2023-11-26 Thread Clive Bruton
Sorry I can't reply in French. It simply means that a template is expected in your project/app folder at: [project/app]/templates/registration/logout.html -- Clive On 26 Nov 2023, at 11:55, fabrice ayissi awono wrote: -- You received this message because you are subscribed to the

Re: WHAT OTHER REAL TIME MAP CAN I USE IN MY PROJECT ASIDE GOOGLE MAP?

2023-03-25 Thread Clive Bruton
Here maps: https://www.here.com https://heremaps.github.io/ -- Clive -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to

Re: How to fetch 10000 above record within second in django?

2023-01-17 Thread Clive Bruton
On 17 Jan 2023, at 12:06, Ayanfeoluwa Koyinsola wrote: You might now have to display all the data at once, see if you can use paginisation to reduce the numbers of queries I think this will only help if there are related lookups. -- Clive -- You received this message because you are

Re: How to fetch 10000 above record within second in django?

2023-01-17 Thread Clive Bruton
On Tue, Jan 17, 2023, 12:40 PM Clive Bruton wrote: On 17 Jan 2023, at 05:01, Prashanth Patelc wrote: > I written query it's taking more time like 38 seconds, how to to > fetch the lac of records within seconds any example in django using > orm or MySQL query ? Are you saying that you

Re: How to fetch 10000 above record within second in django?

2023-01-16 Thread Clive Bruton
On 17 Jan 2023, at 05:01, Prashanth Patelc wrote: I written query it's taking more time like 38 seconds, how to to fetch the lac of records within seconds any example in django using orm or MySQL query ? Are you saying that you have a raw SQL query, or you are using a Django query?

Re: How to access the value of a field that failed validation

2023-01-15 Thread Clive Bruton
If you print: dir(form_instance) You'll get the methods available to the form. From memory, amongst these you will find "data" and "initial", I think that "data" contains the information submitted in the form action. So, to show that: print(form.data) -- Clive On 2 Jan 2023, at

Re: join on plain integerfield

2022-12-08 Thread Clive Bruton
Try Django Relativity: https://pypi.org/project/django-relativity/ -- Clive On 21 Nov 2022, at 10:11, Marek Rouchal wrote: Any suggestion how I can model such an integerfield, so that I can do joins on it using the Django ORM queryset syntax? -- You received this message because you

Re: Need to Replace django default I'd with UUID field

2022-12-08 Thread Clive Bruton
It's more or less the same problem, use a new field to insert your new foreign keys (UUIDs), looking them up via your old foreign keys to get the new UUID values. Or, as the other Jason suggests, if you can, just use the UUIDs for external access. -- Clive On 22 Nov 2022, at 19:02,

Re: Quiz app

2022-11-16 Thread Clive Bruton
Questions.objects.all().order_by('?')[:5] ie get all the rows from the Questions table, in a random order, then show me the first five. https://docs.djangoproject.com/en/dev/topics/db/queries/#limiting- querysets -- Clive On 16 Nov 2022, at 01:14, Lakshyaraj Dash wrote: Hello

Re: Single Sign On in Django

2022-11-16 Thread Clive Bruton
You can use django-allauth: https://github.com/pennersr/django-allauth On 10 Nov 2022, at 09:59, venkat Bukka wrote: Hello all, Could anyone please let me know how we can implement SSO in the django...for authenticating multiple apps in a base application. -- You received this message

Re: dynamic formular

2022-11-12 Thread Clive Bruton
Try django-extra-views https://github.com/AndrewIngram/django-extra-views Hugely simplifies formsets On 10 Nov 2022, at 11:14, Arnold Falanga wrote: Hello can anyone help me to design a dynamic form with Django the idea is to have two parts in this form. a link to add the lines -- You

Re: OperationalError at /admin/login database or disk is full

2022-05-27 Thread Clive Bruton
On 27 May 2022, at 22:37, Andrew Rea wrote: OperationalError at /admin/login/ database or disk is full Is this because my SQLite database is full from other projects? Or possibly because I have too many virtual envs from those same other projects? Or is it due to my personal computer's

Re: Reusable django templates

2022-03-12 Thread Clive Bruton
On 12 Mar 2022, at 17:43, Heman Okumbo wrote: How comes I'm not able to modify my templates after extending from a base template.eg can't add extra contents,the template only display contents of the inherited template. Some code might help. It's not really clear to me what you are

Re: How to create dynamic models in django??

2022-02-28 Thread Clive Bruton
On 28 Feb 2022, at 16:24, Prashanth Patelc wrote: Any example? Just read the django-extra-views documentation. Essentially a formset can be as simple to use as any of the built-in class-based views, eg: from extra_views import InlineFormSetView class

Re: How to create dynamic models in django??

2022-02-28 Thread Clive Bruton
On 27 Feb 2022, at 17:54, Steve Smith wrote: ...the documentation on Formsets is scarce in my opinion and to get them to work is a lot of trial and error... To massively simplify formsets try django-extra-views -- Clive -- You received this message because you are subscribed to the

Re: Login & Register

2022-02-26 Thread Clive Bruton
Use django-allauth package. On 26 Feb 2022, at 15:09, Ankit Chaurasia wrote: Hey, I am new in Djnaog and I want to make Login and Register Page with Email Verification. Can anone share the code ? and please gide me for the same. -- You received this message because you are subscribed to

Re:

2021-04-02 Thread Clive Bruton
Find a project on github and suggest some easy fixes. I'm no django expert, but I've had patches accepted on at least three projects. The last one I contributed to was updating the code from django 1.x to 3.x, so that it would run on more recent versions. This is quite easy to do, since

How to avoid select lists on formsets and ManyToMany?

2021-04-01 Thread Clive Bruton
I have a ManyToMany model set, that on the edit uses a formset to add/ edit rows. I have this working, but the unfortunate part of it is that the select that results from the ManyToMany relationship populates with 16,000 records. What I would like to do is, once the records are added, just

Re: getting 404 page not found on part 3 of the tutorial

2020-11-11 Thread Clive Bruton
name 'polls' following. I believe you have to put the app name following that. It was working before with http://127.0.0.1:8000/polls/, but then I did something and tried to backtrack and the whole system got messed up. I tried to reset everything back to the original but it is still not work

Re: getting 404 page not found on part 3 of the tutorial

2020-11-11 Thread Clive Bruton
On 11 Nov 2020, at 23:37, George P. Olson wrote: So when I go to this url: http://127.0.0.1:8000/polls/ Although the urlpatterns below shows "# ex: /polls/", the defined path has no path elements, so you just need: http://127.0.0.1:8000/ I think. urlpatterns = [ # ex: /polls/

Re: Get datetime now, not at server initialisation

2020-11-01 Thread Clive Bruton
On 30 Oct 2020, at 11:00, Carles Pina i Estany wrote: Let me know if it's not clear or if I explained something that you didn't ask! Thanks you very much for spending the time on this, to explain it to me - it was very helpful! -- Clive -- You received this message because you are

Re: Get datetime now, not at server initialisation

2020-10-28 Thread Clive Bruton
' is not defined``` Sorry for so many more questions! -- Clive On 28 Oct 2020, at 08:58, Carles Pina i Estany wrote: Hi, On Oct/27/2020, Clive Bruton wrote: I have a function that uses the current date to set up a file path for uploaded images: def upload_path

Get datetime now, not at server initialisation

2020-10-27 Thread Clive Bruton
I have a function that uses the current date to set up a file path for uploaded images: def upload_path(): dtnow = datetime.now(timezone.utc) dtstr = '{:%Y/%m/%d/%H/%M/%S}'.format(dtnow) print('dtstr: ') print(dtstr) dtstr =

Re: Dynamic Logo

2020-10-18 Thread Clive Bruton
On 18 Oct 2020, at 12:53, Asaduzzaman Sohel wrote: I am creating a django application. now I would like to create logo, site name & info which will be dynamic. I want to create Model for this , but problem is use create many logo, site name or info. but Use can create or edit only one

Django conditional field display on form

2020-10-15 Thread Clive Bruton
I am trying to make a simple form, that conditionally shows the "website" input field based on the value of another database field (that is not on the form) "status". For the sake of this process the "status" field is not editable by the user, just by the admin. Both fields are in the same

Re: transforming form input

2020-07-08 Thread Clive Bruton
On 7 Jul 2020, at 22:58, Kai Kobschätzki wrote: I render one input field surname. And if the user writes one string in the input field it should be saved to surname (so forename is None). If the user writes two strings (separated through a white space) than the first part should be saved

Adding an 'or' to filter

2020-07-06 Thread Clive Bruton
I am working into someone else's solution, with this code in forms.py: *** class SearchForm(forms.Form): area = forms.ModelChoiceField(label=_('Area'), queryset=Area.objects.all(), required=False) group = forms.ModelChoiceField(label=_('Group'),

Re: Trouble getting kwargs into filter

2020-07-06 Thread Clive Bruton
Thank you. On 6 Jul 2020, at 05:24, Stephen J. Butler wrote: def get_queryset(self): qs = super().get_queryset() return qs.filter(user__id=self.kwargs['userlist']) -- You received this message because you are subscribed to the Google Groups "Django users" group. To

Trouble getting kwargs into filter

2020-07-05 Thread Clive Bruton
I am struggling with getting kwarg values into a queryset filter: class UsersItemsView(ListView): template_name = 'testapp/user_item_list.html' def get_queryset(self, **kwargs): print('kwargs-userlist') print(kwargs) #return

Re: Primary keys using sequences

2020-07-01 Thread Clive Bruton
On 2 Jul 2020, at 00:06, Stats Student wrote: Hi, I am using a Postgres database and have been populating the primary key from a sequence. Is there any way to define this behavior through Django's ORM? Thanks I think you are basically asking how to create a custom key. This was

Re: CSS file not Loading

2020-06-28 Thread Clive Bruton
If you are testing the site with manage.py runserver, then you have to make sure debug is on. And you have to ensure the app knows where the static directories are. -- Clive On 28 Jun 2020, at 12:21, Suny wrote: Do I need to add STATICFILES_DIRS in settings.py file TREE STRUCTURE for

Re: Form theory - locking a field

2020-06-24 Thread Clive Bruton
On 24 Jun 2020, at 23:03, Chetan Ganji wrote: Try this one https://docs.djangoproject.com/en/3.0/ref/forms/fields/#disabled Ok, well that's a little help, because I can disable the input: status = forms.ChoiceField(choices=Profile.status_choices,

Re: Custom Primary Key

2020-06-24 Thread Clive Bruton
On 24 Jun 2020, at 06:24, Soumen Khatua wrote: Yes, at the time of add a new record in model, automatically I want to create a custom ID and insert it into model There is a post about this at Stack Overflow: https://stackoverflow.com/questions/52070462/django-generate-custom-id -- Clive

Form theory - locking a field

2020-06-24 Thread Clive Bruton
I have a form in which, after filing, I would like one field to be locked for editing, the forms.py looks like this: ** class ProfileForm(forms.ModelForm): status = forms.ChoiceField(choices=Profile.status_choices, widget=forms.RadioSelect) class Meta: model =

Re: Custom Primary Key

2020-06-23 Thread Clive Bruton
On 23 Jun 2020, at 23:32, Oleg Kishenkov wrote: Hello Soumen, you should use a CharField with the primary_key=True attribute for your model. This way no no automatic primary key field is generated, your field will be implicitly unique and non- null though. Only one primary key is allowed

Re: Updating a date field

2020-06-14 Thread Clive Bruton
Apparently the magic is: queryset = Item.edit.filter(**kwargs).update(expires=set_expires (),is_active=True) -- Clive On 14 Jun 2020, at 03:24, Clive Bruton wrote: I am trying to update an existing date field, however when I do that I get the following exception: Exception Type

Updating a date field

2020-06-13 Thread Clive Bruton
I am trying to update an existing date field, however when I do that I get the following exception: Exception Type: TypeError Exception Value: expected string or bytes-like object The query looks like this: queryset = Item.edit.filter(**kwargs).update

Compare logged-in user against record owner in filter

2020-06-10 Thread Clive Bruton
I am trying to create a queryset that filters against the logged-in user's id and the user_id in the record, ie so that only the relevant user can see the record. Without the filter, when I display the page I can capture elements in the template that would allow this comparison, ie:

Re: Python 3.8 Installed, yet Django 1.11 is Automatically Being Installed on Mac

2020-06-09 Thread Clive Bruton
You have to use the correct python install: python3 -m pip install django You can test your versions and locations: which python3 which python python3 -V python -V When you are running the development server: python3 manage.py runserver You

Date comparison as a filter

2020-06-07 Thread Clive Bruton
I would like to add a date comparison filter to a lookup, to find items in a database table that have not yet expired. I tried: .filter(expires>=datetime.today()) \ But this does not appear to have any effect. "expires" is a column in the table of datetime type, that looks like

Re: Categories and shoe Subcategories according to the parent category.

2020-05-19 Thread Clive Bruton
There are django modules for hierarchical navigation https://djangopackages.org/grids/g/navigation/ -- Clive On 19 May 2020, at 23:20, saqlain abbas wrote: Please tell me if anyone knows about this. On Mon, May 18, 2020 at 4:50 PM saqlain abbas wrote: Hi, if i add Categories , for

Re: Bootstrap drop down menu not clickable.

2020-05-16 Thread Clive Bruton
On 16 May 2020, at 15:43, sunday honesty wrote: I included it to installed app and got an error message on the console. "Module not found, no module named bootstrap 4" "bootstrap4" -- Clive -- You received this message because you are subscribed to the Google Groups "Django users"

Re: Bootstrap drop down menu not clickable.

2020-05-16 Thread Clive Bruton
On 16 May 2020, at 15:03, sunday honesty wrote: I did that and got a TemplateSyntaxError stating that bootstrap4 is not a registered tag library Did you put it in your installed_apps? -- Clive -- You received this message because you are subscribed to the Google Groups "Django users"

Re: CSS with Django forms

2020-05-15 Thread Clive Bruton
' button, which are rendered using django forms, cannot be modified using CSS in this way. Is there any other way to fix it? On Wednesday, 13 May 2020 18:58:08 UTC+5:30, Clive Bruton wrote: On 12 May 2020, at 22:41, Anubhav Madhav wrote: > Is there any way to display the forms with my HTML

Viewing available functions and variables

2020-05-13 Thread Clive Bruton
I am using django-allauth for a user registration/log-in system. I have this working, however, as a general question, I would like to understand how one can view the functions/variables available on a given template. For example I see that in some templates these are included: {%

Re: CSS with Django forms

2020-05-13 Thread Clive Bruton
On 12 May 2020, at 22:41, Anubhav Madhav wrote: Is there any way to display the forms with my HTML CSS files. Use {% include %} (https://docs.djangoproject.com/en/3.0/ref/ templates/builtins/#include) in your HTML template files for an embedded style sheet, or just use a link in the head