Thursday, March 16, 2023

Re: sub-list not showing

You need to achieve related fields to achieve the most of this… thank you 

On Thu, 16 Mar 2023 at 23:59, Namanya Daniel <dnamanya.daniel@gmail.com> wrote:
Hello… am using a phone to reply this but I would love to give a hint on something. When you have a child, it's means there's a parent foreign key in the child model. You can use grouper to group child model results so that every is grouped together under a particular parent field. 

On Thu, 16 Mar 2023 at 21:22, nef <frncseric@gmail.com> wrote:
Hi all,
I am facing problem to display a sub-list.
In my model, I ahave a Student and Parent models. A prent can have one or more students.
I want to list all the student in the parent page, but it is not showing. 
Please see here my code.
Models

class Student(models.Model):
    #std_matricule = models.CharField(verbose_name='Student matricule', max_length=6, null=False, unique=True, primary_key=True)
    std_matricule = models.CharField(verbose_name='Matricule', unique=True, max_length=16, null=False, blank=False, help_text='Matricule of the student')
    std_parents = models.ForeignKey(Parents, on_delete=models.DO_NOTHING, related_name='Parents', unique=False, null=True, blank=True, verbose_name='Student parents')
    std_email = models.EmailField(verbose_name='Email', null=False, blank=True, help_text='Enter the email of the student or leave blank if not exist')
    std_password = models.CharField(verbose_name='Password', max_length=512, null=False, blank=True, help_text='Type the password with 6 characters minimum')
    std_surname = models.CharField(verbose_name='Surname', null=False, blank=False, max_length=128, help_text='Type the Surname of the student as in the birth certificate')
    std_firstname = models.CharField(verbose_name='First name', null=False, blank=True, max_length=128, help_text='Type the student first name')
    std_midlename = models.CharField(verbose_name='Midle name', null=False, blank=True, max_length=128, help_text='Type the student first name')
    std_nickname = models.CharField(verbose_name='Student Nickname', max_length=64, null=False, blank=True, help_text='If exist, type student nickname here')

lass Parents(models.Model):
    father_surname = models.CharField(verbose_name='Father surname', max_length=128, null=False, blank=True, help_text='Student Father surname as in the birth certificate')
    father_firstName = models.CharField(verbose_name='Father name', max_length=128, null=False, blank=True)
    father_phone = models.CharField(verbose_name='Father phone number', max_length=24, null=False, blank=True, help_text='Phone number of the Father')
    father_dateOfBirth = models.DateField(verbose_name='Father date of birth', null=True, blank=True)
    father_placeOfBirth = models.CharField(verbose_name='Father place of birth', max_length=512, null=True, blank=True)
    father_nationality = models.CharField('Father nationality', max_length=256, null=False, blank=True)
    father_adress = models.CharField(verbose_name='Father resident adress', max_length=512, null=False, blank=True)  
    father_occupation = models.CharField(verbose_name='Father occupation', max_length=512, null=False, blank=True)
    mother_surname = models.CharField(verbose_name='Mother surname', null=False, max_length=128, help_text='Student Father name as in the birth certificate')
    mother_firstName = models.CharField(verbose_name='Mother name', max_length=128, null=False, blank=True)
    mother_phone = models.CharField(verbose_name='Mother phone number', max_length=64, null=False, blank=True, help_text='Phone number of the mother')
    mother_dateOfBirth = models.DateField(verbose_name='Mother date of birth', null=True, blank=True)
    mother_placeOfBirth = models.CharField(verbose_name='Mother place of birth', max_length=512, null=False, blank=True)
    mother_nationality = models.CharField('Mother nationality', max_length=512, null=False, blank=True)
    mother_adress = models.CharField(verbose_name='Mother resident adress', max_length=512, null=False, blank=True)  
    mother_occupation = models.CharField(verbose_name='Mother occupation', max_length=512, null=False, blank=True)
   

View
def parentsDetails(request, pk):
    parentObj = Parents.objects.get(parent_id=pk)
    context = {'parentObj': parentObj}
    return render(request, "students_management_app/parents-single.html", context)

