Re: Project together

2023-11-26 Thread Jay Senkow
interested.Sent from my iPhoneOn Nov 26, 2023, at 2:46 PM, ekong, emmanuel  wrote:I am interestedPhone ( WhatsApp): +234-8071-505-514On Thu, 23 Nov 2023 at 7:13 PM, Youssef Bachraoui  wrote:Hi developer i search to make a group on WhatsApp to begin a project together anyone interested about that?



-- 
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/d5244e76-6bd3-4bde-bf31-a72720bee1acn%40googlegroups.com.



DisclaimerThis e-mail is intended solely for the named recipient. The information contained in this message is strictly confidential. If you are not the named recipient, you are hereby notified that any use, dissemination or reproduction of this document and or its content is prohibited and may be deemed unlawful.If you are not the named recipient of this e-mail, please notify the sender by a return e-mail and delete all copies of it from your computer and mail.Any views expressed in this e-mail are those of the individual sender, except where the sender specifically states them to be those of Landmark University, to whom no liability shall be attached whatsoever.Thank you



-- 
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/CAAP9wczbDL6n7qW5WARHwGsR8hbVgwV0K%3DdTGJoBqE3aQc4TWA%40mail.gmail.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+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ACC804A9-5EF3-4D3A-B11A-6AE171113174%40gmail.com.


Re: tech newbie

2022-09-26 Thread Jay Jay
Hello bro, I hope you’re doing well? I’m a Jerry, a newbie in software
development, I have basic knowledge in HTML, CSS, JavaScript and python and
I really need a mentor who can help me through, so I can be very skill at
it. I’ll love if you can be my mentor, I would really appreciate it. Thank
you.

On Mon, Sep 26, 2022 at 12:53 PM Abdulfarid Olakunle 
wrote:

> Hello fellow developers, I will be creating a WhatsApp group chat later in
> the day, So I will like my fellow Python Django Developers to join the
> group. It will be much easier to discuss there and I will sacrifice myself
> out for anyone who need my service.
>
> God bless you all
> Enjoy your day
> Biliaminu
>
> --
> 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/CA%2BccuR0goa8Mu9MqNLyZtCAJedHKpVZ6pFfrpXKFJdjaRrgttQ%40mail.gmail.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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK4FT-qJQ6G7vtF-d9ViCP-VR9%2BnFJRycERJzMvcENq01XDgog%40mail.gmail.com.


Sending emails to users

2022-05-17 Thread Dexterr Jay
Hello guys, hope you are doing well
I'm building an online multivendor marketplaces and i want customers to be
able to send email from a form to a vendor in a product details page, can
anyone please help me with this?
A link to a tutorial will be very helpful.
Thanks in advance.

-- 
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/CAC32MkirM%2By2DKx%3DpcSUoCRthmhGaY%3DzKMdobuxoKxoaHkvUZA%40mail.gmail.com.


Help please,

2022-05-06 Thread Dexterr Jay
How do I make my domain be like
https://my domain.herokuapp.com/mainapp/ when I open my Django app hosted
on heroku

-- 
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/CAC32MkgXb34CcinJ9gTx6MPUcO-beqoutw3%3DeUPK4PeGtyBb9g%40mail.gmail.com.


Help please, please help

