Re: ValidationError: ManagementForm data is missing or has been tampered with

2010-04-10 Thread Gramware
Try this for a solution 
http://stackoverflow.com/questions/2536285/django-formset-management-form-validation-error

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



Re: Displaying the fields of two tables on the same admin page

2010-03-29 Thread Gramware


On Mar 29, 7:56 am, Asim Yuksel <a.sinanyuk...@gmail.com> wrote:
> Sorry for not making it clear. The idea is to use default admin
> template and help the admin to enter data from admin interface. I will
> enter data via admin's default template. Lets say I have People and
> Publications Table in my database. So when I click admin's add button,
> it will display some fields to enter data for People and Publication
> Tables. When I click save, the data will be saved to People and
> Publications table. People and Publications are not related. They are
> different tables. I cant use inlines option ind admin,py because the
> tables should be related.
>
> On 28 Mart, 15:37, Gramware <dmb...@gmail.com> wrote:
>
> > On Mar 28, 8:40 pm, Asim Yuksel <a.sinanyuk...@gmail.com> wrote:
>
> > > I have two questions.
> > > 1)I have two tables(People, Publication) and they are not related and
> > > I want to display the fields of these tables on the same admin page.
> > > So when I fill all the fields, I want to insert these values into
> > > people and publication tables.
>
> > I do not fully understand your question, but if you would like to
> > Iterate (loop over) 2 values in your template at  the same time, you
> > can use the zip command like blow
>
> > In your views.py
>
> > peo = People.objects.all()
> > pub=Publications.objects.all()
>
> > render_to_response(template.html, {'tables':zip(peo,pub)})
>
> > in your template (template.html)
>
> > {% for pe, pu in tables %}
> > {{pe.field1}} {{pu.field1}}
> > {% endfor %}
>
> > I am assuming that for each record in people, there is a matching one
> > in publications
>
> > > 2) I also want to insert the id values of people and publication to a
> > > bridge table(lets say PeoplePublication) whenever I do the first step.
>
> > > I guess I cant do the 1st one with inlines. How can I do this?
>
> > Why not use a ForeignKey?
Have you tried the above solutions.
P.S. I have no experience in hacking the Admin Interface, I have made
my own Admin pages using the above process

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



Django Sum all values with a distinct ForeignKey ID & zip them with fields from related table

2010-03-29 Thread Gramware
I would like to perform something similar to
http://stackoverflow.com/questions/861310/summing-the-values-from-the-2nd-table-based-on-id-of-the-1st-table
(ie get the sum of distinct event amounts in a payment table then
group the payments by event details and total money paid for them.
Also getting users and what they have paid for an event will be done)
in Django using PostgreSQL.

My models are as below:

class UserProfile(User):
onames = models.CharField(max_length=30, blank=True)
phoneNumber = models.CharField(max_length=15, blank=True)
regNo = models.CharField(max_length=15)
designation =
models.CharField(max_length=3,choices=DESIGNATION_CHOICES,
default='MEM')
image = models.ImageField(max_length=100,upload_to='photos/%Y/%m/
%d', blank=True, null=True, default='photos/2010/03/placeholder.jpg')
course = models.CharField(max_length=30, blank=True, null=True)
timezone = models.CharField(max_length=50, default='Africa/
Nairobi')
smsCom = models.BooleanField()
mailCom = models.BooleanField()

class Payments(models.Model):
username = models.ForeignKey(UserProfile, related_name='payer')
receiptNo = models.CharField(max_length=30, primary_key=True)
particulars = models.CharField(max_length=50)
date = models.DateField(auto_now_add=True)
amount = models.FloatField(max_length=99, blank=True)
eventID = models.ForeignKey('events', null=True, blank=True)
receiver = models.ForeignKey(UserProfile,
related_name='receiver')
deleted = models.BooleanField()

class events(models.Model):
eventName  = models.CharField(max_length=100)
eventID =  models.AutoField(primary_key=True)
details = models.TextField()
attendanceFee = models.FloatField(max_length=99)
date = models.DateField()
username = models.ManyToManyField(UserProfile,
related_name='user')
eventposter = models.ForeignKey(UserProfile,
related_name='event_poster')
deleted = models.BooleanField()

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



Re: Displaying the fields of two tables on the same admin page

2010-03-28 Thread Gramware


On Mar 28, 8:40 pm, Asim Yuksel  wrote:
> I have two questions.
> 1)I have two tables(People, Publication) and they are not related and
> I want to display the fields of these tables on the same admin page.
> So when I fill all the fields, I want to insert these values into
> people and publication tables.

I do not fully understand your question, but if you would like to
Iterate (loop over) 2 values in your template at  the same time, you
can use the zip command like blow

In your views.py

peo = People.objects.all()
pub=Publications.objects.all()

render_to_response(template.html, {'tables':zip(peo,pub)})

in your template (template.html)

{% for pe, pu in tables %}
{{pe.field1}} {{pu.field1}}
{% endfor %}

I am assuming that for each record in people, there is a matching one
in publications

> 2) I also want to insert the id values of people and publication to a
> bridge table(lets say PeoplePublication) whenever I do the first step.
>
> I guess I cant do the 1st one with inlines. How can I do this?

