Backend In Web Programming | PHP, Laravel, ASP.NET, Django

2023-03-06 Thread PATRICK OFOSU AGYEMANG
Hi everyone, currently looking for a remote challenging opportunity for my 
next career.

Kindly find attached my CV.

Let me know if any help comes up.

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/a5314098-4f11-4a64-bcdd-08e27515bc88n%40googlegroups.com.


PAT_RICK_AGYE_MANG_CV.pdf
Description: Adobe PDF document


Re: DRF and React - request.user is "Anonymous user"

2022-09-19 Thread Jackson Patrick
Do i need to pass token in headers?

On Tue, 20 Sep, 2022, 9:44 am Mohammad Ehsan Ansari, 
wrote:

> make sure you have listed auth as jwt and added permission class for
> authentication
>
> On Monday, 12 September 2022 at 09:52:22 UTC+5:30 jacks...@gmail.com
> wrote:
>
>> I have used simple JWT for authentication and i have successfully logged
>> in and am getting tokens also. But when i do a request.user in backend i
>> get "Annonymous user".
>> Tried passing Authorization header in axios post in FE REACT but it
>> throws error. Am setting both refresh and access in a state variable and
>> store it in local storage . Am really new into this and I'm totally stuck
>> here.
>>
>> All i did was to temporarily solve the issue is to send the user id from
>> frontend to backend and by the way it's a bad practice.
>>
>> So please help me out in this guys.
>>
> --
> 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/1f69ceeb-7294-4d51-a25c-b1a222c534d0n%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/CAG2dbb0KZ79AbF35cuyq9Rk%2BkC1v8-YwCJeQN5xFrwvG%3DgSnNw%40mail.gmail.com.


DRF and React - request.user is "Anonymous user"

2022-09-11 Thread Jackson Patrick
I have used simple JWT for authentication and i have successfully logged in
and am getting tokens also. But when i do a request.user in backend i get
"Annonymous user".
Tried passing Authorization header in axios post in FE REACT but it throws
error. Am setting both refresh and access in a state variable and store it
in local storage . Am really new into this and I'm totally stuck here.

All i did was to temporarily solve the issue is to send the user id from
frontend to backend and by the way it's a bad practice.

So please help me out in this guys.

-- 
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/CAG2dbb0r4%3DwLgw2zBMyXxSkaOXjRjCbPk-zZf6V5z5uxNyOfHQ%40mail.gmail.com.


DRF - request.user returns None

2022-08-26 Thread Jackson Patrick
I am trying to get user using request.user and when printing gets None and
in console it shows
"Annoymous user". and am using simple jwt

-- 
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/CAG2dbb2N14X_5vcBqTjf%2Bji%2Bxq41x2i8dta2865fw_v5Ze5LpA%40mail.gmail.com.


Quick question for web hosting production

2021-10-08 Thread Patrick Luke Astrero
I want to ask a quick question guys that, is it possible to host 2 apps in 
one cloud service? like for example, angular for the front end and django 
for the backend? and they would use one ip address right but on a different 
port?


-- 
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/ca218ee3-0953-4eb6-b3c6-26c1473a21ebn%40googlegroups.com.


testing class based generic views

2020-10-24 Thread Patrick Carra
Can anyone point me towards a tutorial for how to test a CreateView 
function? 

-- 
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/76d377cf-a6e2-46ec-b4ee-5d1279988b32n%40googlegroups.com.


Re: How to redirect to a new view other than what is defined in get_absolute_url

2020-10-01 Thread Patrick Carra
Sorry the pictures I used to show my code did not work

#tickets/models.py
from django.db import models
from django.urls import reverse
from menu.models import Menu_Item
from home.models import tableTable
# Create your models here.
class ordersTable(models.Model):
order_type = [
('dine-in', 'dine-in'),
('carryout', 'carryout'),
('delivery', 'delivery'),
]   
status = [
('needDrinks', 'Needs Drinks'),
('needToOrder', 'Needs to Order'),
('orderTaken', 'Order Taken'),
('sentToKitchen', 'Sent To Kitchen'),
('sentBacktoServer', 'Sent to Server'),
('orderCompleted', 'Order Completed'),
('delivered', 'Delivered'),
]
customerName = models.CharField(max_length=255)
orderType = models.CharField(max_length=10, choices=order_type, 
default='dine-in')
status = models.CharField(max_length=255, choices=status, 
default='needsDrinks')
timeOrdered = models.DateField(null=True, blank=True)
timeCompleted = models.DateField(null=True, blank=True)
table = models.ForeignKey(tableTable, on_delete=models.CASCADE, 
to_field='id', db_column='table', null=True, blank=True)
total = models.DecimalField(max_digits = 7, decimal_places=2, 
null=True, blank=True)
def __str__(self):
return str(self.id) + " - " + self.customerName + " - " + 
self.orderType 
def get_absolute_url(self):
return reverse('viewOrder', args=[str(self.id)])
class itemTable(models.Model):
menuItem = [
('',''),
]
status = [
('waiting', 'waiting'),
('preparing', 'preparing'),
('completed', 'completed'),
('delivered', 'delivered'),
]
order = models.ForeignKey(ordersTable, on_delete=models.CASCADE, 
to_field='id', db_column='order')
menuItem = models.ForeignKey(Menu_Item, on_delete=models.CASCADE, 
to_field='id', db_column='menuItem', default=1)
specialInstructions = models.CharField(max_length=255, blank=True, 
null=True)
allergies = models.CharField(max_length=255, blank=True, null=True)
server = models.CharField(max_length=255, blank=True, null=True)
orderTime = models.DateField(blank=True, null=True)
completionTime = models.DateField(blank=True, null=True)
status = models.CharField(max_length=255, choices=status, blank=True, 
null=True)
def __str__(self):
return str(self.order) + " - " + str(self.menuItem)
def get_absolute_url(self):
return reverse('viewOrder', args=[str(self.order.id)])

#tickets/views.py
from django.shortcuts import render
from django.views.generic import (CreateView, DetailView, ListView, 
UpdateView, DeleteView)
from django_tables2.views import SingleTableMixin
from django_filters.views import FilterView
from . models import ordersTable, itemTable
from . tables import searchOrdersTable
from . filters import searchOrdersFilter
# Create your views here.
class addCustomerOrder(CreateView):
model = ordersTable
fields = ['customerName', 'orderType']
class searchOrders(SingleTableMixin, FilterView):
model = ordersTable
table_class = searchOrdersTable
template_name = 'tickets/searchOrders.html'
filterset_class = searchOrdersFilter
class viewOrder(DetailView):
model = ordersTable
class addItem(CreateView):
model = itemTable
fields = ['order', 'menuItem', 'specialInstructions', 'allergies', 
'server', 'orderTime', 'completionTime', 'status'] 
def get_initial(self, **kwargs):
initial = super(CreateView, self).get_initial()
initial['order'] = self.kwargs['pk']
return initial
class editItem(UpdateView):
model = itemTable
fields = ['order', 'menuItem', 'specialInstructions', 'allergies', 
'server', 'orderTime', 'completionTime', 'status']
 
#chef/views.py
from django.shortcuts import render, redirect
from django.views.generic import (CreateView, DetailView, ListView, 
UpdateView, DeleteView)
from django_tables2.views import SingleTableMixin
from django_filters.views import FilterView
from tickets.models import ordersTable, itemTable
from tickets.tables import searchOrdersTable
from tickets.filters import searchOrdersFilter
# Create your views here.
def searchOrders(request):
table = 
searchOrdersTable(ordersTable.objects.filter(status='sentToKitchen'))
template = "chef/searchOrders.html"
filters = searchOrdersFilter
context = {'table': table, 'filter': filters}
return render(request, template, context)
On Thursday, October 1, 2020 at 10:59:11 AM UTC-5 Patrick Carra wrote:

> I am using linkify in django_tables2 to create a link to an order by 
> defininig get_absolute_url on the model.  My question is if I want to use a 
> url other than the get_absolute_url in another class how do I do this? Is 
> there a way to override this?
>
> #tickets/models.py
>
&g

Re: Setting up models and postgres in django 3.1

2020-09-25 Thread Patrick Carra
Figured it out 3.1 is more strict about how it creates tables in postgres.  
The workaround I used was to put the tables into the various 
appname/models.py and then import them as needed when I need them.  

On Friday, September 25, 2020 at 12:38:19 PM UTC-5 Patrick Carra wrote:

> So I have worked in django 2.2 where I have multiple apps that I use the 
> same models.py file in for all of them (same meaning I make sure each one 
> is exactly the same as the others not one single models.py).  When I do 
> migrations I have no problem with anything.  When I started using django 
> 3.1 if I try to do the same it creates tables in the postgres database for  
> each app.  For example I have  a table called Menu_Item it creates tables 
> for home_Menu_Item, custOrders_Menu_Item, and menu_Menu_Item.  How to get 
> them all to use the same postgres table Menu_Item.   Why is django 3 acting 
> differently.  I'm not sure what changed but it isn't working out well for 
> me.
>
> menu/models.py
> from django.db import models
> # Create your models here.
> class Menu_Item(models.Model):
> class MenuTypes(models.TextChoices):
> APPETIZER = "Appetizer"
> ENTREE = "Entree"
> DESSERT = "Dessert"
> WINE = "Wine"
> BEER = "Beer"
> COCKTAIL = "Cocktail"
> name = models.CharField(max_length = 50)
> description = models.CharField(max_length = 250)
> price = models.DecimalField(max_digits = 4, decimal_places= 2)
> item_type = models.CharField(max_length = 10, 
> choices=MenuTypes.choices, default=MenuTypes.APPETIZER)
>   
> 
> def __str__(self):
> return self.name + ' - ' + self.item_type
> class Menu_Drink_Item(models.Model):
> class DrinkChoices(models.TextChoices):
> WINE = "Wine"
> BEER = "Beer"
> COCKTAIL = "Cocktail"
> name = models.CharField(max_length = 50)
> description = models.CharField(max_length = 250)
> price = models.DecimalField(max_digits = 4, decimal_places= 2)
> drink_type = models.CharField(max_length = 10, 
> choices=DrinkChoices.choices, default=DrinkChoices.COCKTAIL)
> pairing_options = models.ForeignKey(Menu_Item, null=True, blank=True, 
> on_delete = models.SET_NULL)
> def __str__(self):
> return self.name
>
> custOrders/models.py
> from django.db import models
> from menu.models import Menu_Item
> # Create your models here.
> class tableTable(models.Model):
> tableTypeChoices = [
> ('bar', 'bar'),
> ('booth', 'booth'),
> ('table', 'table'),
> ('hi-top', 'hi-top'),
> ('patio', 'patio'),
> ]
> statusChoices = [
> ('cleaned', 'cleaned'),
> ('seated', 'seated'),
> ('closed', 'closed'),
> ('reserved', 'reserved'),
> ]
> #primary key field
> seats = models.IntegerField(blank=False, null=False)
> tableType = models.CharField(max_length=255, blank=False, null=False, 
> choices=tableTypeChoices)
> status = models.CharField(max_length=255, blank=False, null=False, 
> choices=statusChoices)
> server = models.CharField(max_length=255, blank=False, null=False)
> def __str__(self):
> return '%s %s' % (self.id, self.tableType)
> class Menu_Item(models.Model):
> class MenuTypes(models.TextChoices):
> APPETIZER = "Appetizer"
> ENTREE = "Entree"
> DESSERT = "Dessert"
> WINE = "Wine"
> BEER = "Beer"
> COCKTAIL = "Cocktail"
> name = models.CharField(max_length = 50)
> description = models.CharField(max_length = 250)
> price = models.DecimalField(max_digits = 4, decimal_places= 2)
> item_type = models.CharField(max_length = 10, 
> choices=MenuTypes.choices, default=MenuTypes.APPETIZER)
>   
> 
> def __str__(self):
> return self.name + ' - ' + self.item_type
>
>
> Any ideas?
>

-- 
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/10a8253c-53df-40d2-808e-d9737e5e6e42n%40googlegroups.com.


Setting up models and postgres in django 3.1

2020-09-25 Thread Patrick Carra
So I have worked in django 2.2 where I have multiple apps that I use the 
same models.py file in for all of them (same meaning I make sure each one 
is exactly the same as the others not one single models.py).  When I do 
migrations I have no problem with anything.  When I started using django 
3.1 if I try to do the same it creates tables in the postgres database for  
each app.  For example I have  a table called Menu_Item it creates tables 
for home_Menu_Item, custOrders_Menu_Item, and menu_Menu_Item.  How to get 
them all to use the same postgres table Menu_Item.   Why is django 3 acting 
differently.  I'm not sure what changed but it isn't working out well for 
me.

menu/models.py
from django.db import models
# Create your models here.
class Menu_Item(models.Model):
class MenuTypes(models.TextChoices):
APPETIZER = "Appetizer"
ENTREE = "Entree"
DESSERT = "Dessert"
WINE = "Wine"
BEER = "Beer"
COCKTAIL = "Cocktail"
name = models.CharField(max_length = 50)
description = models.CharField(max_length = 250)
price = models.DecimalField(max_digits = 4, decimal_places= 2)
item_type = models.CharField(max_length = 10, 
choices=MenuTypes.choices, default=MenuTypes.APPETIZER)
  

def __str__(self):
return self.name + ' - ' + self.item_type
class Menu_Drink_Item(models.Model):
class DrinkChoices(models.TextChoices):
WINE = "Wine"
BEER = "Beer"
COCKTAIL = "Cocktail"
name = models.CharField(max_length = 50)
description = models.CharField(max_length = 250)
price = models.DecimalField(max_digits = 4, decimal_places= 2)
drink_type = models.CharField(max_length = 10, 
choices=DrinkChoices.choices, default=DrinkChoices.COCKTAIL)
pairing_options = models.ForeignKey(Menu_Item, null=True, blank=True, 
on_delete = models.SET_NULL)
def __str__(self):
return self.name

custOrders/models.py
from django.db import models
from menu.models import Menu_Item
# Create your models here.
class tableTable(models.Model):
tableTypeChoices = [
('bar', 'bar'),
('booth', 'booth'),
('table', 'table'),
('hi-top', 'hi-top'),
('patio', 'patio'),
]
statusChoices = [
('cleaned', 'cleaned'),
('seated', 'seated'),
('closed', 'closed'),
('reserved', 'reserved'),
]
#primary key field
seats = models.IntegerField(blank=False, null=False)
tableType = models.CharField(max_length=255, blank=False, null=False, 
choices=tableTypeChoices)
status = models.CharField(max_length=255, blank=False, null=False, 
choices=statusChoices)
server = models.CharField(max_length=255, blank=False, null=False)
def __str__(self):
return '%s %s' % (self.id, self.tableType)
class Menu_Item(models.Model):
class MenuTypes(models.TextChoices):
APPETIZER = "Appetizer"
ENTREE = "Entree"
DESSERT = "Dessert"
WINE = "Wine"
BEER = "Beer"
COCKTAIL = "Cocktail"
name = models.CharField(max_length = 50)
description = models.CharField(max_length = 250)
price = models.DecimalField(max_digits = 4, decimal_places= 2)
item_type = models.CharField(max_length = 10, 
choices=MenuTypes.choices, default=MenuTypes.APPETIZER)
  

def __str__(self):
return self.name + ' - ' + self.item_type


Any ideas?

-- 
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/ebd76d62-ca29-40df-94e9-1e1dcd831916n%40googlegroups.com.


Re: TypeError: object() takes No Parameters

2020-09-17 Thread Patrick Carra
[Thu Sep 17 23:07:26.870983 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290] Internal Server Error: /functions/ClassMonthlyCost/
[Thu Sep 17 23:07:26.871052 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290] Traceback (most recent call last):
[Thu Sep 17 23:07:26.871057 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290]   File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/exception.py",
 
line 34, in inner
[Thu Sep 17 23:07:26.871060 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290] response = get_response(request)
[Thu Sep 17 23:07:26.871064 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290]   File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py",
 
line 115, in _get_response
[Thu Sep 17 23:07:26.871067 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290] response = self.process_exception_by_middleware(e, 
request)
[Thu Sep 17 23:07:26.871070 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290]   File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py",
 
line 113, in _get_response
[Thu Sep 17 23:07:26.871073 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290] response = wrapped_callback(request, 
*callback_args, **callback_kwargs)
[Thu Sep 17 23:07:26.871079 2020] [wsgi:error] [pid 39120] [remote 
142.136.2.27:45290] TypeError: object() takes no parameters


On Thursday, September 17, 2020 at 3:00:08 PM UTC-5 Patrick Carra wrote:

> The actual trace coolguy is 
>
> TypeError at /functions/ClassMonthlyCost/object() takes no 
> parametersRequest 
> Method: GETRequest 
> URL: http://98.8.61.133:8080/functions/ClassMonthlyCost/Django 
> Version: 2.2.4Exception 
> Type: TypeErrorException 
> Value: object() takes no parametersException 
> Location: 
> /home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py
>  
> in _get_response, line 113Python 
> Executable: /home/db_user/ciopsdb/venv/bin/pythonPython 
> Version:3.6.8
> Python Path:
> ['/home/db_user/ciopsdb', '/usr/lib64/python36.zip', 
> '/usr/lib64/python3.6', '/usr/lib64/python3.6/lib-dynload', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages', 
> '/home/db_user/ciopsdb/venv/lib/python3.6/site-packages', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
> '/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf']
> Server time: Thu, 17 Sep 2020 18:29:52 +  
>
> On Thursday, September 17, 2020 at 2:26:32 PM UTC-5 coolguy wrote:
>
>> is there any specific line number that message is pointing too. Can you 
>> share the actual error message and its trace...
>>
>> On Thursday, September 17, 2020 at 2:35:53 PM UTC-4 pcar...@gmail.com 
>> wrote:
>>
>>> Hello everyone, I am trying to utilize the SIngleTableMixin of 
>>> django_tables2 using a custom function that queries my database and 
>>> aggregates the data into a list of dictionaries.  I read to use the 
>>> SingleTableMixin that all I needed was an iterable containing a data 
>>> structure that has a key(a list of dicts) and then to instantiate a table 
>>> in tables.py and pass to a my views Class.  I am getting an error when I do 
>>> this TypeError: Object() takes no parameters.  I have included a link to 
>>> the django tables 2 doc and my code below:
>>>
>>> #views.py
>>> from django_tables2.views import SingleTableMixin
>>> from django_tables2.export.views import ExportMixin
>>> from django_filters.views import FilterView
>>> from django.views.generic.list import ListView
>>> from django.shortcuts import render
>>>
>>> from finance.models import Circuitinfotable, Budget
>>> from .forms import monthlyCostForm
>>> from .tables import CircuitTable, monthlyCostTable
>>> from .filters import CircuitinfotableFilter
>>>
>>> from datetime import datetime
>>> from decimal import Decimal
>>> from re import sub
>>> import calendar
>>>
>>> #convert a distinct queryset into a singular list of values
>>> def getList(qs, key):
>>> resultsList = []
>>> for each in qs:
>>> resultsList.append(each[key])
>>> return resultsList
>>>
>>>
>>> def ge

Re: TypeError: object() takes No Parameters

2020-09-17 Thread Patrick Carra
The actual trace coolguy is 

TypeError at /functions/ClassMonthlyCost/object() takes no 
parametersRequest 
Method: GETRequest 
URL: http://98.8.61.133:8080/functions/ClassMonthlyCost/Django 
Version: 2.2.4Exception 
Type: TypeErrorException 
Value: object() takes no parametersException 
Location: 
/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py
 
in _get_response, line 113Python 
Executable: /home/db_user/ciopsdb/venv/bin/pythonPython 
Version:3.6.8
Python Path:
['/home/db_user/ciopsdb', '/usr/lib64/python36.zip', 
'/usr/lib64/python3.6', '/usr/lib64/python3.6/lib-dynload', 
'/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages', 
'/home/db_user/ciopsdb/venv/lib/python3.6/site-packages', 
'/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
'/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
'/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
'/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
'/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
'/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf', 
'/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/odf']
Server time: Thu, 17 Sep 2020 18:29:52 +  

On Thursday, September 17, 2020 at 2:26:32 PM UTC-5 coolguy wrote:

> is there any specific line number that message is pointing too. Can you 
> share the actual error message and its trace...
>
> On Thursday, September 17, 2020 at 2:35:53 PM UTC-4 pcar...@gmail.com 
> wrote:
>
>> Hello everyone, I am trying to utilize the SIngleTableMixin of 
>> django_tables2 using a custom function that queries my database and 
>> aggregates the data into a list of dictionaries.  I read to use the 
>> SingleTableMixin that all I needed was an iterable containing a data 
>> structure that has a key(a list of dicts) and then to instantiate a table 
>> in tables.py and pass to a my views Class.  I am getting an error when I do 
>> this TypeError: Object() takes no parameters.  I have included a link to 
>> the django tables 2 doc and my code below:
>>
>> #views.py
>> from django_tables2.views import SingleTableMixin
>> from django_tables2.export.views import ExportMixin
>> from django_filters.views import FilterView
>> from django.views.generic.list import ListView
>> from django.shortcuts import render
>>
>> from finance.models import Circuitinfotable, Budget
>> from .forms import monthlyCostForm
>> from .tables import CircuitTable, monthlyCostTable
>> from .filters import CircuitinfotableFilter
>>
>> from datetime import datetime
>> from decimal import Decimal
>> from re import sub
>> import calendar
>>
>> #convert a distinct queryset into a singular list of values
>> def getList(qs, key):
>> resultsList = []
>> for each in qs:
>> resultsList.append(each[key])
>> return resultsList
>>
>>
>> def getDistinct(key):
>> return Circuitinfotable.objects.all().values(key).distinct()
>>
>>
>> def convertCurrency(val):
>> return Decimal(sub(r'[^\d.]', '', val))
>>
>>
>> def getMonthlyCostQuery(year, field):
>> circuits = Circuitinfotable.objects.all()
>> field_list = getList(getDistinct(field), field)
>>
>> results_list = []
>> resultsDict={'field': 'None', 'Jan': 0, 'Feb': 0, 'Mar': 0, 'Apr': 0, 
>> 'May': 0, 'Jun': 0, 'Jul': 0, 'Aug': 0, 'Sep': 0, 'Oct': 0, 'Nov': 0, 
>> 'Dec': 0,
>>  'Janbw': 0, 'Febbw': 0, 'Marbw': 0, 'Aprbw': 0, 'Maybw': 
>> 0, 'Junbw': 0, 'Julbw': 0, 'Augbw': 0, 'Sepbw': 0, 'Octbw': 0, 'Novbw': 0, 
>> 'Decbw': 0}
>> results_list.append(resultsDict)
>> for each in field_list:
>> if each!=None and each!='None':
>> resultsDict={'field': '', 'Jan': 0, 'Feb': 0, 'Mar': 0, 
>> 'Apr': 0, 'May': 0, 'Jun': 0, 'Jul': 0, 'Aug': 0, 'Sep': 0, 'Oct': 0, 
>> 'Nov': 0, 'Dec': 0,
>>  'Janbw': 0, 'Febbw': 0, 'Marbw': 0, 'Aprbw': 0, 
>> 'Maybw': 0, 'Junbw': 0, 'Julbw': 0, 'Augbw': 0, 'Sepbw': 0, 'Octbw': 0, 
>> 'Novbw': 0, 'Decbw': 0}
>> resultsDict['field'] = each
>> results_list.append(resultsDict)
>>
>> for circuit in circuits:
>> #If you add a field to forms.py to aggregate by then add here
>> if field=='region':
>> matchField = circuit.region
>> elif field=='carrier':
>> matchField = circuit.carrier
>> elif field=='bandwidth':
>> matchField = circuit.bandwidth
>> elif field=='status':
>> matchField = circuit.status
>> #get the budget for each circuit
>> for budgetItem in circuit.budget_set.filter(yearnum=year):
>> #if an item is budgeted for given month
>> if(budgetItem.actualmrc!=0):
>> #Cycle through results_list to find the correct dictionary
>> for each in results_list:
>> if each['field']==matchField:
>> #update budgetItem and bw
>> if 

TypeError: object() takes No Parameters

2020-09-17 Thread Patrick Carra
Hello everyone, I am trying to utilize the SIngleTableMixin of 
django_tables2 using a custom function that queries my database and 
aggregates the data into a list of dictionaries.  I read to use the 
SingleTableMixin that all I needed was an iterable containing a data 
structure that has a key(a list of dicts) and then to instantiate a table 
in tables.py and pass to a my views Class.  I am getting an error when I do 
this TypeError: Object() takes no parameters.  I have included a link to 
the django tables 2 doc and my code below:

#views.py
from django_tables2.views import SingleTableMixin
from django_tables2.export.views import ExportMixin
from django_filters.views import FilterView
from django.views.generic.list import ListView
from django.shortcuts import render

