Possible bug in Django WSGI get_script_name ?

2014-07-15 Thread Petr Tůma
Hello,

while debugging a Django site recently, I came across surprising behavior 
related to WSGI handling. In django/core/handlers/wsgi.py (current git 
head), the get_script_name function contains the following fragment:

if script_url:
path_info = get_bytes_from_wsgi(environ, 'PATH_INFO', '')
script_name = script_url[:-len(path_info)]

This should remove whatever path fragment was appended to script name when 
that is retrieved from SCRIPT_URL rather than SCRIPT_NAME, but the code 
does not handle the special case where PATH_INFO is empty (which it can be 
according to comments in PEP 333). In that case, script name is set to an 
empty string, rather than being left as it is (as it should be).

Is it possible that this is a bug, or am I looking at things wrong ?

Thanks, Petr

-- 
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/25524a89-c0d0-4008-9887-b61a7efedaa7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how do i return an int as the returned object for admin panel

2014-07-15 Thread monoBOT
The __unicode__ method is meant to return a human readable representation
of the model object as a unicode.
EG:

def __unicode__(self):
return u'%(id)s' % {'id': self.vm__id}

althought not very human readable is a correct __unicode__ method.

The reason behind you wanting a int number in the __unicode__ method is
strange for me/us.
Also, creating a method just to get the object id doesnt seem too bright.

why not just object.vm__id ?



2014-07-14 23:39 GMT+01:00 Tom Evans :