2022-05-05 Thread Dexterr Jay
my main project urls.py file  has
urlpatterns = [
 path('mainapp/', include('mainapp.urls', namespace='mainap)),
]
and my app urls.py has the following path
path('', views.item_list, name='item_list'),

my allowed hosts in settings is
ALLOWED_HOSTS = ['.herokuapp.com']
i have already deployed the app in heroku, and but i'm getting a 404 page
not found error when i open the app in my browser
How do I set my Allowed Hosts to  point  to
https://mydomain.herokuapp/mainapp?

-- 
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/CAC32Mki%3DmD8B0yPwDMTVvmAmk6QXpshXQF3mTysOc%3D1vjnnPhw%40mail.gmail.com.


Re: runserver not working

2022-03-26 Thread Kevin Jay
Did you activate your virtual environment?

Sent from my iPhone

> On Mar 22, 2022, at 10:32 PM, 'Delvin Alexander' via Django users 
>  wrote:
> 
> i did that but the problem still remains :(
> 
>> On Tuesday, March 22, 2022 at 2:09:33 AM UTC-7 sebasti...@gmail.com wrote:
>> Hey,
>> 
>> I think yoz don't have installed django package. Please install it over pip 
>> install django
>> 
>> Regards
>> 
>> 'Delvin Alexander' via Django users  schrieb am 
>> Di., 22. März 2022, 06:07:
>>> would anyone know why my "manage.py runserver" is not working?
>>> 
>>> Every time i try running it on the command prompt, i get relocated to my 
>>> visual studio of manage.py file that states this:
>>> 
>>> #!/usr/bin/env python
>>> """Django's command-line utility for administrative tasks."""
>>> import os
>>> import sys
>>> 
>>> 
>>> def main():
>>> """Run administrative tasks."""
>>> os.environ.setdefault('DJANGO_SETTINGS_MODULE', 
>>> 'django_project.settings')
>>> try:
>>> from django.core.management import execute_from_command_line
>>> except ImportError as exc:
>>> raise ImportError(
>>> "Couldn't import Django. Are you sure it's installed and "
>>> "available on your PYTHONPATH environment variable? Did you "
>>> "forget to activate a virtual environment?"
>>> ) from exc
>>> execute_from_command_line(sys.argv)
>>> 
>>> 
>>> if __name__ == '__main__':
>>> main()
>>> 
>>> 
>>> A step in the right direction will be super helpful for me.
>>> 
>> 
>>> -- 
>>> 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/69291c68-61e7-4557-8175-7b705bcfcbb0n%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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/a60f5102-0638-4fae-9dec-e870e6c2c98fn%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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/934F4336-CA23-48AF-B83C-174AEAD0A1A5%40gmail.com.


Re: Help : Embedding pdf in Django detailview

2022-03-18 Thread Dexterr Jay
Thanks, I'll check it out

On Thu, Mar 17, 2022, 10:05 RANGA BHARATH JINKA 
wrote:

> Hi,
>
> Please try this.
>
>
> https://stackoverflow.com/questions/11779246/how-to-show-a-pdf-file-in-a-django-view
>
> On Thu, Mar 17, 2022 at 12:12 PM Dexterr Jay  wrote:
>
>> Hello guys, I'm developing a job board, and I want to display uploaded
>> files in job detailview without downloading the file.
>> When job seakers open a posted job I want the uploaded file from employer
>> to be rendered in web browser
>>
>> --
>> 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/CAC32Mkjj-frMgLdc0_MY1_sBrN_MxV0DLPb3gXAY8%3DZ4oL%2BnXQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAC32Mkjj-frMgLdc0_MY1_sBrN_MxV0DLPb3gXAY8%3DZ4oL%2BnXQ%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
>
>
> --
> Thanks and Regards
>
> J. Ranga Bharath
> cell: 9110334114
>
> --
> 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/CAK5m315HHYbmF-tX67SjZh5SoXvS7dscwJbUfTsddynoJr2zjg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAK5m315HHYbmF-tX67SjZh5SoXvS7dscwJbUfTsddynoJr2zjg%40mail.gmail.com?utm_medium=email_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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAC32MkhO1GyDjhOeHtQZ6FaN%2BfS7qhSd_o305yJrcFTUaqOT6A%40mail.gmail.com.


Help : Embedding pdf in Django detailview

2022-03-17 Thread Dexterr Jay
Hello guys, I'm developing a job board, and I want to display uploaded
files in job detailview without downloading the file.
When job seakers open a posted job I want the uploaded file from employer
to be rendered in web browser

-- 
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/CAC32Mkjj-frMgLdc0_MY1_sBrN_MxV0DLPb3gXAY8%3DZ4oL%2BnXQ%40mail.gmail.com.


Product comparison in Django e-commerce website

2022-01-20 Thread Dexterr Jay
Hello guys, can someone please help me to implement product comparison in
Django e-commerce website, perhaps some guideline or link to a tutorial
will be very helpful. Thanks

-- 
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/CAC32Mki8%2Bz164P%2Btc-hc1K_uy1BrsH9nrKZe_yMgGcK8mweSKA%40mail.gmail.com.


Image Outside Intro

2021-04-15 Thread Jay Grace
We're trying to place and image outside of the intro on the bottom left of 
the screen over the parallax image.  We could make a flowing image that 
stays on the bottom left but we would prefer a one time image on the first 
page/image only.

Any assistance would be greatly appreciated.

-- 
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/ae68c739-0a30-491f-a688-1e06ed26ecb1n%40googlegroups.com.


models design for student result system

2020-12-04 Thread Dexterr Jay
[image: image.png]
i need help with design of the above models for my student result system
project

-- 
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/CAC32Mkg%3DQu_Trk0C4idfPdu14uB88jadLPNAO5qAMh-0BvMyAA%40mail.gmail.com.


Re: Exception Type: TemplateSyntaxError at /login/ Exception Value: Invalid block tag on line 23: 'csrf_tocken', expected 'endblock'. Did you forget to register or load this tag?

2020-11-30 Thread jay goldymae lamsen

{% endblock %}
On Friday, November 27, 2020 at 8:16:43 PM UTC+9 zica...@gmail.com wrote:

> It is misspelled, the right is *csrf_token*
>
> Em quinta-feira, 26 de novembro de 2020 às 14:57:37 UTC-3, 
> dils...@gmail.com escreveu:
>
>> hi friends,
>>
>> please help me to  resolve this issue..
>>
>>
>> Environment:
>>
>>
>> Request Method: GET
>> Request URL: http://127.0.0.1:8000/login/
>>
>> Django Version: 3.1.3
>> Python Version: 3.9.0
>> Installed Applications:
>> ['django.contrib.admin',
>>  'django.contrib.auth',
>>  'django.contrib.contenttypes',
>>  'django.contrib.sessions',
>>  'django.contrib.messages',
>>  'django.contrib.staticfiles',
>>  'log']
>> Installed Middleware:
>> ['django.middleware.security.SecurityMiddleware',
>>  'django.contrib.sessions.middleware.SessionMiddleware',
>>  'django.middleware.common.CommonMiddleware',
>>  'django.middleware.csrf.CsrfViewMiddleware',
>>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>>  'django.contrib.messages.middleware.MessageMiddleware',
>>  'django.middleware.clickjacking.XFrameOptionsMiddleware']
>>
>>
>> Template error:
>> In template C:\django-projects\dp1\site1\log\templates\log\login.html, 
>> error at line 23
>>Invalid block tag on line 23: 'csrf_tocken', expected 'endblock'. Did 
>> you forget to register or load this tag?
>>13 :
>>14 :
>>15 :
>>16 : {% extends "log/base.html" %}
>>17 : {% block content %}
>>18 : Login page
>>19 : 
>>20 : 
>>21 : 
>>22 : 
>>23 :  {% csrf_tocken %} 
>>24 : 
>>25 : 
>>26 : >  placeholder="Enter Username" name="username">
>>27 : 
>>28 : 
>>29 : 
>>30 : 
>>31 : > class="form-control" placeholder="Enter Password" name="password">
>>32 : 
>>33 : 
>>
>>
>> Traceback (most recent call last):
>>   File 
>> "C:\django-projects\venv\lib\site-packages\django\template\base.py", line 
>> 470, in parse
>> compile_func = self.tags[command]
>>
>> During handling of the above exception ('csrf_tocken'), another exception 
>> occurred:
>>   File 
>> "C:\django-projects\venv\lib\site-packages\django\core\handlers\exception.py",
>>  
>> line 47, in inner
>> response = get_response(request)
>>   File 
>> "C:\django-projects\venv\lib\site-packages\django\core\handlers\base.py", 
>> line 179, in _get_response
>> response = wrapped_callback(request, *callback_args, 
>> **callback_kwargs)
>>   File "C:\django-projects\dp1\site1\log\views.py", line 20, in login_user
>> return render(request, 'log/login.html', {})
>>   File "C:\django-projects\venv\lib\site-packages\django\shortcuts.py", 
>> line 19, in render
>> content = loader.render_to_string(template_name, context, request, 
>> using=using)
>>   File 
>> "C:\django-projects\venv\lib\site-packages\django\template\loader.py", line 
>> 61, in render_to_string
>> template = get_template(template_name, using=using)
>>   File 
>> "C:\django-projects\venv\lib\site-packages\django\template\loader.py", line 
>> 15, in get_template
>> return engine.get_template(template_name)
>>   File 
>> "C:\django-projects\venv\lib\site-packages\django\template\backends\django.py",
>>  
>> line 34, in get_template
>> return Template(self.engine.get_template(template_name), self)
>>   File 
>> "C:\django-projects\venv\lib\site-packages\django\template\engine.py", line 
>> 143, in get_template
>> template, origin = self.find_template(template_name)
>>   File 
>> "C:\django-projects\venv\lib\site-packages\django\template\engine.py", line 
>> 125, in find_template
>> template = loader.get_template(name, skip=skip)
>>   File 
>> "C:\django-projects\venv\lib\site-packages\django\template\loaders\base.py", 
>> line 29, in get_template
>> return Template(
>>   File 
>> "C:\django-projects\venv\lib\site-packages\django\template\base.py", line 
>> 155, in __init__
>> self.nodelist = self.compile_nodelist()
>>   File 
>> "C:\django-projects\venv\lib\site-packages\django\template\base.py", line 
>> 193, in compile_nodelist
>> return parser.parse()
>>   File 
>> "C:\django-projects\venv\lib\site-packages\django\template\base.py", line 
>> 478, in parse
>> raise self.error(token, e)
>>   File 
>> "C:\django-projects\venv\lib\site-packages\django\template\base.py", line 
>> 476, in parse
>> compiled_result = compile_func(self, token)
>>   File 
>> "C:\django-projects\venv\lib\site-packages\django\template\loader_tags.py", 
>> line 270, in do_extends
>> nodelist = parser.parse()
>>   File 
>> "C:\django-projects\venv\lib\site-packages\django\template\base.py", line 
>> 478, in parse
>> raise self.error(token, e)
>>   File 
>> "C:\django-projects\venv\lib\site-packages\django\template\base.py", line 

Help me with the view please

2020-09-08 Thread Dexterr Jay


My Models
class Student(models.Model):
name = models.CharField(max_length=200, null=True, blank=True)
classroom = models.ForeignKey(‘Classroom’,
on_delete=models.DO_NOTHING,blank=True, null=True)
class Classroom(models.Model):
name = models.CharField(max_length=40,blank=True, null=True)

class Fee(models.Model):
student = models.ForeignKey(Student, on_delete=models.CASCADE, null=True,)
classroom = models.ForeignKey(Classroom, on_delete=models.CASCADE, 
null=True)
school_fees = models.FloatField(default=100)
paid_fees = models.FloatField(null=False)
remaining_fees = models.FloatField(blank=True)
completed = models.BooleanField(null=False, default=False)

views.py
def student(request, pk):
student = Student.objects.get(id=pk)
fees = student.fee_set.all().order_by('-publish_date') total_fees = 
student.fee_set.all().filter(student__id=pk) 
.aggregate(sum=Sum('paid_fees', flat=True)['sum'] 
fees_remaining = () 
return render(request, 'website/students.html', context)  

-- 
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/6c03e499-43b8-487f-851b-a7742bb89fb7n%40googlegroups.com.


Re: Static not working on unix while working on windows

2020-07-07 Thread Kevin Jay
You also need to close your quote.

On Tue, Jul 7, 2020 at 11:54 AM Kevin Jay  wrote:

> I’ve had the same issue in the past. I fixed it by removing
> *rel="stylesheet *
>
>
> On Mon, Jul 6, 2020 at 1:20 PM ashish goyal 
> wrote:
>
>> Hi All,
>>
>> I have created a django app on windows and have used bootstrap navbar n
>> other functions which are working good on windows.
>>
>> Same files I have imported on unix server then i am able to get all
>> details but getting issue with css and js files saying below error
>>
>> *Refused to apply style from  because its MIME type ('text/html') is
>> not a supported stylesheet MIME type, and strict MIME checking is enabled
>> angular*
>>
>> I am using below script in windows which is working in windows but not on
>> unix
>>
>> *{ % load static %}*
>> *> 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/D45C33B1-949B-4BBE-8338-8982F2A246BF%40gmail.com
>> <https://groups.google.com/d/msgid/django-users/D45C33B1-949B-4BBE-8338-8982F2A246BF%40gmail.com?utm_medium=email_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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEtabwesOTudueuyFYdyhj8vzKCMqCR24SmKKEnAaus5mXXBhw%40mail.gmail.com.


Re: Static not working on unix while working on windows

2020-07-07 Thread Kevin Jay
I’ve had the same issue in the past. I fixed it by removing
*rel="stylesheet *


On Mon, Jul 6, 2020 at 1:20 PM ashish goyal 
wrote:

> Hi All,
>
> I have created a django app on windows and have used bootstrap navbar n
> other functions which are working good on windows.
>
> Same files I have imported on unix server then i am able to get all
> details but getting issue with css and js files saying below error
>
> *Refused to apply style from  because its MIME type ('text/html') is
> not a supported stylesheet MIME type, and strict MIME checking is enabled
> angular*
>
> I am using below script in windows which is working in windows but not on
> unix
>
> *{ % load static %}*
> * 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/D45C33B1-949B-4BBE-8338-8982F2A246BF%40gmail.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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEtabwcUaMsPwztfk-aep_t3cKjva-fSAtfYcX3wJDgA6NhwXg%40mail.gmail.com.


Need help in Django calculated field/queryset

2020-04-30 Thread Jay Prajapati
Hello everyone,

Still stucked on this pointHas anyone tried it?

-- 
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/f1f56856-a7cd-469a-896b-2427bd53b2ff%40googlegroups.com.


Need help in Django calculated field/queryset

2020-04-18 Thread Jay Prajapati
Hello Everyone,

I need a help from you. I'm learning Django and working on my own project but 
got stuck on a point. Your inputs will be highly appreciated.

Little background: I'm creating a web app like investment portfolio. I have 
created a model based form to input the stock transaction i.e. buy and sell.

class eq_txn(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE,)
investor_name = models.CharField(max_length=50)
deal_type = models.CharField(max_length=50)
deal_date = models.DateField()
scrip_name = models.CharField(max_length=50, blank=True)
quantity = models.FloatField(default=0)
price = models.FloatField(default=0)
isin = models.CharField(max_length=50, blank=True)
folio = models.CharField(max_length=50)

def deal_value(self):
  return self.quantity * self.price

I have created a calculated field to derived deal value. Now I'm trying to 
create Cost of Investment and Weighted Average Price (WAP) but no luck yet. 
Please help with this or any alternate workaround for same either by model or 
view. Below is the logic that I want to plot (also i have created the same in 
excel sheet):

Cost of Investment: This will be a cumulative running sum value where deal_type 
is equal to Buy needs to be add in accumulated running total value with similar 
calculation of deal_value and where deal_type is equal to Sell needs to be 
calulated as (WAP)*(quantity) then deduct from cumulative running total value.

WAP: This will be also cumulative running sum value as calulated when deal_type 
is equal to Buy then it should be Cost of Investment devided by Cumulative 
Quantity (May be additional field which can be derived by adding Buy quantity 
and sell quantity should be deducted in running total), When deal_value is Sell 
then it should use previous transaction's calculated WAP.

Here are the codes i have tried through queryset to derived by not worked 
exactly I wanted.

all_txn =eq_txn.objects.annotate(cumqty=Window(Sum(Case(When(deal_type='Buy', 
then='quantity'),
When(deal_type='Sell', then=F('quantity')*-1))), 
partition_by=[F('scheme_name'),], order_by=F('deal_date').asc()), 
cumamt=Window(Sum(Case(When(deal_type='Buy', 
then=F('price')*F('quantity', partition_by=[F('scheme_name'),], 
order_by=F('deal_date').asc()),
)\
 .all().order_by('deal_date').filter(user=request.user)
test = all_txn.annotate(wap=Case(When(deal_type='Buy', 
then=F('cumamt')/F('cumqty'))),
cumamtsale=Case(When(deal_type='Sell', then=(F('wap')*F('quantity')*-1)), 
default=Value('0')),
amt=F('cumamt')+F('cumamtsale')).values().filter(user=request.user)

Thank you !

-- 
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/ca50ba51-ff41-4150-b7a3-b6edbeea41b2%40googlegroups.com.


equity cases.xlsx
Description: MS-Excel 2007 spreadsheet


Need help in Django calculated field/queryset

2020-04-18 Thread Jay Prajapati
Hello All,

Hope you are doing well!

I need a help. I'm learning Django and working on my own project but got stuck 
on a point. Your inputs will be highly appreciated.

Little background: I'm creating a web app like investment portfolio. I have 
created a model based form to input the stock transaction i.e. buy and sell.

class eq_txn(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE,)
investor_name = models.CharField(max_length=50)
deal_type = models.CharField(max_length=50)
deal_date = models.DateField()
scrip_name = models.CharField(max_length=50, blank=True)
quantity = models.FloatField(default=0)
price = models.FloatField(default=0)
isin = models.CharField(max_length=50, blank=True)
folio = models.CharField(max_length=50)

def deal_value(self):
  return self.quantity * self.price
I have created a calculated field to derived deal value. Now I'm trying to 
create Cost of Investment and Weighted Average Price (WAP) but no luck yet. 
Please help with this or any alternate workaround for same either by model or 
view. Below is the logic that I want to plot:

Cost of Investment: This will be a cumulative running sum value where deal_type 
is equal to Buy needs to be add in accumulated running total value with similar 
calculation of deal_value and where deal_type is equal to Sell needs to be 
calulated as (WAP)*(quantity) then deduct from cumulative running total value.

WAP: This will be also cumulative running sum value as calulated when deal_type 
is equal to Buy then it should be Cost of Investment devided by Cumulative 
Quantity (May be additional field which can be derived by adding Buy quantity 
and sell quantity should be deducted in running total), When deal_value is Sell 
then it should use previous transaction's calculated WAP.

Here are the codes i have tried through queryset to derived by not worked 
exactly I wanted.

all_txn =eq_txn.objects.annotate(cumqty=Window(Sum(Case(When(deal_type='Buy', 
then='quantity'),
When(deal_type='Sell', then=F('quantity')*-1))), 
partition_by=[F('scheme_name'),], order_by=F('deal_date').asc()), 
cumamt=Window(Sum(Case(When(deal_type='Buy', 
then=F('price')*F('quantity', partition_by=[F('scheme_name'),], 
order_by=F('deal_date').asc()),
)\
  .all().order_by('deal_date').filter(user=request.user)
test = all_txn.annotate(wap=Case(When(deal_type='Buy', 
then=F('cumamt')/F('cumqty'))),
cumamtsale=Case(When(deal_type='Sell', then=(F('wap')*F('quantity')*-1)), 
default=Value('0')),
amt=F('cumamt')+F('cumamtsale')).values().filter(user=request.user)

Thank you !

-- 
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/e32e03b3-e477-4377-8171-351c6ed59fa7%40googlegroups.com.


Re: Populate script not working

2020-04-02 Thread jay sharma
Sir hi I am aman , look at following error message:
django.contrib.auth.models.DoesNotExist: User matching query does not
exist.


So on this my suggestion is

What you importing from django.contrib.auth.models
first check that needed query is present at above or not...

On Wed, Apr 1, 2020, 11:54 PM Jeff Waters  wrote:

> I've created a population script to test my website - please see below -
> but I get the following error message:
> django.contrib.auth.models.DoesNotExist: User matching query does not exist.
>
> Given that I've created a hypothetical user, I'm not sure why this is?
>
> Any suggestions would much appreciated.
>
> Thank you.
>
> Jeff
>
> EDIT : I have done both makemigrations and migrate.
>
> import os
> import django
>
> os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mynowandthen.settings')
> django.setup()
>
> from django.contrib.auth.models import User
> from nowandthen.models import Picture, Comment, UserProfile
>
> def populate():
> banana_user = [{'username': 'Banana','email': 'ban...@cat.com',
> 'password': 'Banana1234'},]
> johann_user = [{'username': 'Banana', 'email': 'ban...@cat.com',
> 'password': 'Banana1234'},]
> wmffre_user = [{'username': 'Wmffre', 'email': 'wmf...@cat.com',
> 'password': 'Wmffre1234'},]
>
>
> maryhill_comments = [{'user': banana_user,
> 'body': 'wowo I love this photo - reminds me of when I used to
> live there!'},
> {'user': johann_user,'body': 'I love Maryhill - its such a pretty
> part of Glasgow lol'},
> {'user': wmffre_user,'body': 'gonnae no dae that lol', 'user_id':
> 3}]
>
> fireworks_comments = [{'user': banana_user,'body': 'amazing fireworks
> - thanks for sharing :)'},
> {'user': johann_user,'body': 'love fireworks, love this, love
> YOU!'},
> {'user': wmffre_user,'body': 'whoop!'}]
>
> cityscape_comments = [{'user': banana_user,'body': 'more pics like
> this one please!!'},
> {'user': johann_user,'body': 'what a sucky picture hahah'},
> {'user': wmffre_user,'body': 'great - love it!'}]
>
> pics = {'Maryhill': {'comments': maryhill_comments,
>  'image':
> 'shared_pics/View-from-kitchen-window-of-Maryhill-tenements.1970.jpg',
>  'title': 'Maryhill Laundry',
>  'description': 'back view',
>  'tag_one': 'Maryhill',
>  'tag_two': 'Laundry',
>  'era': '1970s',
>  'likes': 64},
> 'Fireworks': {'comments': fireworks_comments,
>   'image': 'shared_pics/fireworks.jpg',
>   'title': 'Glasgow Fireworks',
>   'description': 'Fireworks at Glasgow Green',
>   'tag_one': 'Glasgow',
>   'tag_two': 'Fireworks',
>   'era': '2010s',
>   'likes': 32},
> 'Cityscape': {'comments': cityscape_comments,
>   'image': 'shared_pics/glasgow_cityscape_copy.jpg',
>   'title': 'Glasgow Cityscape',
>   'descrpition': 'View over Glasgow',
>   'tag_one': 'Cityscape',
>   'tag_two': 'Glasgow',
>   'era': '1990s',
>   'likes': 16}}
>
> for pic, pic_data in pics.items():
> p = add_picture(pic,
> pic_data['image'],
> pic_data['title'],
> pic_data['description'],
> pic_data['tag_one'],
> pic_data['tag_two'],
> pic_data['era'])
> for c in pic_data['comments']:
> add_comment(c[0], c[1])
>
> for p in Picture.objects.all():
> for c in Comment.objects.filter(picture=p):
> print(f' - {p}: {c}')
>
>
> def add_user(name, email, password):
> u = User.objects.get_or_create(username=name, first_name='Test',
> last_name='User', email=email)[0]
> u.set_password(password)
> up = UserProfile.objects.get_or_create(user=u)[0]
> u.save()
> return up
>
>
> def add_picture(image, title, description, tag_one, tag_two, era, likes=0):
> p = Picture.objects.get_or_create(image=image, title=title)[0]
> p.description = description
> p.tag_one = tag_one
> p.tag_two = tag_two
> p.era = era
> p.like = likes
> p.save()
> return p
>
>
> def add_comment(user, body):
> u = User.objects.get(username=user)
> up = UserProfile.objects.get(user=u)
> c = Comment.objects.get_or_create(user=up, body=body)[0]
> c.save()
> return c
>
>
> if __name__ == '__main__':
> print('Starting Now And Then population script...')
> populate()
>
> --
> 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 

Best way to organize custom admin views?

2019-11-22 Thread Jay
What's the best way (or the standard way, or your preferred way) to 
organize custom admin views? Assuming we want to leave the built-in Django 
Admin in place and create entirely new admin views, would the optimal 
organization be:

*A new app?*
blogapp/
  views.py
  viewsets.py
  models.py
shoppingapp/
  views.py
  viewsets.py
  models.py
adminapp/
  views.py
  viewsets.py
  models.py


*Directories within each app?*
blogapp/
  admin/
views.py
viewsets.py
models.py
shoppingapp/
  admin/
views.py
viewsets.py
models.py


*A flat structure?*
blogapp/
  admin_views.py
  admin_viewsets.py
  admin_models.py
  views.py
  viewsets.py
  models.py
shoppingapp/
  admin_views.py
  admin_viewsets.py
  admin_models.py
  views.py
  viewsets.py
  models.py


*Something else altogether?*


> *It’s usually not worth it to heavily customize the Django admin. 
> Sometimes, creating a simple view or form from scratch results in the same 
> desired functionality with a lot less work. We’ve always had better results 
> with creating custom management dashboards for client projects than we have 
> with modifying the admin to fit the need of the client.”Excerpt From: 
> Daniel Roy Greenfeld. “Two Scoops of Django 1.11.”*



-- 
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/f279689c-53ad-4cca-b644-243fddeabe67%40googlegroups.com.


Re: Fedora 30 server (Configuring Postgresql with Django)

2019-10-29 Thread Kevin Jay
I meant to type ‘harish.b’

On Tue, Oct 29, 2019 at 11:37 PM Kevin Jay  wrote:

> Does the user ‘garish.b’ have a system password?
>
> On Tue, Oct 29, 2019 at 10:38 PM hari49pf  wrote:
>
>> Hi sir,
>> I didn't understood, can u elaborate, I am new to django, Plz, help me
>> out.
>>
>> regards.
>> Harish.Bheemanpaly
>>
>> On Wednesday, October 30, 2019 at 1:21:50 AM UTC+5:30, sacrac wrote:
>>>
>>> Hi i see one error
>>> USERS is incorrect
>>> see the doc
>>> https://docs.djangoproject.com/en/2.2/ref/databases/#id12
>>>
>>> On Mon, Oct 28, 2019 at 11:15 PM Harish Bheemanpally 
>>> wrote:
>>>
>>
>>>> Hi,
>>>>
>>>> Please find the attachment, below are the screen shots of the setting &
>>>> DB permissions please help me
>>>>
>>>>
>>>> [image: Screenshot from 2019-10-29 10-40-47.png]
>>>>
>>>>
>>>> [image: Screenshot from 2019-10-29 10-40-40.png]
>>>>
>>>>
>>>> On Monday, October 28, 2019 at 7:57:47 PM UTC+5:30, sacrac wrote:
>>>>>
>>>>> You can show the settings and permissions of the DB, because the user
>>>>> harish.b and harishb are different!
>>>>>
>>>>> On Mon, Oct 28, 2019 at 5:00 AM Motaz Hejaze 
>>>>> wrote:
>>>>>
>>>>>> did you install all required packages for postgresql ?
>>>>>>
>>>>>>
>>>>>> On Mon, Oct 28, 2019 at 12:55 PM Harish Bheemanpally <
>>>>>> hari...@gmail.com> wrote:
>>>>>>
>>>>>>> Yes it was running perfectly in sqllie & Mysql. But in postgresql i
>>>>>>> am unable to configure Djanog
>>>>>>> the postger server screen shot
>>>>>>>
>>>>>>> please let me know for any information requried
>>>>>>>
>>>>>>>
>>>>>>> Postgresql image with djanog
>>>>>>>
>>>>>>> [image: Screenshot from 2019-10-28 10-28-38.png]
>>>>>>>
>>>>>>>
>>>>>>> On Monday, October 28, 2019 at 2:12:08 PM UTC+5:30, Motaz Hejaze
>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Does it run on sqlite ??
>>>>>>>> You need to show the code
>>>>>>>>
>>>>>>>> On Mon, 28 Oct 2019, 8:10 am Harish Bheemanpally, <
>>>>>>>> hari...@gmail.com> wrote:
>>>>>>>>
>>>>>>>>> There is not user with harish in *DB*(postgresql)
>>>>>>>>>
>>>>>>>>> [image: Screenshot from 2019-10-28 16-20-04.png]
>>>>>>>>> the harish is the user of *OS*.
>>>>>>>>>
>>>>>>>>> As suggested by sacrac:
>>>>>>>>>
>>>>>>>>> I have created a new user in DB with the name harishb who is the
>>>>>>>>> owner of the DB and changed the setting.py still raising same error
>>>>>>>>> when i am trying to run migrate or run the django
>>>>>>>>>
>>>>>>>>> PLZ Help me.
>>>>>>>>>
>>>>>>>>> On Monday, October 28, 2019 at 9:04:03 AM UTC+5:30, sacrac wrote:
>>>>>>>>>>
>>>>>>>>>> Hi, Maybe you need change permission role user harish
>>>>>>>>>> #ALTER ROLE harish CREATEROLE CREATEDB; or SUPERUSER;
>>>>>>>>>>
>>>>>>>>>> On Sun, Oct 27, 2019 at 11:58 AM Harish Bheemanpally <
>>>>>>>>>> hari...@gmail.com> wrote:
>>>>>>>>>>
>>>>>>>>>>> OS: Fedora30 server X64
>>>>>>>>>>> DB: Postgesql-12
>>>>>>>>>>> Django version:2.2.5
>>>>>>>>>>> connector: psycopg2.binary
>>>>>>>>>>>
>>>>>>>>>>> [image: Screenshot from 2019-10-27 13-20-35.png]
>>>>>>>>>>>
>>>>>>>>>>> i have configured the settings file in django folder, but unable
>>>>>>>>>>> to resolve t

Re: Fedora 30 server (Configuring Postgresql with Django)

2019-10-29 Thread Kevin Jay
Does the user ‘garish.b’ have a system password?

On Tue, Oct 29, 2019 at 10:38 PM hari49pf  wrote:

> Hi sir,
> I didn't understood, can u elaborate, I am new to django, Plz, help me out.
>
> regards.
> Harish.Bheemanpaly
>
> On Wednesday, October 30, 2019 at 1:21:50 AM UTC+5:30, sacrac wrote:
>>
>> Hi i see one error
>> USERS is incorrect
>> see the doc
>> https://docs.djangoproject.com/en/2.2/ref/databases/#id12
>>
>> On Mon, Oct 28, 2019 at 11:15 PM Harish Bheemanpally 
>> wrote:
>>
>
>>> Hi,
>>>
>>> Please find the attachment, below are the screen shots of the setting &
>>> DB permissions please help me
>>>
>>>
>>> [image: Screenshot from 2019-10-29 10-40-47.png]
>>>
>>>
>>> [image: Screenshot from 2019-10-29 10-40-40.png]
>>>
>>>
>>> On Monday, October 28, 2019 at 7:57:47 PM UTC+5:30, sacrac wrote:

 You can show the settings and permissions of the DB, because the user
 harish.b and harishb are different!

 On Mon, Oct 28, 2019 at 5:00 AM Motaz Hejaze  wrote:

> did you install all required packages for postgresql ?
>
>
> On Mon, Oct 28, 2019 at 12:55 PM Harish Bheemanpally <
> hari...@gmail.com> wrote:
>
>> Yes it was running perfectly in sqllie & Mysql. But in postgresql i
>> am unable to configure Djanog
>> the postger server screen shot
>>
>> please let me know for any information requried
>>
>>
>> Postgresql image with djanog
>>
>> [image: Screenshot from 2019-10-28 10-28-38.png]
>>
>>
>> On Monday, October 28, 2019 at 2:12:08 PM UTC+5:30, Motaz Hejaze
>> wrote:
>>>
>>> Does it run on sqlite ??
>>> You need to show the code
>>>
>>> On Mon, 28 Oct 2019, 8:10 am Harish Bheemanpally, 
>>> wrote:
>>>
 There is not user with harish in *DB*(postgresql)

 [image: Screenshot from 2019-10-28 16-20-04.png]
 the harish is the user of *OS*.

 As suggested by sacrac:

 I have created a new user in DB with the name harishb who is the
 owner of the DB and changed the setting.py still raising same error
 when i am trying to run migrate or run the django

 PLZ Help me.

 On Monday, October 28, 2019 at 9:04:03 AM UTC+5:30, sacrac wrote:
>
> Hi, Maybe you need change permission role user harish
> #ALTER ROLE harish CREATEROLE CREATEDB; or SUPERUSER;
>
> On Sun, Oct 27, 2019 at 11:58 AM Harish Bheemanpally <
> hari...@gmail.com> wrote:
>
>> OS: Fedora30 server X64
>> DB: Postgesql-12
>> Django version:2.2.5
>> connector: psycopg2.binary
>>
>> [image: Screenshot from 2019-10-27 13-20-35.png]
>>
>> i have configured the settings file in django folder, but unable
>> to resolve the issue,
>> need help.
>>
>> --
>> 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...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/d1eebb46-834f-4ee6-be50-7882ca72cbfd%40googlegroups.com
>> 
>> .
>>
>
>
> --
> att.
> Carlos Rocha
>
 --
 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...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/3217ae2e-d0c7-4b6f-a06d-b1504ba29aa2%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...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/129de4f3-1957-4a5f-9a25-e65d29dbfdfa%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...@googlegroups.com.

Re: Python +django

2019-09-13 Thread Kevin Jay
I also prefer text over video. However, Corey Schafer has an excellent
video series that is really well done. He doesn’t waste time babbling or
stumbling over words. He also provides a link to his github repo so you can
let ok over the code.


On Tue, Sep 10, 2019 at 8:19 PM 'Nicholas Hatch' via Django users <
django-users@googlegroups.com> wrote:

> If you are looking for books, any of the O’Reilly books are good. A
> worthwhile investment is an O’Reilly online subscription, which gives you
> access to all their books plus video tutorials, so you get the best of both
> worlds.
>
> For the price of three or four of their technical books, you get their
> full library, and if you really get into this, you’ll need to dive into
> many other topics anyway.
>
>
>
> Nicholas Hatch
>
>
> On Tue, Sep 10, 2019 at 1:03 PM, Gerardo Palazuelos Guerrero <
> gerardo.palazue...@gmail.com> wrote:
>
> hi,
> Django has been a different beast for me, an .NET programmer...
> You need to find your way...
>
> Following are my go-to resources, always:
> #1: (free) Djangogirls tutorial
> #2: (paid) the books by https://wsvincent.com/books/-- specially that
> book (green one) is an excellent resource for beginners
> #3: (free to read online) Harry Percival's
> https://www.obeythetestinggoat.com/
>
> Note:
> I'm not affiliated or anything with those sites... it's just that those
> materials are helpful for me and I keep mentioning those to folks
>
> --
> Gerardo Palazuelos Guerrero
>
>
>
> On Tue, Sep 10, 2019 at 7:25 AM Mario R. Osorio 
> wrote:
>
>> I must agree that video tutorials are harder to follow, specially if and
>> when they are if at least a bit outdated. I used to hate them however; I've
>> learned to appreciate them specially because of one reason: *YOU CANNOT
>> COPY AND PASTE.*
>>
>> Written tutorials don't help you go thru the full learning process and
>> make you a master of [Ctrl]-[C] & [Ctrl]-[V] since you're not even checking
>> the code nor make sense out of it, let alone memorizing it.
>>
>> Back in the day, when written tutorials were handed to you on paper,
>> probably as photocopy of some else's photocopy (bis), you would learn by
>> typing the code yourself. It is online tutorials that I find not as helpful
>> anymore.
>>
>> Now, don't get me wrong, I have found lost of excellent online tutorials.
>> The problem is that it is all too easy to copy and paste.
>>
>> IMHO (and at least in programming) written tutorials are for the very
>> first baby steps but once you've outpaced those; you need to move away from
>> them, even if we are talking about learning a new programming language,
>> tool, framework or paradigm.
>>
>>
>>
>> On Monday, September 9, 2019 at 7:59:07 AM UTC-4, ajoeiam wrote:
>>>
>>> On Mon, Sep 9, 2019 at 6:33 AM selim atmaca  wrote:
>>> >
>>> > You should learn python basics first but dont dive deep, just the
>>> basics. Then
>>> > There is a nice django video series on youtube. Search for corey
>>> schafer django. There are 17 videos in that series. If I was starting
>>> django today, definetly I would start it with that video series.
>>> >
>>> Hopefully this isn't a thread hijacking - - - - but - - - - -
>>> I am finding that online videos are hugely wasteful of time and would
>>> rather have a text equivalent.
>>> Is there such for this recommended video series?
>>>
>>> Regards
>>>
>> --
>> 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/65360234-aaa6-4365-9e8e-fc6d8a3bc5f2%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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAJ8iCyO7XsMj0JPd8Rj8-PXghPOaxoPnjNELr6e8J73wgvLCpA%40mail.gmail.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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/P4PC8nOmfEd1JqWoqYlzVXO9qMS5Pne1LA1-wTlKy2cwoSlhD8wB28FIFg_bMwUkGVE249jJTynj_PBTqsxWaSudRTlG3FlDth8j-JCnfqE%3D%40thehatchcloud.org
> 

Re: ForeignKey value while querying the model object

2019-09-05 Thread Jay Vasant
Please reply with your models schema.

On Thu, Sep 5, 2019 at 7:56 AM dev  wrote:

> Hi All,
>
> How to get the ForeignKey value while querying the model object.
>
>
>
> I was trying to query a model object "mla" to fetch a specific sets of 
> columns and its working fine but the field ForeignKey i.e "instuid" returning 
> a numeric value instant of actual associated value.
>
>
>
> Do I need to edit the query
>
>
>
>
>
> *def mlas_datasets(request): mlaAll = 
> list(mla.objects.values('mla_name_short','mla_name_full','inst_acronym','mla_type','year_adopted','instuid','mla_uid'))
>  mlaAll = JsonResponse(mlaAll,safe=False) return 
> HttpResponse(mlaAll,content_type='json')*
>
>
> Regards
>
> Deb
>
> --
> 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/2ca903ba-5105-4983-a1bd-f36c17078f27%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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BG34NA04O_AQDktYE4_ORa2Je_OOPjAv_NuwJh2Ptm6%2BAsUOQ%40mail.gmail.com.


Re: How can i share one Database Sqlite between 2 app on pythonanywhere

2019-09-04 Thread Jay Vasant
It isn't possible to share a local db between two apps.

Here are the alternatives you can use:

   - Create api's for all the operations you want to perform.
   - Use an hosted db service(e.g. Postgres on heroku).


On Wed, Sep 4, 2019 at 10:39 AM Balaji Shetty 
wrote:

> Hi Everyone
>
> Can anybody suggest me
> How can i share one Database Sqlite between 2 app on pythonanywhere.
>
> Currently i have deployed one project on PythonAnywhere.
> I have purchases 2 App.
> Now i can execute 2 App simultaneous.
>
> I have deployed app1.pythonanywhere.com and app2.pythonanywhere.com
>
> app1.pythonanywhere.com is my real time hosted project. Before making any
> changes, i create mirror copy of code and Database Sqlite on
> app2.pythonanywhere.com, make changes and if changes are proper. I make
> changes in
> app1.pythonanywhere.com.
>
> But it is time consuming Process. Better solution may be share database
> and make changes in Business Logic and reflect in orignal one.
>
> My Simple Question is
> How can i share sqlite database between two Project here.
>
> OR
>
> Is there any other way to do the same thing more efficiently?
>
> Thanks in Advance.
> --
>
>
> *Mr. Shetty Balaji S.Asst. ProfessorDepartment of Information Technology,*
> *SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India*
> *Official: bsshe...@sggs.ac.in  *
> *  Mobile: +91-9270696267*
>
> --
> 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/CAECSbOv7vBQ8hxZBoPf2PvVgUY2NS-44-yvLuprbphdvN1ZJYw%40mail.gmail.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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BG34NBKyjK5WHkhqBS9f0JADeXU5mwu129MK_UHGF8pfXry2g%40mail.gmail.com.


Re: Write urls without regex in DRF

2019-05-22 Thread Kevin Jay
kevin@kjay,net

On Wed, May 22, 2019 at 10:19 AM Rounak Jain  wrote:

>
> I am using DRF Viewsets to auto-generate URLs for different views. Is it
> possible to write the code below without using regex?
> Thanks
>
> from .views import TaskViewSet
> from rest_framework.routers import DefaultRouter
>
> router = DefaultRouter()
> router.register(r'', TaskViewSet, basename='task')
> urlpatterns = router.urls
>
>
>
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CANNuxWNoPGePbAcxnWqzMgeioYXKXwD1Yn-H_2-FN774MdsbbQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEtabwdw6%2BZofc4dLdHbvMM9nzdMc0Yd_uCqUnFNWAHE2wn9ug%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django wsgi apache Deploy project

2019-05-07 Thread Kevin Jay
Remove the spaces in the paths:
WSGIPythonPath / var / www / html / ecommerce /
should be
WSGIPythonPath  /var/www/html/ecommerce/

Do the same for the other paths

On Tue, May 7, 2019 at 8:57 AM N'BE SORO  wrote:

>
> Hi I'm a beginner in python and I realized a project in Django. I have
> problems in hosting my project. here is my code in the 000-default.conf
>  #ServerName #ServerAlias ServerAdmin webmaster @
> localhost DocumentRoot / var / www / html / ecommerce WSGIScriptAlias ​​/
> /var/www/html/ecommerce/ecommerce/wsgi.py WSGIPythonPath / var / www / html
> / ecommerce / ErrorLog $ {APACHE_LOG_DIR} /error.log CustomLog $
> {APACHE_LOG_DIR} /access.log combined  and I have this error
> Invalid command 'WSGIScriptAlias / /var / www / html / ecommerce /
> ecommerce / wsgi.py ', perhaps misspelled or d efined by a module not
> included in the server configuration
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1912bcdc-cb2f-45a2-932c-d579eb944c0a%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEtabwdEQtikBmkrpvpFLJ0oHY%3DfWJhSm5VLGBU7yxwYWq_b2w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ORM help with INNER JOIN and GROUP BY

2019-05-06 Thread Kevin Jay
You are correct.
Django creates a primary key of 'id' for each table as an integer by
default. So foreignkey will reference that primary key which by default is
an integer.
If the primary key is changed to some other type, Django can still handle
it.
Apparently using integers is the more efficient method.

On Mon, May 6, 2019 at 12:54 PM Matthew Pava  wrote:

> Well, I had always assumed that they do need to be integers, but it looks
> like this has been discussed at length.
>
> https://groups.google.com/forum/#!topic/django-users/0utRzn98Wxo
>
>
>
> It does seem clear, though, that the superior database design uses
> integers for ForeignKeys.
>
> And I didn’t find a way to make it clear to Django not to use an Integer
> ForeignKey.  Maybe something to do with the primary_key attribute on a
> CharField?
>
>
>
> *From:* django-users@googlegroups.com [mailto:
> django-users@googlegroups.com] *On Behalf Of *b...@tanners.org
> *Sent:* Monday, May 6, 2019 12:44 PM
> *To:* Django users
> *Subject:* Re: ORM help with INNER JOIN and GROUP BY
>
>
>
> Just want to make sure I understand. ForeighKeys need to be integers?
>
>
>
> Only integers?
>
>
>
>
>
> You need a ForeignKey relationship between the two models, which is an
> integer value, not a char. You’d have to do migrations to get this adjusted
> properly.
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/9697de34-3d20-4023-81a7-8ea9f257f7f1%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/27eee43ff8024c98bcf9a5e9cd4bfd89%40iss2.ISS.LOCAL
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEtabwdPi16kCzZAx6btpyRFGVn0JyaXGjL%2Bw8JTj2u6pHZxBg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ORM help with INNER JOIN and GROUP BY

2019-05-06 Thread Kevin Jay
 Maybe that was a typo?
The foreignkey relationship would look like this:
object = models.ForeignKey(FacePng'', max_length=128, blank=False,
null=False, unique=True)

On Mon, May 6, 2019 at 12:44 PM  wrote:

> Just want to make sure I understand. ForeighKeys need to be integers?
>
> Only integers?
>
>
> You need a ForeignKey relationship between the two models, which is an
>> integer value, not a char. You’d have to do migrations to get this adjusted
>> properly.
>>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/9697de34-3d20-4023-81a7-8ea9f257f7f1%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEtabwfknJFSeHiYLcLdQ6-0soywHaHwsPz8SLm_T24tbT0Hpg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ORM help with INNER JOIN and GROUP BY

2019-05-06 Thread Kevin Jay
The field within your class should be set to ForeignKey.


Try this:
Object = models.ForeignKey(‘FacePng’, on_delete=SET_NULL, max_length= some_int)

on_delete and max_length need to be set based on your requirements 

Sent from my iPhone

> On May 6, 2019, at 11:28 AM, b...@tanners.org wrote:
> 
> I've inherited an application written django 1.11. The old application uses 
> raw() with INNER JOIN and GROUP BY. 
>  I cannot seem to figure out how to do inner join and group by properly the 
> ORM way.
> 
> The raw() query is below.
> 
> SELECT  * FROM items_monolithic
> INNER JOIN items_facepng
> ON items_monolithic.object == items_facepng.obj
> GROUP BY items_monolithic.object
> ORDER BY object ASC
> 
> 
> Things kind of work with raw() but that doesn't feel right. And I get nasty 
> warnings about RawQuerySet not supporting certain things when I try to use 
> the query set that is returned.
> 
> From what I understand every monolithic object has 1 or more faces 
> (graphic/picture).
> 
> I would call the monolithic a one-to-many relationship with facepng but I see 
> django calls this a ForeignKey.
> 
> I'm working with these models (yes, a field named object is "bad", it's what 
> I was given)
> 
> 
> class Monolithic(models.Model):
> object = models.CharField(max_length=128, blank=False, null=False, 
> unique=True)
> 
> class FacePng(models.Model):
> obj = models.CharField(max_length=128, blank=True, null=True)
> 
> 
> I do not see the ForeignKey relationship between Monolithic and FacePng. 
> 
> Changing Monolithic class to models.ForeignKey() breaks lots of things.
> 
> So I'd prefer to figure out how to do the inner join and group by query but 
> if that's not the django way and I need to change Monolithic.objects to a 
> ForeignKey() and fix all the stuff that is broken I can do that that too. 
> 
> Just need some guidance on how to proceed.
> 
> 
> 
> -- 
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/ab7ecf5b-9ae8-4428-9502-6b7d5dec03b5%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/D5B5695B-D057-4D4D-8F53-2BAF1D6B666A%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: BaseModelFormSet > _construct_form

2019-04-02 Thread Kevin Jay
ke...@kjay.net

On Tue, Apr 2, 2019 at 4:12 PM nikolaysm  wrote:

> Hello,
>
> In function _construct_form variable "pk_key" is generated as:
>  pk_key = "%s-%s" % (self.add_prefix (i), self.model._meta.pk.name) "
>
> So pk_key is not flexible. Because if I overwrite function "add_prefix"
> from class "forms.ModelForm", I get error "MultiValueDictKeyError".
>
> My add_prefix function:
> def add_prefix(self, field_name):
>   return '%s_%s' % (self.prefix, field_name) if self.prefix else
> field_name
>
>
> I see a possibility to solve that for now. Overwrite function
> _construct_form.
>
> Other options?
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/92616dd1-1e04-43f6-9e91-edfc56dfe5bc%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEtabwdvYoD4ypvo%3D3_14M%2BbvOHZoYTtAMNxfs0JcJfs-o1_dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using signals to populate another model based on new registered user

2019-03-10 Thread Kevin Jay
Disregard...Wrong thread.

On Sun, Mar 10, 2019 at 2:47 PM Kevin Jay  wrote:

>
> Here is the relevant template from the link provided
>
>>
>>1. 
>>2. 
>>3. 
>>4. 
>>5. Employee Records
>>6.  {% load staticfiles %}
>>7. 
>>8. 
>>9. 
>>10. 
>>11. 
>>12. 
>>13. Employee ID
>>14. Employee Name
>>15. Employee Email
>>16. Employee Contact
>>17. Actions
>>18. 
>>19. 
>>20. 
>>21. {% for employee in employees %}
>>22. 
>>23. {{ employee.eid }}
>>24. {{ employee.ename }}
>>25. {{ employee.eemail }}
>>26. {{ employee.econtact }}
>>27. 
>>28. >"glyphicon glyphicon-pencil" >Edit
>>29. Delete
>>30. 
>>31. 
>>32. {% endfor %}
>>33. 
>>34. 
>>35. 
>>36. 
>>37. >>Add New Record
>>38. 
>>39. 
>>
>>
>>>
> On Sun, Mar 10, 2019 at 10:06 AM Deepak sharma 
> wrote:
>
>> Simple Answer: DON'T . Resort to signals only when there is No
>> Alternatives left.
>> Using Signals looks tempting but as project grows, it really becomes a
>> Mess to manage each of them. One simply becomes a confused and debugging
>> becomes a real Hell.
>>
>> I suffered from this Problem. hence recommends to Use them as last
>> resort.
>>
>>
>>
>>
>> On Saturday, March 9, 2019 at 8:14:47 PM UTC+5:30, GavinB841 wrote:
>>>
>>> Hi all,
>>>
>>> I am new to working with signals and triggers, what I am trying to
>>> accomplish is:
>>>
>>>1. When a new user registers, I have another model to deal with
>>>subscriptions.
>>>2. I want to create an instance for that subscription model with all
>>>the default values based on the new user.
>>>3. Otherwise no object is created in this model and it has to be
>>>done via a form.
>>>
>>> Would appreciate any help and if any other code is needed let me know.
>>>
>>> *See code below:*
>>>
>>> *Form part of user registration:*
>>>
>>> class ClubInfoForm(forms.ModelForm):
>>> club_address2 = forms.CharField(required=False)
>>> club_address3 = forms.CharField(required=False)
>>>
>>> class Meta():
>>> model = ClubInfo
>>> fields = ('club_name', 'club_logo', 'club_address1', 
>>> 'club_address2',
>>>   'club_address3', 'club_town', 'club_county', 
>>> 'club_country',)
>>>
>>> def clean_club_name(self):
>>> club_name = self.cleaned_data['club_name']
>>> if ClubInfo.objects.filter(club_name=club_name).exists():
>>> raise ValidationError(_("Club already exists"))
>>> return club_name
>>>
>>> *Views for registration:*
>>>
>>> def register(request):
>>> registered = False
>>> if request.method == 'POST':
>>> user_form = UserForm(data=request.POST)
>>> profile_form = ClubInfoForm(data=request.POST)
>>> if user_form.is_valid() and profile_form.is_valid():
>>> user = user_form.save()
>>> user.set_password(user.password)
>>> user.save()
>>> profile = profile_form.save(commit=False)
>>> profile.user = user
>>> if 'profile_pic' in request.FILES:
>>> print('found it')
>>> profile.profile_pic = request.FILES['profile_pic']
>>> profile.save()
>>> registered = True
>>> else:
>>> print(user_form.errors, profile_form.errors)
>>> else:
>>> user_form = UserForm()
>>> profile_form = ClubInfoForm()
>>> return render(request,
>>>   'registration.html',
>>>   {'user_form': user_form,
>>>'profile_form': profile_form,
>>>'registered': registered})
>>>
>>>
>>> *Models for club info used upon registration and the model I want to
>>> update when a

Re: Using signals to populate another model based on new registered user

2019-03-10 Thread Kevin Jay
Here is the relevant template from the link provided

>
>1. 
>2. 
>3. 
>4. 
>5. Employee Records
>6.  {% load staticfiles %}
>7. 
>8. 
>9. 
>10. 
>11. 
>12. 
>13. Employee ID
>14. Employee Name
>15. Employee Email
>16. Employee Contact
>17. Actions
>18. 
>19. 
>20. 
>21. {% for employee in employees %}
>22. 
>23. {{ employee.eid }}
>24. {{ employee.ename }}
>25. {{ employee.eemail }}
>26. {{ employee.econtact }}
>27. 
>28. "glyphicon glyphicon-pencil" >Edit
>29. Delete
>30. 
>31. 
>32. {% endfor %}
>33. 
>34. 
>35. 
>36. 
>37. >Add New Record
>38. 
>39. 
>
>
>>
On Sun, Mar 10, 2019 at 10:06 AM Deepak sharma  wrote:

> Simple Answer: DON'T . Resort to signals only when there is No
> Alternatives left.
> Using Signals looks tempting but as project grows, it really becomes a
> Mess to manage each of them. One simply becomes a confused and debugging
> becomes a real Hell.
>
> I suffered from this Problem. hence recommends to Use them as last resort.
>
>
>
>
> On Saturday, March 9, 2019 at 8:14:47 PM UTC+5:30, GavinB841 wrote:
>>
>> Hi all,
>>
>> I am new to working with signals and triggers, what I am trying to
>> accomplish is:
>>
>>1. When a new user registers, I have another model to deal with
>>subscriptions.
>>2. I want to create an instance for that subscription model with all
>>the default values based on the new user.
>>3. Otherwise no object is created in this model and it has to be done
>>via a form.
>>
>> Would appreciate any help and if any other code is needed let me know.
>>
>> *See code below:*
>>
>> *Form part of user registration:*
>>
>> class ClubInfoForm(forms.ModelForm):
>> club_address2 = forms.CharField(required=False)
>> club_address3 = forms.CharField(required=False)
>>
>> class Meta():
>> model = ClubInfo
>> fields = ('club_name', 'club_logo', 'club_address1', 'club_address2',
>>   'club_address3', 'club_town', 'club_county', 
>> 'club_country',)
>>
>> def clean_club_name(self):
>> club_name = self.cleaned_data['club_name']
>> if ClubInfo.objects.filter(club_name=club_name).exists():
>> raise ValidationError(_("Club already exists"))
>> return club_name
>>
>> *Views for registration:*
>>
>> def register(request):
>> registered = False
>> if request.method == 'POST':
>> user_form = UserForm(data=request.POST)
>> profile_form = ClubInfoForm(data=request.POST)
>> if user_form.is_valid() and profile_form.is_valid():
>> user = user_form.save()
>> user.set_password(user.password)
>> user.save()
>> profile = profile_form.save(commit=False)
>> profile.user = user
>> if 'profile_pic' in request.FILES:
>> print('found it')
>> profile.profile_pic = request.FILES['profile_pic']
>> profile.save()
>> registered = True
>> else:
>> print(user_form.errors, profile_form.errors)
>> else:
>> user_form = UserForm()
>> profile_form = ClubInfoForm()
>> return render(request,
>>   'registration.html',
>>   {'user_form': user_form,
>>'profile_form': profile_form,
>>'registered': registered})
>>
>>
>> *Models for club info used upon registration and the model I want to
>> update when a new user is created:*
>>
>> class ClubInfo(models.Model):
>>
>> user = models.OneToOneField(User, on_delete=models.CASCADE)
>> club_name = models.CharField(max_length=50, default='', unique=True)
>> club_logo = models.ImageField(upload_to='profile_pics', blank=True)
>> club_address1 = models.CharField(max_length=30)
>> club_address2 = models.CharField(max_length=30, default='')
>> club_address3 = models.CharField(max_length=30, default='')
>> club_town = models.CharField(max_length=30)
>> club_county = models.CharField(max_length=30)
>> club_country = models.CharField(max_length=30)
>> created_date = models.DateTimeField(default=timezone.now)
>>
>> def set_default_packages(sender, **kwargs):
>> if kwargs['created']:
>> ClubPackages.objects.create(club_id=kwargs['instance'])
>>
>> post_save.connect(set_default_packages, sender=club_name)
>>
>> def __str__(self):
>> return self.club_name
>>
>>
>> class ClubPackages(models.Model):
>>
>> club_id = models.ForeignKey(ClubInfo, on_delete=models.CASCADE)
>> PACKAGE_STATUS = (
>> ('0', 'Active'),
>> ('1', 'Not Active')
>> )
>> player_register_package = 

Re: Printing model fields organized by category

2018-08-27 Thread Jay
Thank you so much! That worked!!

On Monday, August 27, 2018 at 12:16:09 PM UTC-4, Matthew Pava wrote:
>
> Oh, yes.  I do it all the time myself.
>
>  
>
> You need to change
>
>  
>
> category.model_set
>
>  
>
> to
>
>  
>
> category.model_set.all
>
>  
>
> model_set is the manager.  You need to treat it like any other manager.
>
>  
>
> *From:* django...@googlegroups.com  [mailto:
> django...@googlegroups.com ] *On Behalf Of *Jay
> *Sent:* Monday, August 27, 2018 11:05 AM
> *To:* Django users
> *Subject:* Re: Printing model fields organized by category
>
>  
>
> Hmm, I'm getting an error:
>
>  
>
> [image: Screen Shot 2018-08-27 at 11.58.32 AM.png]
>
>  
>
>  
>
>  
>
>  
>
>  
>
>  
>
>  
>
> I've changed my urls.py to this:
>
>  
>
> from django.urls import path
>
> from . import views
>
>  
>
> urlpatterns = [
>
> path('', views.index, name='index'),
>
> path('books/', views.BookListView.as_view(), name='books'),
>
> path('book/', views.BookDetailView.as_view(), 
> name='book-detail'),
>
> path('category/', views.CategoryListView.as_view(), name='categories'),
>
>
> On Monday, August 27, 2018 at 11:33:14 AM UTC-4, Matthew Pava wrote:
>
> Okay, your URL should point to your CategoryListView.  That should have 
> category_list in its context.  And the template should in the category_list 
> template.
>
>  
>
> *From:* django...@googlegroups.com [mailto:django...@googlegroups.com] *On 
> Behalf Of *Jay
> *Sent:* Monday, August 27, 2018 10:28 AM
> *To:* Django users
> *Subject:* Re: Printing model fields organized by category
>
>  
>
> Thanks Matthew, here is my views.py file:
>
>  
>
>  
>
> from django.shortcuts import render #generates HTML fiels using a template 
> and data
>
> #from django.http import HttpResponse
>
> from .models import Book, Author, BookInstance, Genre, Model, 
> ModelInstance, Category, Ownership, Manufacturer, Location #imports model 
> classes to access data in views
>
> from django.views import generic
>
>  
>
> # Create your views here.
>
>  
>
> #def index(request):
>
> #return HttpResponse("Hey")
>
>  
>
> def index(request):
>
> """View function for home page of site."""
>
>  
>
> #Generate counts of some of the main objects
>
> num_books = Book.objects.all().count()
>
> num_instances = BookInstance.objects.all().count()
>
>  
>
> #Available books (status - 'a')
>
> num_instances_available = 
> BookInstance.objects.filter(status__exact='a').count()
>
>  
>
> #The 'all()' is implied by default.
>
> num_authors = Author.objects.count()
>
>  
>
> #Num visits to this view, as counted in the session variable
>
> num_visits = request.session.get('num_visits', 0)
>
> request.session['num_visits'] = num_visits + 1
>
>  
>
>  
>
> context = {
>
> 'num_books': num_books,
>
> 'num_instances': num_instances,
>
> 'num_instances_available': num_instances_available,
>
> 'num_authors': num_authors,
>
> 'num_visits': num_visits,
>
> }
>
>  
>
> #Render the HTML template index.html with the data in the context 
> variable
>
> return render(request, 'index.html', context=context)
>
>  
>
> class BookListView(generic.ListView):
>
> model = Book
>
>  
>
> class BookDetailView(generic.DetailView):
>
> model = Book
>
>  
>
> class ModelListView(generic.ListView):
>
> model = Model
>
>  
>
> class ModelDetailView(generic.DetailView):
>
> model = Model
>
>  
>
> class CategoryListView(generic.ListView):
>
> model = Category
>
>  
>
> class CategoryDetailView(generic.DetailView):
>
> model = Category
>
>  
>
> from django.contrib.auth.mixins import LoginRequiredMixin
>
>  
>
> class LoanedBooksByUserListView(LoginRequiredMixin,generic.ListView):
>
> """Generic class-based view listing books on loan to current user."""
>
> model = BookInstance
>
> template_name ='catalog/bookinstance_list_borrowed_user.html'
>
> paginate_by = 10
>
>  
>
> def get_queryset(self):
>
> return 
> BookInstance.objects.filter(borrower=self.request.user).filter(status__exact='o').order_by('due_back')
>
>  
>
>
> On Monday, August 27, 2018 at 11:00:57 AM UTC-4, Matt

Re: Printing model fields organized by category

2018-08-27 Thread Jay
Error received:  

path('category/', views.CategoryListview.as_view(), name='categories'),

AttributeError: module 'catalog.views' has no attribute 'CategoryListview'

Thanks for your help I greatly appreciate it. 

On Monday, August 27, 2018 at 12:16:09 PM UTC-4, Matthew Pava wrote:
>
> Oh, yes.  I do it all the time myself.
>
>  
>
> You need to change
>
>  
>
> category.model_set
>
>  
>
> to
>
>  
>
> category.model_set.all
>
>  
>
> model_set is the manager.  You need to treat it like any other manager.
>
>  
>
> *From:* django...@googlegroups.com  [mailto:
> django...@googlegroups.com ] *On Behalf Of *Jay
> *Sent:* Monday, August 27, 2018 11:05 AM
> *To:* Django users
> *Subject:* Re: Printing model fields organized by category
>
>  
>
> Hmm, I'm getting an error:
>
>  
>
> [image: Screen Shot 2018-08-27 at 11.58.32 AM.png]
>
>  
>
>  
>
>  
>
>  
>
>  
>
>  
>
>  
>
> I've changed my urls.py to this:
>
>  
>
> from django.urls import path
>
> from . import views
>
>  
>
> urlpatterns = [
>
> path('', views.index, name='index'),
>
> path('books/', views.BookListView.as_view(), name='books'),
>
> path('book/', views.BookDetailView.as_view(), 
> name='book-detail'),
>
> path('category/', views.CategoryListView.as_view(), name='categories'),
>
>
> On Monday, August 27, 2018 at 11:33:14 AM UTC-4, Matthew Pava wrote:
>
> Okay, your URL should point to your CategoryListView.  That should have 
> category_list in its context.  And the template should in the category_list 
> template.
>
>  
>
> *From:* django...@googlegroups.com [mailto:django...@googlegroups.com] *On 
> Behalf Of *Jay
> *Sent:* Monday, August 27, 2018 10:28 AM
> *To:* Django users
> *Subject:* Re: Printing model fields organized by category
>
>  
>
> Thanks Matthew, here is my views.py file:
>
>  
>
>  
>
> from django.shortcuts import render #generates HTML fiels using a template 
> and data
>
> #from django.http import HttpResponse
>
> from .models import Book, Author, BookInstance, Genre, Model, 
> ModelInstance, Category, Ownership, Manufacturer, Location #imports model 
> classes to access data in views
>
> from django.views import generic
>
>  
>
> # Create your views here.
>
>  
>
> #def index(request):
>
> #return HttpResponse("Hey")
>
>  
>
> def index(request):
>
> """View function for home page of site."""
>
>  
>
> #Generate counts of some of the main objects
>
> num_books = Book.objects.all().count()
>
> num_instances = BookInstance.objects.all().count()
>
>  
>
> #Available books (status - 'a')
>
> num_instances_available = 
> BookInstance.objects.filter(status__exact='a').count()
>
>  
>
> #The 'all()' is implied by default.
>
> num_authors = Author.objects.count()
>
>  
>
> #Num visits to this view, as counted in the session variable
>
> num_visits = request.session.get('num_visits', 0)
>
> request.session['num_visits'] = num_visits + 1
>
>  
>
>  
>
> context = {
>
> 'num_books': num_books,
>
> 'num_instances': num_instances,
>
> 'num_instances_available': num_instances_available,
>
> 'num_authors': num_authors,
>
> 'num_visits': num_visits,
>
> }
>
>  
>
> #Render the HTML template index.html with the data in the context 
> variable
>
> return render(request, 'index.html', context=context)
>
>  
>
> class BookListView(generic.ListView):
>
> model = Book
>
>  
>
> class BookDetailView(generic.DetailView):
>
> model = Book
>
>  
>
> class ModelListView(generic.ListView):
>
> model = Model
>
>  
>
> class ModelDetailView(generic.DetailView):
>
> model = Model
>
>  
>
> class CategoryListView(generic.ListView):
>
> model = Category
>
>  
>
> class CategoryDetailView(generic.DetailView):
>
> model = Category
>
>  
>
> from django.contrib.auth.mixins import LoginRequiredMixin
>
>  
>
> class LoanedBooksByUserListView(LoginRequiredMixin,generic.ListView):
>
> """Generic class-based view listing books on loan to current user."""
>
> model = BookInstance
>
> template_name ='catalog/bookinstance_list_borrowed_user.html'
>
> paginate_by = 10
>
>  
>
> def get_queryset(self):
>
> return 
> Book

Re: Printing model fields organized by category

2018-08-27 Thread Jay
Thanks Matthew, here is my views.py file:


from django.shortcuts import render #generates HTML fiels using a template 
and data
#from django.http import HttpResponse
from .models import Book, Author, BookInstance, Genre, Model, 
ModelInstance, Category, Ownership, Manufacturer, Location #imports model 
classes to access data in views
from django.views import generic

# Create your views here.

#def index(request):
#return HttpResponse("Hey")

def index(request):
"""View function for home page of site."""

#Generate counts of some of the main objects
num_books = Book.objects.all().count()
num_instances = BookInstance.objects.all().count()

#Available books (status - 'a')
num_instances_available = 
BookInstance.objects.filter(status__exact='a').count()

#The 'all()' is implied by default.
num_authors = Author.objects.count()

#Num visits to this view, as counted in the session variable
num_visits = request.session.get('num_visits', 0)
request.session['num_visits'] = num_visits + 1


context = {
'num_books': num_books,
'num_instances': num_instances,
'num_instances_available': num_instances_available,
'num_authors': num_authors,
'num_visits': num_visits,
}

#Render the HTML template index.html with the data in the context 
variable
return render(request, 'index.html', context=context)

class BookListView(generic.ListView):
model = Book

class BookDetailView(generic.DetailView):
model = Book

class ModelListView(generic.ListView):
model = Model

class ModelDetailView(generic.DetailView):
model = Model

class CategoryListView(generic.ListView):
model = Category

class CategoryDetailView(generic.DetailView):
model = Category

from django.contrib.auth.mixins import LoginRequiredMixin

class LoanedBooksByUserListView(LoginRequiredMixin,generic.ListView):
"""Generic class-based view listing books on loan to current user."""
model = BookInstance
template_name ='catalog/bookinstance_list_borrowed_user.html'
paginate_by = 10

def get_queryset(self):
return 
BookInstance.objects.filter(borrower=self.request.user).filter(status__exact='o').order_by('due_back')


On Monday, August 27, 2018 at 11:00:57 AM UTC-4, Matthew Pava wrote:
>
> We need to see your view code.  I’m assuming now that you don’t have 
> category_list in your context variable that you submitted to the template.
>
>  
>
> *From:* django...@googlegroups.com  [mailto:
> django...@googlegroups.com ] *On Behalf Of *Jay
> *Sent:* Monday, August 27, 2018 9:20 AM
> *To:* Django users
> *Subject:* Re: Printing model fields organized by category
>
>  
>
> Thanks for the suggestions, I will change the name from Model after I can 
> get this working. 
>
>  
>
> So, I've changed the code using your help to:
>
>  
>
>   {% if category_list %}
>
> {% for category in category_list %}
>
> {{ category }}
>
>   
>
> {% for model in category.model_set %}
>
>   
>
>{{ 
> model.model_number }}..{{ model.description }} 
>
>   
>
> {% endfor %}
>
>   
>
> {% endfor %}
>
>   {% else %}
>
> There is no equipment in the database
>
>   {% endif %}
>
>  
>
> {% endblock %}
>
>  
>
> However, this just prints "There is no equipment in the database". Am I 
> missing something? I will try to experiment a little more. 
>
>
> On Monday, August 27, 2018 at 9:52:56 AM UTC-4, Matthew Pava wrote:
>
> Hi Jay,
>
> Firstly, I would avoid calling a model “Model.”  Maybe “Product” would be 
> better?  It’s only because of Django’s models.Model class.  That will 
> likely cause confusion in the future for you.
>
>  
>
> You’ll want to work with the Category model primarily and use a reverse 
> lookup to get to the corresponding “Model” instead of working with a 
> model_list.  The reverse lookup of category to model is model_set by 
> default.  You can change the name if you want.
>
>  
>
> {% for category in category_list %}
>
>   {{ category }}
>
>   
>
>   {% for model in category.model_set %}
>
> {{ model }}
>
>   {% endfor %}
>
>   
>
> {% empty %}
>
>   There is no equipment in the database with a category.
>
> {% endfor %}
>
>  
>
>  
>
> Check out 
> https://docs.djangoproject.com/en/2.1/topics/db/examples/many_to_one/
>
>  
>
>  
>
> *From:* django...@googlegroups.com [mailto:django...@googlegroups.com] *On 
> Behalf Of *Jay
> *Sent:* Monday, August 27, 2018 8:02 AM

Re: Printing model fields organized by category

2018-08-27 Thread Jay
Thanks for the suggestions, I will change the name from Model after I can 
get this working. 

So, I've changed the code using your help to:

  {% if category_list %}
{% for category in category_list %}
{{ category }}
  
{% for model in category.model_set %}
  
   {{ model.model_number 
}}..{{ model.description }} 
  
{% endfor %}
  
{% endfor %}
  {% else %}
There is no equipment in the database
  {% endif %}

{% endblock %}

However, this just prints "There is no equipment in the database". Am I 
missing something? I will try to experiment a little more. 

On Monday, August 27, 2018 at 9:52:56 AM UTC-4, Matthew Pava wrote:
>
> Hi Jay,
>
> Firstly, I would avoid calling a model “Model.”  Maybe “Product” would be 
> better?  It’s only because of Django’s models.Model class.  That will 
> likely cause confusion in the future for you.
>
>  
>
> You’ll want to work with the Category model primarily and use a reverse 
> lookup to get to the corresponding “Model” instead of working with a 
> model_list.  The reverse lookup of category to model is model_set by 
> default.  You can change the name if you want.
>
>  
>
> {% for category in category_list %}
>
>   {{ category }}
>
>   
>
>   {% for model in category.model_set %}
>
> {{ model }}
>
>   {% endfor %}
>
>   
>
> {% empty %}
>
>   There is no equipment in the database with a category.
>
> {% endfor %}
>
>  
>
>  
>
> Check out 
> https://docs.djangoproject.com/en/2.1/topics/db/examples/many_to_one/
>
>  
>
>  
>
> *From:* django...@googlegroups.com  [mailto:
> django...@googlegroups.com ] *On Behalf Of *Jay
> *Sent:* Monday, August 27, 2018 8:02 AM
> *To:* Django users
> *Subject:* Printing model fields organized by category
>
>  
>
> I have a Class called "Model" that has a field called "model_numbers". I 
> have another class called "Category" that has a field called "category". In 
> the Model Class, I have a field called category that is a Foreign Key to 
> the field category in the Class category.
>
>  
>
> [image: Screen Shot 2018-08-27 at 8.58.54 AM.png]
>
>  
>
> Also, here is the html that prints the modeul_number and category fields:
>
>  
>
> [image: Screen Shot 2018-08-27 at 9.01.10 AM.png]
>
>  
>
>  
>
> What the code is printing:
>
>  
>
> CATEGORY 1:
>
>  - Field 1
>
>  - Field 2
>
>  - Field 3 
>
>  
>
> CATEGORY 2:
>
>  - Field 1
>
>  - Field 2
>
>  - Field 3
>
>  
>
> What I want it to print is:
>
>  
>
> CATEGORY 1:
>
>  - Field 1
>
>  - Field 2
>
>  
>
> CATEGORY 2:
>
> - Field 3
>
>  
>
> In this way it prints out all the model numbers under their respective 
> category name (instead of all model numbers under every category, which is 
> not correct as each model number only has one category). 
>
>  
>
> I posted about this on stackoverflow, and received a response but I am 
> still confused. 
> <https://stackoverflow.com/questions/51882942/how-can-i-organize-a-list-of-fields-based-on-another-field>
>
>  
>
> Thank you!
>
> -- 
> 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 post to this group, send email to djang...@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/098cc4aa-374a-4e9a-9da1-ee49bab591aa%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/098cc4aa-374a-4e9a-9da1-ee49bab591aa%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/62492e1a-1aeb-48ef-b1c1-47d3bfc77124%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Pulling data from database

2017-11-02 Thread jay seattle
New to Django, coming from C# and I am totally confused how you pull data 
from a database. I have a Postgres DB with a table "customer" created, but 
have NO idea how to connect to it. I have read a bunch of stuff but they 
all seem to work from the Model creation to database (migration), but if 
the table is already created, I can't find detail what to do. 

If I have a table called "customer" and want to pull the data into my 
template, what should I read up on to accomplish this?

Thanks
Jay

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/64ab175d-4897-42ba-8f84-fa3778791226%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to use django.contrib.postgres.forms widgets in the admin site

2016-08-16 Thread Jay Sheldon
Hi there,

I just recently updated my database to postgres, looking to play with the 
django supported field types HStoreField and JSONField 
(reference: https://docs.djangoproject.com/en/1.8/ref/contrib/postgres/fields/ 
)

I got the install working fine, but in my admin section - the widgets that 
come with HStoreField is not appearing (reference: 
https://docs.djangoproject.com/en/1.8/ref/contrib/postgres/forms/ )

I cant see to figure out how to get the admin side to use the widget for 
HStoreField.

Any ideas?

Thank you very much,
Jay

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ce96dfbc-765d-4fb8-9ea8-9c6b3fa5017c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Amazon.com API

2015-10-26 Thread jay . verstreater
First, I want to know if its possible to search for a product on Amazon.com 
and before returning the product cost, do a calculation and then spit out 
the result on my website. Can anyone explain in detail for an absolute 
beginner how this works? Thanks in advance!

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/846b5066-5e82-46b3-97c9-9a4cf4e80dc7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: python / django demand

2015-04-22 Thread Jay
thank you, good info.

On Wednesday, 22 April 2015 05:10:48 UTC-6, mlvora.2010 wrote:
>
> Hey Jay,
>
> I am Malhar Vora from India. I may not be a proper person to answer to 
> your question as I don't have much experience but since 5-6 years I am 
> observing that Python/Django is gaining momentum in Indian market. As a 
> developer I keep track of Python/Django companies to get a job. In last 2-3 
> years I have seen tremendous growth in this stack. 
>
> Mostly this stack is used by startups. At India some of the very 
> successful startups like Goibibbo and Taxiforsure uses Python/Django stack. 
> I daily get lot of job offers for same stack from startups. After launch of 
> OpenStack framework,  Python has become popular in market.
>
> Thank you,
>
> Regds,
> Malhar Vora
>
>
> Regds,
> *Malhar Vora*
> http://about.me/malhar.vora
>
>
> On Tue, Apr 21, 2015 at 11:50 PM, Jay <jma...@gmail.com > 
> wrote:
>
>> Just curious if any long time python / django developers have seen an 
>> increase in the demand/growth/popularity of these skills? I run a dev team 
>> of python/django/aws developers building an ecommerce website and was 
>> curious about what people think the future brings for this stack.  
>> Continued improvement, tools and frameworks, modules, popularity, growth 
>> and demand?
>>
>>
>>   We are located in the south west USA so thats my direct market area.
>>
>>
>>
>> any comments appreciated.
>>
>> Thanks.
>>
>> -- 
>> 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 post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/1b5c1b62-69b2-4b99-8777-c2dc5e89e1bf%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/1b5c1b62-69b2-4b99-8777-c2dc5e89e1bf%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c1bef9bc-980e-40a0-a514-5afb9d9b98de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


python / django demand

2015-04-21 Thread Jay
Just curious if any long time python / django developers have seen an 
increase in the demand/growth/popularity of these skills? I run a dev team 
of python/django/aws developers building an ecommerce website and was 
curious about what people think the future brings for this stack. 
 Continued improvement, tools and frameworks, modules, popularity, growth 
and demand?


  We are located in the south west USA so thats my direct market area.



any comments appreciated.

Thanks.

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1b5c1b62-69b2-4b99-8777-c2dc5e89e1bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Suggestion

2015-03-18 Thread Jay Prasad
Hi All,

I'm started Pyhthon and django ,give me some suggestions and which sites 
was good .help me.thank you all 

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c07141eb-9d7d-48f5-8d10-4b4ac5718d0d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Somethings the connection to the Postgress get lost. Why?

2014-07-12 Thread Jay Crossler
Who woulda thunk it, but switching the DATABASE_HOST to a "" blank string 
(then restarting nginx and postgresql) fixed the intermittent connection 
dropping for me!

On Thursday, March 13, 2008 10:11:00 AM UTC-4, Rajesh Dhawan wrote:
>
> Hi, 
>
> On Mar 12, 12:31 pm, mamcxyz  wrote: 
> > I'm getting this message from a live site, more or less 1-2 each week: 
>
> Do you have your Django apps setup to email you when a 500 Server 
> Error occurs in such cases? If so, does the full trace show such 
> failures whenever a search engine crawler is accessing your site? 
>
> > OperationalError: could not connect to server: Network is unreachable 
> >Is the server running on host "localhost" and accepting 
> >TCP/IP connections on port 5432? 
> > 
> > The site run recent trunk of django and postgress with pyso2. 
> > 
> > I don't see a pattern (each time is a diferent page) and don't see a 
> > way to replicate it. My local test are fine. 
> > 
> > The site is deployed on joyent 
>
> Are you on a Joyent Solaris "Accelerator"? If so, here is some 
> analysis that might help: 
>
> On Solaris, the socket TIME_WAIT parameter defaults to 4 minutes (RFC 
> recommended value but way too high for local TCP/IP sockets). Linux, 
> FreeBSD, etc. default to something like 1 or 2 minutes. What this 
> means is that closed TCP/IP pgsql connections take longer to clear up 
> on Solaris. So, if let's say you allow 100 max simultaneous pgsql 
> connections and a search engine crawler hits your site and manages to 
> issue 110 requests in a span of a minute (the Joyent Accelerator boxes 
> are pretty fast and can serve many more than these many requests per 
> minute), you will easily hit the pgsql max limit and further 
> connections will be disallowed until the TIME_WAIT state connections 
> clear out. You can see if this is happening by looking for the number 
> of pgsql connections in TIME_WAIT using: 
>
> netstat -an | grep "5432" 
>
> Do this right when you get your above mentioned error message. Chances 
> are that you will see a lot of sockets in the TIME_WAIT state. 
>
> The easiest solution is to simply switch to Unix domain sockets. For 
> pgsql, that means settings your DATABASE_HOST to "" (an empty string) 
> instead of localhost. Make a few requests to your app after that and 
> run the above netstat command. You should see no new TCP/IP 
> connections in a TIME_WAIT state. If it doesn't work, open up your 
> pg_hba.conf and make sure the Unix domain sockets entry is uncommented 
> and set to an appropriate authentication (and then restart pgsql). You 
> might also want to disable the TCP socket entries while you are there. 
>
> The Unix domain sockets solution works for you because your pgsql DB 
> is on the same host as your Django app. If that weren't so, you would 
> have to switch back to TCP/IP sockets. 
>
> The second easiest solution is to use connection pooling (pgpool2) 
> which allows you to reuse a controlled small number of connections for 
> multiple requests. 
>
> There is another issue on Joyent/Solaris that you should be aware of: 
> if you are using postgresql from the Blastwave packaging system, it's 
> not compiled with the option that enables a thread-safe libpq (the 
> library that ultimately is used by psycopg). This causes steady memory 
> leaks and could lead to intermittent problems. See the note I've 
> quoted below from the psycopg2 INSTALL file. 
>
> Hope this helps, 
> -Rajesh 
>
> Compiling and installing psycopg 
>  
>
> ** Important note: if you plan to use psyopg2 in a multithreaed 
> application 
>make sure that your libpq has been compiled with the --with-thread- 
> safety 
>option. psycopg2 will work correctly even with a non-thread-safe 
> libpq but 
>libpq will leak memory.

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3d95b96e-26a6-4d8d-b101-68f3227bfc0a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Analysis of csv data

2014-04-10 Thread Jay Parikh
Hi Saransh,

Well for just analyzing csv files you can use simple python file io but in
order to do more from those extracted data then you could use d3.js for
drawing data driven graphs. Could you please provide what kind of csv data
you have then probably it would be easy to sort it out.

Best,
Jay


On Thu, Apr 10, 2014 at 4:13 PM, Saransh Mehta <saransh.meh...@gmail.com>wrote:

> I need to analyze the incoming data from the csv file and present it to
> the user in the best possible way?
> What tools do i need to use for analyzing the csv and drawing graphs etc
> out of the csv?
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/818ecde6-ab66-48f5-8b2c-8590e9e787be%40googlegroups.com<https://groups.google.com/d/msgid/django-users/818ecde6-ab66-48f5-8b2c-8590e9e787be%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD-syJVdzZLBgtC18ypv2HRmA0nFZ%3DwzFyJPGoATGBdJS9h6aQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: if statement in django

2014-04-05 Thread Jay Lozier


On 04/05/2014 11:08 PM, Anthony Smith wrote:

Hi



I have a small project and I have been unable to get the following 
statement to work. Any help would great.User inputs can either 
self_sale_head which is a $ value,if a $ value is not add a 
self.estimated_weight_hd is used to get the total weight, the code 
below should return a estimated_weight_total which can be used for the 
total sale price. All works when I add the estimated_weight_total 
manually. I am lost as why.


|def  calc_estimated_weight_total(self):
 if  self.sale_head<=  0:
 amount=  (self.number*  self.estimated_weight_hd)
 return  amount

def  save(self):
 self.estimated_total_weight=  self.calc_estimated_weight_total()
 super(SaleNote,  self).save()|




Anthony,

In your first function, when the if condition evaluates to False it not 
return anything.


A possible version is:

def calc_estimated_weight_total(self):
if self.sale_head <= 0:
amount = self.number * self.estimated_weight_hd
else:
amount = 0  # (or your default value or other code to calculate 
amount)

return amount

Another version

def calc_estimated_weight_total(self):
amount = 0
if self.sale_head <= 0:
amount = self.number * self.estimated_weight_hd
return amount

Both versions will return a value not matter whether the test condition 
evaluates to True or False. The second version assumes the default value 
is 0


--
Jay Lozier
jsloz...@gmail.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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5340E423.2070700%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie: ImportError during syncdb

2014-03-06 Thread Jay Parikh
Hi David,

Instead of specifying ''django_bookmarks.bookmarks'' in 'INSTALLED_APPS' i
would suggest you to use your app name which you have created e.g someting
like as below:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'bookmarks',
)
I am assuming over here as you have kept your app name as *'bookmarks'*.

-Jay


On Thu, Mar 6, 2014 at 6:43 AM, David <ld...@gmx.net> wrote:

> Dear django users,
>
> I am new to django and have an ImportError: No module named bookmarks
> problem.
>
> It seems that as I tried to syncdb django does not recognize the
> bookmarks module I have created before. In the past I was able to
> syncdb, hence my confusion.
>
> I am trying to teach myself by following "Learning Website Development
> with Django" by Ayman Hourieh.
>
> I am not working in a virtualenv.
>
> Thanks for your guidance and hints!
>
> David
>
>
> settings.py:
>
> INSTALLED_APPS = (
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'django_bookmarks.bookmarks',
> )
>
> david@ubuntu:~/Tools/Python/Code/myCode/Django/django_bookmarks$ python
> manage.py syncdb
> Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File
>
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
> line 399, in execute_from_command_line
> utility.execute()
>   File
>
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
> line 392, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> line 242, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> line 280, in execute
> translation.activate('en-us')
>   File
>
> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py",
> line 130, in activate
> return _trans.activate(language)
>   File
>
> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
> line 188, in activate
> _active.value = translation(language)
>   File
>
> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
> line 177, in translation
> default_translation = _fetch(settings.LANGUAGE_CODE)
>   File
>
> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
> line 159, in _fetch
> app = import_module(appname)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line
> 40, in import_module
> __import__(name)
> ImportError: No module named bookmarks
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5317CBCC.4060908%40gmx.net.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD-syJVV9TM4_VrpxwdieauLK4E%2B2guHPPL%3D1Li9JCTgqLKN2g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Newbie: ImportError during syncdb

2014-03-06 Thread Jay Parikh
Let say for example i am going to create new app say bookmarks then i will
do something like *"python manage.py startapp bookmarks" *likewise whatever
name you have passed in place of *bookmarks.* Just place it inside
INSTALLED_APPS.



On Thu, Mar 6, 2014 at 1:06 PM, Robin Lery  wrote:

> What the name of the app folder? I think its just django_bookmarks.
>
>
> On Thu, Mar 6, 2014 at 6:43 AM, David  wrote:
>
>> Dear django users,
>>
>> I am new to django and have an ImportError: No module named bookmarks
>> problem.
>>
>> It seems that as I tried to syncdb django does not recognize the
>> bookmarks module I have created before. In the past I was able to
>> syncdb, hence my confusion.
>>
>> I am trying to teach myself by following "Learning Website Development
>> with Django" by Ayman Hourieh.
>>
>> I am not working in a virtualenv.
>>
>> Thanks for your guidance and hints!
>>
>> David
>>
>>
>> settings.py:
>>
>> INSTALLED_APPS = (
>> 'django.contrib.admin',
>> 'django.contrib.auth',
>> 'django.contrib.contenttypes',
>> 'django.contrib.sessions',
>> 'django.contrib.messages',
>> 'django.contrib.staticfiles',
>> 'django_bookmarks.bookmarks',
>> )
>>
>> david@ubuntu:~/Tools/Python/Code/myCode/Django/django_bookmarks$ python
>> manage.py syncdb
>> Traceback (most recent call last):
>>   File "manage.py", line 10, in 
>> execute_from_command_line(sys.argv)
>>   File
>>
>> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
>> line 399, in execute_from_command_line
>> utility.execute()
>>   File
>>
>> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
>> line 392, in execute
>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>   File
>> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
>> line 242, in run_from_argv
>> self.execute(*args, **options.__dict__)
>>   File
>> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
>> line 280, in execute
>> translation.activate('en-us')
>>   File
>>
>> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py",
>> line 130, in activate
>> return _trans.activate(language)
>>   File
>>
>> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
>> line 188, in activate
>> _active.value = translation(language)
>>   File
>>
>> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
>> line 177, in translation
>> default_translation = _fetch(settings.LANGUAGE_CODE)
>>   File
>>
>> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
>> line 159, in _fetch
>> app = import_module(appname)
>>   File
>> "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line
>> 40, in import_module
>> __import__(name)
>> ImportError: No module named bookmarks
>>
>> --
>> 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 post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/5317CBCC.4060908%40gmx.net
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>  --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2B4-nGorOGF10TOCuYAWohS%2B3nHjrL-DRpkj%2BDGTtmHDq4u00A%40mail.gmail.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD-syJVuTabkTE2wO7%2BEt3tSN68RDSVU49j6%2BA8JLvxWamLXxw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: python manage.py runserver error

2013-07-23 Thread Jay Lozier
virtualenv works, this for the link.

On Sunday, July 21, 2013 10:09:59 PM UTC-4, Jay Lozier wrote:
>
> I get the following error when run python manage.py runserver:
>
> OS openSUSE 12.3
> django 1.7
>
>
> boopers@linux-nss6:~/myfirstsite> python manage.py runserver
> Traceback (most recent call last):
> File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
> File "/home/boopers/django-trunk/django/core/management/__init__.py", line 
> 397, in execute_from_command_line
> utility.execute()
> File "/home/boopers/django-trunk/django/core/management/__init__.py", line 
> 390, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
> File "/home/boopers/django-trunk/django/core/management/__init__.py", line 
> 261, in fetch_command
> app_name = get_commands()[subcommand]
> File "/home/boopers/django-trunk/django/core/management/__init__.py", line 
> 107, in get_commands
> apps = settings.INSTALLED_APPS
> File "/home/boopers/django-trunk/django/conf/__init__.py", line 54, in 
> __getattr__
> self._setup(name)
> File "/home/boopers/django-trunk/django/conf/__init__.py", line 50, in 
> _setup
> self._configure_logging()
> File "/home/boopers/django-trunk/django/conf/__init__.py", line 68, in 
> _configure_logging
> from django.utils.log import DEFAULT_LOGGING
> File "/home/boopers/django-trunk/django/utils/log.py", line 7, in 
> from django.views.debug import ExceptionReporter, 
> get_exception_reporter_filter
> File "/home/boopers/django-trunk/django/views/debug.py", line 10, in 
> 
> from django.http import (HttpResponse, HttpResponseServerError,
> File "/home/boopers/django-trunk/django/http/__init__.py", line 4, in 
> 
> from django.http.response import (HttpResponse, StreamingHttpResponse,
> File "/home/boopers/django-trunk/django/http/response.py", line 16, in 
> 
> from django.utils import six, timezone
> File "/home/boopers/django-trunk/django/utils/timezone.py", line 11, in 
> 
> import pytz
> File "/usr/lib/python2.7/site-packages/pytz/__init__.py", line 35, in 
> 
> from pkg_resources import resource_stream
> File 
> "/usr/lib/python2.7/site-packages/setuptools-0.9.6-py2.7.egg/pkg_resources.py",
>  
> line 3027, in 
> add_activation_listener(lambda dist: dist.activate())
> File 
> "/usr/lib/python2.7/site-packages/setuptools-0.9.6-py2.7.egg/pkg_resources.py",
>  
> line 741, in subscribe
> callback(dist)
> File 
> "/usr/lib/python2.7/site-packages/setuptools-0.9.6-py2.7.egg/pkg_resources.py",
>  
> line 3027, in 
> add_activation_listener(lambda dist: dist.activate())
> File 
> "/usr/lib/python2.7/site-packages/setuptools-0.9.6-py2.7.egg/pkg_resources.py",
>  
> line 2514, in activate
> list(map(declare_namespace, self._get_metadata('namespace_packages.txt')))
> File 
> "/usr/lib/python2.7/site-packages/setuptools-0.9.6-py2.7.egg/pkg_resources.py",
>  
> line 2094, in declare_namespace
> _handle_ns(packageName, path_item)
> File 
> "/usr/lib/python2.7/site-packages/setuptools-0.9.6-py2.7.egg/pkg_resources.py",
>  
> line 2059, in _handle_ns
> raise TypeError("Not a package:", packageName)
> TypeError: ('Not a package:', 'cgi')
>
>
> The sys paths are
>
> /usr/lib/python2.7/site-packages/pymongo-2.5.1-py2.7-linux-x86_64.egg
> /usr/lib/python2.7/site-packages/bottle-0.11.6-py2.7.egg
> /usr/lib/python2.7/site-packages/translationstring-1.1-py2.7.egg
> /usr/lib/python2.7/site-packages/venusian-1.0a8-py2.7.egg
> /usr/lib/python2.7/site-packages/zope.deprecation-4.0.2-py2.7.egg
> /usr/lib/python2.7/site-packages/setuptools-0.9.6-py2.7.egg
> /home/boopers/django-trunk
> /usr/lib/python27.zip
> /usr/lib64/python2.7
> /usr/lib64/python2.7/plat-linux2
> /usr/lib64/python2.7/lib-tk
> /usr/lib64/python2.7/lib-old
> /usr/lib64/python2.7/lib-dynload
> /usr/lib64/python2.7/site-packages
> /usr/lib64/python2.7/site-packages/FontTools
> /usr/lib64/python2.7/site-packages/PIL
> /usr/local/lib64/python2.7/site-packages
> /usr/local/lib/python2.7/site-packages
> /usr/lib64/python2.7/site-packages/gst-0.10
> /usr/lib64/python2.7/site-packages/gtk-2.0
> /usr/lib64/python2.7/site-packages/input-pad-1.0
> /usr/lib/python2.7/site-packages
> /usr/lib64/python2.7/site-packages/wx-2.9.4-gtk2
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django-admin.py startproject mysite error

2013-07-23 Thread Jay Lozier
virtualenv seems to work well and I can get django tamed.

On Saturday, July 20, 2013 5:55:21 PM UTC-4, Jay Lozier wrote:
>
> Using openSUSE 12.3
> python 2.7.3
> django 1.5.1 installed manually and verified
>
> When I enter "django-admin.py startproject mysite" at the command prompt I 
> get the following traceback:
>
> Traceback (most recent call last):
> File "/usr/bin/django-admin.py", line 5, in 
> management.execute_from_command_line()
> File 
> "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 
> 453, in execute_from_command_line
> utility.execute()
> File 
> "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 
> 392, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
> File 
> "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 
> 272, in fetch_command
> klass = load_command_class(app_name, subcommand)
> File 
> "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 
> 77, in load_command_class
> module = import_module('%s.management.commands.%s' % (app_name, name))
> File "/usr/lib/python2.7/site-packages/django/utils/importlib.py", line 
> 35, in import_module
> __import__(name)
> File 
> "/usr/lib/python2.7/site-packages/django/core/management/commands/startproject.py",
>  
> line 2, in 
> from django.core.management.templates import TemplateCommand
> File 
> "/usr/lib/python2.7/site-packages/django/core/management/templates.py", 
> line 20, in 
> from django.template import Template, Context
> File "/usr/lib/python2.7/site-packages/django/template/__init__.py", line 
> 53, in 
> from django.template.base import (ALLOWED_VARIABLE_CHARS, BLOCK_TAG_END,
> File "/usr/lib/python2.7/site-packages/django/template/base.py", line 18, 
> in 
> from django.utils.formats import localize
> File "/usr/lib/python2.7/site-packages/django/utils/formats.py", line 5, 
> in 
> from django.utils import dateformat, numberformat, datetime_safe
> File "/usr/lib/python2.7/site-packages/django/utils/dateformat.py", line 
> 25, in 
> from django.utils.timezone import is_aware, is_naive
> File "/usr/lib/python2.7/site-packages/django/utils/timezone.py", line 11, 
> in 
> import pytz
> File "/usr/lib/python2.7/site-packages/pytz/__init__.py", line 35, in 
> 
> from pkg_resources import resource_stream
> File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2978, in 
> 
> add_activation_listener(lambda dist: dist.activate())
> File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 709, in 
> subscribe
> callback(dist)
> File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2978, in 
> 
> add_activation_listener(lambda dist: dist.activate())
> File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2465, in 
> activate
> map(declare_namespace, self._get_metadata('namespace_packages.txt'))
> File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2045, in 
> declare_namespace
> _handle_ns(packageName, path_item)
> File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2010, in 
> _handle_ns
> raise TypeError("Not a package:", packageName)
> TypeError: ('Not a package:', 'cgi')
>
> How do I fix this?
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




python manage.py runserver error

2013-07-22 Thread Jay Lozier
I get the following error when run python manage.py runserver:

OS openSUSE 12.3
django 1.7


boopers@linux-nss6:~/myfirstsite> python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
File "/home/boopers/django-trunk/django/core/management/__init__.py", line 
397, in execute_from_command_line
utility.execute()
File "/home/boopers/django-trunk/django/core/management/__init__.py", line 
390, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/boopers/django-trunk/django/core/management/__init__.py", line 
261, in fetch_command
app_name = get_commands()[subcommand]
File "/home/boopers/django-trunk/django/core/management/__init__.py", line 
107, in get_commands
apps = settings.INSTALLED_APPS
File "/home/boopers/django-trunk/django/conf/__init__.py", line 54, in 
__getattr__
self._setup(name)
File "/home/boopers/django-trunk/django/conf/__init__.py", line 50, in 
_setup
self._configure_logging()
File "/home/boopers/django-trunk/django/conf/__init__.py", line 68, in 
_configure_logging
from django.utils.log import DEFAULT_LOGGING
File "/home/boopers/django-trunk/django/utils/log.py", line 7, in 
from django.views.debug import ExceptionReporter, 
get_exception_reporter_filter
File "/home/boopers/django-trunk/django/views/debug.py", line 10, in 

from django.http import (HttpResponse, HttpResponseServerError,
File "/home/boopers/django-trunk/django/http/__init__.py", line 4, in 

from django.http.response import (HttpResponse, StreamingHttpResponse,
File "/home/boopers/django-trunk/django/http/response.py", line 16, in 

from django.utils import six, timezone
File "/home/boopers/django-trunk/django/utils/timezone.py", line 11, in 

import pytz
File "/usr/lib/python2.7/site-packages/pytz/__init__.py", line 35, in 

from pkg_resources import resource_stream
File 
"/usr/lib/python2.7/site-packages/setuptools-0.9.6-py2.7.egg/pkg_resources.py", 
line 3027, in 
add_activation_listener(lambda dist: dist.activate())
File 
"/usr/lib/python2.7/site-packages/setuptools-0.9.6-py2.7.egg/pkg_resources.py", 
line 741, in subscribe
callback(dist)
File 
"/usr/lib/python2.7/site-packages/setuptools-0.9.6-py2.7.egg/pkg_resources.py", 
line 3027, in 
add_activation_listener(lambda dist: dist.activate())
File 
"/usr/lib/python2.7/site-packages/setuptools-0.9.6-py2.7.egg/pkg_resources.py", 
line 2514, in activate
list(map(declare_namespace, self._get_metadata('namespace_packages.txt')))
File 
"/usr/lib/python2.7/site-packages/setuptools-0.9.6-py2.7.egg/pkg_resources.py", 
line 2094, in declare_namespace
_handle_ns(packageName, path_item)
File 
"/usr/lib/python2.7/site-packages/setuptools-0.9.6-py2.7.egg/pkg_resources.py", 
line 2059, in _handle_ns
raise TypeError("Not a package:", packageName)
TypeError: ('Not a package:', 'cgi')


The sys paths are

/usr/lib/python2.7/site-packages/pymongo-2.5.1-py2.7-linux-x86_64.egg
/usr/lib/python2.7/site-packages/bottle-0.11.6-py2.7.egg
/usr/lib/python2.7/site-packages/translationstring-1.1-py2.7.egg
/usr/lib/python2.7/site-packages/venusian-1.0a8-py2.7.egg
/usr/lib/python2.7/site-packages/zope.deprecation-4.0.2-py2.7.egg
/usr/lib/python2.7/site-packages/setuptools-0.9.6-py2.7.egg
/home/boopers/django-trunk
/usr/lib/python27.zip
/usr/lib64/python2.7
/usr/lib64/python2.7/plat-linux2
/usr/lib64/python2.7/lib-tk
/usr/lib64/python2.7/lib-old
/usr/lib64/python2.7/lib-dynload
/usr/lib64/python2.7/site-packages
/usr/lib64/python2.7/site-packages/FontTools
/usr/lib64/python2.7/site-packages/PIL
/usr/local/lib64/python2.7/site-packages
/usr/local/lib/python2.7/site-packages
/usr/lib64/python2.7/site-packages/gst-0.10
/usr/lib64/python2.7/site-packages/gtk-2.0
/usr/lib64/python2.7/site-packages/input-pad-1.0
/usr/lib/python2.7/site-packages
/usr/lib64/python2.7/site-packages/wx-2.9.4-gtk2

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django-admin.py startproject mysite error

2013-07-21 Thread Jay Lozier
I get this

note: I have completely deleted any django packages on the my system and 
could get any version but the dev version to even get past the first step.
the dev 1.7 version would run django-admin.py startproject myfirstsite but 
now python manage.py runserver does not work
error in line 10

/usr/lib/python2.7/site-packages/pymongo-2.5.1-py2.7-linux-x86_64.egg
/usr/lib/python2.7/site-packages/bottle-0.11.6-py2.7.egg
/usr/lib/python2.7/site-packages/translationstring-1.1-py2.7.egg
/usr/lib/python2.7/site-packages/venusian-1.0a8-py2.7.egg
/usr/lib/python2.7/site-packages/zope.deprecation-4.0.2-py2.7.egg
/usr/lib/python2.7/site-packages/setuptools-0.9.6-py2.7.egg
/home/boopers/django-trunk
/usr/lib/python27.zip
/usr/lib64/python2.7
/usr/lib64/python2.7/plat-linux2
/usr/lib64/python2.7/lib-tk
/usr/lib64/python2.7/lib-old
/usr/lib64/python2.7/lib-dynload
/usr/lib64/python2.7/site-packages
/usr/lib64/python2.7/site-packages/FontTools
/usr/lib64/python2.7/site-packages/PIL
/usr/local/lib64/python2.7/site-packages
/usr/local/lib/python2.7/site-packages
/usr/lib64/python2.7/site-packages/gst-0.10
/usr/lib64/python2.7/site-packages/gtk-2.0
/usr/lib64/python2.7/site-packages/input-pad-1.0
/usr/lib/python2.7/site-packages
/usr/lib64/python2.7/site-packages/wx-2.9.4-gtk2

On Saturday, July 20, 2013 5:55:21 PM UTC-4, Jay Lozier wrote:
>
> Using openSUSE 12.3
> python 2.7.3
> django 1.5.1 installed manually and verified
>
> When I enter "django-admin.py startproject mysite" at the command prompt I 
> get the following traceback:
>
> Traceback (most recent call last):
> File "/usr/bin/django-admin.py", line 5, in 
> management.execute_from_command_line()
> File 
> "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 
> 453, in execute_from_command_line
> utility.execute()
> File 
> "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 
> 392, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
> File 
> "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 
> 272, in fetch_command
> klass = load_command_class(app_name, subcommand)
> File 
> "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 
> 77, in load_command_class
> module = import_module('%s.management.commands.%s' % (app_name, name))
> File "/usr/lib/python2.7/site-packages/django/utils/importlib.py", line 
> 35, in import_module
> __import__(name)
> File 
> "/usr/lib/python2.7/site-packages/django/core/management/commands/startproject.py",
>  
> line 2, in 
> from django.core.management.templates import TemplateCommand
> File 
> "/usr/lib/python2.7/site-packages/django/core/management/templates.py", 
> line 20, in 
> from django.template import Template, Context
> File "/usr/lib/python2.7/site-packages/django/template/__init__.py", line 
> 53, in 
> from django.template.base import (ALLOWED_VARIABLE_CHARS, BLOCK_TAG_END,
> File "/usr/lib/python2.7/site-packages/django/template/base.py", line 18, 
> in 
> from django.utils.formats import localize
> File "/usr/lib/python2.7/site-packages/django/utils/formats.py", line 5, 
> in 
> from django.utils import dateformat, numberformat, datetime_safe
> File "/usr/lib/python2.7/site-packages/django/utils/dateformat.py", line 
> 25, in 
> from django.utils.timezone import is_aware, is_naive
> File "/usr/lib/python2.7/site-packages/django/utils/timezone.py", line 11, 
> in 
> import pytz
> File "/usr/lib/python2.7/site-packages/pytz/__init__.py", line 35, in 
> 
> from pkg_resources import resource_stream
> File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2978, in 
> 
> add_activation_listener(lambda dist: dist.activate())
> File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 709, in 
> subscribe
> callback(dist)
> File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2978, in 
> 
> add_activation_listener(lambda dist: dist.activate())
> File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2465, in 
> activate
> map(declare_namespace, self._get_metadata('namespace_packages.txt'))
> File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2045, in 
> declare_namespace
> _handle_ns(packageName, path_item)
> File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2010, in 
> _handle_ns
> raise TypeError("Not a package:", packageName)
> TypeError: ('Not a package:', 'cgi')
>
> How do I fix this?
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




django-admin.py startproject mysite error

2013-07-20 Thread Jay Lozier
Using openSUSE 12.3
python 2.7.3
django 1.5.1 installed manually and verified

When I enter "django-admin.py startproject mysite" at the command prompt I 
get the following traceback:

Traceback (most recent call last):
File "/usr/bin/django-admin.py", line 5, in 
management.execute_from_command_line()
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", 
line 453, in execute_from_command_line
utility.execute()
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", 
line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", 
line 272, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", 
line 77, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/usr/lib/python2.7/site-packages/django/utils/importlib.py", line 35, 
in import_module
__import__(name)
File 
"/usr/lib/python2.7/site-packages/django/core/management/commands/startproject.py",
 
line 2, in 
from django.core.management.templates import TemplateCommand
File 
"/usr/lib/python2.7/site-packages/django/core/management/templates.py", 
line 20, in 
from django.template import Template, Context
File "/usr/lib/python2.7/site-packages/django/template/__init__.py", line 
53, in 
from django.template.base import (ALLOWED_VARIABLE_CHARS, BLOCK_TAG_END,
File "/usr/lib/python2.7/site-packages/django/template/base.py", line 18, 
in 
from django.utils.formats import localize
File "/usr/lib/python2.7/site-packages/django/utils/formats.py", line 5, in 

from django.utils import dateformat, numberformat, datetime_safe
File "/usr/lib/python2.7/site-packages/django/utils/dateformat.py", line 
25, in 
from django.utils.timezone import is_aware, is_naive
File "/usr/lib/python2.7/site-packages/django/utils/timezone.py", line 11, 
in 
import pytz
File "/usr/lib/python2.7/site-packages/pytz/__init__.py", line 35, in 

from pkg_resources import resource_stream
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2978, in 

add_activation_listener(lambda dist: dist.activate())
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 709, in 
subscribe
callback(dist)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2978, in 

add_activation_listener(lambda dist: dist.activate())
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2465, in 
activate
map(declare_namespace, self._get_metadata('namespace_packages.txt'))
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2045, in 
declare_namespace
_handle_ns(packageName, path_item)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2010, in 
_handle_ns
raise TypeError("Not a package:", packageName)
TypeError: ('Not a package:', 'cgi')

How do I fix this?

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Misfiring signal handler

2011-12-30 Thread Jay Wineinger
Hey guys,

I have an odd problem where a post_save signal handler is getting
called from a class different than what I specified as the sender.
The code is at http://dpaste.com/hold/679348/ and also below for when
the pastebin is deleted.

I'm connecting the rating_denormalizer() function to the post_save
signal of the Rating model.  However, when I visit the site with a
fresh browser a new Session is created and for some reason, this
signal handler is called with a Session instance.

I was able to fix this by moving this code from users/signals.py to
bars/signals.py, directly importing Rating instead of using get_model,
and moving the AppUser import inside rating_denormalizer().  However,
I still would like to figure out why this was happening.

# users/signals.py
from django.db.models.signals import post_save
from django.db.models import F, get_model

Rating = get_model('bars','Rating')
AppUser = get_model('users','AppUser')

def rating_denormalizer(sender, instance, created, **kwargs):
"""
Post-save signal handler on Rating to keep the denormalized fields
on
AppUser up-to-date
"""
if created:
AppUser.objects.filter(pk=instance.user_id).update(
rating_count=F('rating_count') + 1,
last_rating=instance.created,
)
post_save.connect(rating_denormalizer, sender=Rating,
dispatch_uid='rating_denormalizer')


# Get a 500 error when going to /admin/ with a fresh browser
2011-12-27 16:45:07,608 ERROR Internal Server Error: /admin/
Traceback (most recent call last):
  File "/var/www/python/myapp/lib/python2.6/site-packages/django/core/
handlers/base.py", line 178, in get_response
response = middleware_method(request, response)
  File "/var/www/python/myapp/lib/python2.6/site-packages/django/
contrib/sessions/middleware.py", line 36, in process_response
request.session.save()
  File "/var/www/python/myapp/lib/python2.6/site-packages/django/
contrib/sessions/backends/db.py", line 63, in save
obj.save(force_insert=must_create, using=using)
  File "/var/www/python/myapp/lib/python2.6/site-packages/django/db/
models/base.py", line 460, in save
self.save_base(using=using, force_insert=force_insert,
force_update=force_update)
  File "/var/www/python/myapp/lib/python2.6/site-packages/django/db/
models/base.py", line 570, in save_base
created=(not record_exists), raw=raw, using=using)
  File "/var/www/python/myapp/lib/python2.6/site-packages/django/
dispatch/dispatcher.py", line 172, in send
response = receiver(signal=self, sender=sender, **named)
  File "/var/www/python/myapp/App/users/signals.py", line 13, in
rating_denormalizer
AppUser.objects.filter(pk=instance.user_id).update(
AttributeError: 'Session' object has no attribute 'user_id'

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Constraints on a one-to-many relationship and related problems

2011-12-28 Thread Jay De Lanoy
I'd go for a separate table instead, with something like

class BillingInfo(models.Model):
customer = models.OneToOneField(Customer)
billing_address = models.OneToOneField(Address)

and then just have logic in the views and templates to account for
existence/nonexistence of a given customer's billing address.

On Dec 28, 9:21 am, Dan Gentry  wrote:
> Just looking at the models, I'd like to make a couple of suggestions.
>
> Instead of using a Foreign Key relationship in Customer to indicate
> the billing address,  I would include a flag called 'billing_address'
> in the Address table that would be set to True for the customer
> selected address.
>
> An override of save() in the Address model is then used to enforce the
> 'only one billing address' rule.
>
>     def save(self):
>         ''' This will turn off the billing address flag for all other
> addresses for this customer if the new record is selected '''
>         if self.billing_address:
>             old_billing_address =
> Address.objects.filter(customer=self.customer).filter(billing_flag=
> True)
>             for s in old_billing_address:
>                 s.billing_flag = False
>                 s.save()
>         super(Address, self).save()
>
> Hope this helps,
>
> Dan
>
> On Dec 28, 6:02 am, Bart Nagel  wrote:
>
>
>
>
>
>
>
> > I'm new to Django. I'm finding it very impressive so far but have hit
> > a cluster of problems. I'm using the SVN version.
>
> > Sorry for the length of this, I'm just trying to explain as fully as I
> > can what I'm trying to do, what I have and what's going wrong.
>
> > The relevant parts of my model, in the simplest terms, look like this.
>
> >     from django.db import models
>
> >     class Address(models.Model):
> >         customer = models.ForeignKey("Customer")
> >         street = models.CharField(max_length=128)
> >         city = models.CharField(max_length=128)
>
> >         def __unicode__(self):
> >             return "%s, %s" % (self.street, self.city)
>
> >     class Customer(models.Model):
> >         last_name = models.CharField(blank=True, max_length=64)
> >         first_name = models.CharField(blank=True, max_length=64)
> >         billing_address = models.ForeignKey("Address", related_name="+")
>
> >         def __unicode__(self):
> >             return "%s %s" % (self.first_name, self.last_name)
>
> > So customers can have many addresses, and one of those addresses is
> > pointed to by the customer as being the billing address.
>
> > I then have the Customer admin page set up so that Address entries are
> > edited inline on the same form.
>
> > 1. The billing address should be required, but obviously when it's a
> >    new Customer there won't be any addresses on file, so there will be
> >    no choices on the billing address dropdown.
>
> >    So I need a way to accept a blank selection for billing address,
> >    maybe have it labelled as "use first address given below", and then
> >    just complain if no addresses are given below.
>
> >    Later when there needs to be something to stop the billing address
> >    from being deleted.
>
> > 2. Related to the previous, there needs to be a constraint so there
> >    must be at least one Address for each customer.
>
> > 3. When editing an existing customer, only that customer's addresses
> >    should be shown in the dropdown for billing address.
>
> > Here's what I've tried...
>
> > I set the billing address field to be optional for now.
>
> > Problem 3 seemed easiest so I decided to tackle that first, and made a
> > bunch of customers and addresses so I could test with the database
> > somewhat populated.
>
> > I found the ForeignKey.limit_choices_to in the documentation but since
> > there's no "self" when I'm setting up the database fields I've no idea
> > how I'd tell it to limit the options to something like
> > self.addresses_set.all(), let alone have that updated as addresses are
> > added, removed, edited in the inline form below.
>
> > I first posted this problem on Stacko Overflow
> > (http://stackoverflow.com/questions/8637912/) and a suggestion was to
> > use a ModelChoiceField. I had a look at the documentation and it
> > wasn't obvious what the difference is between that an ForeignKey, plus
> > it looks like I'd have exactly the same problem as above.
>
> > So I'm totally stuck on that one.
>
> > Next I had a go at the other two problems. It seemed to me (bearing in
> > mind I'm a newbie here) it'd be best to add that logic to the
> > Customer.clean() method -- I could check the number of addresses which
> > had been entered there and raise an Exception if it was zero. At the
> > same time I could set the billing address, if not already set, to the
> > first address given. All sounds simple enough, but apparently not.
>
> > In the Customer.clean() method, I can't seem to get at what was posted
> > as addresses. In there, self.address_set.all().count() is zero. I
> > don't 

render only 1 radioselect field

2011-11-10 Thread jay K.

Hello,

does anyone know how to render only 1 radioselect in
a django template?

for now I have {{ form.options }} but it renders the whole
list. I'd like to have more control on which ones I want to render

thanks in advance

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: render_to_response pointing to multiple templates

2011-11-08 Thread jay K.
Hello, Tom

thanks for your answer

I believe it can be done like the way you suggested

I should clarify that I am new to django and have no web developing
background, so
my questions may sound a bit silly sometimes

I got another one, if you dont mind

how can I retrieve information on a template, such as name and url inside
a view? I'd like to use it to differentiate between templates and
use logic to pick the template I want to render

again, Tom, thanks for your assistance



On Mon, Nov 7, 2011 at 2:04 PM, Tom Evans <tevans...@googlemail.com> wrote:

> On Mon, Nov 7, 2011 at 3:59 PM, jay K. <jay.developer2...@gmail.com>
> wrote:
> > hi, Tom
> >
> > thanks for the reply
> >
> > what I actually want to do is to
> > list several templates in the render_to_response
> > function and be able to choose which one to use
> >
> > can I choose which template to use?
> >
> > thanks again, and let me know if my question is clear enough
> >
>
> Of course you can; use logic in your view to decide which template to
> render, and call render_to_response with that template name… I must be
> missing something?
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



template information in django view

2011-11-08 Thread jay K.

Hello,

Is there any way I could retrieve information about a template,
such as template name, url, etc inside a view? is there built-in
object that represents the template object?

thanks

regards

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: render_to_response pointing to multiple templates

2011-11-07 Thread jay K.
hi, Tom

thanks for the reply

what I actually want to do is to
list several templates in the render_to_response
function and be able to choose which one to use

can I choose which template to use?

thanks again, and let me know if my question is clear enough

On Mon, Nov 7, 2011 at 12:18 PM, Tom Evans <tevans...@googlemail.com> wrote:

> On Mon, Nov 7, 2011 at 3:09 PM, jay K. <jay.developer2...@gmail.com>
> wrote:
> >
> > Hello
> >
> > I have a view with the following render_to_template function
> >
> > ...
> >
> > return render_to_response( 'template/template.html', {var'': var},
> > context_instance=RequestContext(request))
> > ...
> >
> > I want the render_to_response to point to more than 1 template. So far
> > I've tried adding a dictionary of templates but it gives me an error,
> > maybe I'm
> > not doing it properly
> >
> > If anyone can teach me how to do it I'd really appreciate it
> >
> > thanks
> >
>
> What do you want to happen with your list of templates? Do you want to
> find the first one that exists and render that one? If so, you can
> pass an iterable to render_to_response instead of a single template
> name, and it will render the first available one, see the docs:
>
> https://docs.djangoproject.com/en/1.3/topics/http/shortcuts/#id1
>
> Otherwise, you will have to explain what you are trying to do, as it
> is non-obvious.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



render_to_response pointing to multiple templates

2011-11-07 Thread jay K.

Hello

I have a view with the following render_to_template function

...

return render_to_response( 'template/template.html', {var'': var},
context_instance=RequestContext(request))
...

I want the render_to_response to point to more than 1 template. So far
I've tried adding a dictionary of templates but it gives me an error,
maybe I'm
not doing it properly

If anyone can teach me how to do it I'd really appreciate it

thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



one view for multiple templates

2011-11-07 Thread jay K.

Hello,

I have a page with a form on it

the form is handled by a view

I want to create another page and embed the same form on it

how can I use the same view on another template?
do I have to modify the 'render_to_response' so it points to the other
template (besides the current template)?

thanks

jay k

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Catching the autogenerated admin post

2011-09-29 Thread Jay Martin
Awesome, I think that's it. Much thanks.

jay


On Sep 29, 2011, at 6:31 PM, Andres Reyes wrote:

> You could try doing your processing in the save_model method of ModelAdmin
> 
> https://docs.djangoproject.com/en/1.3/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_model
> 
> 2011/9/29 bazaarsoft <jay_mar...@me.com>
> Hello - I'm new to Django and love what I see so far. I have the need
> to "catch" the admin post for one of my models: essentially, the model
> contains a file and from the file I want to extract data for some of
> the other model fields that are required for that particular model.
> So, can I "break" into the admin form processing to get it or am I
> just going to have to build my own forms?
> 
> Thanks - and sorry if this is covered in another post, I searched here
> and in the docs and didn't seem to come up with anything.
> 
> jay
> 
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 
> 
> 
> 
> -- 
> Andrés Reyes Monge
> armo...@gmail.com
> +(505)-8873-7217
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: sending and receiving data using ajax/html

2011-09-15 Thread jay K.
I do not know anything about send and receiving data using forms in html
django,
I just heard that ajax was good for receiving and sending data (it was
faster)

any suggestions would be good

2011/9/15 Yaşar Arabacı <yasar11...@gmail.com>

> Why do you want to use ajax, instead of regular form post to next page.
> When in next page, you can create hidden form fields to store data you
> passed from first page, and then you can post them again in any page you
> want.
>
> 2011/9/15 jay K. <jay.developer2...@gmail.com>
>
>
>> Hello
>>
>> I have a page where a user makes a selection
>>
>> What I want to do is to take the user's selection to the "next page"
>> so I can process the user's request in a new page
>>
>> How can I do that?
>>
>> I know I have to use ajax (but if there is a better method please let
>> me know), so
>> how can I use ajax to send and receive the information?
>>
>> Thanks
>>
>> Regards
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>
>
> --
> http://yasar.serveblog.net/
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



sending and receiving data using ajax/html

2011-09-15 Thread jay K.

Hello

I have a page where a user makes a selection

What I want to do is to take the user's selection to the "next page"
so I can process the user's request in a new page

How can I do that?

I know I have to use ajax (but if there is a better method please let
me know), so
how can I use ajax to send and receive the information?

Thanks

Regards

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: forms and form processing

2011-06-30 Thread jay K.
Hello,

thanks for the reply

I dont have email settings in my settings.py file? is that straightforward,
like an import statement or
something more complex?

I am using django version (1, 1, 1, 'final', 0) - that's what i got after
typing import django django.VERSION on the python shell

Jay k

On Thu, Jun 30, 2011 at 3:36 AM, urukay <radovan.be...@gmail.com> wrote:

> Hi,
> have you got email settings set in your settings.py?
> What version of Django are you using?
>
> Radovan
> http://www.yau.sk
>
> On 29. Jún, 00:23 h., "jay K." <jay.developer2...@gmail.com> wrote:
> > Hello,
> >
> > I need to add a form on my django website
> >
> > so far this is what i have:
> >
> > in my models.py:
> >
> >  import statements not shown here
> >
> > CONTACT_OPTIONS = (
> >  ('skype video anruf','Skype Video-
> > Anruf'),
> >  ('skype anruf ','Skype Anruf'),
> >  ('telefon','Telefon')
> > )
> >
> > class ContactForm(forms.Form):
> >
> > #wann
> > date_input = forms.CharField(max_length=30, required=True) #,
> > initial="MO-FR"
> > time_input = forms.CharField(max_length=30, required=True) # 14:00
> > - 22:00
> >
> > #wie
> > choice_options = forms.ChoiceField(widget=RadioSelect,
> > choices=CONTACT_OPTIONS, required=True)
> >
> > #contact
> > email = forms.EmailField(max_length=30, required=True)
> > telephone = forms.CharField(max_length=30, required=False)
> > skype = forms.CharField(max_length=30, required=False)
> >
> > #comment
> > comment_text = forms.CharField(widget=forms.Textarea,
> > required=False)
> >
> > my views.py
> >
> > from website.contact.models import ContactForm
> > from django.shortcuts import render_to_response
> > from django.template.context import RequestContext
> > from django.http import HttpResponseRedirect, HttpResponse
> > from django.core.mail import send_mail
> >
> > def contact(request):
> >
> > if request.method == 'POST': # If the form has been submitted...
> > form = ContactForm(request.POST) # A form bound to the POST
> > data
> >
> > if form.is_valid(): # All validation rules pass
> > # Process the data in form.cleaned_data
> >
> > subject = form.cleaned_data['subject']
> > message = form.cleaned_data['message']
> > sender = form.cleaned_data['sender']
> > cc_myself = form.cleaned_data['cc']
> >
> > date_input = form.cleaned_data['date input']
> > time_input = form.cleaned_data['time input']
> > choice_options = form.cleaned_data['contact options']
> >
> > telephone = form.cleaned_data['telefone']
> > email = form.cleaned_data['email'] # this is the sender's
> > email
> > skype = form.cleaned_data['skype']
> >
> > comment_text = form.cleaned_data['comment text']
> >
> > """
> > recipients = ['joung.k...@lingua-group.org']
> > if cc_myself:
> > recipients.append(sender)
> > """
> >#subject
> > send_mail('subject', 'message', 'myem...@myemail.com',
> > ['myem...@myemail.com', email], fail_silently=False)
> >
> > return HttpResponseRedirect('/danke/')
> >
> > else:
> > form = ContactForm() # An unbound form
> >
> > return render_to_response('beratungstermin.html', {'form': form},
> > context_instance=RequestContext(request))
> >
> > And on the website I have all the fields inside the form tag
> > 
> > {{ forms.as_p }}
> > 
> >
> > What I want to do basically is to add the fields for name, email, tel,
> > some of them being compulsory, so the form should not be processed if
> > there is some info. missing.
> >
> > I also want to receive a confirmation email whenever a user sends
> > information through the page, to my "myem...@myemail.com" (this is not
> > working on my code either), and a "CC" button if the user wants a copy
> > of his/her own message.
> >
> > Thanks
> >
> > Let me know if you need any details
> >
> > PS: i copied most of the code from the official django tutorial
> athttps://docs.

forms and form processing

2011-06-28 Thread jay K.

Hello,

I need to add a form on my django website

so far this is what i have:

in my models.py:

 import statements not shown here

CONTACT_OPTIONS = (
 ('skype video anruf','Skype Video-
Anruf'),
 ('skype anruf ','Skype Anruf'),
 ('telefon','Telefon')
)

class ContactForm(forms.Form):

#wann
date_input = forms.CharField(max_length=30, required=True) #,
initial="MO-FR"
time_input = forms.CharField(max_length=30, required=True) # 14:00
- 22:00

#wie
choice_options = forms.ChoiceField(widget=RadioSelect,
choices=CONTACT_OPTIONS, required=True)

#contact
email = forms.EmailField(max_length=30, required=True)
telephone = forms.CharField(max_length=30, required=False)
skype = forms.CharField(max_length=30, required=False)

#comment
comment_text = forms.CharField(widget=forms.Textarea,
required=False)


my views.py


from website.contact.models import ContactForm
from django.shortcuts import render_to_response
from django.template.context import RequestContext
from django.http import HttpResponseRedirect, HttpResponse
from django.core.mail import send_mail

def contact(request):

if request.method == 'POST': # If the form has been submitted...
form = ContactForm(request.POST) # A form bound to the POST
data

if form.is_valid(): # All validation rules pass
# Process the data in form.cleaned_data

subject = form.cleaned_data['subject']
message = form.cleaned_data['message']
sender = form.cleaned_data['sender']
cc_myself = form.cleaned_data['cc']

date_input = form.cleaned_data['date input']
time_input = form.cleaned_data['time input']
choice_options = form.cleaned_data['contact options']

telephone = form.cleaned_data['telefone']
email = form.cleaned_data['email'] # this is the sender's
email
skype = form.cleaned_data['skype']

comment_text = form.cleaned_data['comment text']

"""
recipients = ['joung.k...@lingua-group.org']
if cc_myself:
recipients.append(sender)
"""
   #subject
send_mail('subject', 'message', 'myem...@myemail.com',
['myem...@myemail.com', email], fail_silently=False)

return HttpResponseRedirect('/danke/')

else:
form = ContactForm() # An unbound form

return render_to_response('beratungstermin.html', {'form': form},
context_instance=RequestContext(request))


And on the website I have all the fields inside the form tag

{{ forms.as_p }}


What I want to do basically is to add the fields for name, email, tel,
some of them being compulsory, so the form should not be processed if
there is some info. missing.

I also want to receive a confirmation email whenever a user sends
information through the page, to my "myem...@myemail.com" (this is not
working on my code either), and a "CC" button if the user wants a copy
of his/her own message.

Thanks

Let me know if you need any details


PS: i copied most of the code from the official django tutorial at
https://docs.djangoproject.com/en/dev/topics/forms/?from=olddocs , but
somehow I do not receive any emails after hitting the submit button.
Also, even if I declared in my views.py that some fields are
"required=True", I can still hit the send button with no error
messages for those unfilled textfields.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



django page loads forever

2011-06-22 Thread jay K.

Hello, everyone

I have a django page which loads indefinitely

some of the javascript that is supposed to come up does not appear on
the screen (while
the page is still loading), but i checked with firebugs and there are
no error messages at all

any advice would be helpful

thanks

jay k

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: storing django object into javascript variable/array

2011-06-15 Thread jay K.
Actually i had my code like this

for(var i = 0; i < city_schools.length; i++){ . }

But somehow i missed the .length when I posted my message... sorry if it
caused any confusions

I think the problem is that the data is not being stored in the array
properly, or at least I'm not doing it right



On Wed, Jun 15, 2011 at 1:36 PM, John Finlay <fin...@moeraki.com> wrote:

>  On 6/15/11 8:59 AM, jay K. wrote:
>
> Hello,
>
> I apologize for seeming too impatient or rude, actually I'm a bit in a
> hurry because I was given a project
> and was told that it was urgent. I miscalculated how much time it was going
> to take me to learn django
>
> Anyway, what I want to do is to use the variables variables city_schools,
> city_latitudes and city_longitudes
> as javascript arrays in a separate js file
>
> For instance, like this
>
> //INSIDE JAVASCRIPT FILE
>
> 
>
> for(var i = 0; i < city_schools; i++){
>
>
> shouldn't this be:
>
> for(var i = 0; i < city_schools.length; i++){
>
>
>
> var lat = city_latitude[i];
> var long = city_longitude[i];
>
> googlemap.addmarker(lat, long);
>
> ..
> }
>
> 
> //END
>
> The whole point here is to add markers to an existing google map. Somehow
> the variables store the data from django into the js arrays, but
> I am unable to access them they way I want, so I was wondering if I need to
> do anything extra before manipulating the js arrays.
>
> Any suggestions would be welcomed
>
> Thanks, and again sorry for seeming rude/desperate, it was all my fault
>
>
>
>
> On Wed, Jun 15, 2011 at 10:45 AM, Ian Clelland <clell...@gmail.com> wrote:
>
>> On Wed, Jun 15, 2011 at 7:27 AM, jay K. <jay.developer2...@gmail.com>wrote:
>>
>>> Hello,
>>>
>>> I've posted my question before, but I believe I didn't provide enough
>>> detail. I intend to present my issue again, this time with more
>>> detail.
>>>
>>> Let me tell you that I am not a django developer, so I have very
>>> limited exposure to django. I just know html, css, javascript, jquery,
>>> php (also java and c++, so I'm familiar with object-oriented
>>> programming).
>>
>>
>>  ...
>>
>>
>>>
>>> Now, I manage to see the output of the javascript written above
>>> through Firefox's "View - Page Source" and it comes up like this
>>>
>>> //BEGINNING
>>> var city_schools = ["EC","St. Giles Central","St. Giles Highgate"];
>>>
>>> var city_latitudes = ["58","88","25"];
>>>
>>> var city_longtitudes = ["7","99","100"];
>>>
>>> //END
>>>
>>>
>>> I have a separate javascript file where I add the code for the google
>>> map. What I want to do is to be able to access each of the
>>> city_schools, city_latitudes, and city_longitudes and use its data to
>>> I can mark the schools inside a google map. It would be ideal if I
>>> could retrieve the info as if it was a js array, but any method that
>>> works is more than welcome
>>>
>>
>>  What you have is very clearly a JavaScript array, as you asked for the
>> first time you posed this question. In fact, by copying the code, you have
>> produced three JavaScript arrays.
>>
>>  What you haven't done, in this newest version of your question, is show
>> exactly what it is you want. We now have a rough idea of what your models
>> look like, but no idea at all why the JavaScript output you have pasted is
>> insufficient.
>>
>>  You say that you know JavaScript, so what you're going to have to do is
>> come up with a sample of what you'd *like* to see as the template output,
>> and hopefully we can help you with the Django template code to produce that
>> output.
>>
>>  [Also, it really doesn't help to be posting and reposting the same
>> question, just hours apart -- it just looks very impatient]
>>
>> --
>> Regards,
>> Ian Clelland
>> <clell...@gmail.com>
>>   --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
> --
> You received this message because you a

Re: storing django object into javascript variable/array

2011-06-15 Thread jay K.
Hello,

I apologize for seeming too impatient or rude, actually I'm a bit in a hurry
because I was given a project
and was told that it was urgent. I miscalculated how much time it was going
to take me to learn django

Anyway, what I want to do is to use the variables variables city_schools,
city_latitudes and city_longitudes
as javascript arrays in a separate js file

For instance, like this

//INSIDE JAVASCRIPT FILE



for(var i = 0; i < city_schools; i++){

var lat = city_latitude[i];
var long = city_longitude[i];

googlemap.addmarker(lat, long);

..
}


//END

The whole point here is to add markers to an existing google map. Somehow
the variables store the data from django into the js arrays, but
I am unable to access them they way I want, so I was wondering if I need to
do anything extra before manipulating the js arrays.

Any suggestions would be welcomed

Thanks, and again sorry for seeming rude/desperate, it was all my fault




On Wed, Jun 15, 2011 at 10:45 AM, Ian Clelland <clell...@gmail.com> wrote:

> On Wed, Jun 15, 2011 at 7:27 AM, jay K. <jay.developer2...@gmail.com>wrote:
>
>> Hello,
>>
>> I've posted my question before, but I believe I didn't provide enough
>> detail. I intend to present my issue again, this time with more
>> detail.
>>
>> Let me tell you that I am not a django developer, so I have very
>> limited exposure to django. I just know html, css, javascript, jquery,
>> php (also java and c++, so I'm familiar with object-oriented
>> programming).
>
>
> ...
>
>
>>
>> Now, I manage to see the output of the javascript written above
>> through Firefox's "View - Page Source" and it comes up like this
>>
>> //BEGINNING
>> var city_schools = ["EC","St. Giles Central","St. Giles Highgate"];
>>
>> var city_latitudes = ["58","88","25"];
>>
>> var city_longtitudes = ["7","99","100"];
>>
>> //END
>>
>>
>> I have a separate javascript file where I add the code for the google
>> map. What I want to do is to be able to access each of the
>> city_schools, city_latitudes, and city_longitudes and use its data to
>> I can mark the schools inside a google map. It would be ideal if I
>> could retrieve the info as if it was a js array, but any method that
>> works is more than welcome
>>
>
> What you have is very clearly a JavaScript array, as you asked for the
> first time you posed this question. In fact, by copying the code, you have
> produced three JavaScript arrays.
>
> What you haven't done, in this newest version of your question, is show
> exactly what it is you want. We now have a rough idea of what your models
> look like, but no idea at all why the JavaScript output you have pasted is
> insufficient.
>
> You say that you know JavaScript, so what you're going to have to do is
> come up with a sample of what you'd *like* to see as the template output,
> and hopefully we can help you with the Django template code to produce that
> output.
>
> [Also, it really doesn't help to be posting and reposting the same
> question, just hours apart -- it just looks very impatient]
>
> --
> Regards,
> Ian Clelland
> <clell...@gmail.com>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: storing django object into javascript array

2011-06-14 Thread jay K.
Hello,

I was given the following solution for storing a django object in a
javascript variable

//SOLUTION BEGINS HERE
1. Use a loop in the template:

var map_schools = [{% for school in city.school_set.all %}"{{
school|escapejs }}"{% if not forloop.last %},{% endif %}{% endfor %}];

You'll notice a couple of things there:
  - there is a "for" loop there, to iterate over all of the schools in the
result set
  - the quotes are present in the template, to make sure that the school
names are strings in the JavaScript
  - there is a test after every string to see if a "," is needed as a
separator (some javascript implementations are not very forgiving if you put
a comma after the last element)
  - Every school name is passed through the "escapejs" filter, to avoid
breaking out of the string.

//SOLUTION ENDS

Now, I was wondering how I can store the {{ school|escapejs }} into a
javascript array, and use the data inside school as if it were an array
element, like map_schools[1], map_schools[3] etc

Thanks

regards,

JK


On Fri, Jun 10, 2011 at 12:21 PM, Ian Clelland <clell...@gmail.com> wrote:

>
>
> On Fri, Jun 10, 2011 at 7:48 AM, jay K. <jay.developer2...@gmail.com>wrote:
>
>>
>> Hello,
>>
>> I am not a django developer, but I have a background on html, css,
>> javascript, jquery and php.
>>
>> I was wondering if you can help me with a question regarding django,
>> since I'm working on a website built on django (which was not started
>> by me)
>>
>> I want to store a django object into a javascript array. So far I have
>> this code:
>>
>> In my template file:
>>
>> 
>>
>> var map_schools = {{ city.school_set.all }};
>>
>> 
>>
>> Unfortunately the django object is not stored as desired, but instead
>> it gets stored like the following:
>>
>> var map_schools = [School: Oxford, Eckersley]
>>
>>
> [] is the printable representation of your query
> set (what you get when you call city.school_set.all()) -- what you need to
> do is build up a JavaScript literal that you can insert into the code. There
> are two fairly simple ways of doing this:
>
> 1. Use a loop in the template:
>
> var map_schools = [{% for school in city.school_set.all %}"{{
> school|escapejs }}"{% if not forloop.last %},{% endif %}{% endfor %}];
>
> You'll notice a couple of things there:
>   - there is a "for" loop there, to iterate over all of the schools in the
> result set
>   - the quotes are present in the template, to make sure that the school
> names are strings in the JavaScript
>   - there is a test after every string to see if a "," is needed as a
> separator (some javascript implementations are not very forgiving if you put
> a comma after the last element)
>   - Every school name is passed through the "escapejs" filter, to avoid
> breaking out of the string.
>
> 2. Construct a JSON string in python:
>
> In your view, do something like this:
>
> from django.utils.simplejson import dumps
> ...
> school_list = dumps([school.name for school in city.school_set.all()])
>
> and then add school_list to the context variables that are passed to the
> template. Then in the template, you can just use {{ school_list }}, and it
> will be a properly formatted JavaScript array.
>
>
>
> --
> Regards,
> Ian Clelland
> <clell...@gmail.com>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



storing django object into javascript array

2011-06-10 Thread jay K.

Hello,

I am not a django developer, but I have a background on html, css,
javascript, jquery and php.

I was wondering if you can help me with a question regarding django,
since I'm working on a website built on django (which was not started
by me)

I want to store a django object into a javascript array. So far I have
this code:

In my template file:



var map_schools = {{ city.school_set.all }};



Unfortunately the django object is not stored as desired, but instead
it gets stored like the following:

var map_schools = [School: Oxford, Eckersley]

I am unable to work with the javascript array. Right now this piece of
code is commented out because enabling it prevents the rest of the js
code from running properly

Any suggestions are welcome

Thanks,

Regards,

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



using a models fields

2011-04-04 Thread jay K.
Hello,

I got a couple of fields from a model I want to use

so the models.py looks like this
*
class XZY():

   latitude = models.CharField()
   longitude = models.CharField(.)
   zoomlevel = models.CharField()*

I want to retrieve the data inside latitude, longitude and zoomlevel
to be able to create a static map for different locations, using google maps

How can I retrieve the fields data?

thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



creating a URL from scratch

2011-04-04 Thread jay K.
Hello

I have a website with www.xyz.com/subpage

I want to change the name of the subpage

how do you do it?

thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



multilingual django

2011-04-04 Thread jay K.
Hello,

Currently I have 2 folders, one for german and english language
translations, respectively

The translations are inside a django.po file for each language.

I want to add a new language

How can I do it?

thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: south for django

2011-03-31 Thread jay K.
I think i found the source of all problems

I am not a python expert, so I was wondering if anybody can tell me what
this code means

// beginning of code

*from django.db import models


class TranslationForeignKey(models.ForeignKey):
"""
"""
pass
*
// end of code

This piece of code has been generating an error when executing the *python
manage.py schemamigration myApp --initial* command in South

If the above code has doesn't do anything, I will comment it out



On Thu, Mar 31, 2011 at 5:04 PM, jay K. <jay.developer2...@gmail.com> wrote:

>
> Hello,
>
> I've been using south to migrate a database
>
> I followed all the commands to make the migrations in south (--initial and
> --auto), all
> of this, after making my desired changes in modes.py
>
> but when I refresh my page I still get a "Error 505" messages
>
> I've checked spelling mistakes etc but found nothing
>
> Any other suggestions would be great
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



south for django

2011-03-31 Thread jay K.
Hello,

I've been using south to migrate a database

I followed all the commands to make the migrations in south (--initial and
--auto), all
of this, after making my desired changes in modes.py

but when I refresh my page I still get a "Error 505" messages

I've checked spelling mistakes etc but found nothing

Any other suggestions would be great

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: south for django

2011-03-31 Thread jay K.
that's weird, because I keep getting the same error

the field that I'm using is not custom (models.TextField)

it may be located somewhere else


On Thu, Mar 31, 2011 at 4:47 PM, Shawn Milochik  wrote:

> You don't need that inspection feature for fields known to Django. Just
> custom types.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: south for django

2011-03-31 Thread jay K.
All I did to change my models.py, was to add the following line

*map_text = models.TextField( 'Map text', blank = True, null = False,
help_text = 'text on the subpage "map"')*

As you can see, I intend to add a new text area in my models.py

At the bottom of the page, I type this code

*from south.modelsinspector import add_introspection_rules
add_introspection_rules([], ["^destinations\.map_text"])*

The name of my application is "destinations" and the new field is called
"map_text"

Unfortunately it stills gives me the same error message


On Thu, Mar 31, 2011 at 4:37 PM, Shawn Milochik  wrote:

> Are you typing your app name in camelCase? Try all-lower.
>
> Are you using any model field types other than the ones that come with
> Django?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



south for django

2011-03-31 Thread jay K.
hello,

I've downloaded and installed south successfully to manage changes
with my models.py file

I type the following command

*python manage.py schemamigration myApp --auto*

then, get the following message

*You cannot use --auto on an app with no migrations. Try --initial.*

So I do as stated, with the command: *python manage.py schemamigration myApp
--initial*, but get the following message:

*Cannot freeze field*

what's wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: new text area in django admin page

2011-03-31 Thread jay K.
thanks, it works fine!!

I can't believe I spent 2 days trying to sort out my database issues

greatly appreciate your advice :)

On Thu, Mar 31, 2011 at 3:04 PM, Shawn Milochik <sh...@milochik.com> wrote:

>
> On Mar 31, 2011 1:55 PM, "jay K." <jay.developer2...@gmail.com> wrote:
> >
> > Thanks for the advice,
> >
> > But I am not exactly migrating databases, just modifying an existing one
> >
> >
> And that's exactly what South is for.
>
> > On Thu, Mar 31, 2011 at 2:50 PM, Shawn Milochik <sh...@milochik.com>
> wrote:
> >>
> >> On Thu, Mar 31, 2011 at 1:39 PM, jay K. <jay.developer2...@gmail.com>
> wrote:
> >>
> >> 
> >> >
> >> >
> >> > So what am I doing wrong?
> >> >
> >>
> >> Use South for your database migrations:
> >> http://south.aeracode.org/
> >>
> >> Otherwise you have to write raw SQL statements to modify the database,
> >> or delete the entire database and use syncdb to re-create it to match
> >> you model.
> >>
> >> I think South is the best of those options.
> >>
> >> Shawn
> >>
> >> --
> >>
> >> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> >> To post to this group, send email to django-users@googlegroups.com.
> >> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> >> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> >>
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: new text area in django admin page

2011-03-31 Thread jay K.
Thanks for the advice,

But I am not exactly migrating databases, just modifying an existing one


On Thu, Mar 31, 2011 at 2:50 PM, Shawn Milochik <sh...@milochik.com> wrote:

> On Thu, Mar 31, 2011 at 1:39 PM, jay K. <jay.developer2...@gmail.com>
> wrote:
>
> 
> >
> >
> > So what am I doing wrong?
> >
>
> Use South for your database migrations:
> http://south.aeracode.org/
>
> Otherwise you have to write raw SQL statements to modify the database,
> or delete the entire database and use syncdb to re-create it to match
> you model.
>
> I think South is the best of those options.
>
> Shawn
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: new text area in django admin page

2011-03-31 Thread jay K.
that right, I've provided a very vague question

I have to modify an existing models.py file. What I basically want to do is
to add
a new Text Area in the django admin page so I can add a new subpage.

Here is what I do step by step

1) I open models.py and insert the following code:

// start of code

*class City( models.Model ):

   
   class Translation (multilingual.Translation):
 ...
 climate_text = models.TextField ( 'Climate text', blank = True,
null = False, help_text = 'text on the subpage "clima"' )
 map_text = models.TextField( 'Map text', blank = True, null =
False, help_text = 'text on the subpage "map"')
*

// end of code

The code in bold and italics is the text area I want to add to my models.py.

Then, I update my database by executing the following code:

python manage.py sql *my-application*

However, when I refresh my website, I get an *Error 505. *This error appears
only in the pages that use
the models.py file I've modified, so the rest of the website works fine.

So what am I doing wrong?

Thanks



On Thu, Mar 31, 2011 at 11:58 AM, Daniel Roseman <dan...@roseman.org.uk>wrote:

> On Thursday, March 31, 2011 3:35:15 PM UTC+1, jay K. wrote:
>>
>> hello
>>
>> how can i add a new text field in the django admin area
>>
>> i want to create a new subpage
>>
>> thanks
>>
>>
>>
> Before asking a question, have a think about what you actually want to ask.
> Then think about whether you're providing all the information needed for
> anyone to answer the question. Now look at what you've written. Do you
> seriously, honestly think that anyone will have the remotest idea what
> you're asking, or be able to even start answering you?
>
> Now try again.
> --
> DR.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



new text area in django admin page

2011-03-31 Thread jay K.
hello

how can i add a new text field in the django admin area

i want to create a new subpage

thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: new subpage in django

2011-03-30 Thread jay K.
hello,

what i'm trying to do is to create a subpage for a website written in django

e.g.

for http://www.xzy.com/subpage I'd like to add 'subpage2', so it would look
like

http://www.xzy.com/subpage/subpage2

how do i do that?

thanks

On Wed, Mar 30, 2011 at 4:20 PM, Xavier Ordoquy <xordo...@linovia.com>wrote:

>
> Le 30 mars 2011 à 21:16, jay K. a écrit :
>
> > Hello,
> >
> > How do you create a new subpage in django?
> >
> > thanks
>
> Hi,
>
> What do you mean or I'd rather ask, what are you trying to do ?
>
> Regards,
> Xavier.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



new subpage in django

2011-03-30 Thread jay K.
Hello,

How do you create a new subpage in django?

thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: manage.py command not found

2011-03-30 Thread jay K.
hi, Shawn

I finally managed to get python manage.py shell to work, by commenting
out those INSTALLED_APPS that had an issue with 'import x'

it turns out that 'import x' was the problem.

do you have any suggestions to fix 'import x'?

thanks


On Wed, Mar 30, 2011 at 12:25 PM, jay K. <jay.developer2...@gmail.com>wrote:

> Hello, Shawn
>
> I type python manage.py shell in my project directory and get the following
> error
>
> Error: No module named xx
>
> regards
>
>
> On Wed, Mar 30, 2011 at 11:52 AM, Shawn Milochik <sh...@milochik.com>wrote:
>
>> Check the permissions on manage.py. I'm guessing it's not executable.
>>
>> Either use chmod +x on manage.py or execute it with Python: python
>> manage.py.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: manage.py command not found

2011-03-30 Thread jay K.
Hello, Shawn

I type python manage.py shell in my project directory and get the following
error

Error: No module named xx

regards

On Wed, Mar 30, 2011 at 11:52 AM, Shawn Milochik  wrote:

> Check the permissions on manage.py. I'm guessing it's not executable.
>
> Either use chmod +x on manage.py or execute it with Python: python
> manage.py.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



manage.py command not found

2011-03-30 Thread jay K.
Hello,

I am following the tutorial at
http://south.aeracode.org/docs/installation.html#installation-configure in
order
to install South.

I've installed it successfully and modified INSTALLED_APPS so
it includes 'south', in the settings.py

now I execute the command: ./manage.py shell inside my current project, but
get a "permission denied" message,
so I execute the same command, this time with sudo, so sudo ./manage.py ,
but it tells me that
./manage.py command not found

can anyone explain me what's wrong?

thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



need to change models

2011-03-30 Thread jay K.

Hello,

I've been struggling for quite a white with this

whenever i change my models.py file by adding a new text area
I get a 'error 500 internal server error'

besides i keep getting an error whenever i try to syncdb my database

can anyone please explain what i'm doing wrong?

thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: how do you build an html website in python?

2010-04-17 Thread jay
Codecub,

Actually his blog is a web application.

Maybe this tutorials will help

http://www.webmonkey.com/2010/02/Get_Started_With_Django/

It will show you how to create a small blog, which is exactly what that
particular site is, just on a larger scale. It will also introduce you to
some basic concepts in Django.

Happy coding!

Jay

On Sat, Apr 17, 2010 at 3:27 PM, codecub <groilin...@gmail.com> wrote:

> that's really unhelpful dude, i read through that and it doesnt even
> help at all thats for software/applications not websites
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django Tutorial 1.1: Viewing SQLite3 tables

2010-01-09 Thread Jay Godse
If you want to get comfortable with SQLite, try some of the tutorials
at:

http://www.squidoo.com/sqlitehammer
http://www.squidoo.com/sqlitetutorial
http://www.squidoo.com/sqliteprogramming

There are also videos at

http://www.youtube.com/user/Jaynonymous1

which you  may find useful.

Cheers,   Jay

On Jan 7, 6:50 pm, wormser17 <matt.lo...@gmail.com> wrote:
> Hello. First, some quick context about my approach (I am not a
> programmer):
>
> This is the directory where I installed Django: /Library/Python/2.6/
> site-packages/django
> This is my project directory: /Users/mlooby/Sites/mysite
>
> Situation
> 1) I created a SQLite3 database, named "project.db," by editing
> settings.py with the following:
>
>         DATABASE_ENGINE = 'django.db.backends.sqlite3'
>         DATABASE_NAME = '/Users/mlooby/Sites/mysite/project.db'
>
> 2) I created tables for the apps under INSTALLED_APPS by running:
>
>         python manage.py syncdb
>
> 3) Next, I created my superuser account.
>
> 4) The tutorial then states the following:
>
>         "If you're interested, run the command-line client for your database
> and type \dt (PostgreSQL), SHOW TABLES; (MySQL), or .schema(SQLite) to
> display the tables Django created."
>
> My Issue: I cannot get SQLite to display the tables that Django just
> created after entering/running the following in a new Terminal shell:
>
>         mlooby$ sqlite3
>         SQLite version 3.6.12
>         Enter ".help" for instructions
>         Enter SQL statements terminated with a ";"
>         sqlite> .schema
>         sqlite> .schema;
>         unknown command or invalid arguments:  "schema;". Enter ".help" for
> help
>         sqlite> .schema project.db
>         sqlite> .schema project
>         sqlite> .schema project;
>         sqlite>
>
> I've reviewedwww.sqlite.comand some related Google Groups, but my
> searches were fruitless. Does anyone know why I can't get SQLite to
> display the tables?
>
> Finally, please let me know if I've omitted any information that would
> help identify the issue.
>
> Thank you.
-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Fwd: InlineModelAdmin paging

2009-11-02 Thread Jay Coulter
Hi all,



Django documentation states that the inlines inherit same functionality as
modeladmin so I want to enable paging on an inline but it doesn’t appear to
work.



This is the code for my inline, is the syntax incorrect??



class CustomerCardsInline(admin.TabularInline):

model = CustomerCards

verbose_name = 'Account Cards'

ordering = ('cc_number',)

extra = 0

list_per_page  = 50

fields = ['account', 'cc_number', 'cc_effective_dt',
'cc_expire_dt', 'cc_closed_dt', 'cc_frozen_dt', 'cc_card_printed']



Thanks!



Jay

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Keeping request.GET keys

2009-09-30 Thread Jay

I do not quite follow your statement. Do you mean redirect
(request.get_full_path())?

On Sep 30, 10:47 pm, "bax...@gretschpages.com" 
wrote:
> I'm passing through a testcookie function and would like to keep the
> request.GET keys
>
> so if the original URL is /testcookie/?foo=1=2
>
> When testcookie works, I want to redirect to the new URL with foo and
> bar intact. How?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Help on query

2009-09-30 Thread Jay

Use the aggregation way:
user.report_set.annotate(count = Count('report_set')).filter(count =
1)

On Sep 29, 10:39 pm, luismmontielg  wrote:
> yeah, something like that is what I want, but to me, that is not the
> best way of doing it ...
> Maybe there's a simpler way?
>
> thanks in advance
>
> On Sep 29, 8:46 am, sunn  wrote:
>
> > This should hopefully work as well
> > user_reports = user.report_set.exclude(users__id__lt = user.id,
> > users_id_gt = user.id)
>
> > On Sep 29, 4:32 pm, sunn  wrote:
>
> > > If you don't want to write SQL I think the easiest way is to combine
> > > two querysets
>
> > > # You can combine queries with & and |.>>> s1 = 
> > > Article.objects.filter(id__exact=1)
> > > >>> s2 = Article.objects.filter(id__exact=2)
> > > >>> s1 | s2
>
> > > [, ]>>> 
> > > s1 & s2
>
> > > []
>
> > > Fromhttp://www.djangoproject.com/documentation/models/basic/
>
> > > On Sep 29, 3:58 pm, luismmontielg  wrote:
>
> > > > that brings me all reports that have that user, but also the reports
> > > > that have user and user2.. i want only the reports that have 1 user
> > > > and id is equal to user.id
>
> > > > On Sep 29, 4:35 am, Joshua Russo  wrote:
>
> > > > > oh ok, so just use the filter(user_id = user.id)
>
> > > > > On Tue, Sep 29, 2009 at 12:21 AM, luismmontielg 
> > > > > wrote:
>
> > > > > > Actually there it is,
>
> > > > > > users = models.ManyToManyField(User, symmetrical=True)
>
> > > > > > but I want to filter only the reports that contain only this user, 
> > > > > > or
> > > > > > exclude the ones that do not have the user.
>
> > > > > > Thanks again
>
> > > > > > On 28 sep, 20:16, luismmontielg  wrote:
> > > > > > > sorry forgot to mention its a many to many relation so a report 
> > > > > > > can
> > > > > > > have multiple users
>
> > > > > > > On Sep 28, 4:29 pm, Joshua Russo  wrote:
>
> > > > > > > > On Mon, Sep 28, 2009 at 7:55 PM, luismmontielg <
> > > > > > luismmonti...@gmail.com>wrote:
>
> > > > > > > > > Hello,
> > > > > > > > > I have my models like this...
>
> > > > > > > > > class Report(models.Model):
> > > > > > > > >    title = models.CharField(max_length=50, blank=True)
> > > > > > > > >    users = models.ManyToManyField(User, symmetrical=True)
> > > > > > > > >    categories = models.ManyToManyField("Category",
> > > > > > > > > through='ReportDetail', \
> > > > > > > > >                 symmetrical=True)
>
> > > > > > > > > I would like to get all reports from 1 user, but that only 
> > > > > > > > > contain
> > > > > > > > > that user
>
> > > > > > > > > I was looking for ne, not equals, but its removed, I cant do 
> > > > > > > > > it with
> > > > > > > > > the exclude:
> > > > > > > > > I want to make something like this
> > > > > > > > > user = User.objects.get(pk=1)
> > > > > > > > > user_reports = user.report_set.exclude(users__id__NOTEQUAL = 
> > > > > > > > > user.id
> > > > > > )
>
> > > > > > > > > how can I achieve this?
>
> > > > > > > > I'm not sure I completely follow, but user.report_set only 
> > > > > > > > gives you
> > > > > > reports
> > > > > > > > for the associated user, and it seems like that is what you 
> > > > > > > > want. You
> > > > > > don't
> > > > > > > > need any further filters or excludes.
>
> > > > > > > > For future reference:
> > > > > > > >     exclude(user_id__ne = user.id)
> > > > > > > > is the same as
> > > > > > > >     filter(user_id = user.id)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Passing parent with multiple childs from View to HTML

2009-09-27 Thread Jay

In Django template, you can make methed call. So you can pass the
auther object to the template, then
  {% for book in auther.books.all %}

{% for section in book.sections.all %}
  
{% end for %}
  {% endfor %}

The ordering is using the definition in the Model Meta class.
auther.books and book.sections is my assumption for your FK related
names.

If you want to change the ordering, maybe a template tag is more
suitable for your purpose.

And about Form, I'm not clear what you want? A whole page with forms
for authors, books and sections? If so, you can have a look at
formset, specially the inlineformset. (http://docs.djangoproject.com/
en/dev/topics/forms/modelforms/#inline-formsets) If you just want to
get a simple form for inline editing in the author-book-section view
page, using js to generate it is my only choice

On Sep 27, 1:39 am, PlanetUnknown  wrote:
> I have been studying the modalforms & inline formsets but am not able
> to wrap my head around my composite objects, and want to see how
> things are done in django world -
>
> I have this hierarchical model
> "Author" has many "Books"
>   Each "Book" has 4 Sections -> Section-01, Section-02, Section-03 &
> Section-04
>     Each "Section" has number of attributes.
>
> I want to show all books on its own line
> If a book is clicked, I'll expand a hidden DIV, which will show the 4
> sections of that book.
> Like so -
> Book-1 | Short Description of book (when clicked, shows the below
> section)
> Section-01 | Section-02 | Section-04 | Section-04 |
> Book-2 | Short Description of book (when clicked, shows the below
> section)
> Section-01 | Section-02 | Section-04 |...
> ...
> ..
> .
>
> I have all the HTML code figured out, using jquery to show/hide Divs.
>
> Question - I'm confused as to how I can pass all this data from the
> view to the HTML page and then render so that when user edits
> something, things are passed back, in the form of Forms.
>
> But is there a way to pass this whole composite object - Author+Books
> +AllSectionsInBook in one go.
>
> Would be great if you could point me in a direction or how you solved
> this composition problem.
> Thanks a lot in advance !
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to customize field to get the correct python value?

2009-09-26 Thread Jay

hi all,
I paste the snippet on DjangoSnippet now, and you can see what I meant
via http://www.djangosnippets.org/snippets/1741/.

This code is perfect if I get the money type from a full-fetched model
instance, but the raw integer representation will be shown when trying
aggregation or partly fetch. (values(), only(), .etc.) I cannot find
any material to make it smarter. So I wonder if I missed something or
it is just a Django bug as to_python is not called?

BRs/Jay

On 9月25日, 上午10时39分, "jay.sh...@gmail.com" <jay.sh...@gmail.com> wrote:
> Hi there,
>
> I have a question on customize the db field. For this field, I want to
> save integers in db, but want them to be my custom class when they are
> used in Python code. In Django docs, it's said that I should set the
> __metaclass__ to be models.SubfieldBase to make to_python() work. I
> tried it and succeeded when all data of one db row are fetched.
>
> But I then found that if I use query method like values(), values_list
> () or only(), the data of my custom field will not be converted into
> my desired type but the raw db integer. Then I tried Django's own
> DateField, it works OK also in such scenario. So I think there must be
> something I missed.
>
> Could you help on this question? I cannot find more materials to move
> on, so I'm very eager to get your help. Many thanks!
>
> --http://j-lite.net
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: custom authentication backend not being used...

2009-08-19 Thread Jay

Sorry, nevermind.  I finally figured this out right after I posted
this.

On Aug 19, 12:48 pm, Jay <krustymon...@gmail.com> wrote:
> First off, I'm using Django 1.1.
>
> I've been having problems getting my custom authentication backend to
> work, specifically in the "admin" site.
>
> I've been using this page as guide to put together an auth backend
> that uses my subclass of the User model to authenticate.
>
> http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-mod...
>
> I will post all code below, but for the moment here is the problem.
> I'm trying to log into the django admin site and I'm getting an
> exception on "check_password()" that shows me that the admin login
> system is using the User.check_password() rather than my subclass'
> check_password(). I'm working with an existing database here and I
> don't want to change my password hashing scheme if I don't have to.
> The thing that's driving me crazy is that the admin site doesn't seem
> to be using my User subclass.
>
> Is there something I'm forgetting/missing here?
>
> Thanks for any help anyone has to offer.
>
> Here is all relevant code (if there is something I'm forgetting, do
> let me know):
>
> settings.py
> --
>
> ...
> ...
> AUTHENTICATION_BACKENDS = (
>     'mf_pyweb.auth_backends.EmUserModelBackend' ,
> )
> CUSTOM_USER_MODEL = 'mfmain.EmUser'
>
> INSTALLED_APPS = (
>     'django.contrib.auth',
>     'django.contrib.contenttypes',
>     'django.contrib.sessions',
>     'django.contrib.sites',
>     'django.contrib.admin',
>     'mf_pyweb.mfmain',
>     'mf_pyweb.mfadmin',
> )
>
> --
>
> auth_backends.py
> --
>
> from django.conf import settings
> from django.contrib.auth.backends import ModelBackend
> from django.core.exceptions import ImproperlyConfigured
> from django.db.models import get_model
>
> class EmUserModelBackend(ModelBackend):
>     def authenticate(self , username=None , password=None ,
> email=None):
>         try:
>             user = None
>             if email or '@' in username:
>                 user = self.user_class.objects.get(email=email)
>             elif username:
>                 user = self.user_class.objects.get(username=username)
>             else:
>                 return None
>             if user.check_password(password):
>                 return user
>         except:
>             return None
>
>     def get_user(self , user_id):
>         try:
>             return self.user_class.objects.get(pk=user_id)
>         except:
>             return None
>
>     def get_user(self , user_id):
>         try:
>             return self.user_class.objects.get(pk=user_id)
>         except:
>             return None
>
>     @property
>     def user_class(self):
>         if not hasattr(self , '_user_class'):
>             self._user_class = get_model(
>                     *settings.CUSTOM_USER_MODEL.split('.' , 2))
>             if not self._user_class:
>                 raise ImproperlyConfigured('Could not get custom user
> model')
>         return self._user_class
>
> --
>
> mfmain/models.py:
> --
>
> ...
> ...
> class EmUser(User):
>     domain = models.ForeignKey(Domain , db_index=True ,
> db_column='dom_id')
>     report_freq = models.PositiveIntegerField()
>     report_time = models.DateTimeField()
>     userdir = models.CharField(max_length=1024)
>
>     objects = UserManager()
>
>     def set_password(self , raw_pass):
>         self.password = getPHash(raw_pass)
>
>     def check_password(self , raw_pass):
>         salt , hash = self.password.split('$')
>         return (getPHash(raw_pass , salt , False) == hash)
>
>     def __str__(self):
>         return self.email
>
>     class Meta:
>         db_table = 'users'
>         ordering = ['email' , 'username' , 'date_joined']
>         verbose_name_plural = 'users'
> ...
> ...
> --
>
> --
> Jay Deiman
>
> \033:wq!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



custom authentication backend not being used...

2009-08-19 Thread Jay

First off, I'm using Django 1.1.

I've been having problems getting my custom authentication backend to
work, specifically in the "admin" site.

I've been using this page as guide to put together an auth backend
that uses my subclass of the User model to authenticate.

http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/

I will post all code below, but for the moment here is the problem.
I'm trying to log into the django admin site and I'm getting an
exception on "check_password()" that shows me that the admin login
system is using the User.check_password() rather than my subclass'
check_password(). I'm working with an existing database here and I
don't want to change my password hashing scheme if I don't have to.
The thing that's driving me crazy is that the admin site doesn't seem
to be using my User subclass.

Is there something I'm forgetting/missing here?

Thanks for any help anyone has to offer.

Here is all relevant code (if there is something I'm forgetting, do
let me know):

settings.py
--

...
...
AUTHENTICATION_BACKENDS = (
'mf_pyweb.auth_backends.EmUserModelBackend' ,
)
CUSTOM_USER_MODEL = 'mfmain.EmUser'

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'mf_pyweb.mfmain',
'mf_pyweb.mfadmin',
)


--

auth_backends.py
--

from django.conf import settings
from django.contrib.auth.backends import ModelBackend
from django.core.exceptions import ImproperlyConfigured
from django.db.models import get_model

class EmUserModelBackend(ModelBackend):
def authenticate(self , username=None , password=None ,
email=None):
try:
user = None
if email or '@' in username:
user = self.user_class.objects.get(email=email)
elif username:
user = self.user_class.objects.get(username=username)
else:
return None
if user.check_password(password):
return user
except:
return None

def get_user(self , user_id):
try:
return self.user_class.objects.get(pk=user_id)
except:
return None

def get_user(self , user_id):
try:
return self.user_class.objects.get(pk=user_id)
except:
return None

@property
def user_class(self):
if not hasattr(self , '_user_class'):
self._user_class = get_model(
*settings.CUSTOM_USER_MODEL.split('.' , 2))
if not self._user_class:
raise ImproperlyConfigured('Could not get custom user
model')
return self._user_class


--

mfmain/models.py:
--

...
...
class EmUser(User):
domain = models.ForeignKey(Domain , db_index=True ,
db_column='dom_id')
report_freq = models.PositiveIntegerField()
report_time = models.DateTimeField()
userdir = models.CharField(max_length=1024)

objects = UserManager()

def set_password(self , raw_pass):
self.password = getPHash(raw_pass)

def check_password(self , raw_pass):
salt , hash = self.password.split('$')
return (getPHash(raw_pass , salt , False) == hash)

def __str__(self):
return self.email

class Meta:
db_table = 'users'
ordering = ['email' , 'username' , 'date_joined']
verbose_name_plural = 'users'
...
...
------


--
Jay Deiman

\033:wq!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Weird transaction issue in apache?

2009-06-25 Thread Jay Wineinger

I have an Order model and a Payment model (which FK's to Order as
"payments").  I have a handler for post_delete on Payment which sends
a custom signal which may do some updating on Order.  The problem I'm
seeing is that when I delete a Payment, the custom signal handler can
still query for the deleted payment.  It seems to work fine and as
expected through the shell but when run via apache (mod_wsgi/python2.6/
mysql5 with innodb) my handler cannot update because the payment that
should be deleted is still showing up in queries.

Here is the whole thing with models,views,urls, shell test, and apache
test. http://dpaste.com/hold/59869/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



nested dereferencing of values within value calls in templates

2009-03-17 Thread Jay Deiman

Ok, I'm wondering if there is any way to do this.  Let me give a couple 
of ***simplified*** examples to clarify what I'm talking about here.  I 
make "simplified" previously apparent because what I'm actually trying 
to do is much more complicated than these examples.

View code:
==

return render_to_response('/path/to/html' , {
 'foo': {'bar': 'eggs'} ,
 'spam': 'bar' ,
})

==

Now, in my template I want to access {{ foo.bar }} via the dereferenced 
*value* of "spam".  Essentially, though I know this doesn't work, it 
would look like this:

Template code:
==

Output "eggs": {{ foo.{{ spam }} }}

==

Is there any way at all to do something like that?

Here is another example, though I already know a workaround for it (at 
the bottom), it seems like there should be a better way.

View code:
==

list1 = ['one' , 'two' , 'three']
list2 = [1 , 2 , 3]
return render_to_response('/path/to/html' , {
 'list1': list1 ,
 'list2': list2 ,
})

==

In the template, while looping through "list1", I want to be able to 
directly access by index the corresponding value in "list2".  I know the 
following doesn't work, but again, it seems like there should be a way 
to do this.  Note that this is a greatly simplified version of what I'm 
actually trying to accomplish!!

Template code:
==

{% for item in list1 %}
   {{ item }}: {{ list2.{{ forloop.counter0 }} }}
{% endfor %}

==

Now, I know I can accomplish the above with a highly inefficient nested 
loop:

Template code:
==

{% for item in list1 %}
   {{ item }}:
 {% for item2 in list2 %}
   {% ifequal forloop.counter0 forloop.parentloop.counter0 %}
 {{ item2 }}
   {% endifequal %}
 {% endfor %}
{% endfor %}

==

Essentially, is there any way of performing a nested dereference 
operation like these?

Jay

-- 
Jay Deiman

\033:wq!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



  1   2   3   4   5   >