from finance.models import Circuitinfotable, Budget
from .forms import monthlyCostForm
from .tables import CircuitTable, monthlyCostTable
from .filters import CircuitinfotableFilter

from datetime import datetime
from decimal import Decimal
from re import sub
import calendar

#convert a distinct queryset into a singular list of values
def getList(qs, key):
resultsList = []
for each in qs:
resultsList.append(each[key])
return resultsList


def getDistinct(key):
return Circuitinfotable.objects.all().values(key).distinct()


def convertCurrency(val):
return Decimal(sub(r'[^\d.]', '', val))


def getMonthlyCostQuery(year, field):
circuits = Circuitinfotable.objects.all()
field_list = getList(getDistinct(field), field)

results_list = []
resultsDict={'field': 'None', 'Jan': 0, 'Feb': 0, 'Mar': 0, 'Apr': 0, 
'May': 0, 'Jun': 0, 'Jul': 0, 'Aug': 0, 'Sep': 0, 'Oct': 0, 'Nov': 0, 
'Dec': 0,
 'Janbw': 0, 'Febbw': 0, 'Marbw': 0, 'Aprbw': 0, 'Maybw': 
0, 'Junbw': 0, 'Julbw': 0, 'Augbw': 0, 'Sepbw': 0, 'Octbw': 0, 'Novbw': 0, 
'Decbw': 0}
results_list.append(resultsDict)
for each in field_list:
if each!=None and each!='None':
resultsDict={'field': '', 'Jan': 0, 'Feb': 0, 'Mar': 0, 'Apr': 
0, 'May': 0, 'Jun': 0, 'Jul': 0, 'Aug': 0, 'Sep': 0, 'Oct': 0, 'Nov': 0, 
'Dec': 0,
 'Janbw': 0, 'Febbw': 0, 'Marbw': 0, 'Aprbw': 0, 
'Maybw': 0, 'Junbw': 0, 'Julbw': 0, 'Augbw': 0, 'Sepbw': 0, 'Octbw': 0, 
'Novbw': 0, 'Decbw': 0}
resultsDict['field'] = each
results_list.append(resultsDict)

for circuit in circuits:
#If you add a field to forms.py to aggregate by then add here
if field=='region':
matchField = circuit.region
elif field=='carrier':
matchField = circuit.carrier
elif field=='bandwidth':
matchField = circuit.bandwidth
elif field=='status':
matchField = circuit.status
#get the budget for each circuit
for budgetItem in circuit.budget_set.filter(yearnum=year):
#if an item is budgeted for given month
if(budgetItem.actualmrc!=0):
#Cycle through results_list to find the correct dictionary
for each in results_list:
if each['field']==matchField:
#update budgetItem and bw
if budgetItem != None:

each[calendar.month_abbr[budgetItem.monthnum]]+=convertCurrency(budgetItem.actualmrc)
if circuit.bw!= None:
each[calendar.month_abbr[budgetItem.monthnum] + 
'bw']+=int(circuit.bw)
elif matchField==None:
if budgetItem != None:

results_list[0][calendar.month_abbr[budgetItem.monthnum]]+=convertCurrency(budgetItem.actualmrc)
if circuit.bw!= None:

results_list[0][calendar.month_abbr[budgetItem.monthnum]+'bw']+=int(circuit.bw)

results_list = sorted(results_list, key=lambda i:i['field'])
return results_list


class MonthlyCost(SingleTableMixin):
template_name = 'functions/ClassMonthlyCost.html'
context_object_name = 'qs'
queryset = monthlyCostTable(getMonthlyCostQuery(2020, 'region'))


#tables.py
import django_tables2 as tables
from django_tables2.utils import A
from .models import Circuitinfotable

class CircuitTable(tables.Table):
class Meta:
model = Circuitinfotable
export_formats = ['csv', 'xlsx']
template_name = "django_tables2/bootstrap.html"
Id1 = tables.Column(linkify={"viewname": "viewLit", "args": 
[tables.A('id1__pk')]})
fields = ("id1", "circuitid", "bandwidth", "region", "carrier", 
"segmentname", "status", "mrcnew", "diversity", )

class monthlyCostTable(tables.Table):
field = tables.Column()
Jan = tables.Column()
Janbw = tables.Column()
Feb = tables.Column()
Febbw = tables.Column()
Mar = tables.Column()
Marbw = tables.Column()
Apr = tables.Column()
Aprbw = tables.Column()
May = tables.Column()

Re: Setting an existing field to use ForeignKey can't access the object

2020-09-11 Thread Patrick Carra
Okay I figured it out. First I was using the wrong table (an old table that 
I should have deleted out). Second I needed to set the db_column attribute 
in my ForeignKey options).  Works like a charm now.  Sorry but thanks for 
the help!

On Friday, September 11, 2020 at 11:59:56 AM UTC-5 Patrick Carra wrote:

> OGUNSANYA I'm trying to access the related objects in the budget table 
> from the Circuitinfotable.  From what I can tell once they are related 
> using the ForeignKey I should be able to do this with c.budget but it 
> doesn't work for me.
>
> On Friday, September 11, 2020 at 10:43:39 AM UTC-5 Ogunsanya Opeyemi wrote:
>
>> Your ciecuitinfotable model does not have budget and budget_set field
>>
>> On Friday, September 11, 2020, Patrick Carra  wrote:
>>
>>> hello I am attempting to relate two existing tables 
>>>
>>> class Circuitinfotable(models.Model):
>>> id1 = models.AutoField(primary_key=True, null=False, unique=True)
>>> pid = models.CharField(max_length=255, blank=True, null=True)
>>> circuitid = models.CharField(max_length=255, blank=True, null=True)
>>> bandwidth = models.CharField(max_length=255, blank=True, null=True, 
>>> choices=bandwidth_list)
>>> region = models.CharField(max_length=255, blank=True, null=True, 
>>> choices=region_list)
>>> bw = models.IntegerField(blank=True, null=True)
>>> pathname = models.CharField(max_length=255, blank=True, null=True)
>>> handoffalocaddress = models.CharField(max_length=255, blank=True, 
>>> null=True)
>>> handoffaloccity = models.CharField(max_length=255, blank=True, 
>>> null=True)
>>> handoffalocst = models.CharField(max_length=255, blank=True, 
>>> null=True)
>>> alocationaddress = models.CharField(max_length=255, blank=True, 
>>> null=True)
>>> alocationcity = models.CharField(max_length=255, blank=True, 
>>> null=True)
>>>
>>> class Budgettable(models.Model):
>>> id = models.CharField(primary_key=True, max_length=255)
>>> circuitid = models.CharField(max_length=255, blank=True, null=True)
>>> pid = models.CharField(max_length=255, blank=True, null=True)
>>> monthnum = models.IntegerField(blank=True, null=True)
>>> yearnum = models.IntegerField(blank=True, null=True)
>>> budgetmrc = models.TextField(blank=True, null=True)  # This field 
>>> type is a guess.
>>> actualmrc = models.TextField(blank=True, null=True)  # This field 
>>> type is a guess.
>>> region = models.CharField(max_length=255, blank=True, null=True)
>>> circuitref = models.ForeignKey(Circuitinfotable, 
>>> on_delete=models.CASCADE, to_field='id1')
>>>
>>> class Meta:
>>> managed = False
>>>
>>> If open a shell and import Circuitinfotable and Budget and run the 
>>> following code:
>>> from finance.models import Circuitinfotable, Budget
>>> c=Circuitinfotable.objects.get(id1=695)
>>> c.budget
>>> c.budget_set.all
>>>
>>> I get an error:
>>> Traceback (most recent call last):
>>>   File "", line 1, in 
>>> AttributeError: 'Circuitinfotable' object has no attribute 'budget'
>>>
>>> or 
>>>
>>> Traceback (most recent call last):
>>>   File "", line 1, in 
>>> AttributeError: 'Circuitinfotable' object has no attribute 'budget_set'
>>>
>>> I set up my budget file to have the circuitref populated with the id1 
>>> field of the Circuitinfotable.
>>>
>>> In my code I can query these two objects and manually relate them myself 
>>> in the view but I cannot get the django ORM to do this for me.  Any 
>>> suggestions?
>>>
>>> -- 
>>> 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/350ce6b2-d63b-45ae-bdc6-f9b123b3d04cn%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/django-users/350ce6b2-d63b-45ae-bdc6-f9b123b3d04cn%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>>
>>
>> -- 
>> OGUNSANYA OPEYEMI
>>
>>

-- 
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/0c0d7b78-c04c-45b0-af41-a29b76715021n%40googlegroups.com.


Re: Setting an existing field to use ForeignKey can't access the object

2020-09-11 Thread Patrick Carra
OGUNSANYA I'm trying to access the related objects in the budget table from 
the Circuitinfotable.  From what I can tell once they are related using the 
ForeignKey I should be able to do this with c.budget but it doesn't work 
for me.

On Friday, September 11, 2020 at 10:43:39 AM UTC-5 Ogunsanya Opeyemi wrote:

> Your ciecuitinfotable model does not have budget and budget_set field
>
> On Friday, September 11, 2020, Patrick Carra  wrote:
>
>> hello I am attempting to relate two existing tables 
>>
>> class Circuitinfotable(models.Model):
>> id1 = models.AutoField(primary_key=True, null=False, unique=True)
>> pid = models.CharField(max_length=255, blank=True, null=True)
>> circuitid = models.CharField(max_length=255, blank=True, null=True)
>> bandwidth = models.CharField(max_length=255, blank=True, null=True, 
>> choices=bandwidth_list)
>> region = models.CharField(max_length=255, blank=True, null=True, 
>> choices=region_list)
>> bw = models.IntegerField(blank=True, null=True)
>> pathname = models.CharField(max_length=255, blank=True, null=True)
>> handoffalocaddress = models.CharField(max_length=255, blank=True, 
>> null=True)
>> handoffaloccity = models.CharField(max_length=255, blank=True, 
>> null=True)
>> handoffalocst = models.CharField(max_length=255, blank=True, 
>> null=True)
>> alocationaddress = models.CharField(max_length=255, blank=True, 
>> null=True)
>> alocationcity = models.CharField(max_length=255, blank=True, 
>> null=True)
>>
>> class Budgettable(models.Model):
>> id = models.CharField(primary_key=True, max_length=255)
>> circuitid = models.CharField(max_length=255, blank=True, null=True)
>> pid = models.CharField(max_length=255, blank=True, null=True)
>> monthnum = models.IntegerField(blank=True, null=True)
>> yearnum = models.IntegerField(blank=True, null=True)
>> budgetmrc = models.TextField(blank=True, null=True)  # This field 
>> type is a guess.
>> actualmrc = models.TextField(blank=True, null=True)  # This field 
>> type is a guess.
>> region = models.CharField(max_length=255, blank=True, null=True)
>> circuitref = models.ForeignKey(Circuitinfotable, 
>> on_delete=models.CASCADE, to_field='id1')
>>
>> class Meta:
>> managed = False
>>
>> If open a shell and import Circuitinfotable and Budget and run the 
>> following code:
>> from finance.models import Circuitinfotable, Budget
>> c=Circuitinfotable.objects.get(id1=695)
>> c.budget
>> c.budget_set.all
>>
>> I get an error:
>> Traceback (most recent call last):
>>   File "", line 1, in 
>> AttributeError: 'Circuitinfotable' object has no attribute 'budget'
>>
>> or 
>>
>> Traceback (most recent call last):
>>   File "", line 1, in 
>> AttributeError: 'Circuitinfotable' object has no attribute 'budget_set'
>>
>> I set up my budget file to have the circuitref populated with the id1 
>> field of the Circuitinfotable.
>>
>> In my code I can query these two objects and manually relate them myself 
>> in the view but I cannot get the django ORM to do this for me.  Any 
>> suggestions?
>>
>> -- 
>> 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/350ce6b2-d63b-45ae-bdc6-f9b123b3d04cn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/350ce6b2-d63b-45ae-bdc6-f9b123b3d04cn%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>
>
> -- 
> OGUNSANYA OPEYEMI
>
>

-- 
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/dcc6787c-48b8-4d11-894b-e9fb9d57542dn%40googlegroups.com.


Setting an existing field to use ForeignKey can't access the object

2020-09-11 Thread Patrick Carra
hello I am attempting to relate two existing tables 

class Circuitinfotable(models.Model):
id1 = models.AutoField(primary_key=True, null=False, unique=True)
pid = models.CharField(max_length=255, blank=True, null=True)
circuitid = models.CharField(max_length=255, blank=True, null=True)
bandwidth = models.CharField(max_length=255, blank=True, null=True, 
choices=bandwidth_list)
region = models.CharField(max_length=255, blank=True, null=True, 
choices=region_list)
bw = models.IntegerField(blank=True, null=True)
pathname = models.CharField(max_length=255, blank=True, null=True)
handoffalocaddress = models.CharField(max_length=255, blank=True, 
null=True)
handoffaloccity = models.CharField(max_length=255, blank=True, 
null=True)
handoffalocst = models.CharField(max_length=255, blank=True, null=True)
alocationaddress = models.CharField(max_length=255, blank=True, 
null=True)
alocationcity = models.CharField(max_length=255, blank=True, null=True)

class Budgettable(models.Model):
id = models.CharField(primary_key=True, max_length=255)
circuitid = models.CharField(max_length=255, blank=True, null=True)
pid = models.CharField(max_length=255, blank=True, null=True)
monthnum = models.IntegerField(blank=True, null=True)
yearnum = models.IntegerField(blank=True, null=True)
budgetmrc = models.TextField(blank=True, null=True)  # This field type 
is a guess.
actualmrc = models.TextField(blank=True, null=True)  # This field type 
is a guess.
region = models.CharField(max_length=255, blank=True, null=True)
circuitref = models.ForeignKey(Circuitinfotable, 
on_delete=models.CASCADE, to_field='id1')

class Meta:
managed = False

If open a shell and import Circuitinfotable and Budget and run the 
following code:
from finance.models import Circuitinfotable, Budget
c=Circuitinfotable.objects.get(id1=695)
c.budget
c.budget_set.all

I get an error:
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'Circuitinfotable' object has no attribute 'budget'

or 

Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'Circuitinfotable' object has no attribute 'budget_set'

I set up my budget file to have the circuitref populated with the id1 field 
of the Circuitinfotable.

In my code I can query these two objects and manually relate them myself in 
the view but I cannot get the django ORM to do this for me.  Any 
suggestions?

-- 
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/350ce6b2-d63b-45ae-bdc6-f9b123b3d04cn%40googlegroups.com.


Re: NoReverseMatch at /searchlit/customsearch and bigger problem of exporting a filtered queryset

2020-08-31 Thread Patrick Carra
Thanks bharath for the info I'm going to dig more in to these.

On Friday, August 28, 2020 at 9:05:04 PM UTC-5 bharath...@gmail.com wrote:

> Hi,
>  
> Please check this package. This may help you. All the best
>
> https://django-tables2.readthedocs.io/en/latest/pages/filtering.html
>   
>
> On Sat, 29 Aug 2020, 4:36 am Patrick Carra,  wrote:
>
>> Hello All!  I need some help with a problem I have been struggling with.  
>> One of you generous geniuses has the answer I'm sure of it.  I am working 
>> on integrating an export to csv button(link) on my template to export 
>> filtered data from one of my tables.  I have previously only been able to 
>> dump the entire table to csv which isn't exactly what I need.  So my 
>> thoughts were to place a button/link on the template passes a 
>> parameter(dictionary of my filter criteria) to a view named ExportSearch.  
>> The view then calls a function that I have defined to perform my filtered 
>> query to the table and then writes outs to csv.  In theory I thought this 
>> should work but I keep getting errors that I have not been able to resolve 
>> and I am at the end of my knowledge capacity here.  Applicable code below.  
>> Did I mention THANK YOU
>>
>> *From searchLit/urls.py*
>> from django.urls import include, path
>> from . import views
>> from .views import search
>>
>> app_name= "searchLit"
>>
>> urlpatterns=[
>> path('customsearch/', views.search, name='search'),
>> path('customsearch//', views.search, name='search'),
>> path('noccustomsearch/', views.nocSearch, name='nocSearch'),
>> path('nocreport/export/', views.noc_export, name='noc_export'),
>> path('customsearch/export/', views.searchLit_export, 
>> name='SearchLit_export'),
>> path('customsearch/exportSearch//', views.exportSearch, 
>> name='exportSearch'),
>> ]
>>
>> *From searchLit/views.py*
>> def filterCircuits(params, search_vector):
>> circuits=[]
>> if(params['circuitid']==None and params['bandwidth']==None and 
>> params['region']==None and params['carrier']==None and 
>> params['status']==None and params['segmentname']==None and 
>> params['mrcnew']==None):
>> circuits=Circuitinfotable.objects.all()
>> else:
>> if(params['multipleSearch']!=None and 
>> params['multipleSearch']!=""):
>> 
>> circuits=Circuitinfotable.objects.annotate(search=search_vector).filter(search=params['multipleSearch'])
>> else:
>> circuits = Circuitinfotable.objects.all()
>> if(params['circuitid']!=None and params['circuitid']!=""):
>> circuits = Circuitinfotable.objects.all()
>> 
>> circuits=circuits.filter(circuitid__icontains=params['circuitid'])
>> if(params['bandwidth']!=None and params['bandwidth']!="" and 
>> params['bandwidth']!='Select Bandwidth'):
>> circuits=circuits.filter(bandwidth=params['bandwidth'])
>> if(params['region']!=None and params['region']!="" and 
>> params['region']!='Select Region'):
>> circuits=circuits.filter(region=params['region'])
>> if(params['carrier']!=None and params['carrier']!="" and 
>> params['carrier']!='Select Carrier'):
>> circuits=circuits.filter(carrier=params['carrier'])
>> if(params['status']!=None and params['status']!="" and 
>> params['status']!='Select Status'):
>> circuits=circuits.filter(status=params['status'])
>> if(params['segmentname']!=None and params['segmentname']!="" and 
>> params['segmentname']!='Select Segment'):
>> circuits=circuits.filter(segmentname=params['segmentname'])
>> if(params['mrcnew']!=None and params['mrcnew']!=""):
>> circuits=circuits.filter(mrcnew=params['mrcnew'])
>> if(params['diversity']!='Select Option'):
>> if(params['diversity']=='None'):
>> circuits=circuits.filter(diversity=None)
>> else:
>> 
>> circuits=circuits.filter(diversity__icontains=params['diversity'])
>> if(params['kmz']!='Select YES/NO'):
>> if(params['kmz']=='No'):
>> circuits=circuits.filter(kmz=None)
>> else:
>> circuits=circuits.filter(kmz__isnull=False)
>> return(circuits)
>>
>>
>> def search(request):
>> form = CircuitForm
>> template =  'custom

Re: NoReverseMatch at /searchlit/customsearch and bigger problem of exporting a filtered queryset

2020-08-31 Thread Patrick Carra
*Thanks coolguy I changed my urls.py to this and that resolved the error:*

from django.urls import include, path
from . import views
from .views import search

app_name= "searchLit"

urlpatterns=[
path('customsearch/', views.search, name='search'),
path('exportlit/', views.searchLit_export, name='SearchLit_export'),
path('noccustomsearch/', views.nocSearch, name='nocSearch'),
path('exportnoc/', views.noc_export, name='noc_export'),
path('exportSearch//', views.exportSearch, 
name='exportSearch'),
]

*I now am getting:*

Reverse for 'exportSearch' with arguments '("{'circuitid': '', 'bandwidth': 
'Select Bandwidth', 'region': 'Central', 'carrier': 'Select Carrier', 
'status': 'Select Status', 'segmentname': 'Select Segment', 'mrcnew': '', 
'diversity': 'Select Option', 'kmz': 'Select YES/NO', 'multipleSearch': 
''}",)' not found. 1 pattern(s) tried: 
['searchlit\\/exportSearch\\/(?P[^/]+)\\/$']  

*When I try to use this code in my template to pass a dictionary(containing 
my search parameters) to the export function to export only filtered table 
data:*

*template:*



*views.py:*
def exportSearch(request, params):
params = ast.literal_eval(params)
search_vector = SearchVector('circuitid', 'carrier', 'pathname', 
'segmentname', 'segmentid', 'alocationaddress', 'alocationcity', 'alocst', 
'zlocationaddress', 'zlocationcity', 'zlocst', 'handoffalocaddress', 
'handoffalocst',
 'handoffaloccity', 'handoffzlocaddress', 
'handoffzloccity', 'handoffzlocst', 'latestjiraticket', 
'installciopsticket', 'retermciopsticket', 'discociopsticket', 'notes', 
'diversitynotes')
allcircuits=filterCircuits(params, search_vector)
return render_to_csv_response(allcircuits)

*I assume that I need to use a different path converter but I am unsure.  
Any tips am I thinking about this the right way or is there a better way to 
do what I am trying to do?*


On Friday, August 28, 2020 at 10:28:46 PM UTC-5 coolguy wrote:

> You can't have the same name twice. You need to change the name for one of 
> the followings:
> path('customsearch/', views.search, name='search'),
> path('customsearch//', views.search, name='search_xxx')
>
> Reverse method requires a url identified by name parameter which must be 
> unique. Its looking for search and it find it on two places so you are 
> getting this error.
>
> On Friday, August 28, 2020 at 7:06:09 PM UTC-4 pcar...@gmail.com wrote:
>
>> Hello All!  I need some help with a problem I have been struggling with.  
>> One of you generous geniuses has the answer I'm sure of it.  I am working 
>> on integrating an export to csv button(link) on my template to export 
>> filtered data from one of my tables.  I have previously only been able to 
>> dump the entire table to csv which isn't exactly what I need.  So my 
>> thoughts were to place a button/link on the template passes a 
>> parameter(dictionary of my filter criteria) to a view named ExportSearch.  
>> The view then calls a function that I have defined to perform my filtered 
>> query to the table and then writes outs to csv.  In theory I thought this 
>> should work but I keep getting errors that I have not been able to resolve 
>> and I am at the end of my knowledge capacity here.  Applicable code below.  
>> Did I mention THANK YOU
>>
>> *From searchLit/urls.py*
>> from django.urls import include, path
>> from . import views
>> from .views import search
>>
>> app_name= "searchLit"
>>
>> urlpatterns=[
>> path('customsearch/', views.search, name='search'),
>> path('customsearch//', views.search, name='search'),
>> path('noccustomsearch/', views.nocSearch, name='nocSearch'),
>> path('nocreport/export/', views.noc_export, name='noc_export'),
>> path('customsearch/export/', views.searchLit_export, 
>> name='SearchLit_export'),
>> path('customsearch/exportSearch//', views.exportSearch, 
>> name='exportSearch'),
>> ]
>>
>> *From searchLit/views.py*
>> def filterCircuits(params, search_vector):
>> circuits=[]
>> if(params['circuitid']==None and params['bandwidth']==None and 
>> params['region']==None and params['carrier']==None and 
>> params['status']==None and params['segmentname']==None and 
>> params['mrcnew']==None):
>> circuits=Circuitinfotable.objects.all()
>> else:
>> if(params['multipleSearch']!=None and 
>> params['multipleSearch']!=""):
>> 
>> circuits=Circuitinfotable.objects.annotate(search=search_vector).filter(search=params['multipleSearch'])
>> else:
>> circuits = Circuitinfotable.objects.all()
>> if(params['circuitid']!=None and params['circuitid']!=""):
>> circuits = Circuitinfotable.objects.all()
>> 
>> circuits=circuits.filter(circuitid__icontains=params['circuitid'])
>> if(params['bandwidth']!=None and params['bandwidth']!="" and 
>> params['bandwidth']!='Select Bandwidth'):
>> 

NoReverseMatch at /searchlit/customsearch and bigger problem of exporting a filtered queryset

2020-08-28 Thread Patrick Carra
Hello All!  I need some help with a problem I have been struggling with.  
One of you generous geniuses has the answer I'm sure of it.  I am working 
on integrating an export to csv button(link) on my template to export 
filtered data from one of my tables.  I have previously only been able to 
dump the entire table to csv which isn't exactly what I need.  So my 
thoughts were to place a button/link on the template passes a 
parameter(dictionary of my filter criteria) to a view named ExportSearch.  
The view then calls a function that I have defined to perform my filtered 
query to the table and then writes outs to csv.  In theory I thought this 
should work but I keep getting errors that I have not been able to resolve 
and I am at the end of my knowledge capacity here.  Applicable code below.  
Did I mention THANK YOU

*From searchLit/urls.py*
from django.urls import include, path
from . import views
from .views import search

app_name= "searchLit"

urlpatterns=[
path('customsearch/', views.search, name='search'),
path('customsearch//', views.search, name='search'),
path('noccustomsearch/', views.nocSearch, name='nocSearch'),
path('nocreport/export/', views.noc_export, name='noc_export'),
path('customsearch/export/', views.searchLit_export, 
name='SearchLit_export'),
path('customsearch/exportSearch//', views.exportSearch, 
name='exportSearch'),
]