Template
{% extends 'main.html' %}

    {% block content %}
       
        <h1>A parent page for more details </h1>
        <!-- <img src= "{{ buildingObj.buildingIMG1.url }}"> -->
        <h1>{{parentObj.std_matricule}}</h1>
        <br>
        <h2>Father full name: {{parentObj.father_firstName}} {{parentObj.father_surname}}</h2>
        <br>
        <h2>Mother full name: {{parentObj.mother_firstName}} {{parentObj.mother_surname}}</h2>
        <p>
            Register date: {{parentObj.parent_createDate}}
        </p>
        <p><a href="{% url 'parents-list' %}">Add parents</a><br/></p>
        <br/>
           
        {% if parentObj.student_set.all %}
            {% for student in parentObj.students_set.all %}
           
                <h2>List of students</h2>
                <p>{{student.std_matricule}}</p>
                <p>{{student.std_firstname}} {{student.std_midlename}} {{student.std_surname}}</p>
                <p>{{student.std_sex}}</p>

            {% endfor %}
        {% endif %}
        <p>No Student found in the database</p>
       
    {% endblock content %}
       
    <p>Footer</p>

The page is displaying well with all the information for the parent, but not student data.
Thank you
Eric

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7e44e886-b51b-4478-b1b5-dfd5924a5822n%40googlegroups.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAP4VW2Vbz1Rqc-RcWUF3m_XyKqWqRjTym5OvEkL0212Y4O8VyQ%40mail.gmail.com.

Re: sub-list not showing

Hello… am using a phone to reply this but I would love to give a hint on something. When you have a child, it's means there's a parent foreign key in the child model. You can use grouper to group child model results so that every is grouped together under a particular parent field. 

On Thu, 16 Mar 2023 at 21:22, nef <frncseric@gmail.com> wrote:
Hi all,
I am facing problem to display a sub-list.
In my model, I ahave a Student and Parent models. A prent can have one or more students.
I want to list all the student in the parent page, but it is not showing. 
Please see here my code.
Models

class Student(models.Model):
    #std_matricule = models.CharField(verbose_name='Student matricule', max_length=6, null=False, unique=True, primary_key=True)
    std_matricule = models.CharField(verbose_name='Matricule', unique=True, max_length=16, null=False, blank=False, help_text='Matricule of the student')
    std_parents = models.ForeignKey(Parents, on_delete=models.DO_NOTHING, related_name='Parents', unique=False, null=True, blank=True, verbose_name='Student parents')
    std_email = models.EmailField(verbose_name='Email', null=False, blank=True, help_text='Enter the email of the student or leave blank if not exist')
    std_password = models.CharField(verbose_name='Password', max_length=512, null=False, blank=True, help_text='Type the password with 6 characters minimum')
    std_surname = models.CharField(verbose_name='Surname', null=False, blank=False, max_length=128, help_text='Type the Surname of the student as in the birth certificate')
    std_firstname = models.CharField(verbose_name='First name', null=False, blank=True, max_length=128, help_text='Type the student first name')
    std_midlename = models.CharField(verbose_name='Midle name', null=False, blank=True, max_length=128, help_text='Type the student first name')
    std_nickname = models.CharField(verbose_name='Student Nickname', max_length=64, null=False, blank=True, help_text='If exist, type student nickname here')

