how to initialize input form fields using URL parameters

2023-01-22 Thread Andrew Brown

I am trying to pass initial values to my form set via URL Query
ex) Localhost:8000?/First_name_id_0=Samuel
[image: forms.py.png]

I was told to use the initial parameter and not the instance in my view 
first

"An inline formset is related to one instance of the parent model. You 
identify *which* instance the formset is related to by the “instance” 
parameter. The “initial” parameter has a different usage, which is defined 
in the docs."

But I can't seem to find an examples in the docs
[image: Views.py.png]

How do I change my view so that that it initialize my form set with URL 
Query?

-- 
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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/34ccbb87-11dc-4097-84ac-95f229d9183an%40googlegroups.com.


Re: Uptime all the time

2023-01-22 Thread Mike Dewhirst

On 23/01/2023 5:12 am, j harvey wrote:
I am looking for ideas on how to keep my app running all the time, 
even when uploading data that will replace the current data. Some of 
these tables will have a million rows or more. Ideas?


Almost a question for the PostgreSQL users list - assuming that is your 
DBMS. It will depend on so many aspects of what is actually happening 
during/after upload.


In theory, if you upload data in a single transaction - or even many 
transactions - there will be no impact on users until the moment of 
committing.


In practice, theory might be inadequate.



Thanks in advance,

John
--
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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8087a569-f379-4e0e-b3fa-92d281abad69n%40googlegroups.com 
.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4bec18f0-42c2-675a-cc5a-c079add41a81%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


In my html page shows an error like this when click on logout button

2023-01-22 Thread Sadiqali ard
In my html page shows an error like this:
Page not found (404) Request Method:GET Request URL:   
 http://127.0.0.1:8000/credentails/logout Using the URLconf defined in 
travelproject.urls, Django tried these URL patterns, in this order:  admin/ 
[name='demo'] credentials/ ^static\/(?P.*)$ 





this is my html page here created the link to the user








My site


Home
About us
{% if user.is_authenticated %}
Hello {{user.username}}

Logout
{% else %}
Register
Login


{% endif %}


Call us: 00-56 445 678 33

-- 
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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fc934bec-74bd-403d-a8a9-38dc73780260n%40googlegroups.com.


BUG USING modelformset_factory MODULE

2023-01-22 Thread Michael Maina


Hello,

 

I have a challenge using the modelformset_factory module (
https://docs.djangoproject.com/en/3.2/topics/forms/modelforms/) and invite 
your advice. 

 

I can automatically generate a pre-populated webpage with a select dataset 
from the database, but the generated template creates two sets of fields on 
my form. One entry has the pre-populated dataset, while the second set is 
blank.
 The challenge is any attempt to update the retrieved dataset, leads to the 
creation of a new (*unnecessary*) entry in my database. Any assistance on 
how to resolve this is most welcome. Details of my setup are highlighted 
below: 

A) PIP FREEZE 

(tickets) michael@Data-Wrangler tickets % pip freeze   

asgiref==3.5.2

backports.zoneinfo==0.2.1

certifi==2022.6.15

charset-normalizer==2.0.12

crispy-bootstrap5==0.6

Django==3.2.13

django-cors-headers==3.10.1

Django-crispy-forms==1.14.0

django-webpack-loader==1.6.0

djangorestframework==3.13.1

idna==3.3

image==1.5.33

importlib-resources==5.4.0

pdfkit==1.0.0

phonenumbers==8.12.51

Pillow==9.2.0

PyQRCode==1.2.1

pytz==2022.1

requests==2.27.1

six==1.16.0

sqlparse==0.4.2

typing_extensions==4.1.1

urllib3==1.26.9

uWSGI==2.0.20

zipp==3.6.0

(tickets) michael@Data-Wrangler tickets % 
 B)  VIEW 

@login_required
def eventupdate(request, event_id):
try:
status = ClientProfile.objects.filter(username=str(request.user).strip()).
values('operational')
except: 
status = False
if (status[0]['operational']) != True:
return render(request, 'website/dashboard.html')
context = {}
ProductFormSet = modelformset_factory(Product, fields = ('name', 'image', 
'visible' , 'brief', 'details', 'venue', 'date', 'time', 'promoters', 
'advance_ticket', 'gate_ticket','regular_ticket', 'vip_ticket',
'under18_ticket',))