*From searchLit/views.py*
def filterCircuits(params, search_vector):
circuits=[]
if(params['circuitid']==None and params['bandwidth']==None and 
params['region']==None and params['carrier']==None and 
params['status']==None and params['segmentname']==None and 
params['mrcnew']==None):
circuits=Circuitinfotable.objects.all()
else:
if(params['multipleSearch']!=None and params['multipleSearch']!=""):

circuits=Circuitinfotable.objects.annotate(search=search_vector).filter(search=params['multipleSearch'])
else:
circuits = Circuitinfotable.objects.all()
if(params['circuitid']!=None and params['circuitid']!=""):
circuits = Circuitinfotable.objects.all()

circuits=circuits.filter(circuitid__icontains=params['circuitid'])
if(params['bandwidth']!=None and params['bandwidth']!="" and 
params['bandwidth']!='Select Bandwidth'):
circuits=circuits.filter(bandwidth=params['bandwidth'])
if(params['region']!=None and params['region']!="" and 
params['region']!='Select Region'):
circuits=circuits.filter(region=params['region'])
if(params['carrier']!=None and params['carrier']!="" and 
params['carrier']!='Select Carrier'):
circuits=circuits.filter(carrier=params['carrier'])
if(params['status']!=None and params['status']!="" and 
params['status']!='Select Status'):
circuits=circuits.filter(status=params['status'])
if(params['segmentname']!=None and params['segmentname']!="" and 
params['segmentname']!='Select Segment'):
circuits=circuits.filter(segmentname=params['segmentname'])
if(params['mrcnew']!=None and params['mrcnew']!=""):
circuits=circuits.filter(mrcnew=params['mrcnew'])
if(params['diversity']!='Select Option'):
if(params['diversity']=='None'):
circuits=circuits.filter(diversity=None)
else:

circuits=circuits.filter(diversity__icontains=params['diversity'])
if(params['kmz']!='Select YES/NO'):
if(params['kmz']=='No'):
circuits=circuits.filter(kmz=None)
else:
circuits=circuits.filter(kmz__isnull=False)
return(circuits)


def search(request):
form = CircuitForm
template =  'customsearch/customsearch.html'
search_vector = SearchVector('circuitid', 'carrier', 'pathname', 
'segmentname', 'segmentid', 'alocationaddress', 'alocationcity', 'alocst', 
'zlocationaddress', 'zlocationcity', 'zlocst', 'handoffalocaddress', 
'handoffalocst',
 'handoffaloccity', 'handoffzlocaddress', 
'handoffzloccity', 'handoffzlocst', 'latestjiraticket', 
'installciopsticket', 'retermciopsticket', 'discociopsticket', 'notes', 
'diversitynotes')

params={'circuitid': request.GET.get('circuitid'),
'bandwidth': request.GET.get('bandwidth'),
'region': request.GET.get('region'),
'carrier': request.GET.get('carrier'),
'status': request.GET.get('status'),
'segmentname': request.GET.get('segmentname'),
'mrcnew': request.GET.get('mrcnew'),
'diversity': request.GET.get('diversity'),
'kmz': request.GET.get('kmz'),
'multipleSearch': request.GET.get('multipleSearch')
   }