lass Parents(models.Model):
    father_surname = models.CharField(verbose_name='Father surname', max_length=128, null=False, blank=True, help_text='Student Father surname as in the birth certificate')
    father_firstName = models.CharField(verbose_name='Father name', max_length=128, null=False, blank=True)
    father_phone = models.CharField(verbose_name='Father phone number', max_length=24, null=False, blank=True, help_text='Phone number of the Father')
    father_dateOfBirth = models.DateField(verbose_name='Father date of birth', null=True, blank=True)
    father_placeOfBirth = models.CharField(verbose_name='Father place of birth', max_length=512, null=True, blank=True)
    father_nationality = models.CharField('Father nationality', max_length=256, null=False, blank=True)
    father_adress = models.CharField(verbose_name='Father resident adress', max_length=512, null=False, blank=True)  
    father_occupation = models.CharField(verbose_name='Father occupation', max_length=512, null=False, blank=True)
    mother_surname = models.CharField(verbose_name='Mother surname', null=False, max_length=128, help_text='Student Father name as in the birth certificate')
    mother_firstName = models.CharField(verbose_name='Mother name', max_length=128, null=False, blank=True)
    mother_phone = models.CharField(verbose_name='Mother phone number', max_length=64, null=False, blank=True, help_text='Phone number of the mother')
    mother_dateOfBirth = models.DateField(verbose_name='Mother date of birth', null=True, blank=True)
    mother_placeOfBirth = models.CharField(verbose_name='Mother place of birth', max_length=512, null=False, blank=True)
    mother_nationality = models.CharField('Mother nationality', max_length=512, null=False, blank=True)
    mother_adress = models.CharField(verbose_name='Mother resident adress', max_length=512, null=False, blank=True)  
    mother_occupation = models.CharField(verbose_name='Mother occupation', max_length=512, null=False, blank=True)
   

View
def parentsDetails(request, pk):
    parentObj = Parents.objects.get(parent_id=pk)
    context = {'parentObj': parentObj}
    return render(request, "students_management_app/parents-single.html", context)

Template
{% extends 'main.html' %}

    {% block content %}
       
        <h1>A parent page for more details </h1>
        <!-- <img src= "{{ buildingObj.buildingIMG1.url }}"> -->
        <h1>{{parentObj.std_matricule}}</h1>
        <br>
        <h2>Father full name: {{parentObj.father_firstName}} {{parentObj.father_surname}}</h2>
        <br>
        <h2>Mother full name: {{parentObj.mother_firstName}} {{parentObj.mother_surname}}</h2>
        <p>
            Register date: {{parentObj.parent_createDate}}
        </p>
        <p><a href="{% url 'parents-list' %}">Add parents</a><br/></p>
        <br/>
           
        {% if parentObj.student_set.all %}
            {% for student in parentObj.students_set.all %}
           
                <h2>List of students</h2>
                <p>{{student.std_matricule}}</p>
                <p>{{student.std_firstname}} {{student.std_midlename}} {{student.std_surname}}</p>
                <p>{{student.std_sex}}</p>

            {% endfor %}
        {% endif %}
        <p>No Student found in the database</p>
       
    {% endblock content %}
       
    <p>Footer</p>

The page is displaying well with all the information for the parent, but not student data.
Thank you
Eric

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7e44e886-b51b-4478-b1b5-dfd5924a5822n%40googlegroups.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAP4VW2Uhvx6v49UTnm_hzrzj8A%2B7G%2BdZTWt89i5xOdxFV1iLBw%40mail.gmail.com.

Deleted django_content_type table

Now i am not able to do anything and i cannot lose the data please help restore contenttypes

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/879a1674-05c1-4a53-a89e-aec35309f062n%40googlegroups.com.

Monday, March 13, 2023

Re: Django Admin

In my previous case, I only use this:

CSRF_TRUSTED_ORIGINS = ['https://your site url',]


On Tue, 14 Mar 2023 at 04:33, Prosper Lekia <lekiaprosper@gmail.com> wrote:
This is how I deal with all csrf related issues.

Make sure csrf MiddleWare is in your MiddleWare list 

'django.middleware.csrf.CsrfViewMiddleware'

Add the settings below in your settings.py to prevent all csrf related issues

CSRF_TRUSTED_ORIGINS = ['https://your site url',]
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'http')
CSRF_USE_SESSIONS = False
CSRF_COOKIE_SECURE = True
SECURE_BROWSER_XSS_FILTER = True

CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_ALLOW_ALL = True


SECURE_CONTENT_TYPE_NOSNIFF = True
SECURE_FRAME_DENY = True
SECURE_HSTS_SECONDS = 2592000
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
SECURE_HSTS_PRELOAD = True
X_FRAME_OPTIONS = 'SAMEORIGIN'
SECURE_REFERRER_POLICY = 'same-origin