if request.method == 'POST':
formset = ProductFormSet(request.POST, request.FILES, queryset
=Product.objects.filter(pk=int(event_id)))

if formset.is_valid():
formset.save()
return HttpResponseRedirect(reverse('website-store'))
else: 

formset = ProductFormSet(queryset=Product.objects.filter(pk=int(event_id)))

return render(request, template_name='website/eventupdate.html', context={
'formset': formset, 'status': status, 'event': event_id })




   1. TEMPLATE

 
{% extends "website/base_portal.html" %}
{% block title %} EVENT UPLOAD - EVENTS MAURITIUS {% endblock %}
{% block content %}
{% load crispy_forms_tags %}
{% load static %}



UPDATEANEXISTINGEVENT



{% csrf_token %}
{{ formset | crispy }}


Update Event Details






const event = {{event}}
//document.getElementsByClassName("multiField").style.display = "hidden";
//document.getElementByClassName("multiField").style.visibility = "none";
//$("multiField").remove();

{% endblock %}

 

   1. MODEL

 
class Product(models.Model):
name = models.CharField(max_length=1000 , blank=True, null=True, 
help_text="Full 
name of the event")
price = models.DecimalField(max_digits=7, decimal_places=2, default=0)
digital = models.BooleanField(default=False, null=True, blank=True)
image = models.ImageField(upload_to='store/', null=True, blank=True)
portfolio = models.ForeignKey(ProductImage, on_delete=models.SET_NULL, null=
True, blank=True)
#category = models.ForeignKey(ProductCategory, on_delete=models.SET_NULL, 
null=True, blank=True)
#tag = models.ManyToManyField(ProductTag)
venue = models.CharField(max_length=200, blank=True, null=True)
promoters = models.CharField(max_length=200, blank=True, null=True)
brief = models.CharField(max_length=200, blank=True, null=True, help_text="A 
brief description of the event")
details = models.TextField(blank=True, null=True, help_text="Separate each 
line with a fullstop and leave the last line empty")
advance_ticket_deadline = models.PositiveIntegerField(default=0)
advance_ticket = models.PositiveIntegerField(default=0)
gate_ticket = models.PositiveIntegerField(default=0)
regular_ticket = models.PositiveIntegerField(default=0)
vip_ticket = models.PositiveIntegerField(default=0)
under18_ticket = models.PositiveIntegerField(default=0)
date = models.DateField(blank=False, null=False, default=timezone.now)
time = models.CharField(blank=True, null=True, max_length=20)
visible = models.BooleanField(default=False, help_text="Select this field 
to activate this event on the home page")

def __str__(self):
return self.name
class Meta:
ordering = ['date']
dayOfWeek = {0:'MON', 1:'TUE', 2:'WED', 3:'THU', 4:'FRI', 5:'SAT', 6:'SUN'}
monthOfYear = {1:'JAN', 2:'FEB', 3:'MAR', 4:'APR', 5:'MAY', 6:'JUN', 7:'JUL', 
8:'AUG', 9:'SEP', 10:'OCT', 11:'NOV', 12:'DEC'}

@property
def imageURL(self):
try:
url = self.image.url

 

 

   1. DUPLICATED HTML

 








 

Name

  Full name 
of the event   

Image

   Currently  
 http://localhost:8080/uploads/store/bernache_VfSjPGz.jpg>">
store/bernache_VfSjPGz.jpg   
  Clear   






  




 

Visible

 Select 
this field to activate this event on the home page

Brief

  A brief 
description of the event   

Details

 

Dress 

Uptime all the time

2023-01-22 Thread j harvey
I am looking for ideas on how to keep my app running all the time, even 
when uploading data that will replace the current data. Some of these 
tables will have a million rows or more. Ideas?

Thanks in advance,

John

-- 
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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8087a569-f379-4e0e-b3fa-92d281abad69n%40googlegroups.com.


Casesentives in models in django

2023-01-22 Thread Hi ND


I tried to put this code to deactivate the sensitivity of the characters 
when logging in, but it does not work. What is the problem with it? It 
still appears to me. Please consider the sensitivity of the characters

I want to use this method. I do not want to use the backend method Please 
help me find the problem


-- 
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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/40f1a882-e996-40f6-9996-b81b61b80b0an%40googlegroups.com.