context=filterCircuits(params, search_vector)
#encoded_params = urllib.parse.urlencode(params)
numCircuits=len(context)
paramString = str(params)
return render(request, template, {'form':form, 

Do I need to change my normal Django code when introducing Django Channels?

2020-07-10 Thread Marlon Patrick
Hi guys, I'm new to the python world and consequently I'm new to Django, 
Channels, WSGI, ASGI, etc.

I asked this question on StackOverflow but I still haven't had any answers, 
so I decided to post here in order to try to receive some guidance.

https://stackoverflow.com/questions/62544489/do-i-need-to-change-my-normal-django-code-when-introducing-django-channels

I have a small backend application using Django + Django Rest Framework. My 
code is very trivial, composed of the most common concepts in the 
framework: views, serializers, models, urls, etc. In addition, I use a 
relational database.


My environment is this:

   - Python 3.8
   - Django 3
   - Django Rest Framework 3.11

Now, I need to add support for WebSockets and I did the basic configuration 
described in the Django Channels tutorial. At the moment, I have not 
configured any channel layers or created any WebSocket endpoint.


After these configurations the runserver is using an ASGI development 
server and apparently my REST endpoints are all working.


Some questions:

   - 
   
   Considering that all my code is synchronous, wouldn't it be necessary to 
   make any adjustments to it?
   - 
   
   This configuration above, already does all the magic necessary for my 
   synchronous code to be executed safely in daphene considering that it is an 
   ASGI server?
   
Where exactly should care be taken regarding synchronous code?

   - 
   
   Can I serve normal HTTP and WebSockets requests using only ASGI in a 
   reliable and stable manner? Or, is it recommended to serve HTTP traffic 
   using WSGI and leave only WebSockets traffic to daphene?
   

-- 
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/c70a754c-88ce-4fca-b56b-19efde8930c6o%40googlegroups.com.


Re: Populate choices from existing values in a model field

2020-06-23 Thread Patrick Carra
I'm not directly modifying any code in a .py file I am simply adding a 
value to the database table but I am unable to see the change reflected in 
my drop down lists until I restart the server.  Is there a better way of 
populating choices for my drop down menu?  Or could I simply add a cron job 
that restarts the server periodically(this seems like not a great solution).

On Saturday, June 20, 2020 at 8:39:03 AM UTC-5, Integr@te System wrote:
>
> Hi Patrick,
>
> Plz review for your suitable case:
> https://stackoverflow.com/questions/3742734/django-restart-server-or-httpd
>
> Nice.
>
> On Sat, Jun 20, 2020, 1:32 AM Patrick Carra  > wrote:
>
>> I am trying to read distinct values from a model field and use the tuple 
>> list to populate the choices in a Form.  The problem I have is that every 
>> time a new value is added I must reset the httpd server in order to include 
>> the new value in the form.  I have researched and tried this a few 
>> different ways but so far am unable to come up with a better solution. Any 
>> ideas?
>>
>> *models.py*
>> class Circuitinfotable(models.Model):
>> id1 = models.IntegerField(primary_key=True, blank=True,null=False,
>> unique=True)
>> pathname = models.CharField(max_length=255, blank=True, null=True)
>> segmentname = models.CharField(max_length=255, blank=True, null=True)
>> region = models.CharField(max_length=255, blank=True, null=True)
>>
>>
>>
>>
>>
>> *forms.py*
>> def getList(item_list, keyValue):
>> valueList=[]
>> for each in item_list:
>> valueList.append(each[keyValue])
>> return valueList
>>
>> def listCreator(field, query):
>> newList_query = getList(query, field)
>> sorted_newList = sorted(getUnique(newList_query))
>> sorted_newList.insert(0, ("", ""))
>> return sorted_newList
>>
>>
>> class CircuitinfotableForm(ModelForm):
>>
>>
>> class Meta:
>> pathlistQuery = Circuitinfotable.objects.all().values('pathname'
>> ).exclude(pathname=None).exclude(pathname='None')
>> path_list = listCreator('pathname', pathlistQuery)
>>
>>
>> model = Circuitinfotable
>> fields = ['circuitid', 'pathname', 'segmentname', 'region']
>> widgets = {'circuitid': forms.TextInput(attrs={'size':40}), 
>> 'pathname': forms.Select(choices=path_list), 'segmentname': forms.Select(
>> choices=segment_list),
>>'region':  forms.Select(choices=region_list)}
>>
>> I shortened this code to only include some of the relevant fields and 
>> code for brevity.  Here I created two functions to create a list of tuples 
>> for pathname from the values I retrieve using a query and pass it to the 
>> Select widget using choices.
>>
>> -- 
>> 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/b63b6f32-0040-42ee-9021-e45657e9caf7o%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/b63b6f32-0040-42ee-9021-e45657e9caf7o%40googlegroups.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/66b8fce5-43c6-48a6-a873-2527bdf2b126o%40googlegroups.com.


Populate choices from existing values in a model field

2020-06-19 Thread Patrick Carra
I am trying to read distinct values from a model field and use the tuple 
list to populate the choices in a Form.  The problem I have is that every 
time a new value is added I must reset the httpd server in order to include 
the new value in the form.  I have researched and tried this a few 
different ways but so far am unable to come up with a better solution. Any 
ideas?

*models.py*
class Circuitinfotable(models.Model):
id1 = models.IntegerField(primary_key=True, blank=True,null=False,unique
=True)
pathname = models.CharField(max_length=255, blank=True, null=True)
segmentname = models.CharField(max_length=255, blank=True, null=True)
region = models.CharField(max_length=255, blank=True, null=True)





*forms.py*
def getList(item_list, keyValue):
valueList=[]
for each in item_list:
valueList.append(each[keyValue])
return valueList

def listCreator(field, query):
newList_query = getList(query, field)
sorted_newList = sorted(getUnique(newList_query))
sorted_newList.insert(0, ("", ""))
return sorted_newList


class CircuitinfotableForm(ModelForm):


class Meta:
pathlistQuery = Circuitinfotable.objects.all().values('pathname').
exclude(pathname=None).exclude(pathname='None')
path_list = listCreator('pathname', pathlistQuery)


model = Circuitinfotable
fields = ['circuitid', 'pathname', 'segmentname', 'region']
widgets = {'circuitid': forms.TextInput(attrs={'size':40}), 
'pathname': forms.Select(choices=path_list), 'segmentname': forms.Select(
choices=segment_list),
   'region':  forms.Select(choices=region_list)}

I shortened this code to only include some of the relevant fields and code 
for brevity.  Here I created two functions to create a list of tuples for 
pathname from the values I retrieve using a query and pass it to the Select 
widget using choices.

-- 
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/b63b6f32-0040-42ee-9021-e45657e9caf7o%40googlegroups.com.


passing a parameter through CreateView to a be an initial value in a form

2020-02-19 Thread Patrick Carra
Hello I am trying to pass a value from a link into CreateView and use that 
value as an inital value in a form.  I am not having much success and am 
not sure that I am doing this correctly.  Here is what I have so far:
Link:
Circuit Ref: {{ record.id1 }}

urls.py
path('addXC//', views.addXC.as_view(), name='addXC'),

views.py
class addXC(CreateView):
model = Xcinventorytable
fields = ['circuitref', 'circuitid', 'vendor', 'legacy', 'address', 
'city', 'state', 'ciopsticket', 'notes']
success_url="/thanks/xcadded/"


def get_form_kwargs(self):
kwargs=super(addXC, self).get_form_kwargs()
kwargs.update({'circuitref': circuitref})
return kwargs

forms.py
class XcinventorytableForm(ModelForm):
class Meta:
model = Xcinventorytable
widgets = {'notes': forms.TextInput(attrs={'size':200, 'rows':2})}
help_texts = {'Circuitref': ('Enter the circuitref listed at the 
top of the last screen')}
fields = '__all__'


def __init__(self, *args, **kwargs):
circuitref = kwargs.pop('circuitref')
super(XcinventoryForm, self).__init__(*args, **kwargs)
self.fields['circuitref'].initial = circuitref


Any help or suggestions are 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/fd729e92-6256-4c3a-84df-79250794d6f6%40googlegroups.com.


Re: passing an argument to ListView class and accessing using kwargs

2019-12-11 Thread Patrick Carra
Thank you Dominick your second suggestion worked beautifully!  I appreciate 
your time and expertise!

-- 
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/fe6e98de-a0c3-42e4-ab36-d439243faf29%40googlegroups.com.


Re: passing an argument to ListView class and accessing using kwargs

2019-12-10 Thread Patrick Carra
One more additional note this is the url that gets access when the link is 
clicked

http://98.8.61.133:8080/viewLit/St.%20Louis%20to%20Mt.%20Vernon/viewutilization

-- 
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/5bf13205-e8e7-41c9-9c65-dc513e2dc50f%40googlegroups.com.


passing an argument to ListView class and accessing using kwargs

2019-12-10 Thread Patrick Carra
Hello I am attempting to pass an argument to a Class(ListView) and then 
perform a filter using a kwarg that contains the argument passed in the 
url.  I am having a problem because I cannot access the variable in the url 
using kwargs.  I am not sure what I'm doing wrong below is the link that 
I'm using to pass this value:
Click to View Utilization

my viewLit/urls.py is:
urlpatterns= [
 path('/', views.viewLit, name='viewLit'),
 path('/edit', views.editLit.as_view(), name='editLit'),
 path('/editXC', views.editXC.as_view(), name='editXC'),
 path('/viewutilization', 
views.viewUtilization.as_view(), name='viewUtilization'),
]

my views.py is:
class viewUtilization(ListView):
pk_url_kwarg = 'pathname'
model=Utilizationtable

def get_queryset(self, **kwargs):
qs = Utilizationtable.objects.filter(pathname=kwargs)
return qs


and my template is:




You have made it to the utilization page
{% block content %}
  Utilization
{% for object in object_list %}
  {{ object.reportdate }} {{ object.utilization }}
{% endfor %}
{% endblock %}



My query comes back as this:
*SELECT* ••• *FROM* "utilizationtable" *WHERE* "utilizationtable"."pathname" 
= '{}'

I know I'm missing something simple but I'm not sure what?!?!?!?!??!!

-- 
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/663edf79-246c-47d5-abb5-d9cb0e6ae718%40googlegroups.com.


Adding drop down selection to my form and filter

2019-12-04 Thread Patrick Carra
Hello I am working on adding a drop down selection to my filters so far I 
am not having any luck. I recently changed my views.py to use a class 
instead of a def for this.  Now when I use filter.form it shows every field 
in my models.  It should only show the following fields circuitid, 
bandwidth, region, carrier, status, segmentname, and mrcnew  and each 
should be a dynamically generated drop down list from the respective model 
field only displaying distinct values.  I tried creating my own form with a 
function that would return these values using choicefield but I can't get 
this form to come into the template.  A point in the right direction would 
be much appreciated!

class Circuitinfotable(models.Model):
id1 = models.IntegerField(blank=True, null=True)
pid = models.CharField(max_length=255, blank=True, null=True)
circuitid = models.CharField(primary_key=True,max_length=255, 
blank=False, null=False)
bandwidth = models.CharField(max_length=255, blank=True, null=True)
region = models.CharField(max_length=255, blank=True, null=True)
bw = models.IntegerField(blank=True, null=True)
tableaupathname = models.CharField(max_length=255, blank=True, 
null=True)
handoffalocaddress = models.CharField(max_length=255, blank=True, 
null=True)
handoffaloccity = models.CharField(max_length=255, blank=True, 
null=True)
handoffalocst = models.CharField(max_length=255, blank=True, null=True)
alocationaddress = models.CharField(max_length=255, blank=True, 
null=True)
alocationcity = models.CharField(max_length=255, blank=True, null=True)
alocst = models.CharField(max_length=255, blank=True, null=True)
handoffzlocaddress = models.CharField(max_length=255, blank=True, 
null=True)
carrier = models.CharField(max_length=255, blank=True, null=True)
handoffzloccity = models.CharField(max_length=255, blank=True, 
null=True)
handoffzlocst = models.CharField(max_length=255, blank=True, null=True)
zlocationaddress = models.CharField(max_length=255, blank=True, 
null=True)
zlocationcity = models.CharField(max_length=255, blank=True, null=True)
zlocst = models.CharField(max_length=255, blank=True, null=True)
segmentid = models.CharField(max_length=255, blank=True, null=True)
segmenttype = models.CharField(max_length=255, blank=True, null=True)
status = models.CharField(max_length=255, blank=True, null=True)
purpose = models.CharField(max_length=255, blank=True, null=True)
installdate = models.DateField(blank=True, null=True)
termdate = models.DateField(blank=True, null=True)
termlengthmos = models.IntegerField(blank=True, null=True)
legacy = models.CharField(max_length=255, blank=True, null=True)
installciopsticket = models.CharField(max_length=255, blank=True, 
null=True)
retermciopsticket = models.CharField(max_length=255, blank=True, 
null=True)
discociopsticket = models.CharField(max_length=255, blank=True, 
null=True)
notes = models.CharField(max_length=255, blank=True, null=True)
kma = models.CharField(max_length=255, blank=True, null=True)
group = models.IntegerField(blank=True, null=True)
cktidkey = models.IntegerField(blank=True, null=True)
visiolink = models.CharField(max_length=255, blank=True, null=True)
latestjiraticket = models.CharField(max_length=255, blank=True, 
null=True)
disconnectdate = models.DateField(blank=True, null=True)
segmentname = models.CharField(max_length=255, blank=True, null=True)
mrcnew = models.TextField(blank=True, null=True)  # This field type is 
a guess.
termyrs = models.IntegerField(blank=True, null=True)
monthbudget = models.IntegerField(blank=True, null=True)
monthdisco = models.IntegerField(blank=True, null=True)
mrcold = models.TextField(blank=True, null=True)  # This field type is 
a guess.
kmz = models.CharField(max_length=255, blank=True, null=True)

def __str__(self):
return self

class Meta:
managed = False
db_table = 'circuitinfotable'



My filter.py code is below:

from .models import Circuitinfotable
from .forms import CircuitForm
import django_filters

class CircuitInfoFilter(django_filters.FilterSet.form):
class Meta:
model=Circuitinfotable
#fields = ['circuitid', 'bandwidth', 'region', 'carrier', 'status', 
'segmentname', 'mrcnew']
form=CircuitForm


My forms.py is below:
from django import forms
from .models import Circuitinfotable

def getList(item_list, keyValue):
valueList=[]
for each in item_list:
valueList.append(each[keyValue])
return valueList

class CircuitForm(forms.Form):
class Meta:
model = Circuitinfotable
fields = ('circuitid', 'bandwidth', 'region', 'carrier', 'status', 
'segmentname', 'mrcnew')

region_dict=Circuitinfotable.objects.values('region').distinct('region')

def __init__(self, *args, **kwargs):
super(CircuitForm, self).__init__(*args, 

Re: Trying to update a record using UpdateView Error: Circuitinfotable matching query does not exist

2019-11-27 Thread Patrick Carra
okay so I dumped all the contents of my editCircuit.html into a file called 
circuitinfotable_form.html and now I get my form.  But I still don't 
understand why I had to use this name since I never specified it anywhere.

-- 
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/4419ba31-8535-4723-9c61-3627faadf9bb%40googlegroups.com.


Re: Trying to update a record using UpdateView Error: Circuitinfotable matching query does not exist

2019-11-27 Thread Patrick Carra
I don't have a circuitinfotable_form.html.  I never specified 
circuitinfotable_form in any of my code.  What should that form contain?  
My /viewLit/editCircuit.html form contains the following:




{% block content %}


{% csrf_token %}
{{form.as_p}}





{% endblock %}



Shouldn't that suffice for the template form?  What is calling the 
circuitinfotable_form.html?

-- 
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/a06f82fb-0920-4e76-b0cb-027cda1ced92%40googlegroups.com.


Re: Trying to update a record using UpdateView Error: Circuitinfotable matching query does not exist

2019-11-27 Thread Patrick Carra
I didn't have one.  I thought UpdateView would create the form for me.  But 
I was working the problem and made one:
from django.forms import ModelForm
from . models import Circuitinfotable

class CircuitinfotableForm(ModelForm):
class Meta:
model = Circuitinfotable
fields = '__all__'


So I also changed my view:
class editLit(UpdateView):
pk_url_kwarg = 'circuitid'
model=Circuitinfotable
form_class= CircuitinfotableForm
template="/viewLit/editCircuit.html"
#fields='__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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cdbc9127-6a2f-4022-bbda-dfec83101834%40googlegroups.com.


Re: Trying to update a record using UpdateView Error: Circuitinfotable matching query does not exist

2019-11-27 Thread Patrick Carra
Raja that was a great suggestion thank you!  Once a started playing around 
with the urls in the project level I found that it was still being routed 
to viewLit despite the edit/ in the url I was passing.  I decided to put 
all these classes into the same app viewLit/views.py and now my parameter 
is correct.

*SELECT* ••• *FROM* "circuitinfotable" *WHERE* "circuitinfotable".
"circuitid" = 'STTK-100G-18040-01-WRBB'

The problem I am now having is that UpdateView cannot find the template 
circuitinfotable_form.html
Environment:


Request Method: GET
Request URL: http://98.8.61.133:8080/viewLit/STTK-100G-18040-01-WRBB/edit

Django Version: 2.2.4
Python Version: 3.6.8
Installed Applications:
['editLit.apps.EditlitConfig',
 'viewLit.apps.ViewlitConfig',
 'searchLit.apps.SearchlitConfig',
 'homepage.apps.HomepageConfig',
 'base.apps.BaseConfig',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'debug_toolbar']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'debug_toolbar.middleware.DebugToolbarMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']

Template loader postmortem
Django tried loading these templates, in this order:

Using engine django:
* django.template.loaders.filesystem.Loader: 
/home/db_user/ciopsdb/base/templates/viewLit/circuitinfotable_form.html 
(Source does not exist)
* django.template.loaders.filesystem.Loader: 
/home/db_user/ciopsdb/templates/viewLit/circuitinfotable_form.html (Source 
does not exist)
* django.template.loaders.app_directories.Loader: 
/home/db_user/ciopsdb/editLit/templates/viewLit/circuitinfotable_form.html 
(Source does not exist)
* django.template.loaders.app_directories.Loader: 
/home/db_user/ciopsdb/viewLit/templates/viewLit/circuitinfotable_form.html 
(Source does not exist)
* django.template.loaders.app_directories.Loader: 
/home/db_user/ciopsdb/searchLit/templates/viewLit/circuitinfotable_form.html 
(Source does not exist)
* django.template.loaders.app_directories.Loader: 
/home/db_user/ciopsdb/homepage/templates/viewLit/circuitinfotable_form.html 
(Source does not exist)
* django.template.loaders.app_directories.Loader: 
/home/db_user/ciopsdb/base/templates/viewLit/circuitinfotable_form.html 
(Source does not exist)
* django.template.loaders.app_directories.Loader: 
/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/contrib/admin/templates/viewLit/circuitinfotable_form.html
 
(Source does not exist)
* django.template.loaders.app_directories.Loader: 
/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/contrib/auth/templates/viewLit/circuitinfotable_form.html
 
(Source does not exist)
* django.template.loaders.app_directories.Loader: 
/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/debug_toolbar/templates/viewLit/circuitinfotable_form.html
 
(Source does not exist)



Traceback:

File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/exception.py"
 
in inner
  34. response = get_response(request)

File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py"
 
in _get_response
  145. response = self.process_exception_by_middleware(e, 
request)

File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py"
 
in _get_response
  143. response = response.render()

File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/template/response.py"
 
in render
  106. self.content = self.rendered_content

File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/template/response.py"
 
in rendered_content
  81. template = self.resolve_template(self.template_name)

File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/template/response.py"
 
in resolve_template
  63. return select_template(template, using=self.using)

File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/template/loader.py"
 
in select_template
  47. raise TemplateDoesNotExist(', '.join(template_name_list), 
chain=chain)

Exception Type: TemplateDoesNotExist at 
/viewLit/STTK-100G-18040-01-WRBB/edit
Exception Value: viewLit/circuitinfotable_form.html


My viewLit/models.py is:
class Circuitinfotable(models.Model):
id1 = models.IntegerField(blank=True,null=True)
pid = models.CharField(max_length=255, blank=True, null=True)
circuitid = models.CharField(primary_key=True, max_length=255, 
blank=True, null=False)
bandwidth = models.CharField(max_length=255, blank=True, 

Re: Trying to update a record using UpdateView Error: Circuitinfotable matching query does not exist

2019-11-26 Thread Patrick Carra
It's actually this I copy and pasted the wrong thing:

Edit Circuit Info



My project level urls.py is:

from django.contrib import admin
from django.urls import path, include
from django.conf.urls import url
import debug_toolbar

urlpatterns = [
path('admin/', admin.site.urls),
path('', include('homepage.urls')),
path('searchlit/', include('searchLit.urls')),
path('viewLit/edit/', include('editLit.urls')),
path('viewLit/', include('viewLit.urls')),
path('edit/', include('editLit.urls')),
path(r'^__debug__/', include(debug_toolbar.urls)),
]

So, *editLit.urls* will be:

[...]
urlpatterns = [
[...]
 path('circuit/', 
views.editLit.as_view(),name='editLit'),
[]

]

But it doesn't work it gives me the same error:

*SELECT* ••• *FROM* "circuitinfotable" *WHERE* "circuitinfotable"."circuitid" 
= 'edit/circuit/STTK-100G-18040-01-WRBB'

-- 
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/a4e4c292-11cb-443f-8a2a-bcb91053f6f1%40googlegroups.com.


Re: Trying to update a record using UpdateView Error: Circuitinfotable matching query does not exist

2019-11-26 Thread Patrick Carra
Ha that was my mistake my brain has turned to mush anyhow the change was 
made and it still is broken :(

On Tuesday, November 26, 2019 at 3:34:45 PM UTC-6, Patrick Carra wrote:
>
> Correct me if i'm wrong but I think you meant:
>
> urlpatterns= [
>  path('circuit/', 
> views.editLit.as_view(),name='editLit'),
> ]
>
> I did make that change but the results were the same.
>

-- 
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/9bd047f5-0d6f-4197-b699-e92675b9d595%40googlegroups.com.


Re: Trying to update a record using UpdateView Error: Circuitinfotable matching query does not exist

2019-11-26 Thread Patrick Carra
Correct me if i'm wrong but I think you meant:

urlpatterns= [
 path('circuit/', 
views.editLit.as_view(),name='editLit'),
]

I did make that change but the results were the same.

-- 
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/53dd1d57-4465-4af3-9b9e-183a2f9b6913%40googlegroups.com.


Re: Trying to update a record using UpdateView Error: Circuitinfotable matching query does not exist

2019-11-26 Thread Patrick Carra
Yea! This toolbar is an awesome tool thanks for the tip.  So now I guess 
I'm not understanding how to route url's really.  The a href is:
 Edit Jira Info

My project level urls.py is:

from django.contrib import admin
from django.urls import path, include
from django.conf.urls import url
import debug_toolbar

urlpatterns = [
path('admin/', admin.site.urls),
path('', include('homepage.urls')),
path('searchlit/', include('searchLit.urls')),
path('viewLit/edit/', include('editLit.urls')),
path('viewLit/', include('viewLit.urls')),
path('edit/', include('editLit.urls')),
path(r'^__debug__/', include(debug_toolbar.urls)),
]

my editLit urls.py is:
from django.urls import path, include
from django.conf.urls import  url
from . import views

urlpatterns= [
 path('edit/circuit/', 
views.editLit.as_view(),name='editLit'),
]


And finally my editLit views.py is:
class editLit(UpdateView):
pk_url_kwarg = 'circuitid'
model=Circuitinfotable
template="/editLit/editCircuit.html"
fields = '__all__'


So I don't understand either how to just pull the param without the 
edit/circuit/ part or can that be stripped before it is passed to the view?

-- 
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/9685efa1-b9b1-46e2-b831-d6144e0ebdf2%40googlegroups.com.


Re: Trying to update a record using UpdateView Error: Circuitinfotable matching query does not exist

2019-11-26 Thread Patrick Carra
I figured out the weirdness with the django-debug-toolbar I wasn't serving 
my static files from the apache/mod_wsgi configuration.  After I figured 
that out this is what I have now:

 QueryTimelineTime (ms)Action
  +  
*SELECT* ••• *FROM* "circuitinfotable" *WHERE* "circuitinfotable"."circuitid" 
= 'edit/circuit/STTK-100G-18040-01-WRBB'
53.76007636826474%
2.42 SelExpl
  +  
*SELECT* ••• *FROM* "circuitinfotable" *LIMIT* 21
15.353203224437845%
0.69 SelExpl
  +  
*SELECT* ••• *FROM* "django_session" *WHERE* ("django_session"."expire_date" 
> '2019-11-26T20:52:52.260094+00:00'::timestamptz *AND* 
> "django_session"."session_key" 
= '0b3x3t7gx8sbl09y5vsbonxtlfmynib4')
16.928298684768777%
0.76 SelExpl
  +  
*SELECT* ••• *FROM* "auth_user" *WHERE* "auth_user"."id" = 1

-- 
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/fbd433a9-bf5d-4ee4-b51c-51efbe110a57%40googlegroups.com.


Re: Trying to update a record using UpdateView Error: Circuitinfotable matching query does not exist

2019-11-26 Thread Patrick Carra
Okay I have worked on it I do have the toolbar on there but it's not 
display correctly it shows up at the bottom of each page and looks like 
this:


   - Hide » 
   -  Versions 
   Django 2.2.4 
   -  Time 
   CPU: 51.78ms (56.68ms) 
   -  Settings 
   -  Headers 
   -  Request 
   index 
   -  SQL 
   2 queries in 2.67ms 
   -  Static files 
   0 files used 
   -  Templates 
   homepage/homepage.html 
   -  Cache 
   0 calls in 0.00ms 
   -  Signals 
   7 receivers of 12 signals 
   -  Logging 
   0 messages 
   - Intercept redirects
   - Profiling
   
«
Versions
[image: loading]
Time
[image: loading]
Settings from ciopsdb.settings
[image: loading]
Headers
[image: loading]
Request
[image: loading]
SQL queries from 1 connection
[image: loading]
Static files (134 found, 0 used)
[image: loading]
Templates (1 rendered)
[image: loading]
Cache calls from 1 backend
[image: loading]
Signals
[image: loading]
Log messages
[image: loading]

-- 
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/863520f7-65dc-4605-98d9-3d28ec1c6d1f%40googlegroups.com.


Re: Trying to update a record using UpdateView Error: Circuitinfotable matching query does not exist

2019-11-26 Thread Patrick Carra
I installed the django-debug-toolbar but its not doing anything. I imported 
it added it to settings.py installed apps and middleware, added the if 
statement to the project level urls.py and Debug is set to True.

-- 
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/bcc80c18-c3e8-4f29-844e-463014476c1e%40googlegroups.com.


Re: Trying to update a record using UpdateView Error: Circuitinfotable matching query does not exist

2019-11-26 Thread Patrick Carra
Could it possibly be that it is trying to match this entire value? 
/viewLit/edit/circuit/STTK-100G-18040-01-WRBB/ and if so what am I doing 
wrong in my urls and views that I am not dropping /viewLit/edit/circuit/?

-- 
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/0f2a1551-27b4-42c0-b251-e17dcb264ab2%40googlegroups.com.


Re: Trying to update a record using UpdateView Error: Circuitinfotable matching query does not exist

2019-11-26 Thread Patrick Carra
Thanks for the reply Gil i did this and was able to find this object.

Python 3.6.8 (default, Aug  7 2019, 17:28:10)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from editLit.models import Circuitinfotable
>>> obj = Circuitinfotable.objects.all()
>>> print(len(obj))
573
>>> obj = Obj.get(circuitid='STTK-100G-18040-01-WRBB')
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'Obj' is not defined
>>> obj = obj.get(circuitid='STTK-100G-18040-01-WRBB')
>>> print(obj)
STTK-100G-18040-01-WRBB

-- 
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/bbb629de-669c-4edf-a896-4402ee61187c%40googlegroups.com.


Re: Trying to update a record using UpdateView Error: Circuitinfotable matching query does not exist

2019-11-25 Thread Patrick Carra
Sorry I forgot one! My models.py for this class is below:

class Circuitinfotable(models.Model):
   id1 = models.IntegerField(blank=True, null=True)
   pid = models.CharField(max_length=255, blank=True, null=True)
   circuitid = models.CharField(primary_key=True, max_length=255, blank=
False, null=False)
   bandwidth = models.CharField(max_length=255, blank=True, null=True)
   region = models.CharField(max_length=255, blank=True, null=True)
   bw = models.IntegerField(blank=True, null=True)
   tableaupathname = models.CharField(max_length=255, blank=True, null=True)
   handoffalocaddress = models.CharField(max_length=255, blank=True, null=
True)
   handoffaloccity = models.CharField(max_length=255, blank=True, null=True)
   handoffalocst = models.CharField(max_length=255, blank=True, null=True)
   alocationaddress = models.CharField(max_length=255, blank=True, null=True
)
   alocationcity = models.CharField(max_length=255, blank=True, null=True)
   alocst = models.CharField(max_length=255, blank=True, null=True)
   handoffzlocaddress = models.CharField(max_length=255, blank=True, null=
True)
   carrier = models.CharField(max_length=255, blank=True, null=True)
   handoffzloccity = models.CharField(max_length=255, blank=True, null=True)
   handoffzlocst = models.CharField(max_length=255, blank=True, null=True)
   zlocationaddress = models.CharField(max_length=255, blank=True, null=True
)
   zlocationcity = models.CharField(max_length=255, blank=True, null=True)
   zlocst = models.CharField(max_length=255, blank=True, null=True)
   segmentid = models.CharField(max_length=255, blank=True, null=True)
   segmenttype = models.CharField(max_length=255, blank=True, null=True)
   status = models.CharField(max_length=255, blank=True, null=True)
   purpose = models.CharField(max_length=255, blank=True, null=True)
   installdate = models.DateField(blank=True, null=True)
   termdate = models.DateField(blank=True, null=True)
   termlengthmos = models.IntegerField(blank=True, null=True)
   legacy = models.CharField(max_length=255, blank=True, null=True)
   installciopsticket = models.CharField(max_length=255, blank=True, null=
True)
   retermciopsticket = models.CharField(max_length=255, blank=True, null=
True)
   discociopsticket = models.CharField(max_length=255, blank=True, null=True
)
   notes = models.CharField(max_length=255, blank=True, null=True)
   kma = models.CharField(max_length=255, blank=True, null=True)
   group = models.IntegerField(blank=True, null=True)
   cktidkey = models.IntegerField(blank=True, null=True)
   visiolink = models.CharField(max_length=255, blank=True, null=True)
   latestjiraticket = models.CharField(max_length=255, blank=True, null=True
, unique=True)
   disconnectdate = models.DateField(blank=True, null=True)
   segmentname = models.CharField(max_length=255, blank=True, null=True)
   mrcnew = models.TextField(blank=True, null=True)  # This field type is a 
guess.
   termyrs = models.IntegerField(blank=True, null=True)
   monthbudget = models.IntegerField(blank=True, null=True)
   monthdisco = models.IntegerField(blank=True, null=True)
   mrcold = models.TextField(blank=True, null=True)  # This field type is a 
guess.
   kmz = models.CharField(max_length=255, blank=True, null=True)

class Meta:
   managed = False
   db_table = 'circuitinfotable'

def __str__(self):
   return self.circuitid

def get_absolute_url(self):
   return reverse('home')



-- 
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/b407aac9-aec7-4e45-b91a-9864c4be2d80%40googlegroups.com.


Trying to update a record using UpdateView Error: Circuitinfotable matching query does not exist

2019-11-25 Thread Patrick Carra
I have a built a database application that users can search and view 
records from.  I am trying to incorporate an update feature to allow users 
to edit information the app is called editLit.  When I try to pass a 
parameter into the editLit app via urls into views.py I get the following 
error:

Environment:


Request Method: GET
Request URL: http://*:8080/viewLit/edit/circuit/STTK-100G-18040-01-WRBB/

Django Version: 2.2.4
Python Version: 3.6.8
Installed Applications:
['editLit.apps.EditlitConfig',
 'viewLit.apps.ViewlitConfig',
 'searchLit.apps.SearchlitConfig',
 'homepage.apps.HomepageConfig',
 'base.apps.BaseConfig',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles']
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']



Traceback:

File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/exception.py"
 
in inner
  34. response = get_response(request)

File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py"
 
in _get_response
  115. response = self.process_exception_by_middleware(e, 
request)

File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py"
 
in _get_response
  113. response = wrapped_callback(request, *callback_args, 
**callback_kwargs)

File "/home/db_user/ciopsdb/viewLit/views.py" in viewLit
  14. record = Circuitinfotable.objects.get(circuitid=circuitid)

File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/manager.py"
 
in manager_method
  82. return getattr(self.get_queryset(), name)(*args, 
**kwargs)

File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py"
 
in get
  408. self.model._meta.object_name

Exception Type: DoesNotExist at 
/viewLit/edit/circuit/STTK-100G-18040-01-WRBB/
Exception Value: Circuitinfotable matching query does not exist.

My template from which I start in a view app contains the a href link below:


Edit Circuit Info

my editLit.urls.py file contains:
from django.urls import path, include
from django.conf.urls import  url
from . import views

urlpatterns= [
 path('circuit//edit', 
views.editLit.as_view(),name='editLit'),
]


my editLit.views.py file contains:
from django.views.generic.edit import UpdateView

from . models import Circuitinfotable

# Create your views here.
class editLit(UpdateView):
model=Circuitinfotable
template="/editLit/editCircuit.html"
fields = '__all__'


And finally my template for the editLit class is:
{% block content %}


{% csrf_token %}
{{form.as_p}}





{% endblock %}


Any ideas about what I'm doing wrong are welcome I am still new to Django.  
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/985bf9e3-fbe4-4604-95db-9ee95ef10809%40googlegroups.com.


Re: django passing a parameter for a view in a url produces Error: Circuitinfotable matching query does not exist.

2019-11-15 Thread Patrick Carra
In case anyone is interested I fixed this with some simple regex in my 
view.  I identified the patterns for which apache was removing the // and 
replacing with a single / and then wrote some rules around that and 
replaced the single / with the // before passing it to my query.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2752a54f-4bdc-4781-b8ba-a842ffcb1a36%40googlegroups.com.


Re: django passing a parameter for a view in a url produces Error: Circuitinfotable matching query does not exist.

2019-11-14 Thread Patrick Carra
Yea I think what I may have to do is write some regex in the template to 
catch anytime there is a // and convert it to something that won't 
interfere with the apache/mod_wsgi due to the url and then when I pass it 
back into my view convert it back to the original in order to perform the 
query and get the correct response.

-- 
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/fa54b31d-c8b6-4900-93d7-e03d8f7ab6c6%40googlegroups.com.


Re: django passing a parameter for a view in a url produces Error: Circuitinfotable matching query does not exist.

2019-11-14 Thread Patrick Carra
I think my assumption was wrong stackoverflow is down right now so I can't 
go to the link but it seems like somebody is suggesting this is an 
apache/mod_wsgi error
https://code.djangoproject.com/ticket/14346

-- 
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/120e943c-55f6-4971-b80e-64713b095b7b%40googlegroups.com.


Re: django passing a parameter for a view in a url produces Error: Circuitinfotable matching query does not exist.

2019-11-14 Thread Patrick Carra
No change Daniel I looked that up and I think that is used for something 
else.  The name makes since but its purpose is for something else.

-- 
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/07bf0a2f-43b1-430a-8ded-1272bfa78863%40googlegroups.com.


Re: django passing a parameter for a view in a url produces Error: Circuitinfotable matching query does not exist.

2019-11-14 Thread Patrick Carra
There was no change after adding |safe after the value within {{}}
example: View

-- 
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/e023361a-1544-4095-ab6d-53461996947b%40googlegroups.com.


Re: django passing a parameter for a view in a url produces Error: Circuitinfotable matching query does not exist.

2019-11-14 Thread Patrick Carra
That is a value from the table in models called Circuitinfotable and the 
field it is pulled from is called circuitid.

-- 
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/e1e709ad-f9ba-49ab-9f91-0e01c54cc3b9%40googlegroups.com.


Re: django passing a parameter for a view in a url produces Error: Circuitinfotable matching query does not exist.

2019-11-14 Thread Patrick Carra
and the actual value is OQYX/173774//ZYO but Django is interpreting it as 
OQYX/173774/ZYO/

On Thursday, November 14, 2019 at 1:41:35 PM UTC-6, Patrick Carra wrote:
>
> That is a value from the table in models called Circuitinfotable and the 
> field it is pulled from is called circuitid.
>

-- 
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/55203f72-f8fb-48d9-8ace-09aa652e1721%40googlegroups.com.


Re: django passing a parameter for a view in a url produces Error: Circuitinfotable matching query does not exist.

2019-11-14 Thread Patrick Carra
Could you provide an example of what you mean?  I'm not sure what you mean 
by method call must include an object instance as argument.  This code 
works for other values of circuitid but does not work for one that contains 
a //.  This tells me, along with the traceback code, that django at some 
point drops one of the /'s and the result is it cannot find a matching 
circuitid in the Circuitinfotable during the query.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/62a01aa1-3686-4451-adcb-48a78f6e98d1%40googlegroups.com.


Re: django passing a parameter for a view in a url produces Error: Circuitinfotable matching query does not exist.

2019-11-14 Thread Patrick Carra
Daniel thank you but I'm not sure what you mean.  The a href link works for 
everything so far except in the case that the circuitid contains a //.  So 
I don't think its that my url's are not routing properly it seems to me 
like a // is being interpreted as an escape character.  I looked over my 
code again and could not understand what you intended to point out.

On Thursday, November 14, 2019 at 11:06:09 AM UTC-6, DANIEL URBANO DE LA 
RUA wrote:
>
> a href="/viewLit/{{ circuit.circuitid }}" t
>
> and in your urls.py 
>
>  path(r'/', views.viewLit, name='viewLit'),
>
> El jue., 14 nov. 2019 a las 18:04, DANIEL URBANO DE LA RUA (<
> dannybo...@gmail.com >) escribió:
>
>> check on your a link you are including vieset/ and there is not on your 
>> url
>>
>> El jue., 14 nov. 2019 a las 17:17, Integr@te System (<
>> datacen...@gmail.com >) escribió:
>>
>>> Hi Informer,
>>> check you model Circuitinfotable, 
>>> Method call must include object instance as argument.
>>>
>>>
>>> On Thu, Nov 14, 2019, 21:42 Patrick Carra >> > wrote:
>>>
>>>> I am passing a parameter in a url to another view and during the 
>>>> process it gets changed.  An original parameter example that produces the 
>>>> error is OQYX/173774//ZYO but gets changed to '/viewLit/OQYX/173774/ZYO/' 
>>>> It drops the second / between 173774 and ZYO. I assumed this was because 
>>>> it 
>>>> was treating it as an escape character? So I tried adding an r in the 
>>>> urls.py file but it did not have any effect. Here is my template code for 
>>>> the page that generates the hyperlink:
>>>>
>>>> 
>>>> 
>>>> 
>>>> Circuits
>>>> 
>>>> h1 {
>>>> color:blue;
>>>> }
>>>> h4 {
>>>> color:red;
>>>> }
>>>> .tabledata {
>>>>   background: #395870; color:#fff;
>>>> }
>>>> .tablerow:nth-child(even) {
>>>>   background-color: #f2f2f2;
>>>> }
>>>> .form{
>>>>   width:100%;
>>>> }
>>>> .field {
>>>>   background: #white; float: left; margin: 1%; width: 200;
>>>> }
>>>> 
>>>> {% block content %}
>>>>   Search Lit Circuits
>>>> Enter your search criteria below:
>>>> 
>>>> 
>>>>   
>>>> Circuit ID:>>> name="circuitid" maxlength="100">
>>>> Bandwidth:>>> name="bandwidth" maxlength="100">
>>>> Region:>>> "region" maxlength="100">
>>>>   
>>>>   
>>>> Carrier:>>> "carrier" maxlength="100">
>>>> Status:>>> "status" maxlength="100">
>>>> Segmentname:>>> name="segmentname" maxlength="100">
>>>>   
>>>>   
>>>> MRC:>>> "mrcnew" maxlength="100">
>>>>   
>>>> 
>>>> Search
>>>> 
>>>> 
>>>>   
>>>> 
>>>> {{ filter.qs.count }} circuits returned
>>>> 
>>>>   
>>>> 
>>>>   
>>>> 
>>>>   {% if user.is_authenticated %}
>>>> Edit/
>>>>   {% endif %}
>>>> View
>>>> 
>>>> CircuitID
>>>> Bandwidth
>>>> Region
>>>> Carrier
>>>> Status Segmentname MRC   
>>>>  {% for circuit in filter.qs %}  >>> class="actions"> {% if user.is_authenticated %} >>> title="Edit">Edit {% endif %} >>> title="View">View  {{ circuit.circuitid }} {{ 
>>>> circuit.bandwidth }} {{ circuit.region }} {{ 
>>>> circuit.carrier }} {{ circuit.status }} {{ 
>>>> circuit.segmentname }} {{ circuit.mrcnew }}  {% endfor 
>>>> %} {% endblock %}  
>>>>
>>>>
>>>> My project level urls.py file:
>>>> """ciopsdb URL Configuration
>>>>
>>>> The `urlpatterns` list routes URLs to views. For more information 
>&

django passing a parameter for a view in a url produces Error: Circuitinfotable matching query does not exist.

2019-11-14 Thread Patrick Carra
I am passing a parameter in a url to another view and during the process it 
gets changed.  An original parameter example that produces the error 
is OQYX/173774//ZYO but gets changed to '/viewLit/OQYX/173774/ZYO/' It 
drops the second / between 173774 and ZYO. I assumed this was because it 
was treating it as an escape character? So I tried adding an r in the 
urls.py file but it did not have any effect. Here is my template code for 
the page that generates the hyperlink:




Circuits

h1 {
color:blue;
}
h4 {
color:red;
}
.tabledata {
  background: #395870; color:#fff;
}
.tablerow:nth-child(even) {
  background-color: #f2f2f2;
}
.form{
  width:100%;
}
.field {
  background: #white; float: left; margin: 1%; width: 200;
}

{% block content %}
  Search Lit Circuits
Enter your search criteria below:


  
Circuit ID:
Bandwidth:
Region:
  
  
Carrier:
Status:
Segmentname:
  
  
MRC:
  

Search


  

{{ filter.qs.count }} circuits returned

  

  

  {% if user.is_authenticated %}
Edit/
  {% endif %}
View

CircuitID
Bandwidth
Region
Carrier
Status Segmentname MRC{% 
for circuit in filter.qs %}   {% 
if user.is_authenticated %} Edit {% endif %} View  {{ circuit.circuitid }} {{ 
circuit.bandwidth }} {{ circuit.region }} {{ 
circuit.carrier }} {{ circuit.status }} {{ 
circuit.segmentname }} {{ circuit.mrcnew }}  {% endfor 
%} {% endblock %}  


My project level urls.py file:
"""ciopsdb URL Configuration

The `urlpatterns` list routes URLs to views. For more information please 
see:
https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
1. Add an import:  from my_app import views
2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
1. Add an import:  from other_app.views import Home
2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.conf.urls import url

urlpatterns = [
path('admin/', admin.site.urls),
path('', include('homepage.urls')),
path('searchlit/', include('searchLit.urls')),
path('viewLit/', include('viewLit.urls')),
]


My viewLit app's urls.py

from django.urls import path, include
from django.conf.urls import  url
from . import views

urlpatterns= [
 path(r'/', views.viewLit, name='viewLit'),
]


My viewLit app's views.py

from django.shortcuts import render
from django.http import HttpResponse
from django.views.generic import TemplateView

from . models import Circuitinfotable, Budgettable, Xcinventorytable

# Create your views here.
def viewLit(request, circuitid):
record = Circuitinfotable.objects.get(circuitid=circuitid)
template = 'viewLit/viewCircuit.html'
context = {'record':record}
return render(request, template, context)


The traceback that I receive as an error:

Traceback:File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/exception.py"
 in inner  34. response = get_response(request)File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py"
 in _get_response  115. response = 
self.process_exception_by_middleware(e, request)File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py"
 in _get_response  113. response = wrapped_callback(request, 
*callback_args, **callback_kwargs)File "/home/db_user/ciopsdb/viewLit/views.py" 
in viewLit  9. record = 
Circuitinfotable.objects.get(circuitid=circuitid)File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/manager.py"
 in manager_method  82. return getattr(self.get_queryset(), 
name)(*args, **kwargs)File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py"
 in get  408. self.model._meta.object_nameException Type: 
DoesNotExist at /viewLit/OQYX/173774/ZYO/Exception Value: Circuitinfotable 
matching query does not exist.


Any suggestions are 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/49da6357-27be-42fa-8b88-fc9c223654d8%40googlegroups.com.


Re: Performing a query returns an error

2019-11-13 Thread Patrick Carra
Simon thank you for that I had been playing around with db_column but did 
not realize the exact reference I should have been making.  Thank you for 
the quick reply!

On Wednesday, November 13, 2019 at 9:46:59 AM UTC-6, Simon Charette wrote:
>
> Hello Patrick,
>
> From what I understand you are relying on unmanaged (Meta.managed=False) 
> models
> to use the ORM to query an externally managed database.
>
> The part you missed here is that the ORM maps ForeignKey fields to 
> database columns with
> a "_id" suffix by default. In your case that means it expects a "pid_id" 
> column to exist for the
> Budgettable.pid field.
>
> If you column is actually named "pid" you'll want to use the "db_column" 
> option to let the ORM
> know about it[0]. That is `db_column=pid` in your `pid = ForeignKey` 
> definition.
>
> Cheers,
> Simon
>
> [0] 
> https://docs.djangoproject.com/en/2.2/ref/models/fields/#database-representation
>
> Le mercredi 13 novembre 2019 10:28:30 UTC-5, Patrick Carra a écrit :
>>
>> Hello all I am new to django and I am trying to do a query to that will 
>> provide me with information from multiple tables I have included my 
>> models.py file below:
>> Enter code hclass Circuitinfotable(models.Model):
>> pid = models.CharField(max_length=255, blank=True, null=True)
>> circuitid = models.CharField(primary_key=True, max_length=255, 
>> blank=True, null=False)
>> bandwidth = models.CharField(max_length=255, blank=True, null=True)
>> region = models.CharField(max_length=255, blank=True, null=True)
>> 
>>
>> class Meta:
>> managed = False
>> db_table = 'circuitinfotable'
>>
>>
>> class Budgettable(models.Model):
>> id = models.IntegerField(primary_key=True)
>> circuitid = models.CharField(max_length=255, blank=True, null=True)
>> pid = models.ForeignKey('Circuitinfotable', on_delete=models.CASCADE)
>> monthnum = models.IntegerField(blank=True, null=True)
>> yearnum = models.IntegerField(blank=True, null=True)
>> budgetmrc = models.TextField(blank=True, null=True)  # This field 
>> type is a guess.
>> actualmrc = models.TextField(blank=True, null=True)  # This field 
>> type is a guess.
>> region = models.CharField(max_length=255, blank=True, null=True)
>>
>> class Meta:
>> managed = False
>> db_table = 'budgettable'
>>
>>
>> the code I was using to query this is below:
>> >>> from viewLit.models import Circuitinfotable, Budgettable
>> >>> btc = Circuitinfotable.objects.get(circuitid='ETH100GB-23349286')
>> >>> btc.budgettable_set.all()
>> Traceback (most recent call last):
>>   File 
>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/backends/utils.py",
>>  
>> line 84, in _execute
>> return self.cursor.execute(sql, params)
>> psycopg2.errors.UndefinedColumn: column budgettable.pid_id does not exist
>> LINE 1: ...CT "budgettable"."id", "budgettable"."circuitid", "budgettab...
>>  ^
>> HINT:  Perhaps you meant to reference the column "budgettable.pid".
>>
>>
>> The above exception was the direct cause of the following exception:
>>
>> Traceback (most recent call last):
>>   File "", line 1, in 
>>   File 
>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py",
>>  
>> line 250, in __repr__
>> data = list(self[:REPR_OUTPUT_SIZE + 1])
>>   File 
>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py",
>>  
>> line 274, in __iter__
>> self._fetch_all()
>>   File 
>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py",
>>  
>> line 1242, in _fetch_all
>> self._result_cache = list(self._iterable_class(self))
>>   File 
>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py",
>>  
>> line 55, in __iter__
>> results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, 
>> chunk_size=self.chunk_size)
>>   File 
>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/sql/compiler.py",
>>  
>> line 1100, in execute_sql
>> cursor.execute(sql, params)
>>   File 
>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-pa

Performing a query returns an error

2019-11-13 Thread Patrick Carra
Hello all I am new to django and I am trying to do a query to that will 
provide me with information from multiple tables I have included my 
models.py file below:
Enter code hclass Circuitinfotable(models.Model):
pid = models.CharField(max_length=255, blank=True, null=True)
circuitid = models.CharField(primary_key=True, max_length=255, 
blank=True, null=False)
bandwidth = models.CharField(max_length=255, blank=True, null=True)
region = models.CharField(max_length=255, blank=True, null=True)


class Meta:
managed = False
db_table = 'circuitinfotable'


class Budgettable(models.Model):
id = models.IntegerField(primary_key=True)
circuitid = models.CharField(max_length=255, blank=True, null=True)
pid = models.ForeignKey('Circuitinfotable', on_delete=models.CASCADE)
monthnum = models.IntegerField(blank=True, null=True)
yearnum = models.IntegerField(blank=True, null=True)
budgetmrc = models.TextField(blank=True, null=True)  # This field type 
is a guess.
actualmrc = models.TextField(blank=True, null=True)  # This field type 
is a guess.
region = models.CharField(max_length=255, blank=True, null=True)

class Meta:
managed = False
db_table = 'budgettable'


the code I was using to query this is below:
>>> from viewLit.models import Circuitinfotable, Budgettable
>>> btc = Circuitinfotable.objects.get(circuitid='ETH100GB-23349286')
>>> btc.budgettable_set.all()
Traceback (most recent call last):
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/backends/utils.py",
 
line 84, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedColumn: column budgettable.pid_id does not exist
LINE 1: ...CT "budgettable"."id", "budgettable"."circuitid", "budgettab...
 ^
HINT:  Perhaps you meant to reference the column "budgettable.pid".


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "", line 1, in 
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py",
 
line 250, in __repr__
data = list(self[:REPR_OUTPUT_SIZE + 1])
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py",
 
line 274, in __iter__
self._fetch_all()
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py",
 
line 1242, in _fetch_all
self._result_cache = list(self._iterable_class(self))
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py",
 
line 55, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, 
chunk_size=self.chunk_size)
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/sql/compiler.py",
 
line 1100, in execute_sql
cursor.execute(sql, params)
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/backends/utils.py",
 
line 99, in execute
return super().execute(sql, params)
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/backends/utils.py",
 
line 67, in execute
return self._execute_with_wrappers(sql, params, many=False, 
executor=self._execute)
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/backends/utils.py",
 
line 76, in _execute_with_wrappers
return executor(sql, params, many, context)
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/backends/utils.py",
 
line 84, in _execute
return self.cursor.execute(sql, params)
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/utils.py", 
line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/backends/utils.py",
 
line 84, in _execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: column budgettable.pid_id does not exist
LINE 1: ...CT "budgettable"."id", "budgettable"."circuitid", "budgettab...
 ^
HINT:  Perhaps you meant to reference the column "budgettable.pid".


The next thing that I tried was to just get an object from the Budgettable 
directly code below:

>>> btcBud=Budgettable.objects.get(pid='ETH100GB-23349286')
Traceback (most recent call last):
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/backends/utils.py",
 
line 84, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedColumn: column budgettable.pid_id does not exist
LINE 1: ...CT "budgettable"."id", "budgettable"."circuitid", "budgettab...
 ^
HINT:  Perhaps you meant to reference the column "budgettable.pid".


The above exception was the direct cause of the following exception:

Traceback (most recent call 

Re: Django - How to add a link to a table that will open another page(django app) from an html template and pass a variable with it.

2019-11-11 Thread Patrick Carra
This worked for me but upon more testing I discovered some values such as 
WAVE/123456//IMP 
get changed to WAVE/123456//IMP during the process of passing this 
parameter as a url and django interpreting it.  As a result I get an error: 
Circuitinfotable matching query does not exist.  I'm assuming this is 
because django is interpreting the second / as an escape character?  How do 
I get it to include all /'s in the query so that a correct result will be 
returned.

On Wednesday, September 25, 2019 at 1:27:31 PM UTC-5, Randy Hughes wrote:
>
> views.py
> class *viewLit*(TemplateView): 
>
> def get(self, request, strategy=None):
> circuit_id = self.request.query_params.get('circuitid', None)
>
> urls.py
>
> path('viewlit/', viewlit.as_view(), name='viewlit')
>
>
> search_custom.html
> 
> 
> {{ circuit.circuitid }}
> 
> 
>
>
> ''' this is an example using a query parameter
> the url in urls.py does not need to include this parameter as a slug
>
> the view is able to get the parameter by key name (the same way you get a 
> key from a dict)
> the tag is formatted to create the url ex (127.0.0.1/foo/) query 
> parameters are everything following the ?
> so as you can do something like this 
> 127.0.0.1/foo/?field1=a=b=c
> I am not sure if this is the better than your solution but this should 
> work. As well you can add a redirect in viewlit to a different page if
> circuit_id does not exist.
> '''
>
>
>
> On Wed, Sep 25, 2019 at 1:09 PM Patrick Carra  > wrote:
>
>> Hello I have an app that displays some database information in a table.  
>> Inside of the html template I am making an edit link that I want to open 
>> another app(page viewLit) while passing a value to it's view.  I have added 
>> my code below.  My question is I am unsure of how to make this links url 
>> and pass the object data located inside circuit.circuitid along with it.  I 
>> haven't been able to find the right way to code this yet and this is just 
>> how I thought that this should be done. If anyone has a better idea I am 
>> open to suggestions.
>>
>> search_custom.html(code for link)
>> {% for circuit in filter.qs %}
>> 
>> 
>> View
>> 
>> {{ circuit.circuitid }}
>> 
>> {% endfor %}
>>
>> myapp/myapp/urls.py
>> urlpatterns = [
>> path('viewLit/', include('viewLit.urls')),
>> ]
>>
>> myapp/viewLit/urls.py
>> urlpatterns=[
>> path('viewLit/circuitid.id', views.viewLit, name='viewLit'),
>> ]
>>
>> views.py
>> def viewLit(request, circuitid):
>> #display records fields here
>> return HttpResponse("You are at the viewLit page!")
>>
>> -- 
>> 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/d81bf60a-260c-44c1-9c12-e852b51432a9%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/d81bf60a-260c-44c1-9c12-e852b51432a9%40googlegroups.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/e8ecbed1-e827-4776-a87c-29b31c81ab9e%40googlegroups.com.


Re: Django - How to add a link to a table that will open another page(django app) from an html template and pass a variable with it.

2019-11-07 Thread Patrick Carra
Thank you Randy!

On Wednesday, September 25, 2019 at 12:09:52 PM UTC-5, Patrick Carra wrote:
>
> Hello I have an app that displays some database information in a table.  
> Inside of the html template I am making an edit link that I want to open 
> another app(page viewLit) while passing a value to it's view.  I have added 
> my code below.  My question is I am unsure of how to make this links url 
> and pass the object data located inside circuit.circuitid along with it.  I 
> haven't been able to find the right way to code this yet and this is just 
> how I thought that this should be done. If anyone has a better idea I am 
> open to suggestions.
>
> search_custom.html(code for link)
> {% for circuit in filter.qs %}
> 
> 
> View
> 
> {{ circuit.circuitid }}
> 
> {% endfor %}
>
> myapp/myapp/urls.py
> urlpatterns = [
> path('viewLit/', include('viewLit.urls')),
> ]
>
> myapp/viewLit/urls.py
> urlpatterns=[
> path('viewLit/circuitid.id', views.viewLit, name='viewLit'),
> ]
>
> views.py
> def viewLit(request, circuitid):
> #display records fields here
> return HttpResponse("You are at the viewLit page!")
>

-- 
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/fc5c93e7-2f6e-46f0-9501-84a2e9c60508%40googlegroups.com.


Django - How to add a link to a table that will open another page(django app) from an html template and pass a variable with it.

2019-09-25 Thread Patrick Carra
Hello I have an app that displays some database information in a table.  
Inside of the html template I am making an edit link that I want to open 
another app(page viewLit) while passing a value to it's view.  I have added 
my code below.  My question is I am unsure of how to make this links url 
and pass the object data located inside circuit.circuitid along with it.  I 
haven't been able to find the right way to code this yet and this is just 
how I thought that this should be done. If anyone has a better idea I am 
open to suggestions.

search_custom.html(code for link)
{% for circuit in filter.qs %}


View

{{ circuit.circuitid }}

{% endfor %}

myapp/myapp/urls.py
urlpatterns = [
path('viewLit/', include('viewLit.urls')),
]

myapp/viewLit/urls.py
urlpatterns=[
path('viewLit/circuitid.id', views.viewLit, name='viewLit'),
]

views.py
def viewLit(request, circuitid):
#display records fields here
return HttpResponse("You are at the viewLit page!")

-- 
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/d81bf60a-260c-44c1-9c12-e852b51432a9%40googlegroups.com.


Re: A calendar booking app

2018-06-05 Thread Spence Patrick
I use Google calendar for a booking app that changes events in a public
calendar for everyone to see

On Tue, Jun 5, 2018, 06:33 Kasper Laudrup  wrote:

> Hi fellow Django users,
>
> I'm planning to start up a homepage for my familys summer house.
>
> There are a few ideas of what should be there, user management, possibly
> "blog like" entries, a photo gallery etc. I think I've found some pretty
> good existing Django apps for that, so that shouldn't be a problem to
> integrate them together somehow.
>
> A really cool feature though, would be to have some kind of
> reservation/booking system where any (authenticated) user can see when
> the house has been reserved and when it's available.
>
> Ideally, a non-admin user can request a range of dates, and an admin can
> then accept or decline that request. Naturally, there can only be one
> reservation on a range of dates.
>
> I have found a few calendar/booking like applications, but I'm not sure
> if any of them really fits my purpose.
>
> I could write all the code myself, but it would be a lot easier for me
> if an existing project already supports something similar that I could
> integrate.
>
> Anyone who has any experience with doing something that or could
> recommend where I should look?
>
> Thanks a lot!
>
> Kind regards,
>
> Kasper Laudrup
>
> --
> 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/7c77a814-7416-91ce-25db-1b3f0f22bd03%40stacktrace.dk
> .
> 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/CAD6-5Ci0YMo1HuwLazKHPqCVWdVCdO3%2BzEvgpkMBYF3mHGNt9A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: URL Concatenation Issue

2018-05-30 Thread Spence Patrick
Is your link tag href="./about" or href="/about/"

On Wed, May 30, 2018, 19:14  wrote:

> Hello,
>
> I'm debugging an issue that I'm having with my URL patterns. In my HTML I
> have an "about me" page that is linking to an about.html file in my
> templates/blog/ directory. When I load the homepage and click on the "about
> me" link than "domain.com/about/" loads, which matches the URL pattern in
> my blog/urls.py file, and the page renders perfectly fine.
>
> However, while on the "about me" page I can't link to any other page
> because the URL pattern starts to concatenate instead of overwrite (if that
> makes any sense). For example, if I click on "about me" again than Django
> tries to load domain.com/about/about and I get an error.
>
> I'm using a python 3.5.2 venv and I'm running Django 2.0.5. I'm new to
> programming by the way (to include Python, Django, HTML/CSS).
>
> --
> 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/1213b3f9-c74b-4af9-b585-61f2423720f0%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/CAD6-5Ch7%3DSTQGPdPg3iU%3Dvy2H1GMqcFnycBqb5bquXGDDV6ZBA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Attribute error

2018-05-30 Thread Spence Patrick
The f in field should be capitalized

On Wed, May 30, 2018, 20:10 Caleb Bryson  wrote:

> it is still saying "AttributeError: model 'django.db.models' has no
> attribute 'Charfeild'
>
> On Wednesday, May 30, 2018 at 10:04:04 PM UTC-4, Mike Dewhirst wrote:
>>
>> On 31/05/2018 11:45 AM, Caleb Bryson wrote:
>> > I am getting a attribute error when i try to run my server. does
>> > anyone know what i can change in this code to fix that?
>>
>> Try indenting the __str__ method so it is within the scope of the Post
>> class
>>
>> >
>> > from django.db import models
>> > class Post(models.Model) :
>> > title = models.Charfield(max_length=140)
>> > body = models.Textfield()
>> > date = models.DataTimeField()
>> > def __str__(self):
>> > return self.title
>> > --
>> > 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 https://groups.google.com/group/django-users.
>> > To view this discussion on the web visit
>> >
>> https://groups.google.com/d/msgid/django-users/b0ffbdfa-8eee-4560-9fc1-16849c8fdceb%40googlegroups.com
>> > <
>> https://groups.google.com/d/msgid/django-users/b0ffbdfa-8eee-4560-9fc1-16849c8fdceb%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/e2d17976-18e1-4120-950d-1457858f012b%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/CAD6-5Chfe5X_J8KbfWs7Otz7W45T4QVfYULW4UDkYU%3D2AAaZrg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Aggregation and following relationships backwards multiple levels

2017-02-01 Thread Patrick Joy
Hi,

Thank you for your response, this works perfectly!

Patrick

On Thursday, February 2, 2017 at 4:07:21 AM UTC+11, pradam.programming 
wrote:
>
> Hi Patrick,
> you can do like this:
> def total(self):
> return ContractItem.objects.filter(contract__subbudget__budge__in=
> self.budget_set.all()).aggregate(Sum('total'))['total__sum']
>
> try like this..!
>
> On Wed, Feb 1, 2017 at 7:14 PM, Patrick Joy <pat...@joytech.com.au 
> > wrote:
>
>> Hi all,
>>
>> Would appreciate some advice on this, I'm having trouble working out the 
>> best way to aggregate across multiple foreign key relationships. I have 
>> come up with the solution below however I'm not sure if this is the correct 
>> way to handle this situation. Any advice would be appreciated.
>>
>> Thanks
>>
>>
>> As an example I have a model structure that is 5 levels deep with foreign 
>> keys between each level, cost information is recorded at the lowest level 
>> (ContractItem) 
>>
>> --- Project
>>|--- Budget
>>   |--- SubBudget
>>  |--- Contract
>> |--- ContractItem - $100
>>
>> If I want to aggregate the total cost up to the top project level I do it 
>> in multiple steps like this:
>>
>> class Project(models.Model):
>> name = models.CharField(max_length=50)
>>
>> def total(self):
>> subbudgets = 
>> SubBudget.objects.filter(budget__in=self.budget_set.all())
>> contracts = Contract.objects.filter(subbudget__in=subbudgets)
>> return 
>> ContractItem.objects.filter(contract__in=contracts).aggregate(Sum('total'))['total__sum']
>>
>>
>> Is there a better way of doing this?
>>
>>
>> Full working code:
>>
>> class Project(models.Model):
>> name = models.CharField(max_length=50)
>>
>> def total(self):
>> subbudgets = 
>> SubBudget.objects.filter(budget__in=self.budget_set.all())
>> contracts = Contract.objects.filter(subbudget__in=subbudgets)
>> return 
>> ContractItem.objects.filter(contract__in=contracts).aggregate(Sum('total'))['total__sum']
>>
>> def __str__(self):
>> return self.name
>>
>> class Budget(models.Model):
>> project = models.ForeignKey(Project)
>> name = models.CharField(max_length=50)
>>
>> def __str__(self):
>> return self.name
>>
>> def total(self):
>> contracts = 
>> Contract.objects.filter(subbudget__in=self.subbudget_set.all())
>> return 
>> ContractItem.objects.filter(contract__in=contracts).aggregate(Sum('total'))['total__sum']
>>
>>
>> class SubBudget(models.Model):
>> budget = models.ForeignKey(Budget)
>> name = models.CharField(max_length=50)
>>
>> def __str__(self):
>> return self.name
>>
>> def total(self):
>> return 
>> ContractItem.objects.filter(contract__in=self.contract_set.all()).aggregate(Sum('total'))['total__sum']
>>
>>
>> class Contract(models.Model):
>> subbudget = models.ForeignKey(SubBudget)
>> name = models.CharField(max_length=50)
>>
>> def __str__(self):
>> return self.name
>>
>> def total(self):
>> return self.contractitem_set.aggregate(Sum('total'))['total__sum']
>>
>> class ContractItem(models.Model):
>> contract = models.ForeignKey(Contract)
>> total = models.DecimalField(default=0.00, decimal_places=2, 
>> max_digits=12)
>> name = models.CharField(max_length=50)
>>
>> def __str__(self):
>> return self.name
>>
>> -- 
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/f1a3bfb7-f342-423d-8790-fc0d5bbcf151%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/f1a3bfb7-f342-423d-8790-fc0d5bbcf151%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/4dbc5abe-e913-44d0-aaee-55679c673b46%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Aggregation and following relationships backwards multiple levels

2017-02-01 Thread Patrick Joy
Hi all,

Would appreciate some advice on this, I'm having trouble working out the 
best way to aggregate across multiple foreign key relationships. I have 
come up with the solution below however I'm not sure if this is the correct 
way to handle this situation. Any advice would be appreciated.

Thanks


As an example I have a model structure that is 5 levels deep with foreign 
keys between each level, cost information is recorded at the lowest level 
(ContractItem) 

--- Project
   |--- Budget
  |--- SubBudget
 |--- Contract
|--- ContractItem - $100

If I want to aggregate the total cost up to the top project level I do it 
in multiple steps like this:

class Project(models.Model):
name = models.CharField(max_length=50)

def total(self):
subbudgets = 
SubBudget.objects.filter(budget__in=self.budget_set.all())
contracts = Contract.objects.filter(subbudget__in=subbudgets)
return 
ContractItem.objects.filter(contract__in=contracts).aggregate(Sum('total'))['total__sum']


Is there a better way of doing this?


Full working code:

class Project(models.Model):
name = models.CharField(max_length=50)

def total(self):
subbudgets = 
SubBudget.objects.filter(budget__in=self.budget_set.all())
contracts = Contract.objects.filter(subbudget__in=subbudgets)
return 
ContractItem.objects.filter(contract__in=contracts).aggregate(Sum('total'))['total__sum']
   
def __str__(self):
return self.name

class Budget(models.Model):
project = models.ForeignKey(Project)
name = models.CharField(max_length=50)

def __str__(self):
return self.name

def total(self):
contracts = 
Contract.objects.filter(subbudget__in=self.subbudget_set.all())
return 
ContractItem.objects.filter(contract__in=contracts).aggregate(Sum('total'))['total__sum']


class SubBudget(models.Model):
budget = models.ForeignKey(Budget)
name = models.CharField(max_length=50)

def __str__(self):
return self.name

def total(self):
return 
ContractItem.objects.filter(contract__in=self.contract_set.all()).aggregate(Sum('total'))['total__sum']


class Contract(models.Model):
subbudget = models.ForeignKey(SubBudget)
name = models.CharField(max_length=50)

def __str__(self):
return self.name

def total(self):
return self.contractitem_set.aggregate(Sum('total'))['total__sum']

class ContractItem(models.Model):
contract = models.ForeignKey(Contract)
total = models.DecimalField(default=0.00, decimal_places=2, 
max_digits=12)
name = models.CharField(max_length=50)

def __str__(self):
return self.name

-- 
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/f1a3bfb7-f342-423d-8790-fc0d5bbcf151%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using django/mod_wsgi with apache httpd ErrorDocument seems to confuse reverse URL mapping

2016-06-27 Thread Patrick Ethier
Quick update, the answer to my question in reading the source code is to 
set FORCE_SCRIPT_NAME=/wsgi-app/ from the example below. It also seems that 
the trailing slash in the WSGIScriptAlias is not appropriate, so the 
directive should be:
WSGIScriptAlias /wsgi-app ...

It also seems, as per this Django 
issue: https://code.djangoproject.com/ticket/12464#comment:16

A whole bunch of other sites also propose overwriting with 
request.META['SCRIPT_NAME'] and the request.environ['SCRIPT_NAME'] in 
wsgy.py or to use Apache to manually set X-SCRIPT_NAME to this value, It 
seems they all work in different ways, but the most straight-forward seems 
to be the FORCE_SCRIPT_NAME in settings.py


On Monday, June 27, 2016 at 3:09:13 PM UTC+2, Patrick Ethier wrote:
>
> Hi, I'm trying to set up mod_wsgi and Django to handle authentication and 
> I'm getting a weird problem. After much troubleshooting I've distilled it 
> down to the configs below:
>
> /etc/httpd/conf.d/10-django.conf
> 
> ServerName site.internal
> DocumentRoot /home/user/git/standard-web-site-no-python-stuff/
> alias /static/ /home/user/git/project/app/static/
> 
>   Require all granted
> 
>
> 
>   
> Order Deny, Allow
> Allow from all
> Require all granted
>   
> 
> WSGIDaemonProcess site.internal user=apache processes=2 threads=10 
> display-name=%{GROUP} python-path=/home/user/git/project
> WSGIProcessGroup site.internal
> WSGIScriptAlias /wsgi-app/ /home/user/git/project/app/wsgi.py
> 
>   Order Deny, Allow
>   Allow from all
>   ErrorDocument 404 "/wsgi-app/"
> 
> 
>
> My Django project is set up VERY simply with the following:
> /home/user/git/project/app/wsgi.py
> ...imports...
>
> os.environ.setdefault(*"DJANGO_SETTINGS_MODULE"*, *"app.settings"*)
>
> from django.core.wsgi import get_wsgi_application
>
> application = get_wsgi_application()
>
>
> /home/user/git/project/app/views.py
>
> def main(request):
>
>   return render(request, "appname/template.tmpl")
>
>
> def testme(request):
>
>   return render(request, "appname/template2.tmpl")
>
>
> /home/user/git/project/app/urls.py
>
> urlpatterns = [
>
>   url(r'^$', "app.views.main", name="app-main"),
>
>   url(r'^testme/$', "app.views.testme", name="app-testme"),
>
> ]
>
>
> /home/user/git/project/app/templates/app/template.tmpl
>
> ...HTML Stuff...
>
> testme
>
> ...More HTML stuff
>
>
> --
>
> The above app works 100% fine when I go to http://site.internal/wsgi-app/. 
> If I hover over the "testme" anchor, I get 
> http://site.internal/wsgi-app/testme/
>
>
> BUT! If I go to http://site.internal/non-good-html.html and get 
> redirected by the ErrorDocument 404 directive it shows my views.main() page.
>
> When I hover over the "testme" anchor, I get http://site.internal/testme/ 
> (***Notice the missing /wsgi-app/***)
>
>
> It seems like the app namespace is not preserved when I'm rendering the 
> main() page from an ErrorDocument directive.
>
>
> I tried adding app_name="wsgi-app" to the urls.py but it doesn't change 
> anything.
>
>
> I must be missing something simple as this seems like an easy use-case to 
> implement.
>
>
> Pat
>

-- 
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/7b47b3c3-86b2-41c7-9f27-2291df2ba6ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Using django/mod_wsgi with apache httpd ErrorDocument seems to confuse reverse URL mapping

2016-06-27 Thread Patrick Ethier
Hi, I'm trying to set up mod_wsgi and Django to handle authentication and 
I'm getting a weird problem. After much troubleshooting I've distilled it 
down to the configs below:

/etc/httpd/conf.d/10-django.conf

ServerName site.internal
DocumentRoot /home/user/git/standard-web-site-no-python-stuff/
alias /static/ /home/user/git/project/app/static/

  Require all granted



  
Order Deny, Allow
Allow from all
Require all granted
  

WSGIDaemonProcess site.internal user=apache processes=2 threads=10 
display-name=%{GROUP} python-path=/home/user/git/project
WSGIProcessGroup site.internal
WSGIScriptAlias /wsgi-app/ /home/user/git/project/app/wsgi.py

  Order Deny, Allow
  Allow from all
  ErrorDocument 404 "/wsgi-app/"



My Django project is set up VERY simply with the following:
/home/user/git/project/app/wsgi.py
...imports...

os.environ.setdefault(*"DJANGO_SETTINGS_MODULE"*, *"app.settings"*)

from django.core.wsgi import get_wsgi_application

application = get_wsgi_application()


/home/user/git/project/app/views.py

def main(request):

  return render(request, "appname/template.tmpl")


def testme(request):

  return render(request, "appname/template2.tmpl")


/home/user/git/project/app/urls.py

urlpatterns = [

  url(r'^$', "app.views.main", name="app-main"),

  url(r'^testme/$', "app.views.testme", name="app-testme"),

]


/home/user/git/project/app/templates/app/template.tmpl

...HTML Stuff...

testme

...More HTML stuff


--

The above app works 100% fine when I go to http://site.internal/wsgi-app/. 
If I hover over the "testme" anchor, I get 
http://site.internal/wsgi-app/testme/


BUT! If I go to http://site.internal/non-good-html.html and get redirected 
by the ErrorDocument 404 directive it shows my views.main() page.

When I hover over the "testme" anchor, I get http://site.internal/testme/ 
(***Notice the missing /wsgi-app/***)


It seems like the app namespace is not preserved when I'm rendering the 
main() page from an ErrorDocument directive.


I tried adding app_name="wsgi-app" to the urls.py but it doesn't change 
anything.


I must be missing something simple as this seems like an easy use-case to 
implement.


Pat

-- 
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/aa74d449-18e7-43d5-9b5a-10d38239c1a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: New to Django (stuck at the end of the tutorial)

2016-04-26 Thread Patrick Harding
maybe giving it a namespace would handle it for you? such as 
 include('sistema.urls', namespace='sistema')

if not you can try this. the error i get is that you should "pass the 
callable instead" which means in your imports include the views that you 
want to import, then call them in you url statements.
for example:

from .views import (
post_list,
post_create,
post_detail,
post_update,
post_delete,
)

urlpatterns = [
url(r'^$', post_list, name='list'),
url(r'^create/$', post_create, name='create'),
url(r'^(?P\d+)/$', post_detail, name='detail'),
url(r'^(?P\d+)/edit/$', post_update, name='update'),
url(r'^(?P\d+)/delete/$', post_delete, name='delete'),


]


here you are calling the view, then giving it a name that will show up in 
the URL.

-- 
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/9f969947-ced2-4414-9c6f-8a53cf0022a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Trying to extend the User model to create a user profile page

2016-04-26 Thread Patrick Harding
I am creating an app for our company to have users log in, create a profile 
page, and create updates on some personal progress. I have handled logging 
in and registering with django-registration, and have created the app for 
updates, but i'm not able to create a profile page extending the user's 
information. 

I've tried a few ways to do it (django-custom-user, a few tutorials, 
documentation, etc.) but I can't seem to make it work right. I'm assuming 
it would be a good idea to create an entirely new app for this profile 
page, allowing the user to create on the initial login and edit as changes 
require. I have these capabilities already in the updates section. How can 
I make this work right? 


-- 
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/7394b722-dce2-4c0f-865c-0c3f286781a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


ModelForm has no model class specified

2016-01-18 Thread walukagga patrick
Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/artists/form

Django Version: 1.8.7
Python Version: 2.7.11
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'Album')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware')


Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" 
in get_response
  132. response = wrapped_callback(request, 
*callback_args, **callback_kwargs)
File "/home/corecode/Desktop/Python 
course/ms-django/music_album/Album/views.py" in artistform
  10. form = ArtistForm()
File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py" in 
__init__
  313. raise ValueError('ModelForm has no model class 
specified.')

Exception Type: ValueError at /artists/form
Exception Value: ModelForm has no model class specified.

-- 
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/bf32dca1-31e2-4f66-91f0-ed0ac5729636%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django import forms
from django.forms import ModelForm

# Create your models here.

class Artist(models.Model):
#code
name = models.CharField("artist", max_length=50)
year_formed = models.PositiveIntegerField()

def __str__(self):
return self.name


class ArtistForm(forms.ModelForm):
class meta:
model = Artist
fields = ['name', 'year_formed']


class Album(models.Model):
name = models.CharField("album", max_length=50)
artist = models.ForeignKey(Artist)

def __str__(self):
return self.name   


from django.shortcuts import render, render_to_response
from django.http import HttpRequest, HttpResponse, HttpResponseRedirect
from django.template import RequestContext
from Album.models import *
#from Album.forms import *

# Create your views here.
def artistform(request):
if  request.method == "GET":
form = ArtistForm()
return render('Album/form.html', {'form': form})
elif request.method == "POST":
form = ArtistForm(request.POST)
form.save()
return HttpResponseRedirect('/artists')

def artists(request):
artists = Artist.objects.all()
return render_to_response('Album/artists.html', {'artists': artists})

def artistdetails(request, id):
artist = Artist.objects.get(pk = id)
return render_to_response('Album/artistdetails.html', {'artists': artists})



ModelForm has no model class specified. Request Method:

2016-01-18 Thread walukagga patrick
Am trying to create forms using models but i cant view forms because of 
ModelForm has no model class specified.

-- 
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/5482b24f-9e51-4c20-a08a-84ea520b9c78%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django import forms
from django.forms import ModelForm

# Create your models here.

class Artist(models.Model):
#code
name = models.CharField("artist", max_length=50)
year_formed = models.PositiveIntegerField()

def __str__(self):
return self.name


class ArtistForm(forms.ModelForm):
class meta:
model = Artist
fields = ['name', 'year_formed']


class Album(models.Model):
name = models.CharField("album", max_length=50)
artist = models.ForeignKey(Artist)

def __str__(self):
return self.name   


from django.shortcuts import render, render_to_response
from django.http import HttpRequest, HttpResponse, HttpResponseRedirect
from django.template import RequestContext
from Album.models import *
#from Album.forms import *

# Create your views here.
def artistform(request):
if  request.method == "GET":
form = ArtistForm()
return render('Album/form.html', {'form': form})
elif request.method == "POST":
form = ArtistForm(request.POST)
form.save()
return HttpResponseRedirect('/artists')

def artists(request):
artists = Artist.objects.all()
return render_to_response('Album/artists.html', {'artists': artists})

def artistdetails(request, id):
artist = Artist.objects.get(pk = id)
return render_to_response('Album/artistdetails.html', {'artists': artists})



Re: List of available Jinja2 global symbols

2015-11-22 Thread Patrick Spencer
I see what you mean about not being about to have a global list of symbols 
because everything is subject to change. But it would be nice to have a 
default list of symbols available depending on the default initial setup.

I think the csrf_token and request token are available in the 
django.templates.backend.jinja2 module, as knbk pointed out.

I still don't think the jinja template processor is able to load 
context_processors. Right now my messages aren't working and I think this 
is the reason.

Also, I have django debug bar but when I load a jinja2 template with it it 
says that no templates have been loaded and I can't see any context 
processors. I think this is a bug. 

Does anyone have an idea about how to tell if django is actually loading 
the context_processors when it loads a jinja template. Also, does anyone 
have an idea how to make messages work with jinja templates?

On Sunday, November 22, 2015 at 5:47:58 PM UTC-6, James Schneider wrote:
>
> I'm using Django 1.8.6 with the built in JInja2 support. I spent a while 
>> trying to figure out how to pass a csrf token to a JInja2 template. After a 
>> while I realized one could just write {{ csrf_token }} in the template, 
>> without passing this value through a view, and it would just print out the 
>> token. I also realized you could reference a request object without passing 
>> it through the view i.e. {{ request.user }} returns the current user. Is 
>> there a place in the documentation with all the available global symbols 
>> one can use in a Jinja2 template?
>>
>
> There are no 'global symbols' in Django. The closest you'll come is the 
> list of project settings made available from django.conf.settings (
> https://docs.djangoproject.com/en/1.8/topics/settings/#using-settings-in-python-code).
>  
> The reason that such a list doesn't exist is because it would be impossible 
> to create a static one in the documentation. Everything that is available 
> in the context of a template is generated and made available based on the 
> specific project configuration, with additional information provided by the 
> views.
>
> There are a number of different sources used to populate/modify the 
> template context:
>
>- Template Context Processors
>- Template Tags
>- Views
>
> The {{ csrf_token }} variable and the {{ request }} variable are made 
> available by two specific template context processors, respectively:
>
>
> https://docs.djangoproject.com/en/1.8/ref/templates/api/#django-template-context-processors-csrf
>
> https://docs.djangoproject.com/en/1.8/ref/templates/api/#django-template-context-processors-request
>
> You can see the default context processors that are enabled here:
>
>
> https://docs.djangoproject.com/en/1.8/ref/settings/#template-context-processors
>
> It would appear that you've modified that list at some point, as the 
> 'request' context process is not included by default. It is also possible 
> that you added the extra processors to the OPTIONS for Jinja2 integraiton:
>
>
> https://docs.djangoproject.com/en/1.8/ref/settings/#std:setting-TEMPLATES-OPTIONS
>
> This is, of course, assuming that you are using RequestContext in your 
> function-based views, or the generic class-based views (which use 
> RequestContext by default). 
>
> To see what is available in your context (which is likely different per 
> page view), I would recommend installing the django-debug-toolbar, which in 
> addition to a ton of other valuable tools, allows you to inspect everything 
> that is available in the template context for each page load.
>
> I think the answer to your question is that Django is still rendering your 
> template, just using Jinja2 rather than the internal template engine. While 
> I've never used Jinja2, I'm guessing that Django is still smart enough to 
> understand it's native variable/context references whilst rendering using a 
> different engine. You may also want to investigation the OPTIONS setup I 
> referenced earlier, as it sounds like that may make the same information 
> available natively to the Jinja2 tags and however Jinja2 normally 
> references variables.
>
> -James
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+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/d3c3cb49-3914-42dd-bdc3-732561be87e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: List of available Jinja2 global symbols

2015-11-22 Thread Patrick Spencer
This explains where the csrf_token and request symbols were loaded. Thanks 
for pointing that out.

On Sunday, November 22, 2015 at 5:27:46 PM UTC-6, knbk wrote:
>
> I don't believe there's a list in the documentation, but you can get them 
> from the source code at 
> https://github.com/django/django/blob/master/django/template/backends/jinja2.py#L66
> :
>
> if request is not None:
> context['request'] = request
> context['csrf_input'] = csrf_input_lazy(request)
> context['csrf_token'] = csrf_token_lazy(request)
>
> On Sunday, November 22, 2015 at 1:17:59 PM UTC+1, JirkaV wrote:
>>
>> Hi there, I'm not a Jinja2 user, but standard Django templates get these 
>> variables via context processors‎. Check out 
>> https://docs.djangoproject.com/en/1.8/topics/templates/#context-processors
>>
>>  HTH
>>
>>Jirka
>>
>> *From: *Patrick Spencer
>> *Sent: *neděle, 22. listopadu 2015 5:45
>> *To: *Django users
>> *Reply To: *django...@googlegroups.com
>> *Subject: *List of available Jinja2 global symbols
>>
>> I'm using Django 1.8.6 with the built in JInja2 support. I spent a while 
>> trying to figure out how to pass a csrf token to a JInja2 template. After a 
>> while I realized one could just write {{ csrf_token }} in the template, 
>> without passing this value through a view, and it would just print out the 
>> token. I also realized you could reference a request object without passing 
>> it through the view i.e. {{ request.user }} returns the current user. Is 
>> there a place in the documentation with all the available global symbols 
>> one can use in a Jinja2 template?
>>
>> -- 
>> 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/537bd366-180e-4876-8b91-5791f8e22d44%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/537bd366-180e-4876-8b91-5791f8e22d44%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/861c4e44-2fe6-4228-9a17-c28528f0fe29%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: List of available Jinja2 global symbols

2015-11-22 Thread Patrick Spencer
After reading a bit, it looks like only the Django Template backend can use 
context processors, not the Jinja2 backend. If this is true then Jinja2 
isn't using any context processors  I'm wondering how the Jinja2 templates 
are getting the value for csrf_token and request then. I guess from the 
middleware. I just wish there was a list of globals that were accessible 
from the JInja2 templates.

On Sunday, November 22, 2015 at 6:17:59 AM UTC-6, JirkaV wrote:
>
> Hi there, I'm not a Jinja2 user, but standard Django templates get these 
> variables via context processors‎. Check out 
> https://docs.djangoproject.com/en/1.8/topics/templates/#context-processors
>
>  HTH
>
>Jirka
>
> *From: *Patrick Spencer
> *Sent: *neděle, 22. listopadu 2015 5:45
> *To: *Django users
> *Reply To: *django...@googlegroups.com 
> *Subject: *List of available Jinja2 global symbols
>
> I'm using Django 1.8.6 with the built in JInja2 support. I spent a while 
> trying to figure out how to pass a csrf token to a JInja2 template. After a 
> while I realized one could just write {{ csrf_token }} in the template, 
> without passing this value through a view, and it would just print out the 
> token. I also realized you could reference a request object without passing 
> it through the view i.e. {{ request.user }} returns the current user. Is 
> there a place in the documentation with all the available global symbols 
> one can use in a Jinja2 template?
>
> -- 
> 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/537bd366-180e-4876-8b91-5791f8e22d44%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/537bd366-180e-4876-8b91-5791f8e22d44%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/e04203a4-c3fb-46ed-82df-a2d8623ad307%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


List of available Jinja2 global symbols

2015-11-21 Thread Patrick Spencer
I'm using Django 1.8.6 with the built in JInja2 support. I spent a while 
trying to figure out how to pass a csrf token to a JInja2 template. After a 
while I realized one could just write {{ csrf_token }} in the template, 
without passing this value through a view, and it would just print out the 
token. I also realized you could reference a request object without passing 
it through the view i.e. {{ request.user }} returns the current user. Is 
there a place in the documentation with all the available global symbols 
one can use in a Jinja2 template?

-- 
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/537bd366-180e-4876-8b91-5791f8e22d44%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Login with email address

2015-11-04 Thread Patrick Breitenbach
Is there a current "best" approach or module for signup/login with an email 
address?

I can't believe this is not included with django. In fact, it should 
be the default. 80-99% of services and projects do not use usernames.

-- 
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/1bc440aa-6afb-48e1-bb1e-1ab937cb328c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Authenticate users with both username and email

2015-11-04 Thread Patrick Breitenbach
Are you suggesting that there's a relatively easy way to implement "email 
address as username"? Is it as easy as just putting an email address into 
the username field? And making sure to update it when someone updates their 
email address?


On Monday, January 19, 2015 at 2:33:35 AM UTC-8, James Schneider wrote:
>
> I guess I'm not clear on what you are trying to achieve. There are a 
> couple of scenarios to consider.
>
> As it stands with the default contrib.auth authentication backend, sending 
> both the username and email address entered by the user will only work IF 
> the user registered/was created using their email address as their 
> username, meaning that user.username is either their username (a string 
> that isn't their email), or an email address, regardless of what user.email 
> returns. The default contrib.auth authentication backend only looks at 
> user.username.
>
> What I suspect you want is to be able to use either user.username OR 
> user.email as the identifying tokens for the user in order to authenticate 
> them. For that, you'll need to roll at least a partial custom 
> authentication backend, in addition to the changes for the forms, etc. that 
> you've already laid out. 
>
> From 
> https://docs.djangoproject.com/en/1.7/topics/auth/customizing/#writing-an-authentication-backend
> :
>
> "If you wish to provide custom behavior for only part of the backend API, 
> you can take advantage of Python inheritance and subclass *ModelBackend* 
> instead of implementing the complete API in a custom backend."
>
> Specifically, you'll need to override the authenticate() method of the 
> authentication backend.
>
> I've done this, it's actually pretty easy. See:
>
>
> https://github.com/django/django/blob/master/django/contrib/auth/backends.py#L11
>
> In this case, you should also roll a custom user model as well to ensure 
> that both user.username and user.email are unique columns. If you use the 
> email address as an identifying token, it will need to be unique among all 
> users, which is not true/enforced for the built-in contrib.auth User model. 
> You will also need to override the custom User manager for your new 
> CustomUser, probably with and override for get_by_natural_key(token) so 
> that the user can be retrieved in the backend authenticate() method. The 
> key change in get_by_natural_key() being the filter for the user object 
> being changed to something like User.objects.get(Q(username=token) | 
> Q(email=token)).
>
> (If you haven't seen the Q() notation, check 
> https://docs.djangoproject.com/en/1.7/ref/models/queries/#q-objects)
>
> The custom user you probably want is somewhat similar to the example given 
> in the docs:
>
>
> https://docs.djangoproject.com/en/1.7/topics/auth/customizing/#a-full-example
>
> You'll need to add a 'username' field back in (remember to make it unique) 
> along with several other tweaks to be able to use either a username or 
> email field. An alternative would be a custom user class inheriting from 
> AbstractBaseUser and copying in the goodies you need from AbstractUser 
> (which is probably everything except the username and email fields, which 
> you'll be defining as unique). Be sure to include the Permission mixins 
> that AbstractUser has if you intend to use the built-in permission system 
> with your CustomUser.
>
> Sorry about the lengthy message, there are a bunch of ways to tackle this, 
> but ultimately I think you'll be rolling your own user and at least part of 
> the authentication system, not to mention having to customize the user 
> forms. The user will be slightly tricky, as there is no clear inheritance 
> path that will make it easy AFAICT, but the auth backend should be just a 
> class with a single authenticate() function if you inherit from 
> ModelBackend. Be sure to either include your custom backend in 
> AUTHENTICATION_BACKENDS, or possibly even replacing it if you go with the 
> Q() query I specified earlier (since an auth request using an email would 
> generate two authentication queries if both backends are used, and the 
> username field is checked twice).
>
> TL;DR; Overriding the user forms is probably not enough, you'll need a 
> custom user and custom authentication backend.
>
> Not sure if I made the situation better or worse, but HTH...
>
> Obviously, YMMV, I haven't tried this myself, but I have done a fair bit 
> of overriding for a custom object-based permission system, which touches 
> many of the same structures above.
>
> -James
>
>
>
>
>
>
> On Mon, Jan 19, 2015 at 1:26 AM, Abraham Varricatt <
> abraham@googlemail.com > wrote:
>
>> Ignoring the malformed code, will the call to authenticate() even work 
>> without username? According to the docs,
>>
>> https://docs.djangoproject.com/en/1.7/topics/auth/default/#django.contrib.auth.authenticate
>>
>> It takes credentials in the form of keyword arguments, for the default 
>>> configuration this is username and password, and it returns a 

Django Admin should really support Twitter Bootsrap

2015-04-13 Thread Patrick Lemiuex
It's about time, the django admin tool should support twitter bootstrap 
markups and styling. This is the third django project where I've had to 
deal with custom form widgets because the admin tool supports kind of an 
outdated layout scheme in the admin template.

This also affects a lot of third party apps as well. It would be something 
worth contributing to the community by 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+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/80fd3f22-5348-49bf-ba46-baee3cd76bc6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Writing your first Django app, part 5 Testing

2015-02-21 Thread Gavin Patrick McCoy
Ok. I get you. Thanks very much!

On Saturday, 21 February 2015 11:56:50 UTC, Daniel Roseman wrote:
>
> You're doing this in the shell, which uses your devv database in which you 
> have obviously defined a poll already. 
>
> The docs are taking about running this in a unit test, which would create 
> a blank db without any polls. 
> -- 
> DR.

-- 
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/408cefd6-b563-43a6-ae3f-29554e8b17cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Writing your first Django app, part 5 Testing

2015-02-21 Thread Gavin Patrick McCoy
I got a code 200. Thanks for your reply.

On Saturday, 21 February 2015 11:05:35 UTC, 严超 wrote:
>
> I think the purpose here is to test reverse() function. As long as you 
> got code 200, it's ok whatever html it returns.
> Is it right ?
>
> *Best Regards!*
>
>
> *Chao Yan--About me : http://about.me/chao_yan 
> <http://about.me/chao_yan>*
>
> *My twitter: @yanchao727 <https://twitter.com/yanchao727>*
> *My Weibo: http://weibo.com/herewearenow <http://weibo.com/herewearenow>*
> *--*
>  
> 2015-02-21 18:41 GMT+08:00 Gavin Patrick McCoy <gavin@mail.dcu.ie 
> >:
>
>> Hi, 
>>
>> I'm on part 5 of the polls tutorial (
>> https://docs.djangoproject.com/en/1.7/intro/tutorial05/) and I am 
>> running Django 1.7 and Python 3.4 on Windows 8. Just want to make sure I'm 
>> on the right track.
>>
>> For the following part of tutorial:
>>
>> >>> # get a response from '/'>>> response = client.get('/')>>> # we should 
>> >>> expect a 404 from that address>>> response.status_code404>>> # on the 
>> >>> other hand we should expect to find something at '/polls/'>>> # we'll 
>> >>> use 'reverse()' rather than a hardcoded URL>>> from 
>> >>> django.core.urlresolvers import reverse>>> response = 
>> >>> client.get(reverse('polls:index'))>>> response.status_code200>>> 
>> >>> response.content'\n\n\nNo polls are available.\n\n' 
>> >>> *<-Not getting this. See below. Seeing What's up?*>>> # note - you 
>> >>> might get unexpected results if your ``TIME_ZONE``>>> # in 
>> >>> ``settings.py`` is not correct. If you need to change it,>>> # you will 
>> >>> also need to restart your shell session>>> from polls.models import 
>> >>> Question>>> from django.utils import timezone>>> # create a Question and 
>> >>> save it>>> q = Question(question_text="Who is your favorite Beatle?", 
>> >>> pub_date=timezone.now())>>> q.save()>>> # check the response once 
>> >>> again>>> response = client.get('/polls/')>>> response.content'\n\n\n
>> >>> \n\nWho is your favorite 
>> >>> Beatle?\n\n\n\n' *Seeing What's up? here too.*
>> >>> # If the following doesn't work, you probably omitted the call to>>> # 
>> >>> setup_test_environment() described above>>> 
>> >>> response.context['latest_question_list'][> >>> Beatle?>] *Seeing What's up? here too*
>>
>>
>> Instead of getting '\n\n\nNo polls are available.\n\n' , the 
>> What's up poll is coming up i.e. b'r\n\t\r\n\t\r\n\t\t> href="/polls/1/">Whatse up?\r\n\t\r\n\t\r\n? The rest of 
>> the code works fine as in adding the Beatles question but the What's up? 
>> question is also coming up along with the Beatles question. Is this ok? Any 
>> help would be greatly appreciated.
>>
>> Thanks,
>>
>> Gavin
>>
>>  -- 
>> 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/fc23070f-8f90-4c4c-925a-94c24d3ee8bf%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/fc23070f-8f90-4c4c-925a-94c24d3ee8bf%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/24834d06-e86a-4221-af71-5a250715076d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Writing your first Django app, part 5 Testing

2015-02-21 Thread Gavin Patrick McCoy
Hi, 

I'm on part 5 of the polls tutorial 
(https://docs.djangoproject.com/en/1.7/intro/tutorial05/) and I am running 
Django 1.7 and Python 3.4 on Windows 8. Just want to make sure I'm on the 
right track.

For the following part of tutorial:

>>> # get a response from '/'>>> response = client.get('/')>>> # we should 
>>> expect a 404 from that address>>> response.status_code404>>> # on the other 
>>> hand we should expect to find something at '/polls/'>>> # we'll use 
>>> 'reverse()' rather than a hardcoded URL>>> from django.core.urlresolvers 
>>> import reverse>>> response = client.get(reverse('polls:index'))>>> 
>>> response.status_code200>>> response.content'\n\n\nNo polls are 
>>> available.\n\n' *<-Not getting this. See below. Seeing What's 
>>> up?*>>> # note - you might get unexpected results if your ``TIME_ZONE``>>> 
>>> # in ``settings.py`` is not correct. If you need to change it,>>> # you 
>>> will also need to restart your shell session>>> from polls.models import 
>>> Question>>> from django.utils import timezone>>> # create a Question and 
>>> save it>>> q = Question(question_text="Who is your favorite Beatle?", 
>>> pub_date=timezone.now())>>> q.save()>>> # check the response once again>>> 
>>> response = client.get('/polls/')>>> response.content'\n\n\n\n\n 
>>>Who is your favorite Beatle?\n
>>> \n\n\n' *Seeing What's up? here too.*
>>> # If the following doesn't work, you probably omitted the call to>>> # 
>>> setup_test_environment() described above>>> 
>>> response.context['latest_question_list'][>> Beatle?>] *Seeing What's up? here too*


Instead of getting '\n\n\nNo polls are available.\n\n' , the What's 
up poll is coming up i.e. b'r\n\t\r\n\t\r\n\t\tWhatse up?\r\n\t\r\n\t\r\n? The rest of the 
code works fine as in adding the Beatles question but the What's up? question 
is also coming up along with the Beatles question. Is this ok? Any help would 
be greatly appreciated.

Thanks,

Gavin

-- 
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/fc23070f-8f90-4c4c-925a-94c24d3ee8bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Writing your first Django app, part 1 - Django 1.7 - # Make sure our __str__() addition worked.

2015-02-04 Thread Gavin Patrick McCoy
Sorry about that. Thanks a million for your reply.

On Wednesday, 4 February 2015 17:38:16 UTC, Vijay Khemlani wrote:
>
> The method is called "__str__" (note the double underscore at both ends)
>
> On Wed, Feb 4, 2015 at 2:29 PM, Gavin Patrick McCoy <gavin@mail.dcu.ie 
> > wrote:
>
>> Hi,
>>
>> Just started learning Django today. I got down to the last grey box of 
>> code on 
>> https://docs.djangoproject.com/en/1.7/intro/tutorial01/#writing-your-first-django-app-part-1
>>  and 
>> when I checked to see of the __str__() addition to models.py worked, it 
>> didn't. I didn't get [], I got [> Question object>]. I tried creating a new question again and did but now 
>> I get  [, ]. I 
>> then tried 'the three-step guide to making model changes: Change your 
>> models (in models.py). Run python manage.py makemigrations 
>> <https://docs.djangoproject.com/en/1.7/ref/django-admin/#django-admin-makemigrations>
>>  
>> to create migrations for those changes. Run python manage.py migrate 
>> <https://docs.djangoproject.com/en/1.7/ref/django-admin/#django-admin-migrate>
>>  
>> to apply those changes to the database.' I still got  [> Question object>, ]. Any ideas? Any help 
>> would be greatly appreciated. 
>>
>> Thanks, Gavin
>>
>> My models.py looks like this: 
>>
>> import datetime
>> from django.db import models
>> from django.utils import timezone
>> # Create your models here.
>> class Question(models.Model):
>> question_text = models.CharField(max_length=200)
>> pub_date = models.DateTimeField('date published')
>> 
>> def _str_(self):
>> return self.question_text
>> 
>> def was_published_recently(self):
>> return self.pub_date >= timezone.now() - 
>> datetime.timedelta(days=1)
>> 
>> class Choice(models.Model):
>> question = models.ForeignKey(Question)
>> choice_text = models.CharField(max_length=200)
>> votes = models.IntegerField(default=0)
>> def __str(self):
>> return self.choice_text
>>
>> -- 
>> 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/e518a27e-da82-4c93-884f-a7a941d23853%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/e518a27e-da82-4c93-884f-a7a941d23853%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/6acc2808-2fe9-4643-9d17-c5eaec00e592%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Writing your first Django app, part 1 - Django 1.7 - # Make sure our __str__() addition worked.

2015-02-04 Thread Gavin Patrick McCoy
Hi,

Just started learning Django today. I got down to the last grey box of code 
on 
https://docs.djangoproject.com/en/1.7/intro/tutorial01/#writing-your-first-django-app-part-1
 and 
when I checked to see of the __str__() addition to models.py worked, it 
didn't. I didn't get [], I got []. I tried creating a new question again and did but now I get  
[, ]. I then tried 'the 
three-step guide to making model changes: Change your models (in models.py). 
Run python manage.py makemigrations 

 
to create migrations for those changes. Run python manage.py migrate 
 
to apply those changes to the database.' I still got  [, ]. Any ideas? Any help would be greatly 
appreciated. 

Thanks, Gavin

My models.py looks like this: 

import datetime
from django.db import models
from django.utils import timezone
# Create your models here.
class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')

def _str_(self):
return self.question_text

def was_published_recently(self):
return self.pub_date >= timezone.now() - datetime.timedelta(days=1)

class Choice(models.Model):
question = models.ForeignKey(Question)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
def __str(self):
return self.choice_text

-- 
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/e518a27e-da82-4c93-884f-a7a941d23853%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Initial stages of django

2015-02-01 Thread patrick
The Django tutorial is definitely worth going through but there are other great 
resources:

Buddy Lindsey at GoDjango.com has  free (and more advanced paid) video 
tutorials that are short but highly informative. 

Tobias Abdon's ultimatedjango.com  is a step-by-step tutorial for building a 
CRM app  (the basic Django tutorial seems to now be available with registration 
to a newsletter, more features, source code and additional courses are 
available in paid packages). 

Teamtreehouse.com has online Python classes lead by Kenneth Love (free trial 
available)

No affiliation to any other than as a subscriber or customer. 

-- 
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/bd863733-c2f7-48b9-afdc-3146a428c988%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Advice needed: Adaptive/Responsive Images in Django?

2014-11-20 Thread Patrick Beeson
AListApart recently published a great article on responsive 
images: http://alistapart.com/article/responsive-images-in-practice

On Thursday, November 20, 2014 1:05:45 AM UTC-5, ThomasTheDjangoFan wrote:
>
> Hi guys,
>
> do you have a tip for implementing adaptive (responsive) images in django?
>
> Basically I want to server smaller images to mobile-users and bigger 
> images to desktop users.
> I don't really now about best practices for SEO and Siteload-Performance.
>
> Are there any apps that you can recon for this?
>
> Thanks a lot for your tips!
>
> Kind regards
> Thomas
>

-- 
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/0ea0a557-8043-4bfa-bc2f-23c2561e2245%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Making a field Read-Only in Django

2014-11-17 Thread Patrick Beeson
I believe you can set this via a built-in widget's attrs:

somefield = forms.CharField(
widget=forms.TextInput(attrs={'readonly':'readonly'}))


On Monday, November 17, 2014 1:48:44 AM UTC-5, Frankline wrote:
>
> Hi all,
>
> I'm running Django 1.7 and Python 3.4. I'm trying to make the username 
> field of my custom model to be read-only. I think this is usually set in 
> the form. Below is what I currently have in my *forms.py*
>
> class AuthUserChangeForm(UserChangeForm):
> """
> A form for updating users. Includes all the fields on the user, but 
> replaces the password field with admin's password hash display field.
> """
> password = ReadOnlyPasswordHashField(label="password",
>  help_text="""Raw passwords are 
> not stored, so there is no way to see this
>  user's password, but you can 
> change the password using 
>  this form""")
>
> class Meta:
> model = AuthUser
> fields = ('username', 'email', 'password', 'is_active', 
> 'is_staff', 'is_superuser', 'user_permissions')
> widgets = {
> 'username': TextInput( attrs={'readonly':'readonly'} ),
> 'email': TextInput(),
> }
>
> def clean_username(self):
> # Regardless of what the user provides, reset field to initial 
> value
> # Not appropriate to change usernames once set.
> return self.initial["username"]
> 
> def clean_password(self):
> # Regardless of what the user provides, return the initial value.
> # This is done here, rather than on the field, because the field 
> does 
> # not have access to the initial value
> return self.initial["password"]
>
>
> What I'm I missing here?
>

-- 
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/d2520030-bafa-47aa-9ace-fa480e27cf35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Code: Add context to trans blocks

2014-08-29 Thread Patrick Robertson
Hi all,

Do you have any 'best practices' for translating Django?
It's just come to my attention that in a couple of places, it would be good 
to add some context to certain translations. I just thought I'd ask to see 
if you've discussed it before

A good example is the word 'Save' used in the Django admin to save an 
object to the database (after editing).
In English save has (at least) two meanings, another being to 'save' money. 
(Buy 2 SAVE $5). This brings up a few complcations when translating the 
site to languages which use different words for each context.

Would there be any objections to me adding context to these two places and 
creating a PR?

#: contrib/admin/templates/admin/pagination.html:11
#: contrib/admin/templates/admin/submit_line.html:3

Cheers

-- 
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/2c98d7df-77e7-40ef-a56e-fa8b4ad4fe23%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: NameError at /admin/ name 'HoleImage' is not defined

2014-06-11 Thread Patrick C
Understood, got that error cleared now.

Just a last question - should my HoleImages not present their upload 
options in the Hole part of the admin?

<https://lh3.googleusercontent.com/-ChpLmrlMN-s/U5jEmgNkdrI/ADk/4X45ORinrbU/s1600/Screen+Shot+2014-06-11+at+22.05.07.png>

<https://lh5.googleusercontent.com/-14oEuDDZj9Y/U5jEtIyEW3I/ADw/lun-Q51aNb8/s1600/Screen+Shot+2014-06-11+at+22.05.41.png>


On Wednesday, June 11, 2014 9:57:19 PM UTC+1, Ilya Kazakevich wrote:
>
> Instead of 
>  from holes.models import HoleImage 
> write 
>  from holes.models import HoleImage, Hole 
>
> Please read https://docs.python.org/2/tutorial/modules.html 
>
>
>
>
> Ilya Kazakevich, 
> JetBrains PyCharm (Best Python/Django IDE) 
> http://www.jetbrains.com/pycharm/ 
> "Develop with pleasure!" 
>
>
> >-Original Message- 
> >From: django...@googlegroups.com  
> >[mailto:django...@googlegroups.com ] On Behalf Of Patrick C 
> >Sent: Thursday, June 12, 2014 12:52 AM 
> >To: django...@googlegroups.com  
> >Subject: Re: NameError at /admin/ name 'HoleImage' is not defined 
> > 
> >Should it be this: 
> > 
> >from django.contrib import admin 
> >from holes.models import HoleImage 
> > 
> >class HoleImageInline(admin.TabularInline): 
> >model = HoleImage 
> > 
> >class HoleAdmin(admin.ModelAdmin): 
> >fields = ['hole_number', 'hole_name', 'hole_description'] 
> >list_display = ['hole_number', 'hole_name', 'hole_description'] 
> >inlines = [ HoleImageInline, ] 
> > 
> >admin.site.register(Hole) 
> >admin.site.register(HoleImage) 
> > 
> > 
> > 
> >or this: 
> > 
> >from django.contrib import admin 
> >from holes.models import HoleImage 
> > 
> >class HoleImageInline(admin.TabularInline): 
> >model = HoleImage 
> > 
> >class HoleAdmin(admin.ModelAdmin): 
> >fields = ['hole_number', 'hole_name', 'hole_description'] 
> >list_display = ['hole_number', 'hole_name', 'hole_description'] 
> >inlines = [ HoleImageInline, ] 
> > 
> >admin.site.register(Hole, HoleImages) 
> > 
> > 
> >Still have errors trying either, sorry again for noob questions. 
> > 
> >On Wednesday, June 11, 2014 9:45:10 PM UTC+1, Jorge Andrés Vergara Ebratt 
> >wrote: 
> > 
> >When you import HoleImage don't remove Hole :) 
> > 
> >On Jun 11, 2014 3:41 PM, "Patrick C" <patrick@gmail.com 
>  > 
> >wrote: 
> > 
> > 
> >Hi Jorge, 
> > 
> >Thanks for helping out - I understand that and have just 
> tried it but still 
> >get the error: 
> > 
> > 
> >NameError at /admin/ 
> > 
> >name 'Hole' is not defined 
> >Request Method:GET 
> >Request URL:http://127.0.0.1:8000/admin/ 
> >Django Version:1.6.5 
> >Exception Type:NameError 
> >Exception Value:name 'Hole' is not defined 
> >Exception 
> Location:/Users/my_laptop/development/golfsmart/holes/admin.py 
> >in , line 12 
> >Python Executable: /usr/bin/python 
> >Python Version:2.7.5 
> > 
> > 
> >So just to clarify my structure incase I'm missing 
> something on 
> >pluralisation: 
> > 
> >holes 
> >- admin.py 
> >- model.py 
> > 
> > 
> >models.py: 
> > 
> >from django.db import models 
> > 
> >class Hole(models.Model): 
> >hole_number = models.IntegerField() 
> >hole_name = models.CharField(max_length=255) 
> >hole_description = models.CharField(max_length=500) 
> > 
> >def __str__(self): 
> >return self.hole_number 
> > 
> >class HoleImage(models.Model): 
> >hole = models.ForeignKey(Hole, related_name='images') 
> >image = models.ImageField(upload_to='hole_photos') 
> >caption = models.CharField(max_length=250) 
> > 
> >admin.py: 
> > 
> >from django.contrib import admin 
> >from holes.models import HoleImage 
> > 
> >class HoleImageInline(admin.TabularInline): 
> >    model = HoleImage 
> > 
> > 

Re: NameError at /admin/ name 'HoleImage' is not defined

2014-06-11 Thread Patrick C
Thanks Ilya,

I will go through that this evening - I tend to learn through hardship, 
banging my head off the wall, walking away and finding a moment of clarity, 
I'm quick to understand the logic and approach but I leant the language / 
syntax through repetition. 

On Wednesday, June 11, 2014 9:44:18 PM UTC+1, Ilya Kazakevich wrote:
>
> Hello, 
>
> I believe you should start with Python tutorial: 
> https://docs.python.org/2/tutorial/ 
> After you complete it, you may go to Django tutorial. 
>
> It is generally a good idea to study basic language concepts, syntax and 
> standard library before studying any framework (you've learned PHP _before_ 
> zend/phpcacke/joomla or wordpress, right?:) ) 
>
>
>
> Ilya Kazakevich, 
> JetBrains PyCharm (Best Python/Django IDE) 
> http://www.jetbrains.com/pycharm/ 
> "Develop with pleasure!" 
>
>
> >-Original Message- 
> >From: django...@googlegroups.com  
> >[mailto:django...@googlegroups.com ] On Behalf Of Patrick C 
> >Sent: Thursday, June 12, 2014 12:32 AM 
> >To: django...@googlegroups.com  
> >Cc: ilya.ka...@jetbrains.com  
> >Subject: Re: NameError at /admin/ name 'HoleImage' is not defined 
> > 
> >Hi Ilya, 
> > 
> >Thanks for the swift reply, sorry for the noob question but can you 
> elaborate on 
> >"but you forgot to import HoleImage" - I'm not quite following, I'm sure 
> I will 
> >understand it once explained. 
> > 
> >I'm only about 4 hours into my first workings with Python / Django, 
> perhaps I'm 
> >jumping in a little too quick but so far I have read through a fair bit 
> and live the 
> >prose. 
> > 
> >On Wednesday, June 11, 2014 9:26:30 PM UTC+1, Ilya Kazakevich wrote: 
> > 
> >To use any symbol (including " HoleImage" class) you need to 
> import it first. 
> >You've imported Hole (from holes.models import Hole), but you 
> forgot to 
> >import HoleImage. 
> >So, you got " name 'HoleImage' is not defined " error. 
> > 
> >It is better to use IDE, because it helps you in such cases :) 
> > 
> > 
> > 
> > 
> >Ilya Kazakevich, 
> >JetBrains PyCharm (Best Python/Django IDE) 
> >http://www.jetbrains.com/pycharm/ 
> ><http://www.jetbrains.com/pycharm/> 
> >"Develop with pleasure!" 
> > 
> > 
> >>-Original Message- 
> >>From: django...@googlegroups.com  
> >>[mailto:django...@googlegroups.com  ] On Behalf Of 
> Patrick C 
> >>Sent: Thursday, June 12, 2014 12:19 AM 
> >>To: django...@googlegroups.com  
> >>Subject: NameError at /admin/ name 'HoleImage' is not defined 
> >> 
> >>Hi All, 
> >> 
> >>New to Django / Python (coming from PHP). 
> >> 
> >>Trying to make a site for a golf course where there is a hole by 
> hole guide, 
> >each 
> >>hole has a number, name, description then multiple images for 
> the 
> >gallery. 
> >> 
> >>I've spend the last few hours googling how I'm going wrong here 
> because I 
> >get 
> >>the error in the subject line. 
> >> 
> >>My models.py is: 
> >> 
> >>from django.db import models 
> >> 
> >> 
> >>class Hole(models.Model): 
> >>hole_number = models.IntegerField() 
> >>hole_name = models.CharField(max_length=255) 
> >>hole_description = models.CharField(max_length=500) 
> >> 
> >> 
> >>def __str__(self): 
> >>return self.hole_number 
> >> 
> >> 
> >>class HoleImage(models.Model): 
> >>hole = models.ForeignKey(Hole, related_name='images') 
> >>image = models.ImageField(upload_to='hole_photos') 
> >>caption = models.CharField(max_length=250) 
> >> 
> >> 
> >>and my admin.py is: 
> >> 
> >>from django.contrib import admin 
> >>from holes.models import Hole 
> >> 
> >> 
> >>class HoleImageInline(admin.TabularInline): 
> >>model = HoleImage 
> >> 
> >> 
> >>class HoleAdmin(admin.ModelAdmin): 
> >

Re: NameError at /admin/ name 'HoleImage' is not defined

2014-06-11 Thread Patrick C
Should it be this:

from django.contrib import admin
from holes.models import HoleImage

class HoleImageInline(admin.TabularInline):
model = HoleImage

class HoleAdmin(admin.ModelAdmin):
fields = ['hole_number', 'hole_name', 'hole_description']
list_display = ['hole_number', 'hole_name', 'hole_description']
inlines = [ HoleImageInline, ]

admin.site.register(Hole)
admin.site.register(HoleImage)



or this:

from django.contrib import admin
from holes.models import HoleImage

class HoleImageInline(admin.TabularInline):
model = HoleImage

class HoleAdmin(admin.ModelAdmin):
fields = ['hole_number', 'hole_name', 'hole_description']
list_display = ['hole_number', 'hole_name', 'hole_description']
inlines = [ HoleImageInline, ]

admin.site.register(Hole, HoleImages)


Still have errors trying either, sorry again for noob questions. 

On Wednesday, June 11, 2014 9:45:10 PM UTC+1, Jorge Andrés Vergara Ebratt 
wrote:
>
> When you import HoleImage don't remove Hole :)
> On Jun 11, 2014 3:41 PM, "Patrick C" <patrick@gmail.com > 
> wrote:
>
>> Hi Jorge,
>>
>> Thanks for helping out - I understand that and have just tried it but 
>> still get the error:
>>
>> NameError at /admin/
>>
>> name 'Hole' is not defined
>>
>> Request Method:GET Request URL:http://127.0.0.1:8000/admin/ Django 
>> Version:1.6.5Exception Type: NameErrorException Value:
>>
>> name 'Hole' is not defined
>>
>> Exception Location: 
>> /Users/my_laptop/development/golfsmart/holes/admin.py in , line 
>> 12Python 
>> Executable: /usr/bin/pythonPython Version: 2.7.5
>>
>> So just to clarify my structure incase I'm missing something on 
>> pluralisation:
>>
>> holes
>> - admin.py
>> - model.py
>>
>>
>> *models.py:*
>>
>> from django.db import models
>>
>> class Hole(models.Model):
>> hole_number = models.IntegerField()
>> hole_name = models.CharField(max_length=255)
>> hole_description = models.CharField(max_length=500)
>>
>> def __str__(self):
>> return self.hole_number
>>
>> class HoleImage(models.Model):
>> hole = models.ForeignKey(Hole, related_name='images')
>> image = models.ImageField(upload_to='hole_photos')
>> caption = models.CharField(max_length=250)
>>
>> *admin.py:*
>>
>> from django.contrib import admin
>> from holes.models import HoleImage
>>
>> class HoleImageInline(admin.TabularInline):
>> model = HoleImage
>>
>> class HoleAdmin(admin.ModelAdmin):
>> fields = ['hole_number', 'hole_name', 'hole_description']
>> list_display = ['hole_number', 'hole_name', 'hole_description']
>> inlines = [ HoleImageInline, ]
>>
>> admin.site.register(Hole)
>>
>>
>>
>> On Wednesday, June 11, 2014 9:36:11 PM UTC+1, Jorge Andrés Vergara Ebratt 
>> wrote:
>>>
>>> In admin.py you have
>>>
>>> from hotels.models import Hole
>>>
>>> Add HoleImage to that import
>>> On Jun 11, 2014 3:19 PM, "Patrick C" <patrick@gmail.com> wrote:
>>>
>>>> Hi All,
>>>>
>>>> New to Django / Python (coming from PHP).
>>>>
>>>> Trying to make a site for a golf course where there is a hole by hole 
>>>> guide, each hole has a number, name, description then multiple images for 
>>>> the gallery.
>>>>
>>>> I've spend the last few hours googling how I'm going wrong here because 
>>>> I get the error in the subject line.
>>>>
>>>> My models.py is:
>>>>
>>>> from django.db import models
>>>>
>>>> *class Hole(models.Model):*
>>>> *hole_number = models.IntegerField()*
>>>> *hole_name = models.CharField(max_length=255)*
>>>> *hole_description = models.CharField(max_length=500)*
>>>>
>>>> *def __str__(self):*
>>>> *return self.hole_number*
>>>>
>>>> *class HoleImage(models.Model):*
>>>>  *hole = models.ForeignKey(Hole, related_name='images')*
>>>> *image = models.ImageField(upload_to='hole_photos')*
>>>> *caption = models.CharField(max_length=250)*
>>>>
>>>>
>>>> and my admin.py is:
>>>>
>>>> *from django.contrib import admin*
>>>> *from holes.models import Hole*
>>>>
>>>> *class HoleImageInline(admin.TabularInline):*
>>>> *model = HoleImage*
>>>>
&g

Re: NameError at /admin/ name 'HoleImage' is not defined

2014-06-11 Thread Patrick C
Hi Jorge,

Thanks for helping out - I understand that and have just tried it but still 
get the error:

NameError at /admin/

name 'Hole' is not defined

Request Method:GETRequest URL:http://127.0.0.1:8000/admin/Django Version:
1.6.5Exception Type:NameErrorException Value:

name 'Hole' is not defined

Exception Location:/Users/my_laptop/development/golfsmart/holes/admin.py in 
, line 12Python Executable:/usr/bin/pythonPython Version:2.7.5

So just to clarify my structure incase I'm missing something on 
pluralisation:

holes
- admin.py
- model.py


*models.py:*

from django.db import models

class Hole(models.Model):
hole_number = models.IntegerField()
hole_name = models.CharField(max_length=255)
hole_description = models.CharField(max_length=500)

def __str__(self):
return self.hole_number

class HoleImage(models.Model):
hole = models.ForeignKey(Hole, related_name='images')
image = models.ImageField(upload_to='hole_photos')
caption = models.CharField(max_length=250)

*admin.py:*

from django.contrib import admin
from holes.models import HoleImage

class HoleImageInline(admin.TabularInline):
model = HoleImage

class HoleAdmin(admin.ModelAdmin):
fields = ['hole_number', 'hole_name', 'hole_description']
list_display = ['hole_number', 'hole_name', 'hole_description']
inlines = [ HoleImageInline, ]

admin.site.register(Hole)



On Wednesday, June 11, 2014 9:36:11 PM UTC+1, Jorge Andrés Vergara Ebratt 
wrote:
>
> In admin.py you have
>
> from hotels.models import Hole
>
> Add HoleImage to that import
> On Jun 11, 2014 3:19 PM, "Patrick C" <patrick@gmail.com > 
> wrote:
>
>> Hi All,
>>
>> New to Django / Python (coming from PHP).
>>
>> Trying to make a site for a golf course where there is a hole by hole 
>> guide, each hole has a number, name, description then multiple images for 
>> the gallery.
>>
>> I've spend the last few hours googling how I'm going wrong here because I 
>> get the error in the subject line.
>>
>> My models.py is:
>>
>> from django.db import models
>>
>> *class Hole(models.Model):*
>> *hole_number = models.IntegerField()*
>> *hole_name = models.CharField(max_length=255)*
>> *hole_description = models.CharField(max_length=500)*
>>
>> *def __str__(self):*
>> *return self.hole_number*
>>
>> *class HoleImage(models.Model):*
>> *hole = models.ForeignKey(Hole, related_name='images')*
>> *image = models.ImageField(upload_to='hole_photos')*
>> *caption = models.CharField(max_length=250)*
>>
>>
>> and my admin.py is:
>>
>> *from django.contrib import admin*
>> *from holes.models import Hole*
>>
>> *class HoleImageInline(admin.TabularInline):*
>> *model = HoleImage*
>>
>> *class HoleAdmin(admin.ModelAdmin):*
>> *fields = ['hole_number', 'hole_name', 'hole_description']*
>> *list_display = ['hole_number', 'hole_name', 'hole_description']*
>> *inlines = [ HoleImageInline, ]*
>>
>> *admin.site.register(Hole)*
>>
>>
>> Full admin panel error is:
>>
>> NameError at /admin/
>>
>> name 'HoleImage' is not defined
>>
>> Request Method:GETRequest URL: http://127.0.0.1:8000/admin/Django 
>> Version: 1.6.5Exception Type: NameErrorException Value:
>>
>> name 'HoleImage' is not defined
>>
>> Exception Location: 
>> /Users/my_laptop/development/golfsmart/holes/admin.py in HoleImageInline, 
>> line 5Python Executable: /usr/bin/pythonPython Version: 2.7.5
>>
>>
>> As I say, I'm new to this and have had a good trial and error stab, I'm 
>> sure it's something simple I am overlooking and once I have it resolved I 
>> will have a lesson learned as I have a few other apps to setup that will 
>> use this many type for images.
>>
>> 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...@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/7079f896-e765-428f-a95a-6f953ad105f8%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/7079f896-e765-428f-a95a-6f953ad105f8%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google

Re: NameError at /admin/ name 'HoleImage' is not defined

2014-06-11 Thread Patrick C
Hi Ilya,

Thanks for the swift reply, sorry for the noob question but can you 
elaborate on "but you forgot to import HoleImage" - I'm not quite 
following, I'm sure I will understand it once explained.

I'm only about 4 hours into my first workings with Python / Django, perhaps 
I'm jumping in a little too quick but so far I have read through a fair bit 
and live the prose. 

On Wednesday, June 11, 2014 9:26:30 PM UTC+1, Ilya Kazakevich wrote:
>
> To use any symbol (including " HoleImage" class) you need to import it 
> first. 
> You've imported Hole (from holes.models import Hole), but you forgot to 
> import HoleImage. 
> So, you got " name 'HoleImage' is not defined " error. 
>
> It is better to use IDE, because it helps you in such cases :) 
>
>
>
>
> Ilya Kazakevich, 
> JetBrains PyCharm (Best Python/Django IDE) 
> http://www.jetbrains.com/pycharm/ 
> "Develop with pleasure!" 
>
>
> >-Original Message- 
> >From: django...@googlegroups.com  
> >[mailto:django...@googlegroups.com ] On Behalf Of Patrick C 
> >Sent: Thursday, June 12, 2014 12:19 AM 
> >To: django...@googlegroups.com  
> >Subject: NameError at /admin/ name 'HoleImage' is not defined 
> > 
> >Hi All, 
> > 
> >New to Django / Python (coming from PHP). 
> > 
> >Trying to make a site for a golf course where there is a hole by hole 
> guide, each 
> >hole has a number, name, description then multiple images for the 
> gallery. 
> > 
> >I've spend the last few hours googling how I'm going wrong here because I 
> get 
> >the error in the subject line. 
> > 
> >My models.py is: 
> > 
> >from django.db import models 
> > 
> > 
> >class Hole(models.Model): 
> >hole_number = models.IntegerField() 
> >hole_name = models.CharField(max_length=255) 
> >hole_description = models.CharField(max_length=500) 
> > 
> > 
> >def __str__(self): 
> >return self.hole_number 
> > 
> > 
> >class HoleImage(models.Model): 
> >hole = models.ForeignKey(Hole, related_name='images') 
> >image = models.ImageField(upload_to='hole_photos') 
> >caption = models.CharField(max_length=250) 
> > 
> > 
> >and my admin.py is: 
> > 
> >from django.contrib import admin 
> >from holes.models import Hole 
> > 
> > 
> >class HoleImageInline(admin.TabularInline): 
> >model = HoleImage 
> > 
> > 
> >class HoleAdmin(admin.ModelAdmin): 
> >fields = ['hole_number', 'hole_name', 'hole_description'] 
> >list_display = ['hole_number', 'hole_name', 'hole_description'] 
> >inlines = [ HoleImageInline, ] 
> > 
> > 
> >admin.site.register(Hole) 
> > 
> > 
> > 
> > 
> >Full admin panel error is: 
> > 
> > 
> > 
> >NameError at /admin/ 
> > 
> >name 'HoleImage' is not defined 
> >Request Method:GET 
> >Request URL:http://127.0.0.1:8000/admin/ 
> >Django Version:1.6.5 
> >Exception Type:NameError 
> >Exception Value:name 'HoleImage' is not defined 
> >Exception 
> Location:/Users/my_laptop/development/golfsmart/holes/admin.py 
> >in HoleImageInline, line 5 
> >Python Executable:/usr/bin/python 
> >Python Version:2.7.5 
> > 
> > 
> > 
> > 
> >As I say, I'm new to this and have had a good trial and error stab, I'm 
> sure it's 
> >something simple I am overlooking and once I have it resolved I will have 
> a 
> >lesson learned as I have a few other apps to setup that will use this 
> many type 
> >for images. 
> > 
> >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...@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/7079f896-e765-428f-a95a-6f9 
> >53ad105f8%40googlegroups.com 
> ><
> https://groups.google.com/d/msgid/django-users/7079f896-e765-428f-a95a-6f 
> >953ad105f8%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/c7b136ef-2763-4b8c-929a-f3d17751cd0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


NameError at /admin/ name 'HoleImage' is not defined

2014-06-11 Thread Patrick C
Hi All,

New to Django / Python (coming from PHP).

Trying to make a site for a golf course where there is a hole by hole 
guide, each hole has a number, name, description then multiple images for 
the gallery.

I've spend the last few hours googling how I'm going wrong here because I 
get the error in the subject line.

My models.py is:

from django.db import models

*class Hole(models.Model):*
*hole_number = models.IntegerField()*
*hole_name = models.CharField(max_length=255)*
*hole_description = models.CharField(max_length=500)*

*def __str__(self):*
*return self.hole_number*

*class HoleImage(models.Model):*
*hole = models.ForeignKey(Hole, related_name='images')*
*image = models.ImageField(upload_to='hole_photos')*
*caption = models.CharField(max_length=250)*


and my admin.py is:

*from django.contrib import admin*
*from holes.models import Hole*

*class HoleImageInline(admin.TabularInline):*
*model = HoleImage*

*class HoleAdmin(admin.ModelAdmin):*
*fields = ['hole_number', 'hole_name', 'hole_description']*
*list_display = ['hole_number', 'hole_name', 'hole_description']*
*inlines = [ HoleImageInline, ]*

*admin.site.register(Hole)*


Full admin panel error is:

NameError at /admin/

name 'HoleImage' is not defined

Request Method:GETRequest URL:http://127.0.0.1:8000/admin/Django Version:
1.6.5Exception Type:NameErrorException Value:

name 'HoleImage' is not defined

Exception Location:/Users/my_laptop/development/golfsmart/holes/admin.py in 
HoleImageInline, line 5Python Executable:/usr/bin/pythonPython Version:2.7.5


As I say, I'm new to this and have had a good trial and error stab, I'm 
sure it's something simple I am overlooking and once I have it resolved I 
will have a lesson learned as I have a few other apps to setup that will 
use this many type for images.

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/7079f896-e765-428f-a95a-6f953ad105f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Can't figure out how to attach file to email using EmailMessage

2014-02-21 Thread Patrick Beeson
Good morning y'all!

I'm having a heck of a time figuring out what I'm doing wrong in attaching 
a file uploaded via a ModelForm to an email that's sent if the form is 
valid. Here's a link to my code on Stackoverflow: 
http://stackoverflow.com/questions/21938849/inmemoryuploadedfile-object-has-no-attribute-rfind-when-sending-email-with-a

Thanks for your 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-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/e9973fcb-099f-40ce-9ee7-820eda3d664f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Implementation of a Search Engine. How??

2013-10-09 Thread Patrick Müssig
Hi,

maybe is http://yacy.net/ what are you looking for. You can use Yacy as
Searchengine and fetch over the yacy API the data. Yacy has also a good
crawler to crawling webpages and indexing this pages.

greetz
Patrick Müssig


2013/10/9 Mithil Bhoras <mithilbhora...@gmail.com>

> Hello, I am a newbie in Django. I am required to do a project in Python
> and I've chosen Django as the Web Framework. My project is a 'Smart' Search
> Engine that retrieves results most relevant to user's query. This website
> will:
>
>1. Index all the web pages available
>2. Use Page Ranking algorithm to update the database as the user uses
>it
>3. Give suggestions for more appropriate queries based on the most
>recent queries that other users world wide entered.
>4. Correct queries if user makes a spelling mistake.
>
> We are a team of four under-graduates in our final year of engineering
> trying to implement this web search engine site. Being new to Django, I've
> no idea how I can achieve this. Of course, I've gone through the Django
> documentations, various tutorials on other web pages and familiarized my
> self with the basics by building simple apps like a Blog. I've a basic
> knowledge of Python and Html so problem there. But I don't know how to go
> ahead from there as I've no idea where to start. Can anyone just tell me or
> at least give me a hint of how I can make this possible? Like how do manage
> the database (I'm using SQLite3), make a form to get input query from the
> user or how do I display the search results? 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/0a3daa6b-2c77-4d21-8cfa-466c2e8c86c1%40googlegroups.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/CACtvhK5cPUSJrZrZRJShHyP34iyu1_XfPY9L2yv5fxbKKMmZYg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: pycharm constant error

2013-08-25 Thread Patrick Larmann
Hello,
Thx Mike for the advice. Will do!

On Sunday, August 25, 2013 12:09:13 AM UTC-4, Mike Dewhirst wrote:
>
> On 25/08/2013 1:21pm, Patrick Larmann wrote: 
> > Hello, 
> > Thanks for your response. I reinstalled it but am still getting the 
> > error. How would I do a full revert? 
>
> $ pip uninstall django 
>
> followed by 
>
> $ pip install django 
>
> If you haven't got pip installed you need to get it. 
> https://pypi.python.org/pypi/pip 
>
> Also, I would start again with the tutorials in a fresh directory and 
> use a plain text editor (Notepad++ or Textpad for me) with Python syntax 
> highlighting rather than Pycharm. 
>
> Once you get your head around the tutorials and have a reasonable feel 
> for Django you will be more comfortable with Pycharm. I think an IDE is 
> vital if you are developing a project with your own separate libraries 
> and you are in and out of them making changes all the time. Otherwise, 
> (for me) it is easier to have a bunch of Textpad or Notepad++ windows 
> with all the code I want to work on or refer to. 
>
> Mike 
>
> > Thx! 
> > 
> > On Saturday, August 24, 2013 11:02:38 PM UTC-4, Mike Dewhirst wrote: 
> > 
> > On 25/08/2013 11:56am, Patrick Larmann wrote: 
> >  > Hello guys, 
> >  > I really appreciate the help. I have a problem with Pycharm. I am 
> >  > getting this constant error in my runserver.py in both of my 
> > projects. I 
> >  > did not modify or touch the file, and yet the error persists. 
> >  > I attached a screenshot. 
> > 
> > It looks (to me) as though you are editing a part of Django itself. 
> > Although it is open source you need to really know what you are 
> > doing if 
> > that is your focus. 
> > 
> > I would revert any changes made to django and stay within my own 
> code. 
> > 
> > hth 
> > 
> > 
> >  > Thanks for the help, guys. 
> >  > 
> >  > -- 
> >  > 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 
> > <http://groups.google.com/group/django-users>. 
> >  > For more options, visit https://groups.google.com/groups/opt_out 
> > <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...@googlegroups.com . 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > Visit this group at http://groups.google.com/group/django-users. 
> > 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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: pycharm constant error

2013-08-24 Thread Patrick Larmann
Hello,
Thanks for your response. I reinstalled it but am still getting the error. 
How would I do a full revert?
Thx!

On Saturday, August 24, 2013 11:02:38 PM UTC-4, Mike Dewhirst wrote:
>
> On 25/08/2013 11:56am, Patrick Larmann wrote: 
> > Hello guys, 
> > I really appreciate the help. I have a problem with Pycharm. I am 
> > getting this constant error in my runserver.py in both of my projects. I 
> > did not modify or touch the file, and yet the error persists. 
> > I attached a screenshot. 
>
> It looks (to me) as though you are editing a part of Django itself. 
> Although it is open source you need to really know what you are doing if 
> that is your focus. 
>
> I would revert any changes made to django and stay within my own code. 
>
> hth 
>
>
> > Thanks for the help, guys. 
> > 
> > -- 
> > 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. 
> > 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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Import Error: cannot import name timezone

2013-08-24 Thread Patrick Larmann
Thanks fixed it?

On Saturday, August 24, 2013 5:45:47 PM UTC-4, Robin Lery wrote:
>
> It should be
> 'from django.utils import timezone'
> and not 
> 'from django.db.utils import timezone'
>
>
> On Sun, Aug 25, 2013 at 2:58 AM, Patrick Larmann 
> <rails4pr...@gmail.com
> > wrote:
>
>> He Guys,
>> I am currently completing part 1 of the django tutorial and having 
>> trouble with getting on of the modules correctly set up.
>> I attached my output and my moduls.py file.
>>
>> -- 
>> 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.
>> 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.
For more options, visit https://groups.google.com/groups/opt_out.


Help required using pre_fetched data in aggregate()

2013-08-24 Thread Patrick Joy
Hi all,

Would appreciate some help on how to optimise the following piece of code.

I have two models, "invoice" and "invoice item". The invoice total is 
calculated in invoice_total() by aggregation the sub_total and tax_total 
from all invoice_items (see code below).

The problem I have is that even though I prefetch all the invoice_items in 
the view, when invoice.invoice_total is called in a template 3 identical 
queries will be run for each invoice. For example see some output from a 
profile.

# All invoice items are prefetched correctly
SELECT ••• FROM `billing_invoice_item` WHERE 
`billing_invoice_item`.`invoice_id` IN (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 51, 
53, 54, 55, 56, 58, 59, 60, 61, 62, 65, 66, 67, 68, 69, 70, 72, 73, 74, 75, 
76, 77, 78, 80, 81, 82, 84, 85, 87, 88, 89, 90, 91, 92, 93, 94, 96, 97, 98, 
99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 113, 114, 115, 
116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 128, 129, 130, 131, 
132, 134, 135, 136, 137, 138, 140, 141, 142, 143, 144, 145, 146, 147, 148, 
149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 
164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 
179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 
194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 
209, 210, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 
225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 
240, 241, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 
256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 
271, 272, 273, 274, 275, 276, 277)

but then after this the table is queried 3 more times
SELECT ••• FROM `billing_invoice_item` WHERE 
`billing_invoice_item`.`invoice_id` = 277
SELECT ••• FROM `billing_invoice_item` WHERE 
`billing_invoice_item`.`invoice_id` = 277
SELECT ••• FROM `billing_invoice_item` WHERE 
`billing_invoice_item`.`invoice_id` = 277

I'm using django 1.5 and my code is below.

Any thoughts?

#models.py
class Invoice(models.Model):

customer =  models.ForeignKey(Customer)
:
:
:

def invoice_total(self):  
invoice_total = self.invoice_item_set.aggregate(Sum('sub_total'), 
Sum('tax_total'))
return str(round(invoice_total['sub_total__sum'], 2))

class Invoice_Item(models.Model):
invoice =  models.ForeignKey('Invoice')
sub_total = models.DecimalField(blank=True, null=True, max_digits=9, 
decimal_places=2)
tax_total = models.DecimalField(blank=True, null=True, max_digits=9, 
decimal_places=2)
:
:
:

#views.py
def invoice(request):

invoices = Invoice.objects.all().prefetch_related('invoice_item_set', 
'journals', 'journals__transaction_set', 
'journals__transaction_set__account',  'customer')

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

-- 
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.


Overriding queryset for inline admin

2013-04-12 Thread Patrick Craston
Hi list

I'm having some trouble overriding the queryset for my inline admin.

Here's a bog-standard parent admin and inline admin:

class MyInlineAdmin(admin.TabularInline):
model = MyInlineModel

def queryset(self, request):
qs = super(MyInlineAdmin, self).queryset(request)
return qs

class ParentAdmin(admin.ModelAdmin):
inlines = [MyInlineAdmin]
admin.site.register(ParentAdminModel, ParentAdmin)


Now I can do qs.filter(user=request.user) or 
qs.filter(date__gte=datetime.today()), no problem.

But what I need is either the MyInlineModel instance or the ParentAdminModel 
instance (not the model!), as I need to filter my queryset based on that.

Is it possible to get something like self.instance or obj (like in 
get_readonly_fields())?

Hope this makes sense. Any help is much appreciated.

Patrick

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




RE: PostgresSQL or MySql with django?

2013-03-21 Thread Patrick Craston
I have found the py-mysql2pgsql to work without problems.

Did you install it using "pip install py-mysql2pgsql" (if you are using a 
virtualenv make sure you are running it from there or have activated the 
virtualenv)?

No command found suggests there is a problem with your path and it can't find 
the script.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of frocco
Sent: 21 March 2013 13:06
To: django-users@googlegroups.com
Subject: Re: PostgresSQL or MySql with django?

Has anyone used this?

https://github.com/lanyrd/mysql-postgresql-converter/

I cannot get this working, says cannot find the file

On Thursday, March 21, 2013 8:14:04 AM UTC-4, frocco wrote:
I have not been able to get this to work.
Says no command found.

I must say, porting Mysql data to Postgresql is a big pain on a mac.
I am almost inclined to stay with mysql.

I googled for an easy solution, but could not find anything except dbconvert 
for 100.00


On Wednesday, March 20, 2013 10:20:19 AM UTC-4, Patrick Craston wrote:
Alternatively, I've found this tool works very well:

https://pypi.python.org/pypi/py-mysql2pgsql

(only thing to look out for are Django IPAddressFields as they are char(15) 
fields in MySQL and inet fields in Postgres - py-mysql2pgsql is obviously not 
aware of this)

HTH

Patrick

-Original Message-
From: django...@googlegroups.com<mailto:django...@googlegroups.com> 
[mailto:django...@googlegroups.com] On Behalf Of Tom Evans
Sent: 20 March 2013 14:12
To: django...@googlegroups.com<mailto:django...@googlegroups.com>
Subject: Re: PostgresSQL or MySql with django?

On Wed, Mar 20, 2013 at 1:54 PM, frocco 
<far...@gmail.com<mailto:far...@gmail.com>> wrote:
> Hello,
>
> I know this is not django related, but can someone help me with the
> syntax to port mysql to postgresql?
> I tried the mysqldump command with the postgresql compatibility
> option, but I still cannot import the data.
>
> Thanks
>
>

Django itself has mechanisms for importing and exporting data in a database 
independent format:

https://docs.djangoproject.com/en/1.5/ref/django-admin/#django-admin-dumpdata

If you are not dealing with huge amounts of data, this can be the simplest way 
forward.

Cheers

Tom

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




RE: PostgresSQL or MySql with django?

2013-03-20 Thread Patrick Craston
Alternatively, I've found this tool works very well:

https://pypi.python.org/pypi/py-mysql2pgsql

(only thing to look out for are Django IPAddressFields as they are char(15) 
fields in MySQL and inet fields in Postgres - py-mysql2pgsql is obviously not 
aware of this)

HTH

Patrick

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Tom Evans
Sent: 20 March 2013 14:12
To: django-users@googlegroups.com
Subject: Re: PostgresSQL or MySql with django?

On Wed, Mar 20, 2013 at 1:54 PM, frocco <faro...@gmail.com> wrote:
> Hello,
>
> I know this is not django related, but can someone help me with the 
> syntax to port mysql to postgresql?
> I tried the mysqldump command with the postgresql compatibility 
> option, but I still cannot import the data.
>
> Thanks
>
>

Django itself has mechanisms for importing and exporting data in a database 
independent format:

https://docs.djangoproject.com/en/1.5/ref/django-admin/#django-admin-dumpdata

If you are not dealing with huge amounts of data, this can be the simplest way 
forward.

Cheers

Tom

--
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?hl=en.
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Request for comments on a new Open Source Paas platform for Django

2013-03-01 Thread Patrick
Hi,

I'm building a Juju based Open Source Paas platform for Django and
I need your help because it is a hard task to make a PAAS system
that is flexible enough to deploy any projects and at the same time
simple to use.

For the ones that don't know Juju, it's a service orchestration software
compatible with LXC (local), EC2, HPCloud, OpenStack and Baremetal/Maas
developed by Canonical (the company that makes Ubuntu).

Check out the web site for more details: https://juju.ubuntu.com/

So quickly, here's how it would works:

After installing Juju and configuring it with for your favourite cloud 
provider you
will need to create a configuration file in the YAML format named 
my_django_conf.yaml
in this example::

  my_django_site:
  vcs: git
  repos_url: https://github.com/my_username/my_site.git 
  site_secret_key: abcdefgh123456789
  use_virtualenv: True

Then you will need these commands to bootstrap and launch all the servers::

  juju bootstrap

  juju deploy --config my_django_conf.yaml my_django_site
  juju deploy postgresql # or mysql,mongodb, etc
  juju deploy gunicorn # Or mod_wsgi, etc

  juju add-relation my_django_site postgresql
  juju add-relation my_django_site gunicorn

  juju expose gunicorn # Open the tcp port in the firewall

You will end up with 3 servers running. One will be the controller
and one for each service (django and the database). 
Gunicorn will be a special charm that will be installed on your Django 
server.
After that, adding a new Django node would be as simple as::

  juju add-unit my_django_site



As I said, where it gets tricky is how do I make the configuration flexible 
enough
and at the same time simple.

After looking at what was existing in Django's Paas world, I came with this:

1 - We need a configurable requirements files for both pip and apt-get. By 
default
it would be looking for package in there files at install time::

  requirements_pip_files: requirements.txt,requirements.pip
  requirements_apt_files: requirements.apt

and we could also configure extra packages by adding variables like this in 
the YAML file::

  additional_distro_packages: vim,emacs,etc
  additional_pip_packages: virtualenvwrapper,celery,South,etc

2 - I'm suggesting to use separate configurations files in a settings/ 
directory
so by default it will be injecting configuration in those files::

settings_database_path: settings/20-engine.py
settings_static_path: settings/20-static.py
settings_uploads_path: settings/20-media.py
settings_cache_path: settings/30-cache.py
settings_secret_key_path: settings/20-secret.py

I'm suggesting splitting settings because when the configuration is 
modified,
for some reason, it would be difficult and risky to parse settings.py and 
change only the right thing.

So instead, I would be using topic files rendered with templates.
So if you would need to do more advanced stuff you could just fork the charm
and modify the templates for your needs.

3 - Finally, I was thinking adding some options to execute custom scripts 
that
would run a various time during the deployment. Like after packages 
installation
,database configuration and static file configuration::

post_database_script:
type: string
default: |
  #!/bin/sh
  python manage.py syncdb --noinput
  python manage.py migrate --noinput
post_static_script:
type: string
default: |
  #!/bin/sh
  python manage.py collectstatic -v 0 --noinput

Note that this is not making unanimity so far.
There is several reasons that makes the scripts approach tricky:

* You don't want to execute these scripts every time a little detail change.
* You might need the database configuration to be ready for some script.
* You could be not using south
* You might want to import some initial data and maybe only once at install 
time.
* You could want to compress static files after running collectstatic
* etc

An other idea could be to use a Fabric plug-in that use Juju's database to 
connect
to the machines and run commands like this for example::

  fab -R my_django_site python manage.py pull

would pull the latest version of the site and reload the application on 
every
deployed Django machines.

The bottom line here is that it's not simple to find out what a standard
Django deployment (and is maintenance) looks like.

That being said, I'm really looking forwards for you comments and 
suggestions.

Patrick

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




MySQL, manage.py and nvarchar

2013-02-01 Thread Patrick Loney


Hello,

I'm just starting with Django and am trying to create a db table with 
nvarchar fields as opposed to varchar.

I'm using MySQL and creating objects of type models.CharField() within my 
classes.

Any ideas?

Cheers,

Patrick

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




  1   2   3   4   5   6   >