Why not use a ForeignKey?

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



Re: Making email unique

2010-03-28 Thread Gramware


On Mar 28, 6:44 pm, Wiiboy  wrote:
> Hi guys,
> I've got a Python website that has to integrate with a forum (i.e.
> when a user registers on mysite.com, they also have to be registered
> automatically on forum.mysite.com).  That forum forces email addresses
> to be unique.  How can I force that on Django?

http://docs.djangoproject.com/en/dev/ref/models/fields/#unique

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



Re: Displaying the fields of two tables on the same admin page

2010-03-28 Thread Gramware


On Mar 28, 8:40 pm, Asim Yuksel  wrote:
> I have two questions.
> 1)I have two tables(People, Publication) and they are not related and
> I want to display the fields of these tables on the same admin page.
> So when I fill all the fields, I want to insert these values into
> people and publication tables.
I do not fully understand your question , but if you want to Iterate
over both tables  at the same time, you can do the following . This
will use the zip command to pack your variables

in view.py

peo = People.objects.all()
pub = Publication.objects.all()

render_to_response(template.html, {'tables':zip(peo, pub)} )

in your template(template.html)

{% for t in tables %}
{{t.field1}} {{t.field2}}
{% endfor %}

> 2) I also want to insert the id values of people and publication to a
> bridge table(lets say PeoplePublication) whenever I do the first step.

Why not use Foreign Key or ManyToMany field
>
> I guess I cant do the 1st one with inlines. How can I do this?

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



Re: Need help with django admin panel

2010-03-28 Thread Gramware


On Mar 28, 9:51 am, common_nick  wrote:
> Hello, i am new in Django and i wanted to start with some simple app,
> but have problems with customizing admin panel. Below is my setup
>
> http://pastebin.com/gsXqZWfy
>
> I don't know how to make Mailbox to have single unique owner
> (HostingUserProfile in this case), but be able to assign multiple
> mailboxes to owner.
>
> Thanks in advance.
>
> PS sorry for my bad English

http://docs.djangoproject.com/en/dev/topics/db/models/#many-to-one-relationships

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



Re: Django Admin Site "TemplateDoesNotExist" Error.

2010-01-31 Thread Gramware
Ok, solved this by including

'django.contrib.admin',

in INSTALLED APPS in settings.py

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



Django Admin Site "TemplateDoesNotExist" Error.

2010-01-31 Thread Gramware
I get the following output on running http://localhost:8000/admin/

TemplateDoesNotExist at /admin/
admin/login.html
Request Method: GET
Request URL:http://localhost:8000/admin/
Exception Type: TemplateDoesNotExist
Exception Value:
admin/login.html
Exception Location: /usr/lib/python2.6/site-packages/django/template/
loader.py in find_template_source, line 74
Python Executable:  /usr/bin/python
Python Version: 2.6.2
Python Path:['/home/projects/acms', '/usr/lib/python26.zip', '/usr/
lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/
lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-
dynload', '/usr/lib/python2.6/site-packages', '/usr/lib/python2.6/site-
packages/Numeric', '/usr/lib/python2.6/site-packages/PIL', '/usr/lib/
python2.6/site-packages/gst-0.10', '/usr/lib/python2.6/site-packages/
gtk-2.0']
Server time:Sun, 31 Jan 2010 09:51:17 +0300
Template-loader postmortem

Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.load_template_source:
/home/projects/acms/acms_templates/admin/login.html (File does not
exist)
Using loader
django.template.loaders.app_directories.load_template_source:
Using loader django.template.loaders.eggs.load_template_source:





my url.py is

from django.conf.urls.defaults import *
from acms.views import hello, current_datetime, hours_ahead, login
import os.path

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
('^hello/$', hello),
('^log_in/$', login),
('^time/$', current_datetime),
(r'^admin/', include(admin.site.urls)),
(r'^time/plus/(\d{1,2})/$', hours_ahead),
(r'^media/(?P.*)', 'django.views.static.serve',
{'document_root':
'settings.MEDIA_ROOT'}),




and views.py

from django.shortcuts import render_to_response
from django.http import HttpResponse
import datetime

def hello(request):
return HttpResponse("Hello world")


def current_datetime(request):
now = datetime.datetime.now()
return render_to_response('base.html', {'current_date': now})


def hours_ahead(request, offset):
try:
offset = int(offset)
except ValueError:
raise Http404()
dt = datetime.datetime.now() + datetime.timedelta(hours=offset)
html = " In %s hour(s),  it will be %s. " %
(offset, dt)
return HttpResponse(html)


def login(request):
return render_to_response('login.html', {'': locals()})



What could be the issue, since I am following the Django book? Thanks.

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