> On Mon, Jul 14, 2014 at 11:31 PM, Aeh. ABID  wrote:
> >
> > In your def __unicode__ convert the current returned int to string :
> >
> >>  def __unicode__(self):  # Python 3: def __str__(self):
> >>   return str(self.vm_id)
> >
>
> Stop, you are making my eyes bleed!
>
> It is really fairly important that you return a unicode object from
> the __unicode__ method and not a str object.
> __unicode__ is the method that python calls when python wants to turn
> your object in to a unicode representation of it. The method takes no
> arguments, and the ONLY post-condition is that it returns a unicode
> object - it should not be too taxing to get it right!
>
> If you do not return a unicode object, strange and unpredictable
> things can happen (like AttributeError("'int' object has no attribute
> 'encode'")).
>
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAFHbX1%2B5mn3M5Wm-V3HOcLvtdaW%2Bqh4PELm8F6fq9Fo%3Dg-tzDg%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*monoBOT*
Visite mi sitio(Visit my site): monobotsoft.es/blog/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BxOsGCHYsTMTsG1h%3DP%3DtyBsMH3jybVt-St%3DWKUs1uzS%2BBRmHA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django setup with elsatic beanstalk

2014-07-15 Thread Stefano Tranquillini
i gave up and create a  machine on AWS and deployed everything.
it's not that complex, u can find tutorial online .




On Sat, Jul 12, 2014 at 1:24 AM, Rob  wrote:

>   gmail.com> writes:
>
> >
> >
> > I'm having a similar problem - I don't see errors from the
> EB console - but django is not loaded I
> still get the standard AWS EB page.I have tried editing settings.py
> and app.config according to this
> tutorial:http://docs.aws.amazon.com/elasticbeanstalk
> /latest/dg/create_deploy_Python_django.htmla
> nd have tried many variations. If anyone has
> gotten this working from a windows machine - I would
> appreciate the help.ThxOn Monday, October 8,
> 2012 7:22:51 PM UTC+2, shlomi oberman wrote:
> > I'm trying without succes to setup a simple
> application using django with elastic beanstalk from my
> windows machine.Does anyone have any
> expreience with this? I am currently getting the following
> error from the EB console: "Your
> WSGIPath refers to a file that does not exist."
> >
> >
> >
> >
> >
>
>
> Did you ever solve this problem? I'm experiencing the same thing.
> I know the thread is a little old now.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/qzTomPSNK7c/unsubscribe.
> To unsubscribe from this group and all its topics, 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/loom.20140712T012206-551%40post.gmane.org
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Stefano

-- 
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/CAPQ1%3DkB%2B1XxqZeTRLD7NB7QBa6ver3E7uH492vPAovvw74vDOQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


date field validation

2014-07-15 Thread hardik . sottany
i want validation in form.py in which the datetime should not be less than 
datetime.now

please i need it urgently

please help 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/dda37413-d72f-4a5d-a9d8-b3ca72a4d82b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


checkout system for ecommerce site

2014-07-15 Thread ROHITH KUMAR Miryala
I have an e-commerce site where i need a cart system and checkout system.I 
have the whole website ready and i just needed these two features. Please 
help me in finding django-plugins for accomplishing those tasks.thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fa677eae-54b5-49e1-9054-98aa88c48ee6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: date field validation

2014-07-15 Thread monoBOT
like that:

def clean_date(self):
date = self.cleaned_data['date']

if date < datetime.datetime.now():
raise forms.ValidationError(_(u'Must be a future date'))
return date


2014-07-15 12:29 GMT+01:00 :

> i want validation in form.py in which the datetime should not be less than
> datetime.now
>
> please i need it urgently
>
> please help 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/dda37413-d72f-4a5d-a9d8-b3ca72a4d82b%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*monoBOT*
Visite mi sitio(Visit my site): monobotsoft.es/blog/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BxOsGBUD%3DShyBn7HbD8aOz9C36swSqV6nLxhoZ2bh7KibmjOg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django-admin set foreign key to Null for inlines selected item instead of delete

2014-07-15 Thread ROHITH KUMAR Miryala


>
>
> B-id=models.ForeignKey('B',on_delete=models.SET_NULL)
>

-- 
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/280d4b82-80a2-49f2-928d-015596d9fd4f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: imagens com django templates

2014-07-15 Thread erico
No settings.py 

MEDIA_ROOT = os.path.join(ROOTDIR, 'media')
MEDIA_URL  = '/media/'

urls.py
# arquivos de media-uploads
(r'^media/(.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),


no .html
{% for item in lista_itens %}


{% endfor %}



Altera
imagem = models.ImageField(upload_to='C:/Projeto Budega das 
artes/budegadasartes/media/imagens_ventos',)

para algo como: imagem = models.ImageField(upload_to='sua_pasta_de_images/') 
Já que o ROOTDIT te dará um caminha absoluto.



Em segunda-feira, 14 de julho de 2014 12h04min05s UTC-3, Carlos Andre 
escreveu:
>
> Olá pessoal, estou tentando usar um slideshow e uso um for para iterar as 
> imagens que passam vidas de um repositório, problemas que funciona sem o 
> comando for no template, quando adiciono ele mostra nada para! 
> Pelo que vejo há problemas no reconhecimento dos comandos de templates, 
> caso como o que tenho que usar o caminho do path todo, não está 
> reconhecendo o media. As configurações do settings.py foram feitas e 
> apontam para a pasta das imagens. Se alguém poder me ajudar agradeço, não 
> coloquei trechos do código para não receber criticas por incluir código 
> aqui! 
>
>
> Hello guys, I'm trying to use a slideshow and use one is to iterate 
> through the images that pass a repository lives, works without problems 
> that the command is in the template, when I add anything to it shows! 
> I see no problems in recognizing commands templates, as if I have to use 
> the path of the whole path is not recognizing the media. Settings.py 
> settings were made and point to the folder of images. If someone could help 
> me thank you, excerpts did not put the code to not be criticized for 
> including code 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/5fda1403-a605-4b49-a92b-ff618abd32ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django 1.7c1 app without models data migrations

2014-07-15 Thread aRkadeFR
Hello everyone,

First post on this mailing list. Big thanks to the community and the core dev
of Django!

I'm using Django 1.7c1 with python 3.2 or 3.4.

I'm splitting lots of my website as Django apps. So my main app is handling
(only) the urls routing, the settings, some tests and that's it.

I want to do some data migrations. For example add some
django.contrib.sites.models.Site objects to the database when I migrate my
app. Or some flags (django-waffle) etc. All the data relates to this app.

I don't want to put this data migration into the django.contrib.sites folder
cause it's already packaged as root etc. So it's not runnable from my
development user (to create or read the file into the folder). And it's the
same problem for all these apps I want to add data into.

If I run "python3 manage.py makemigrations --empty ", it create the
0001_initial.py migrations. I create the function to add the data inside the
database, and try to run the migrations with "python3 manage.py migrate
", but get the error:

"CommandError: App  does not have migrations (you cannot selectively
sync unmigrated apps)"

So I'm searching how can I make this  migrated? Create an empty initial
migrations? so the django migrations take this app into account.

Thank you for all your help

aRkadeFR

-- 
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/20140715142108.GA10827%40rkade-thinkpad.
For more options, visit https://groups.google.com/d/optout.


Are these tests redundant?

2014-07-15 Thread Tianyi Wang
Hi,

I have a very simple model:

class Action(models.Model):
name = models.CharField('Name', max_length=100)
deleted = models.BooleanField('Deleted', default=False)

def __unicode__(self):
return self.name

class Meta:
ordering = ('name',)

My tests for this model is 
at https://gist.github.com/tianyi33/f8c327d8b539a7585cec

Do you think my tests are reasonable or some of them are redundant? 

Thanks

Tianyi

-- 
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/dbe37d7f-c9db-48c6-8757-6251689a1141%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Admin UI not commiting to DB

2014-07-15 Thread Timothy W. Cook
On Mon, Jul 14, 2014 at 12:44 PM, Tom Evans 
wrote:

>
>
> Have you ruled out that this is simply a mid air collision? IIRC,
> django admin has no mid air collision detection system
>
> Cheers
>
> Tom
>
> Eg if user A loads Item i, user B loads Item i, user A changes
> i.foo='hi' and saves item i, user B sets i.foo='bar', i.wibble='quuz'.
> User A complains that "admin is not saving my data".
>
>
Thanks Tom.  I haven't had a chance to work on this yet.  However, I can
reproduce it on my development machine with just one user.
Even on the production machine we only have 3 - 5 users at a time and they
are assigned different tasks and aren't likely to be editing the same entry.


I guess the obvious place that this would occur if no one else has the
problem is in the get_form.  It really doesn't do much except check a
boolean and determine if some fields should be readonly.

Example:

def get_form(self, request, obj=None, **kwargs):
try:
if obj.published:
self.readonly_fields =
['prj_name','published','lang','schema_code','data_name','valid_trues','valid_falses','description','sem_attr','resource_uri','asserts',]

except (AttributeError, TypeError) as e:
self.readonly_fields = ['published','schema_code','r_code',]

return super(DvBooleanAdmin, self).get_form(request, obj, **kwargs)


The try/except was added at one point to see if I could prevent this issue.
 It didn't make a difference so I'll probably take it out when I go back to
working on it.

I do have some actions defined but I can't see how they could cause this
since it is happening during the standard  edit/save process.


I don't recall if I said before: Django 1.6.5 (as well as earlier versions)
PostgreSQL 9.2 and now 9.3 on Ubuntu 14.04 and previously CentOS 6.5




Timothy Cook
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
MLHIM http://www.mlhim.org

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3Vf4HE5DUpPnCk1XO%3D%3DP6-%3DJh9T9v2gUT4jjK5miXmSZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Admin Page Customization Questions

2014-07-15 Thread G Z



I have a few questions, is it possible to template the admin page?

second I'm trying to customize some of the individuals pages for my 
particular issue
I have a table named vm_licenses and a licenses table, I have my models set 
up like the following:



class Vm_license(models.Model):
>vm_license_id = models.BigIntegerField(primary_key = True, editable = 
> False, db_column = 'vm_license_id')
>#license= models.ForeignKey(License,  on_delete = models.PROTECT)
>license = models.ManyToManyField(License)
>vm = models.ForeignKey(Vm,  on_delete = models.PROTECT)
>
>class Meta:
>   managed = False
>   db_table = 'vm_licenses'
>
> class License(models.Model):
>license_id = models.BigIntegerField(primary_key = True, editable = 
> False, db_column = 'license_id')
>license_authority = models.ForeignKey(License_authoritie,  on_delete = 
> models.PROTECT)
>product = models.CharField(max_length = 20)
>
>class Meta:
>   managed = False
>   db_table = 'licenses'
>   ordering = ['product']
>
>def __unicode__(self):  # Python 3: def __str__(self):
>   return self.product
>


here is my admin page

class vm_license_admin(admin.ModelAdmin):
list_display = ('vm', 'vm_license_id')
search_fields = ('vm__vm_name',)
ordering = ('vm',)
filter_horizontal = ('license',)





I want to be able to associate licenses with vms like the picture above 
just select which ones are active and move them over. How do i do this. 

The way it is now i get the following 

Exception Type: DatabaseError  Exception Value: 

ORA-00942: table or view does not exist

 Exception Location: 
/usr/local/lib/python2.7/dist-packages/django/db/backends/oracle/base.py 
in execute, line 816
but the table does exist because if i change it from manytomany back to 
foreignkey it will work again.

-- 
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/82699400-0ddd-4491-a289-0c35d2632b6a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Admin Page Customization Questions

2014-07-15 Thread G Z
Ive also tried

class License(models.Model):
   license_id = models.BigIntegerField(primary_key = True, editable = 
False, db_column = 'license_id')
   license_authority = models.ForeignKey(License_authoritie,  on_delete = 
models.PROTECT)
   product = models.CharField(max_length = 20)
   
   class Meta:
  managed = False
  db_table = 'licenses'
  ordering = ['product']

   def __unicode__(self):  # Python 3: def __str__(self):
  return self.product

class LicenseAssignments(models.Model):
license = models.ForeignKey(License, db_column="license_id")
vm_license = models.ForeignKey(Vm_license, db_column="vm_license_id")

class Meta:
db_table = "license_assignments" 
   
class Vm_license(models.Model):
   vm_license_id = models.BigIntegerField(primary_key = True, editable = 
False, db_column = 'vm_license_id')
   license = models.ManyToManyField(License, through="LicenseAssignments")
   vm = models.ForeignKey(Vm,  on_delete = models.PROTECT)
   
   class Meta:
  managed = False
  db_table = 'vm_licenses'
  
but when i sync the db i get the following error

self.execute(*args, **options.__dict__)
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
line 284, in execute
self.validate()
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
line 310, in validate
num_errors = get_validation_errors(s, app)
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py", 
line 34, in get_validation_errors
for (app_name, error) in get_app_errors().items():
  File 
"/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 
196, in get_app_errors
self._populate()
  File 
"/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 
75, in _populate
self.load_app(app_name, True)
  File 
"/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 
99, in load_app
models = import_module('%s.models' % app_name)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", 
line 40, in import_module
__import__(name)
  File "/home/grant/workspace/Django 
Projects/trunk/holon/portal/models.py", line 411, in 
class LicenseAssignments(models.Model):
  File "/home/grant/workspace/Django 
Projects/trunk/holon/portal/models.py", line 413, in LicenseAssignments
vm_license = models.ForeignKey(Vm_license, db_column="vm_license_id")
NameError: name 'Vm_license' is not defined


-- 
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/32a569f4-9a9c-447d-a311-ec1b4cfdc829%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Are these tests redundant?

2014-07-15 Thread Esau Rodriguez
Imho all but 4 are redundant. That is already tested in django itself.

Regards,
Esau Rodriguez.
El 15/07/2014 16:48, "Tianyi Wang"  escribió:

> Hi,
>
> I have a very simple model:
>
> class Action(models.Model):
> name = models.CharField('Name', max_length=100)
> deleted = models.BooleanField('Deleted', default=False)
>
> def __unicode__(self):
> return self.name
>
> class Meta:
> ordering = ('name',)
>
> My tests for this model is at
> https://gist.github.com/tianyi33/f8c327d8b539a7585cec
>
> Do you think my tests are reasonable or some of them are redundant?
>
> Thanks
>
> Tianyi
>
>  --
> 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/dbe37d7f-c9db-48c6-8757-6251689a1141%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB4Jw76CsL0JAimFrXU3FmuroZ-%3D7z9b1oXqJhm7picwVmO2Kw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Are these tests redundant?

2014-07-15 Thread Tianyi Wang
After looking at these tests again, yes, I agree. 
No point of testing model object creation since it's Django's job.
Testing the methods on the Model would be more useful I guess. 

Cheers,

Tianyi
On Tuesday, 15 July 2014 17:59:04 UTC+1, esauro wrote:
>
> Imho all but 4 are redundant. That is already tested in django itself.
>
> Regards,
> Esau Rodriguez.
> El 15/07/2014 16:48, "Tianyi Wang" > 
> escribió:
>
>> Hi,
>>
>> I have a very simple model:
>>
>> class Action(models.Model):
>> name = models.CharField('Name', max_length=100)
>> deleted = models.BooleanField('Deleted', default=False)
>>
>> def __unicode__(self):
>> return self.name
>>
>> class Meta:
>> ordering = ('name',)
>>
>> My tests for this model is at 
>> https://gist.github.com/tianyi33/f8c327d8b539a7585cec
>>
>> Do you think my tests are reasonable or some of them are redundant? 
>>
>> Thanks
>>
>> Tianyi
>>
>>  -- 
>> 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/dbe37d7f-c9db-48c6-8757-6251689a1141%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6fc44af2-d3b3-4177-8fb6-907b491833dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django ManytoMany Relationships

2014-07-15 Thread G Z



I will start by saying I have an existing database, for the purpose of my 
question it has three tables:
Vm
Vm_licenses 
Licenses

This database is per-existing before we decided to make a django 
web-portal. Basically licenses is a database that contains all possibile 
licenses, and Vm contains all the vms under our architecture. We then have 
a table vm_licenses, where it has a unique index vm_license_id, and two 
other columns vm_id with is the primary key for VM and license_id which is 
the primary key for licenses. I want to use the admin page to be able to 
edit the vm_licenses that way when i select a vm from vm_licenses on the 
admin page I can select from a list of licenses which licenses go with that 
vm. The only problem is the database already exist and as far as I can tell 
the relationship between the tables doesn't exist in a way django can do 
this with.

I have the following model set up:

class License(models.Model):
   license_id = models.BigIntegerField(primary_key = True, editable = 
False, db_column = 'license_id')
   license_authority = models.ForeignKey(License_authoritie,  on_delete = 
models.PROTECT)
   product = models.CharField(max_length = 20)
  
   class Meta:
  managed = False
  db_table = 'licenses'
  ordering = ['product']

   def __unicode__(self):  # Python 3: def __str__(self):
  return self.product
 
class Vm_license(models.Model):
   vm_license_id = models.BigIntegerField(primary_key = True, editable = 
False, db_column = 'vm_license_id')
   license= models.ForeignKey(License,  on_delete = models.PROTECT)
   vm = models.ForeignKey(Vm,  on_delete = models.PROTECT)
   
   class Meta:
  managed = False
  db_table = 'vm_licenses'


class Vm(models.Model):
   vm_id = models.BigIntegerField(primary_key = True, editable = False, 
db_column = 'vm_id')
   vm_mor = models.CharField(max_length = 20)
   vm_name = models.CharField(max_length = 256)
   vm_group= models.ForeignKey(Vm_group,  on_delete = models.PROTECT)
   vm_display_name = models.CharField(max_length = 30)
   datacenter= models.ForeignKey(Datacenter,  on_delete = models.PROTECT)
   vcd_managed = models.CharField(max_length = 60)

   class Meta:
  managed = False
  db_table = 'vms'

   def __unicode__(self):  # Python 3: def __str__(self):
  return self.vm_name


My admin page is :

class vm_license_admin(admin.ModelAdmin):
> list_display = ('vm', 'vm_license_id')
> search_fields = ('vm__vm_name',)
> ordering = ('vm',)
> #filter_horizontal = ('license',)
>


it says I need a manytomany relationship so I cahnged  
 
license= models.ForeignKey(License,  on_delete = models.PROTECT)

license= models.ManyToManyField(License)

but then it says it cant find the table or view from oracle when I change 
it..


How do I fix this I want to be able to assign licenses like the following 
picture:


-- 
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/6ce2267b-6618-4ada-b83b-d612c5911d8b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django ManytoMany Relationships

2014-07-15 Thread C. Kirby
ManyToMany fields actually create a new intermediary join table in the 
database. If you are using an unmanaged database then you will need to 
create the intermediary table yourself. See the ManyToMany field reference 


On Tuesday, July 15, 2014 12:44:18 PM UTC-5, G Z wrote:
>
> 
> I will start by saying I have an existing database, for the purpose of my 
> question it has three tables:
> Vm
> Vm_licenses 
> Licenses
>
> This database is per-existing before we decided to make a django 
> web-portal. Basically licenses is a database that contains all possibile 
> licenses, and Vm contains all the vms under our architecture. We then have 
> a table vm_licenses, where it has a unique index vm_license_id, and two 
> other columns vm_id with is the primary key for VM and license_id which is 
> the primary key for licenses. I want to use the admin page to be able to 
> edit the vm_licenses that way when i select a vm from vm_licenses on the 
> admin page I can select from a list of licenses which licenses go with that 
> vm. The only problem is the database already exist and as far as I can tell 
> the relationship between the tables doesn't exist in a way django can do 
> this with.
>
> I have the following model set up:
>
> class License(models.Model):
>license_id = models.BigIntegerField(primary_key = True, editable = 
> False, db_column = 'license_id')
>license_authority = models.ForeignKey(License_authoritie,  on_delete = 
> models.PROTECT)
>product = models.CharField(max_length = 20)
>   
>class Meta:
>   managed = False
>   db_table = 'licenses'
>   ordering = ['product']
>
>def __unicode__(self):  # Python 3: def __str__(self):
>   return self.product
>  
> class Vm_license(models.Model):
>vm_license_id = models.BigIntegerField(primary_key = True, editable = 
> False, db_column = 'vm_license_id')
>license= models.ForeignKey(License,  on_delete = models.PROTECT)
>vm = models.ForeignKey(Vm,  on_delete = models.PROTECT)
>
>class Meta:
>   managed = False
>   db_table = 'vm_licenses'
>
>
> class Vm(models.Model):
>vm_id = models.BigIntegerField(primary_key = True, editable = False, 
> db_column = 'vm_id')
>vm_mor = models.CharField(max_length = 20)
>vm_name = models.CharField(max_length = 256)
>vm_group= models.ForeignKey(Vm_group,  on_delete = models.PROTECT)
>vm_display_name = models.CharField(max_length = 30)
>datacenter= models.ForeignKey(Datacenter,  on_delete = models.PROTECT)
>vcd_managed = models.CharField(max_length = 60)
>
>class Meta:
>   managed = False
>   db_table = 'vms'
>
>def __unicode__(self):  # Python 3: def __str__(self):
>   return self.vm_name
>
>
> My admin page is :
>
> class vm_license_admin(admin.ModelAdmin):
>> list_display = ('vm', 'vm_license_id')
>> search_fields = ('vm__vm_name',)
>> ordering = ('vm',)
>> #filter_horizontal = ('license',)
>>
>
>
> it says I need a manytomany relationship so I cahnged  
>  
> license= models.ForeignKey(License,  on_delete = models.PROTECT)
>
> license= models.ManyToManyField(License)
>
> but then it says it cant find the table or view from oracle when I change 
> it..
>
>
> How do I fix this I want to be able to assign licenses like the following 
> picture:
>
>
>

-- 
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/c3626e86-fc46-4d0d-b0d6-d12fb9589f5d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: MultiValueDictKeyError in Django admin edit inline generic model

2014-07-15 Thread Alex

I am having a similar problem that started when I upgraded from django 
1.4.x to 1.6.5
My parent model has a custom pk and the model in my inline is using the 
default autogenerated id.

Here is some snippets from my models and admin:
(note I have edited down for simplicity and have not tested the code below)

class Transaction(models.Model):   
form = models.ForeignKey(Form)
code = models.CharField(max_length=4)


class Form(models.Model):
form_id = models.CharField(max_length=255, primary_key=True)
form_type = models.CharField(max_length=5)
notes = models.TextField(blank=True)

# admin

class TransactionInline(admin.TabularInline): 
model = Transaction 
fields = ('code', ) 
extra = 0

class FormAdmin(admin.ModelAdmin): 
list_display = ('form_type',) 
readonly_fields = ('form_type', 'form_id') 
fields = ('form_type', 'form_id', 'notes') 
 
inlines = [ 
TransactionInline,
]
admin.site.register(Form, FormAdmin)




On Wednesday, July 9, 2014 11:44:30 PM UTC-4, sacrac wrote:
>
> Hi, me again :) i forgot mention a use the latest release django 1.6.5 and 
> python 2.7.5
>
> any help or tips?
>
> thank.
>
>
> On Wed, Jul 9, 2014 at 9:38 PM, carlos > 
> wrote:
>
>> Hi, i have this error when i edit the data, is similar error the next 
>> link 
>>
>>
>> http://stackoverflow.com/questions/19741314/multivaluedictkeyerror-in-django-admin
>>
>> but the only different is i use generic relation, this is my models.py
>>
>> class Photos(models.Model):
>> name = models.CharField(max_length=150)
>>  imagen = ImageField(upload_to='photos', blank=True, null=True)
>>
>> content_type = models.ForeignKey(ContentType)
>>  object_id = models.PositiveIntegerField()
>> content_object = generic.GenericForeignKey('content_type', 'object_id')
>>
>>
>> def __unicode__(self):
>> return self.name
>>  class Meta:
>> verbose_name_plural = "Photos"
>>
>> and here my other models.py use the model generic Photos
>>
>> class Portfolio(models.Model):
>> service = models.CharField('Nombre del servicio', max_length=250)
>> date = models.DateField()
>> link = models.URLField(blank=True)
>>
>> photos = generic.GenericRelation(Photos)
>>
>> def __unicode__(self):
>> return self.service
>>
>> and this my admin.py 
>>
>> class PhotosAdminInline(generic.GenericTabularInline):
>> model = Photos
>> extra = 1
>>
>> class PortfolioAdmin(admin.ModelAdmin):
>> inlines = [PhotosAdminInline]
>>
>> .
>>
>> when i save the portfolio the fist time only 1 pic or 2 or 3 etc NOT have 
>> error
>> but when i need edit and add new photo i have this error
>>
>> MultiValueDictKeyError at /admin/portfolio/portfolio/6/
>>
>> "u'photos-photos-content_type-object_id-0-id'"
>>
>>
>> maybe this is a bug in Django?
>>
>>
>> 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/8ee68417-8dbb-4168-a753-0074f78aff7b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django ManytoMany Relationships

2014-07-15 Thread G Z
Kirby,

This is what i have so far but i dont understand how to get the table to do 
what I want. Because all I get on vm_licenses is the ability to select the 
vm there is no licenses anymore. I'm not quite sure how all of this works 
together. 

class License(models.Model):
   license_id = models.BigIntegerField(primary_key = True, editable = 
False, db_column = 'license_id')
   license_authority = models.ForeignKey(License_authoritie,  on_delete = 
models.PROTECT)
   product = models.CharField(max_length = 20)
   
   
   class Meta:
  managed = False
  db_table = 'licenses'
  ordering = ['product']

   def __unicode__(self):  # Python 3: def __str__(self):
  return self.product
 
class Vm_license(models.Model):
   vm_license_id = models.BigIntegerField(primary_key = True, editable = 
False, db_column = 'vm_license_id')
   license= models.ManyToManyField(License, through="vm_assignments")
   vm= models.ForeignKey(Vm,  on_delete = models.PROTECT)
   #vm = models.ForeignKey(Vm,  on_delete = models.PROTECT)
   
   class Meta:
  managed = False
  db_table = 'vm_licenses'
  
class vm_assignments(models.Model):
   vm_license = models.ForeignKey(Vm_license,  on_delete = models.PROTECT)
   license = models.ForeignKey(License,  on_delete = models.PROTECT)



On Tuesday, July 15, 2014 12:01:29 PM UTC-6, C. Kirby wrote:
>
> ManyToMany fields actually create a new intermediary join table in the 
> database. If you are using an unmanaged database then you will need to 
> create the intermediary table yourself. See the ManyToMany field reference 
> 
>
> On Tuesday, July 15, 2014 12:44:18 PM UTC-5, G Z wrote:
>>
>> 
>> I will start by saying I have an existing database, for the purpose of my 
>> question it has three tables:
>> Vm
>> Vm_licenses 
>> Licenses
>>
>> This database is per-existing before we decided to make a django 
>> web-portal. Basically licenses is a database that contains all possibile 
>> licenses, and Vm contains all the vms under our architecture. We then have 
>> a table vm_licenses, where it has a unique index vm_license_id, and two 
>> other columns vm_id with is the primary key for VM and license_id which is 
>> the primary key for licenses. I want to use the admin page to be able to 
>> edit the vm_licenses that way when i select a vm from vm_licenses on the 
>> admin page I can select from a list of licenses which licenses go with that 
>> vm. The only problem is the database already exist and as far as I can tell 
>> the relationship between the tables doesn't exist in a way django can do 
>> this with.
>>
>> I have the following model set up:
>>
>> class License(models.Model):
>>license_id = models.BigIntegerField(primary_key = True, editable = 
>> False, db_column = 'license_id')
>>license_authority = models.ForeignKey(License_authoritie,  on_delete = 
>> models.PROTECT)
>>product = models.CharField(max_length = 20)
>>   
>>class Meta:
>>   managed = False
>>   db_table = 'licenses'
>>   ordering = ['product']
>>
>>def __unicode__(self):  # Python 3: def __str__(self):
>>   return self.product
>>  
>> class Vm_license(models.Model):
>>vm_license_id = models.BigIntegerField(primary_key = True, editable = 
>> False, db_column = 'vm_license_id')
>>license= models.ForeignKey(License,  on_delete = models.PROTECT)
>>vm = models.ForeignKey(Vm,  on_delete = models.PROTECT)
>>
>>class Meta:
>>   managed = False
>>   db_table = 'vm_licenses'
>>
>>
>> class Vm(models.Model):
>>vm_id = models.BigIntegerField(primary_key = True, editable = False, 
>> db_column = 'vm_id')
>>vm_mor = models.CharField(max_length = 20)
>>vm_name = models.CharField(max_length = 256)
>>vm_group= models.ForeignKey(Vm_group,  on_delete = models.PROTECT)
>>vm_display_name = models.CharField(max_length = 30)
>>datacenter= models.ForeignKey(Datacenter,  on_delete = models.PROTECT)
>>vcd_managed = models.CharField(max_length = 60)
>>
>>class Meta:
>>   managed = False
>>   db_table = 'vms'
>>
>>def __unicode__(self):  # Python 3: def __str__(self):
>>   return self.vm_name
>>
>>
>> My admin page is :
>>
>> class vm_license_admin(admin.ModelAdmin):
>>> list_display = ('vm', 'vm_license_id')
>>> search_fields = ('vm__vm_name',)
>>> ordering = ('vm',)
>>> #filter_horizontal = ('license',)
>>>
>>
>>
>> it says I need a manytomany relationship so I cahnged  
>>  
>> license= models.ForeignKey(License,  on_delete = models.PROTECT)
>>
>> license= models.ManyToManyField(License)
>>
>> but then it says it cant find the table or view from oracle when I change 
>> it..
>>
>>
>> How do I fix this I want to be able to assign licenses like the following 
>> picture:
>>
>>
>>

-- 
You received this message because you are subscribed to the Goog

Re: Django ManytoMany Relationships

2014-07-15 Thread G Z
Admin.py

class vm_license_admin(admin.ModelAdmin):
list_display = ('vm',)
search_fields = ('vm__vm_name',)
ordering = ('vm',)
filter_horizontal = ('license',)

admin.site.register(Vm_license, vm_license_admin)



class License(models.Model):
   license_id = models.BigIntegerField(primary_key = True, editable = 
False, db_column = 'license_id')
   license_authority = models.ForeignKey(License_authoritie,  on_delete = 
models.PROTECT)
   product = models.CharField(max_length = 20)
   
   
   class Meta:
  managed = False
  db_table = 'licenses'
  ordering = ['product']

   def __unicode__(self):  # Python 3: def __str__(self):
  return self.product
 
class Vm_license(models.Model):
   vm_license_id = models.BigIntegerField(primary_key = True, editable = 
False, db_column = 'vm_license_id')
   license= models.ManyToManyField(License, through="vm_assignments")
   vm= models.ForeignKey(Vm,  on_delete = models.PROTECT)

   
   class Meta:
  managed = False
  db_table = 'vm_licenses'
  
class vm_assignments(models.Model):
   vm = models.ForeignKey(Vm,  on_delete = models.PROTECT)
   vm_license = models.ForeignKey(Vm_license,  on_delete = models.PROTECT)
   license = models.ForeignKey(License,  on_delete = models.PROTECT)


but the only thing that shows on vm_licenses is the vm there is no 
manytomany form element like im trying to get im simply mis understanding 
this

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3fc0ed4f-09f7-4e08-af13-0eda5ea6b045%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Admin Page Customization Questions

2014-07-15 Thread Michiel Overtoom

On Jul 15, 2014, at 17:59, G Z wrote:

> 
> I have a few questions, is it possible to template the admin page?

Yes, you can copy the default admin templates and change them. It is described 
here:

   
https://docs.djangoproject.com/en/dev/intro/tutorial02/#customize-the-admin-look-and-feel

Greetings,

-- 
"Good programming is not learned from generalities, but by seeing how 
significant programs can be made clean, easy to read, easy to maintain and 
modify, human-engineered, efficient, and reliable, by the application of common 
sense and good programming practices. Careful study and imitation of good 
programs leads to better writing."
 - Kernighan and Plauger, motto of 'Software Tools'




-- 
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/C9D025B7-E683-44B2-888F-00A2FF23AA90%40xs4all.nl.
For more options, visit https://groups.google.com/d/optout.


Strange error during migration

2014-07-15 Thread Arkaitz Mugica Islas
I'm migrating from Django 1.5.8 to 1.6.5. I've solved quite a lot of bug 
related to my code, but this time I think it could be a bug. Can anybody help 
me to fix it or should I post it to django-developers?



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

Django Version: 1.6.5
Python Version: 2.7.8


Traceback:
File 
"/Users/arkaitz/Documents/workspace/af73-dev/lib/python2.7/site-packages/django/core/handlers/base.py"
 in get_response
 199. response = middleware_method(request, response)
File 
"/Users/arkaitz/Documents/workspace/af73-dev/lib/python2.7/site-packages/django/contrib/sessions/middleware.py"
 in process_response
 38. request.session.save()
File 
"/Users/arkaitz/Documents/workspace/af73-dev/lib/python2.7/site-packages/django/contrib/sessions/backends/cached_db.py"
 in save
 62. super(SessionStore, self).save(must_create)
File 
"/Users/arkaitz/Documents/workspace/af73-dev/lib/python2.7/site-packages/django/contrib/sessions/backends/db.py"
 in save
 57. 
session_data=self.encode(self._get_session(no_load=must_create)),
File 
"/Users/arkaitz/Documents/workspace/af73-dev/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py"
 in encode
 87. serialized = self.serializer().dumps(session_dict)
File 
"/Users/arkaitz/Documents/workspace/af73-dev/lib/python2.7/site-packages/django/core/signing.py"
 in dumps
 88. return json.dumps(obj, separators=(',', ':')).encode('latin-1')
File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py"
 in dumps
 250. sort_keys=sort_keys, **kw).encode(obj)
File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py"
 in encode
 207. chunks = self.iterencode(o, _one_shot=True)
File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py"
 in iterencode
 270. return _iterencode(o, 0)
File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py"
 in default
 184. raise TypeError(repr(o) + " is not JSON serializable")

Exception Type: TypeError at /
Exception Value: datetime.datetime(2014, 7, 15, 21, 34, 11, 687676) is not JSON 
serializable


Thank you in advance for your help!

Arkaitz Mugica Islas
arkaitzmug...@gmail.com



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/38EEA362-84F1-4506-B8B2-F2D3FC3CDD63%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Strange error during migration

2014-07-15 Thread Tianyi Wang
Hi,

It says that datetime object is not JSON serializable. You should convert 
it to string before converting it to JSON.
For example: 
current_date = datetime.datetime.now()
# it will throw error if you do json.dumps(current_date)
# You should do as below
json_string = json.dumps(('{:%Y-%m-%d %H:%m}'.format(current_date))

P.S. Depends on your exact code, It may caused 
by 
https://docs.djangoproject.com/en/1.5/releases/1.5/#system-version-of-simplejson-no-longer-used
 


Regards,

tianyi

On Tuesday, 15 July 2014 20:54:45 UTC+1, Arkaitz Múgica Islas wrote:
>
> I’m migrating from Django 1.5.8 to 1.6.5. I’ve solved quite a lot of bug 
> related to my code, but this time I think it could be a bug. Can anybody 
> help me to fix it or should I post it to django-developers? 
>
>
>
> Request Method: GET 
> Request URL: http://127.0.0.1:8000/ 
>
> Django Version: 1.6.5 
> Python Version: 2.7.8 
>
>
> Traceback: 
> File 
> "/Users/arkaitz/Documents/workspace/af73-dev/lib/python2.7/site-packages/django/core/handlers/base.py"
>  
> in get_response 
>  199. response = middleware_method(request, response) 
> File 
> "/Users/arkaitz/Documents/workspace/af73-dev/lib/python2.7/site-packages/django/contrib/sessions/middleware.py"
>  
> in process_response 
>  38. request.session.save() 
> File 
> "/Users/arkaitz/Documents/workspace/af73-dev/lib/python2.7/site-packages/django/contrib/sessions/backends/cached_db.py"
>  
> in save 
>  62. super(SessionStore, self).save(must_create) 
> File 
> "/Users/arkaitz/Documents/workspace/af73-dev/lib/python2.7/site-packages/django/contrib/sessions/backends/db.py"
>  
> in save 
>  57. 
> session_data=self.encode(self._get_session(no_load=must_create)), 
> File 
> "/Users/arkaitz/Documents/workspace/af73-dev/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py"
>  
> in encode 
>  87. serialized = self.serializer().dumps(session_dict) 
> File 
> "/Users/arkaitz/Documents/workspace/af73-dev/lib/python2.7/site-packages/django/core/signing.py"
>  
> in dumps 
>  88. return json.dumps(obj, separators=(',', 
> ':')).encode('latin-1') 
> File 
> "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py"
>  
> in dumps 
>  250. sort_keys=sort_keys, **kw).encode(obj) 
> File 
> "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py"
>  
> in encode 
>  207. chunks = self.iterencode(o, _one_shot=True) 
> File 
> "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py"
>  
> in iterencode 
>  270. return _iterencode(o, 0) 
> File 
> "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py"
>  
> in default 
>  184. raise TypeError(repr(o) + " is not JSON serializable") 
>
> Exception Type: TypeError at / 
> Exception Value: datetime.datetime(2014, 7, 15, 21, 34, 11, 687676) is not 
> JSON serializable 
>
>
> Thank you in advance for your help! 
>
> Arkaitz Mugica Islas 
> arkait...@gmail.com  
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/abdfb630-f863-435b-a869-a46322d78e2c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Models PrimaryKey not incrimenting I dont understand this framework and the documentation is poorly written.

2014-07-15 Thread G Z
So I have a database that we are using to collect vm statistics. It is 
always running and writing to a django database.
I built my models file to resemble the db. However I have run into quite a 
few issues. I was wondering if anyone else has run into these issues
and found out how to solve them.

First when I try to add a new entry I get an error returned that the value 
can't be null for the primary key.

ORA-01400: cannot insert NULL into ("DEV"."VM_LICENSES"."VM_LICENSE_ID")

Isn't django supposed to automatically handle this when you set primary_key = 
True?



Also I want to have a list of available licenses from a table called licenses, 
and I want to be able to assign
them by foreign key to each vm by its foreign key in an intermediary table 
called vm_licenses.

Here are the model snippets for that process. However, I can't get manytomany 
to work right.
Bascially our system admins need to be able to manage the associated licenses 
for each vm. I'm trying to allow them to 
do this with the admin page. People keep pointing me to the documentation for 
manytomany but obviously I can't seem to figure out
how django uses already established databases. The django documentation doesn't 
really explain how things work. Thus,
anything outside the basic blog app is unknown territory you just kinda have to 
plug away in the dark. I'm tired of plugging away 
trying to figure out how this framework works.

I would greatly appreciate it if someone could help me understand how the 
django framework interacts with already established databases and how
to do what I want. 


class License(models.Model):
   license_id = models.BigIntegerField(primary_key = True, editable = 
False, db_column='license_id')
   license_authority_id = models.ForeignKey(License_authoritie,  on_delete 
= models.PROTECT, db_column='license_authority_id')
   product = models.CharField(max_length = 20)

   class Meta:
  managed = False
  db_table = 'licenses'
  ordering = ['product']

   def __unicode__(self):  # Python 3: def __str__(self):
  return self.product
 
class Vm_license(models.Model):
   vm_license_id = models.AutoField(primary_key = True, 
db_column='vm_license_id')
   license_id = models.ForeignKey(License,  on_delete = models.PROTECT, 
db_column='license_id')
   vm_id = models.ForeignKey(Vm,  on_delete = models.PROTECT, 
db_column='vm_id')

   class Meta:
  managed = False
  db_table = 'vm_licenses'




Here is my entire models file let me know if you see any problems with it 
because I don't know why i cant add entries.


from __future__ import unicode_literals
from django.db import models
from django.core.exceptions import ValidationError
from django.contrib.auth.models import User

class Cidr_allocation(models.Model):
   cidr_allocation_id = models.BigIntegerField(primary_key = True, editable 
= False, db_column = 'cidr_allocation_id')
   cidr = models.CharField(max_length = 40)
   allocation_name = models.CharField(max_length = 30)
   allocation_date = models.DateTimeField(auto_now = False,  auto_now_add = 
True)
   deallocation_date = models.DateTimeField(auto_now=False, 
auto_now_add=False)
   allocation_source = models.CharField(max_length = 30)
   public_address = models.CharField(max_length = 1)

   class Meta:
  managed = False
  db_table = 'cidr_allocations'
  
   def clean(self):
  if self.public_address != 'Y' and self.public_address != 'N':
 raise ValidationError('Please enter a Y or N')
  
   def __unicode__(self):  # Python 3: def __str__(self):
  return self.allocation_name

class Customer(models.Model):
   customer_id = models.BigIntegerField(primary_key = True, editable = 
False, db_column = 'customer_id')
   customer_name = models.CharField(max_length = 30)
   inactive = models.CharField(max_length = 1)

   class Meta:
  managed = False
  db_table = 'customers'
  ordering = ['customer_name']
  
   def __unicode__(self):  # Python 3: def __str__(self):
  return self.customer_name
   
   def clean(self):
  if self.inactive != 'Y' and self.inactive != 'N':
 raise ValidationError('Please enter a Y or N')

class Vcenter(models.Model):
   vcenter_id = models.BigIntegerField(primary_key = True, editable = 
False, db_column = 'vcenter_id')
   vcenter_ip_address = models.BinaryField()
   vcenter_uuid = models.CharField(max_length = 50)
   username = models.CharField(max_length = 20)
   password = models.CharField(max_length = 20)
   name = models.CharField(max_length = 30)

   class Meta:
  managed = False
  db_table = 'vcenters'

   def __unicode__(self):  # Python 3: def __str__(self):
  return self.name

class Datacenter(models.Model):
   datacenter_id = models.BigIntegerField(primary_key = True, editable = 
False, db_column = 'datacenter_id')
   vcenter_id = models.ForeignKey(Vcenter,  on_delete = models.PROTECT, 
db_column='vcenter_id')
   datacenter_mor = models.CharField(max_length = 20)
   datacenter_

Re: Django Models PrimaryKey not incrimenting I dont understand this framework and the documentation is poorly written.

2014-07-15 Thread G Z
I can update items just not add them always the same error cannot insert 
null for the primary key





-- 
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/44097c44-dc2a-4822-8f69-0bfcf65d6e21%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


using revers inside @user_passes_test

2014-07-15 Thread Domagoj Kovač
Hi Guys,

I have a problem. I have web application that supposed to have two logins, 
one for admin other for regular users. Inside my backend i am using 
@user_passes_test decorator to allow access only to admins. 

This is my code:

my_view

> from django.core.urlresolvers import reverse
> from django.template import RequestContext
> from django.contrib.auth.decorators import login_required, user_passes_test
> from django.shortcuts import render_to_response
> @login_required()
> @user_passes_test(lambda u: u.is_superuser, 
> login_url=reverse("admin-login"))
> def index(request):
> return render_to_response('backend/product_category/index.html', {}, 
> context_instance=RequestContext(request))


my urls.py 

>  urlpatterns = patterns('core.views',
> url(r'^' + base_url + '/account/login$', 'account.login', 
> name="admin-login"),
> url(r'^' + base_url + '/account/logout$', 'account.logout_user', 
> name="admin-logout"),
> url(r'^' + base_url + '/user/form/(?P.*)/', 'users.form', 
> name="admin-user-form"),
> url(r'^' + base_url + '/user/form/', 'users.form', 
> name="admin-user-form"),
> url(r'^' + base_url + '/user/details/(?P.*)', 'users.details', 
> name="admin-user-details"),
> url(r'^' + base_url + '/user/delete/(?P.*)/', 'users.delete', 
> name="admin-user-delete"),
> url(r'^' + base_url + '/user/list', 'users.list', 
> name="admin-user-list"),
> url(r'^' + base_url + '/user/', 'users.index', name="admin-user"),
> url(r'^' + base_url + '/access-denied/$', 'default.access_denied', 
> name="admin-access-denied"),
> url(r'^' + base_url + '/$', 'default.index', name="admin-index")
> )


I am gettings this error.

ViewDoesNotExist at /admin/
> Could not import product_subcategory.backend_views.index. View does not 
> exist in module product_subcategory.backend_views.


Really strange, when i remove revers from login_url everything is ok. What 
is wrong? Can i use reverse inside @user_passes_test decorator?

-- 
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/8b4cef99-c45d-45a6-b7b8-82947d048aba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Models PrimaryKey not incrimenting I dont understand this framework and the documentation is poorly written.

2014-07-15 Thread Tom Evans
On Tue, Jul 15, 2014 at 10:23 PM, G Z  wrote:
> So I have a database that we are using to collect vm statistics. It is
> always running and writing to a django database.
> I built my models file to resemble the db. However I have run into quite a
> few issues. I was wondering if anyone else has run into these issues
> and found out how to solve them.
>
> First when I try to add a new entry I get an error returned that the value
> can't be null for the primary key.
>
> ORA-01400: cannot insert NULL into ("DEV"."VM_LICENSES"."VM_LICENSE_ID")
>
> Isn't django supposed to automatically handle this when you set primary_key
> = True?
>
>
>
> Also I want to have a list of available licenses from a table called
> licenses, and I want to be able to assign
> them by foreign key to each vm by its foreign key in an intermediary table
> called vm_licenses.
>
> Here are the model snippets for that process. However, I can't get
> manytomany to work right.
> Bascially our system admins need to be able to manage the associated
> licenses for each vm. I'm trying to allow them to
> do this with the admin page. People keep pointing me to the documentation
> for manytomany but obviously I can't seem to figure out
> how django uses already established databases. The django documentation
> doesn't really explain how things work. Thus,
> anything outside the basic blog app is unknown territory you just kinda have
> to plug away in the dark. I'm tired of plugging away
> trying to figure out how this framework works.
>
> I would greatly appreciate it if someone could help me understand how the
> django framework interacts with already established databases and how
> to do what I want.
>
>
> class License(models.Model):
>license_id = models.BigIntegerField(primary_key = True, editable = False,
> db_column='license_id')

Auto increment is a feature of AutoField, not of primary keys.

https://docs.djangoproject.com/en/1.6/ref/models/fields/#autofield

BigIntegerField has no auto increment properties.

Marking a field as a primary key simply means that no AutoField named
id is automatically added to your class, and the SQL generated for
that field will mark it as a primary key.

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFHbX1KJXLhiXNAMuOz2zw7o7rd2hB4xp-dnriZVW_H31pM-2A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Models PrimaryKey not incrimenting I dont understand this framework and the documentation is poorly written.

2014-07-15 Thread G Z
Tom,

It fails with both autofield and bigintergerfield

class License(models.Model):
   license_id = models.AutoField(primary_key = True, editable = False, 
db_column='license_id')
   license_authority_id = models.ForeignKey(License_authoritie,  on_delete = 
models.PROTECT, db_column='license_authority_id')
   product = models.CharField(max_length = 20)

   class Meta:
  managed = False
  db_table = 'licenses'
  ordering = ['product']

   def __unicode__(self):  # Python 3: def __str__(self):
  return self.product
class Vm_license(models.Model):
   vm_license_id = models.AutoField(primary_key = True, 
db_column='vm_license_id')
   license_id = models.ForeignKey(License,  on_delete = models.PROTECT, 
db_column='license_id')
   vm_id = models.ForeignKey(Vm,  on_delete = models.PROTECT, db_column='vm_id')

   class Meta:
  managed = False
  db_table = 'vm_licenses'


I get the same thing:


Request Method: POSTRequest URL:
http://127.0.0.1:8000/admin/portal/vm_license/add/Django Version: 
1.6.5Exception Type: IntegrityErrorException Value:

ORA-01400: cannot insert NULL into ("DEV"."VM_LICENSES"."VM_LICENSE_ID")





On Tuesday, July 15, 2014 4:09:29 PM UTC-6, Tom Evans wrote:
>
> On Tue, Jul 15, 2014 at 10:23 PM, G Z > 
> wrote: 
> > So I have a database that we are using to collect vm statistics. It is 
> > always running and writing to a django database. 
> > I built my models file to resemble the db. However I have run into quite 
> a 
> > few issues. I was wondering if anyone else has run into these issues 
> > and found out how to solve them. 
> > 
> > First when I try to add a new entry I get an error returned that the 
> value 
> > can't be null for the primary key. 
> > 
> > ORA-01400: cannot insert NULL into ("DEV"."VM_LICENSES"."VM_LICENSE_ID") 
> > 
> > Isn't django supposed to automatically handle this when you set 
> primary_key 
> > = True? 
> > 
> > 
> > 
> > Also I want to have a list of available licenses from a table called 
> > licenses, and I want to be able to assign 
> > them by foreign key to each vm by its foreign key in an intermediary 
> table 
> > called vm_licenses. 
> > 
> > Here are the model snippets for that process. However, I can't get 
> > manytomany to work right. 
> > Bascially our system admins need to be able to manage the associated 
> > licenses for each vm. I'm trying to allow them to 
> > do this with the admin page. People keep pointing me to the 
> documentation 
> > for manytomany but obviously I can't seem to figure out 
> > how django uses already established databases. The django documentation 
> > doesn't really explain how things work. Thus, 
> > anything outside the basic blog app is unknown territory you just kinda 
> have 
> > to plug away in the dark. I'm tired of plugging away 
> > trying to figure out how this framework works. 
> > 
> > I would greatly appreciate it if someone could help me understand how 
> the 
> > django framework interacts with already established databases and how 
> > to do what I want. 
> > 
> > 
> > class License(models.Model): 
> >license_id = models.BigIntegerField(primary_key = True, editable = 
> False, 
> > db_column='license_id') 
>
> Auto increment is a feature of AutoField, not of primary keys. 
>
> https://docs.djangoproject.com/en/1.6/ref/models/fields/#autofield 
>
> BigIntegerField has no auto increment properties. 
>
> Marking a field as a primary key simply means that no AutoField named 
> id is automatically added to your class, and the SQL generated for 
> that field will mark it as a primary key. 
>
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/65032c69-1139-480c-b739-7c54fc9a1824%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Models PrimaryKey not incrimenting I dont understand this framework and the documentation is poorly written.

2014-07-15 Thread G Z
http://www.oracle.com/technetwork/articles/dsl/vasiliev-django-100257.html

the guide I followed from oracle.

On Tuesday, July 15, 2014 4:16:54 PM UTC-6, G Z wrote:
>
> Tom,
>
> It fails with both autofield and bigintergerfield
>
> class License(models.Model):
>license_id = models.AutoField(primary_key = True, editable = False, 
> db_column='license_id')
>license_authority_id = models.ForeignKey(License_authoritie,  on_delete = 
> models.PROTECT, db_column='license_authority_id')
>product = models.CharField(max_length = 20)
>
>class Meta:
>   managed = False
>   db_table = 'licenses'
>   ordering = ['product']
>
>def __unicode__(self):  # Python 3: def __str__(self):
>   return self.product
> class Vm_license(models.Model):
>vm_license_id = models.AutoField(primary_key = True, 
> db_column='vm_license_id')
>license_id = models.ForeignKey(License,  on_delete = models.PROTECT, 
> db_column='license_id')
>vm_id = models.ForeignKey(Vm,  on_delete = models.PROTECT, 
> db_column='vm_id')
>
>class Meta:
>   managed = False
>   db_table = 'vm_licenses'
>
>
> I get the same thing:
>
>
> Request Method: POSTRequest URL:
> http://127.0.0.1:8000/admin/portal/vm_license/add/Django Version: 
> 1.6.5Exception Type: IntegrityErrorException Value:
>
> ORA-01400: cannot insert NULL into ("DEV"."VM_LICENSES"."VM_LICENSE_ID")
>
>
>
>
>
> On Tuesday, July 15, 2014 4:09:29 PM UTC-6, Tom Evans wrote:
>
> On Tue, Jul 15, 2014 at 10:23 PM, G Z  wrote: 
> > So I have a database that we are using to collect vm statistics. It is 
> > always running and writing to a django database. 
> > I built my models file to resemble the db. However I have run into quite 
> a 
> > few issues. I was wondering if anyone else has run into these issues 
> > and found out how to solve them. 
> > 
> > First when I try to add a new entry I get an error returned that the 
> value 
> > can't be null for the primary key. 
> > 
> > ORA-01400: cannot insert NULL into ("DEV"."VM_LICENSES"."VM_LICENSE_ID") 
> > 
> > Isn't django supposed to automatically handle this when you set 
> primary_key 
> > = True? 
> > 
> > 
> > 
> > Also I want to have a list of available licenses from a table called 
> > licenses, and I want to be able to assign 
> > them by foreign key to each vm by its foreign key in an intermediary 
> table 
> > called vm_licenses. 
> > 
> > Here are the model snippets for that process. However, I can't get 
> > manytomany to work right. 
> > Bascially our system admins need to be able to manage the associated 
> > licenses for each vm. I'm trying to allow them to 
> > do this with the admin page. People keep pointing me to the 
> documentation 
> > for manytomany but obviously I can't seem to figure out 
> > how django uses already established databases. The django documentation 
> > doesn't really explain how things work. Thus, 
> > anything outside the basic blog app is unknown territory you just kinda 
> have 
> > to plug away in the dark. I'm tired of plugging away 
> > trying to figure out how this framework works. 
> > 
> > I would greatly appreciate it if someone could help me understand how 
> the 
> > django framework interacts with already established databases and how 
> > to do what I want. 
> > 
> > 
> > class License(models.Model): 
> >license_id = models.BigIntegerField(primary_key = True, editable = 
> False, 
> > db_column='license_id') 
>
> Auto increment is a feature of AutoField, not of primary keys. 
>
> https://docs.djangoproject.com/en/1.6/ref/models/fields/#autofield"; 
> target="_blank" onmousedown="this.href='
> https://www.google.com/url?q\75https%3A%2F%2Fdocs.djangoproject.com%2Fen%2F1.6%2Fref%2Fmodels%2Ffie
>  
> 
>
> ...

-- 
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/3a9af90e-98f7-435a-8bdb-2500bf5cf792%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Models PrimaryKey not incrimenting I dont understand this framework and the documentation is poorly written.

2014-07-15 Thread Tom Evans
On Tue, Jul 15, 2014 at 11:16 PM, G Z  wrote:
> Tom,
>
> It fails with both autofield and bigintergerfield
>
> class License(models.Model):
>license_id = models.AutoField(primary_key = True, editable = False,
> db_column='license_id')
>license_authority_id = models.ForeignKey(License_authoritie,  on_delete =
> models.PROTECT, db_column='license_authority_id')
>product = models.CharField(max_length = 20)
>
>class Meta:
>   managed = False

Two things:

Auto increment is a property set at the time you create the table, so
changing the code changes nothing unless you recreate the
table/migrations.

Secondly, you have told django you are managing that table yourself.
If you want that field auto increment, make it so.

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFHbX1Jt%2BpAxLx1q%2BgyDVce%2BbA%2BvcZqiStE6SRdjApB-jw6YPw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


combine date time field taking from user and give validation

2014-07-15 Thread hardik . sottany
combine date time field taking from user and give validation

try:
date = cleaned_data.get('date')
except:
date = ''
if not date:
msg = "Please fill up all mandatory fields"
self._errors['date'] = self.error_class([msg])
return self.cleaned_data

try:
time = cleaned_data.get('time')
print "time",time
except:
time = ''
if not time:
msg = "Please fill up all mandatory fields"
self._errors['time'] = self.error_class([msg])
return self.cleaned_data

b=datetime.combine(date,time)
print b
# try:
# date = self.cleaned_data['date']
# print "date",date
# except:
# date=''
# if date < datetime.date.today() and time < datetime.time.today():
# msg = "The date cannot be in the past!"
# self._errors['date'] = self.error_class([msg])
# return self.cleaned_data

-- 
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/a6d1bac3-99d4-491d-b177-7578a054279c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: date field validation

2014-07-15 Thread hardik . sottany
bro i want to check that

i want to give a appointment model

appointment is available for 6 days a week
from monday to saturday
and  from 11 am to 7pm

can you please give me this coding coz i have to submit my project today
















On Tuesday, July 15, 2014 4:59:18 PM UTC+5:30, hardik@fafadiatech.com 
wrote:
>
> i want validation in form.py in which the datetime should not be less than 
> datetime.now
>
> please i need it urgently
>
> please help 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/7681b5a5-e5de-41a5-a9a4-a20fb723acfe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.