On Saturday, March 11, 2023 at 7:04:40 PM UTC+1 James Hunt wrote:
Hi there. I am fairly new to Django but have had previous success with creating an app and being able to access the Admin page.
Recently, if I attempt to access the admin page of a new Django app it throws the CSRF error upon trying to log in!!!

I have attempted several ways to bypass this error including adding allowed hosts but I cant seem to get past this issue.

Can someone please provide me with the definitive way of stopping CSRF error when simply trying to access the admin part of Django? I mean there are no post functions that really apply to this feature so I cant understand the CSRF token.

I cant get past this issue which means I can never access the admin page!!

Please help.

Regards

James

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3f7e8ff3-3619-4ddf-8517-0ee3a613ed20n%40googlegroups.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFKhtoSMJcDx5bDfd3bXUsdt5a1x%2BFBaX%3D7KYk5H8wbCHvQT%2Bw%40mail.gmail.com.

Re: Arbitrage bot

Why create your own crypto bot when there is a crypto arbitrage team cat who pay a percentage of the investment and protect your assets, that is, you are guaranteed to receive your money with interest.

воскресенье, 21 июня 2020 г. в 23:17:16 UTC+2, turing machine go brrr:

On Sun, Jun 21, 2020, 2:33 PM Wai Xian Wu wu <grim...@gmail.com> wrote:
Good afternoon, I was looking at the code, where did you get information from? I was searched on the internet and there is not much and those who know do not share

El El dom, 21 de jun. de 2020 a la(s) 12:15 p. m., nerdfiles <nerd...@gmail.com> escribió:
sure, i tried one https://github.com/nerdfiles/arby/blob/master/analyzer/arby.py

On Saturday, June 20, 2020 at 2:23:44 PM UTC-5 grim...@gmail.com wrote:
Hi guys, someone here has programmed a cryptocurrency arbitrage bot???

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/57951a8b-5dc0-4053-8e61-300e1c98a205n%40googlegroups.com.

--
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...@googlegroups.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/288e75fc-dee7-42d0-98c4-e36cbe853600n%40googlegroups.com.

Re: Django Admin



On Mar 13, 2023, at 5:14 AM, James Hunt <newbypassers@gmail.com> wrote:

I have yet to create a HTML page so I'm not sure that the inclusion of {% csrf_token %} is required. I mean it's just the admin page I am trying to access which is provided by Django and not a page created by me!!!

I am very surprised there is no fix for this issue!!! I might need to abandon Django and move a different framework given that this issue is at the start of a project!!!

There is clearly something else going on in your setup.

Here is a brand new Django project being created just now.

And the admin interface works without any issue.


Can you check if you missed any steps?

Thanks,
  Sandip

Re: Django Admin

ok hope i am not adding to the confusion

I ran into this a while back

CSRF errors are usually (in my case anyways) triggered by apache SSL
setup etc

if you are running Apache + SSL you need to make sure the certificates
and the SNI ssl naming is setup correctly or the CSRF errors will
trigger randomly.

of course the ssl cert has to match the site name

this config assumes APACHE + WSGI + SSL etc. and you are running
multiple virtual sites under apache.

Also note the port 80 redirect (ie everything is directed to the SSL site)

if you are mixing ssl & non-ssl apache / django will get confused and
trip the CSRF error as well.

relative apache config (httpd.conf):

<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin

SSLSessionCache memcache:localhost:11211 <<-- only if using memcache.
</IfModule>


then my apache config for a site ?

admin.scom.ca ?

<VirtualHost *:80>
ServerName admin.scom.ca
ServerAlias admin.scom.ca
Redirect permanent / https://admin.scom.ca/
</VirtualHost>

<VirtualHost *:443>
ServerName admin.scom.ca
ServerAlias admin.scom.ca
DocumentRoot /www/admin.scom.ca

Alias /media/ /www/admin.scom.ca/media/
Alias /static/ /www/admin.scom.ca/statics/
Alias /statics/ /www/admin.scom.ca/statics/

<Directory "/www/admin.scom.ca/statics/">
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>

SSLEngine on
SSLProtocol all
SSLCertificateFile /www/admin.scom.ca/ssl/admin.scom.ca.crt
SSLCertificateKeyFile /www/admin.scom.ca/ssl/admin.scom.ca.key
SSLCertificateChainFile /www/admin.scom.ca/ssl/admin.scom.ca.chain



SuexecUserGroup www www

##Below only used if running WSGI##

WSGIDaemonProcess adminscomcassl user=www group=www processes=10 threads=20
WSGIProcessGroup adminscomcassl
WSGIApplicationGroup %{GLOBAL}
WSGIImportScript /www/admin.scom.ca/django.wsgi
process-group=adminscomcassl application-group=%{GLOBAL}

WSGIScriptAlias / /www/admin.scom.ca/django.wsgi

##End of WSGI##

<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>

<Directory "/www/admin.scom.ca/wp-content/uploads/">
<Files "*.php">
Order Deny,Allow
Deny from All
</Files>
</Directory>

<Directory /www/admin.scom.ca>
php_admin_value open_basedir /www/admin.scom.ca:/var/log/
</Directory>

<Directory /www/admin.scom.ca>
php_admin_value sys_temp_dir /www/admin.scom.ca/tmp/
</Directory>

<Directory /www/admin.scom.ca>
php_admin_value session.save_path /www/admin.scom.ca/tmp/
</Directory>

<Directory /www/admin.scom.ca>
php_admin_value soap.wsdl_cache_dir /www/admin.scom.ca/tmp/
</Directory>

<Directory /www/admin.scom.ca>
php_admin_value upload_tmp_dir /www/admin.scom.ca/tmp
</Directory>

<Directory "/www/admin.scom.ca">
AllowOverride All
php_value session.save_path "/www/admin.scom.ca/"
</Directory>

</VirtualHost>







Happy Monday !!!
Thanks - paul

Paul Kudla


Scom.ca Internet Services <http://www.scom.ca>
004-1009 Byron Street South
Whitby, Ontario - Canada
L1N 4S3

Toronto 416.642.7266
Main 1.866.411.7266
Fax 1.888.892.7266
Email paul@scom.ca

On 3/12/2023 5:44 AM, Muhammad Juwaini Abdul Rahman wrote:
> I think you need to add the following in settings.py:
>
> CSRF_TRUSTED_ORIGIN = ('<your_web_url>')
>
>
>
> On Sun, 12 Mar 2023 at 02:04, James Hunt <newbypassers@gmail.com
> <mailto:newbypassers@gmail.com>> wrote:
>
> Hi there. I am fairly new to Django but have had previous success
> with creating an app and being able to access the Admin page.
> Recently, if I attempt to access the admin page of a new Django app
> it throws the CSRF error upon trying to log in!!!
>
> I have attempted several ways to bypass this error including adding
> allowed hosts but I cant seem to get past this issue.
>
> Can someone please provide me with the definitive way of stopping
> CSRF error when simply trying to access the admin part of Django? I
> mean there are no post functions that really apply to this feature
> so I cant understand the CSRF token.
>
> I cant get past this issue which means I can never access the admin
> page!!
>
> Please help.
>
> Regards
>
> James
>
> --
> 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+unsubscribe@googlegroups.com
> <mailto:django-users+unsubscribe@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e13c7765-831e-45c5-b091-c8fcfbed19c5n%40googlegroups.com <https://groups.google.com/d/msgid/django-users/e13c7765-831e-45c5-b091-c8fcfbed19c5n%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> --
> 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+unsubscribe@googlegroups.com
> <mailto:django-users+unsubscribe@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAFKhtoRactd%2Bhg-3_m8d5MOKSYb0gp9J9m%2BjNM7naykJ8r3Kww%40mail.gmail.com <https://groups.google.com/d/msgid/django-users/CAFKhtoRactd%2Bhg-3_m8d5MOKSYb0gp9J9m%2BjNM7naykJ8r3Kww%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>
> --
> This message has been scanned for viruses and
> dangerous content by *MailScanner* <http://www.mailscanner.info/>, and is
> believed to be clean.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0f9a82dd-4d6e-9904-3e93-7cb190697ef6%40scom.ca.