Re: date picker

2016-01-18 Thread Michal Petrucha
On Mon, Jan 18, 2016 at 12:03:00PM +1100, sum abiut wrote:
> Hi,
> i am having some trouble with my date picker. I probably missing someting,
> the form fields are displaying fine, but some how the datepicker is no
> displaying. probably something to do with my jquery. Please help

Could you perhaps go more into detail? Do you want to have a date
picker widget on both DateFields, or only one of them? Does the date
picker appear on one of them, but not the other, or does it appear on
neither? What does the final rendered HTML look like? (Just the
relevant parts.)

> models.py
> class foreginexchange(models.Model):
> Sold_deal_number=models.CharField(max_length=45)
> Value_date=models.DateField()
> Vatu_equivalent=models.CharField(max_length=45)
> Instructions=models.TextField()
> Done_Date=models.DateField()
> Booked=(
> ('Tonny Garae','Tonny Garae'),
> ('Fredric Jacob','Fredric Jacob'),
> )
> Worked_By=models.CharField(max_length=45,choices=Worked)
> 
> def __unicode__(self):
> return self.Sold_deal_number
> 
> 
> form.py
> 
> from django import forms
> 
> from foregin_exchange.models import foreginexchange
> 
> class foregin_exchange_form(forms.ModelForm):
> class Meta:
> model =foreginexchange
> widgets = {'Value_date':
> forms.DateInput(attrs={'class':'datepicker'}),}
> widgets={'Done_Date':forms.DateInput(attrs={'class':'datepicker'}),}

This here looks wrong. The first assignment to “widgets” would set the
class for “Value_date”, and the following assignment throws the
previous setting away and replaces it with a setting for “Done_Date”.

If the problem is that the date picker works for “Done_Date”, but not
“Value_date”, then this is the problem.

You're probably looking for something like::

widgets = {
'Value_date': forms.DateInput(attrs={'class': 'datepicker'}),
'Done_Date': forms.DateInput(attrs={'class':' datepicker'}),
}

Regards,

Michal

-- 
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/20160118082931.GY20308%40konk.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


Re: turn on "string_if_invalid" as a ‘development default’

2016-01-18 Thread guettli
A second batch of tests?

I am unsure if I understood you: Do you mean new tests, or running the same
tests again, with a different settings file?

If the first: write new tests: How should these tests be different from the 
existing tests?

If the second: Why not run the test with the settings which have 
string_if_invalid enabled in the first run?
What do you gain by running the tests twice?

Regards,
  Thomas Güttler


Am Donnerstag, 14. Januar 2016 18:33:13 UTC+1 schrieb James Schneider:
>
> On Jan 14, 2016 7:50 AM, "guettli"  > wrote:
> >
> > I would like to do this:
> >
> >   turn on "string_if_invalid" as a ‘development default’
> >
> > The django docs say:
> >
> >  While string_if_invalid can be a useful debugging tool, it is a bad 
> idea to turn it on as a ‘development default’.
> >
> > 
> https://docs.djangoproject.com/en/1.9/ref/templates/api/#how-invalid-variables-are-handled
> >
> > We were hit by some nasty bugs in production environment which were not 
> detected in our continous integration plattform.
> >
> > If "string_if_invalid" (or former TEMPLATE_STRING_IF_INVALID) would have 
> been activated,
> > we would have noticed the bug, and the broken code would have gone live.
> >
> > How do you handle this?
> >
>
> Why not have a second batch of tests that use a settings.py file with a 
> non default value for "string_if_invalid" that runs if the default settings 
> file passes? I've never dealt with a CI platform, but I'm assuming you can 
> do something like that.
>
> - 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c8fe8229-cf00-4c7e-b6b5-0bc9daf5fc69%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: excel file upload to MySQL database

2016-01-18 Thread Derek
You could also try:

https://django-import-export.readthedocs.org/en/latest/


On Wednesday, 13 January 2016 16:30:04 UTC+2, girija sameera wrote:
>
> Hello,
>   I am  a Django beginner working on a web application wherein I am 
> required to provide back-end support. I am expected to take an excel file 
> uploaded by the admin from the template , parse the file using available 
> Django libraries and upload it to MySQL database . Also  bulk upload of 
> files needs to be supported.
>
> I would like some suggestions on how to proceed.I would really appreciate 
> links to tutorials and websites.
>
> Thank you,
>
> Girija
>
>
>
>  
>

-- 
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/690f4f59-ce8b-488d-af0f-2f0f25f99465%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Showing BooleanField checkbox on left

2016-01-18 Thread Sayse
Thanks for your reply..

Subclassing the widget won't help because the widget has no knowledge about 
its label. I'd gladly override the form render method if I could find out 
where that would need to be but the source link 
 I 
provided in my first snippet would make this seem as its not possible since 
the label is just a piece of string formatting. The manual formatting is 
what I currently have to use but I should think that it should be possible 
to do this even though it doesn't appear as though it is currently.

On Saturday, 16 January 2016 00:47:01 UTC, Tony Flury wrote:
>
>
>
> On Thursday, 14 January 2016 17:55:41 UTC, Sayse wrote:
>>
>> Yea I've heard of it. Have they managed to achieve this? I'd be 
>> interested to see how they've done it if so... 
>>
>> I was hoping to find a way to do this with native django if possible 
>>
>
> One way that might work is to subclass the CheckboxInputWidget, and in 
> the new widget overide the render method - but there looks like a lot of 
> deep Django Magic in that method : 
> https://docs.djangoproject.com/en/1.9/_modules/django/forms/widgets/#CheckboxInput
>
> Or - look at changing the Form render method - again involving lots of 
> Django Magic
>
> Or - Accept that you can't do that (as you are trying to including one 
> widget (Input) inside the HTML tags for another (Label), and compromise 
> with manual ordering and being more explicit in your form : For instance 
> using {{ field.label_tag }} Example here : 
> https://docs.djangoproject.com/en/1.9/topics/forms/#looping-over-the-form-s-fields
>

-- 
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/a1f1226f-dae2-484d-a202-20a85f43ea08%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: turn on "string_if_invalid" as a ‘development default’

2016-01-18 Thread James Schneider
>
> A second batch of tests?
>
> I am unsure if I understood you: Do you mean new tests, or running the same
> tests again, with a different settings file?
>

I meant the latter. Sorry for not being clear.


>
> If the first: write new tests: How should these tests be different from
> the existing tests?
>
> If the second: Why not run the test with the settings which have
> string_if_invalid enabled in the first run?
> What do you gain by running the tests twice?
>

The two sets of tests could potentially provide two sets of differing
results. The development setting you want to change is known to negatively
interact with templates used by the Django admin and probably third-party
applications that provide templates, per the link that you provided. With
that setting changed, you are testing an application that intentionally
behaves differently than what will be seen in production. That makes me
uncomfortable.

For me, that means running two sets of tests. One of them will closely
match the production settings (probably the settings file you're using
now), and the other can be tweaked to potentially catch edge-cases or other
uncommon bugs that you can/have run in to, or other failure points that may
not be easily exposed by the standard settings file. Perhaps the second
customized set of tests may not be something that you build into your CI,
but may be part of a manual examination performed at various milestones. It
would depend on your workflow and CI process, and how often you think these
particular bugs may present themselves. Maybe only as a pre-release final
check?

Or, if you don't use the admin or any 3rd party applications, you may be
safe in enabling it. I personally wouldn't unless I was also doing so in
production.

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


Django Admin

2016-01-18 Thread Rafael E. Ferrero
Hello everybody,

I'm gonna try to express my use case and hope you can help me to achieve
this objective because i can't figure it out how i can resolve it.

1) I have a model of Products, with a lot of data for description, and
other stuff.
(Let me say, ID, Short Description, Long Description,Minimun Amount Of
Products Per Sale, Cost Price, Sale Price,
2) Then I have an other table (you can call it Sales), in this i need to
save data of Products (Descriptions, Measure of units, and other specific
data of my project)
(Let me say, ID, Short Description, Long Description, Sale Price, Date of
Sale, Number of Document, etc.) where Short and Long Description, and Sale
Price it's from Products model.

The Sales model DO NOT have to be related to Products with a Foreign key
because we use Sales as Historic model too. So i need to take the data from
Products and save it in Sales. So, I think that I can rewrite the method
"save" in Sales model.

But... In the Admin Site, in the Sales form, I need a dropdown box of
Products and when i choose one of them I need to populate the needed data
in the fields of the Sales form, where the user can (If he wish), for
example, add more text to Long Description field.

How I can put data of Products in the fields of Sales form without any
relationship to Products, and how i can populate the fields based on the
selected product??

Thanks in advance !!

Rafael E. Ferrero

-- 
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/CAJJc_8VScv11s-cwRE%2BCFXn2oH-29KL12iUk-%2BJHzD6A3TgVhw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Admin

2016-01-18 Thread Andreas Kuhne
Hi Rafael,

I would use a plugin for django admin that creates an autocomplete field
(django-selectable works). Then when the user chooses something in the
autocomplete list, I would populate the other fields via ajax with the
values that you need. That way you don'ẗ need a foreign key field (even
though you could have it until the product is deleted) and you would get
the functionality that you need.

Regards,

Andréas

2016-01-18 12:54 GMT+01:00 Rafael E. Ferrero :

> Hello everybody,
>
> I'm gonna try to express my use case and hope you can help me to achieve
> this objective because i can't figure it out how i can resolve it.
>
> 1) I have a model of Products, with a lot of data for description, and
> other stuff.
> (Let me say, ID, Short Description, Long Description,Minimun Amount Of
> Products Per Sale, Cost Price, Sale Price,
> 2) Then I have an other table (you can call it Sales), in this i need to
> save data of Products (Descriptions, Measure of units, and other specific
> data of my project)
> (Let me say, ID, Short Description, Long Description, Sale Price, Date of
> Sale, Number of Document, etc.) where Short and Long Description, and Sale
> Price it's from Products model.
>
> The Sales model DO NOT have to be related to Products with a Foreign key
> because we use Sales as Historic model too. So i need to take the data from
> Products and save it in Sales. So, I think that I can rewrite the method
> "save" in Sales model.
>
> But... In the Admin Site, in the Sales form, I need a dropdown box of
> Products and when i choose one of them I need to populate the needed data
> in the fields of the Sales form, where the user can (If he wish), for
> example, add more text to Long Description field.
>
> How I can put data of Products in the fields of Sales form without any
> relationship to Products, and how i can populate the fields based on the
> selected product??
>
> Thanks in advance !!
>
> Rafael E. Ferrero
>
> --
> 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/CAJJc_8VScv11s-cwRE%2BCFXn2oH-29KL12iUk-%2BJHzD6A3TgVhw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Django Admin

2016-01-18 Thread Rafael E. Ferrero
Thanks Andrea I'm gonna investigate this !!!


Rafael E. Ferrero

2016-01-18 9:02 GMT-03:00 Andreas Kuhne :

> Hi Rafael,
>
> I would use a plugin for django admin that creates an autocomplete field
> (django-selectable works). Then when the user chooses something in the
> autocomplete list, I would populate the other fields via ajax with the
> values that you need. That way you don'ẗ need a foreign key field (even
> though you could have it until the product is deleted) and you would get
> the functionality that you need.
>
> Regards,
>
> Andréas
>
> 2016-01-18 12:54 GMT+01:00 Rafael E. Ferrero :
>
>> Hello everybody,
>>
>> I'm gonna try to express my use case and hope you can help me to achieve
>> this objective because i can't figure it out how i can resolve it.
>>
>> 1) I have a model of Products, with a lot of data for description, and
>> other stuff.
>> (Let me say, ID, Short Description, Long Description,Minimun Amount Of
>> Products Per Sale, Cost Price, Sale Price,
>> 2) Then I have an other table (you can call it Sales), in this i need to
>> save data of Products (Descriptions, Measure of units, and other specific
>> data of my project)
>> (Let me say, ID, Short Description, Long Description, Sale Price, Date of
>> Sale, Number of Document, etc.) where Short and Long Description, and Sale
>> Price it's from Products model.
>>
>> The Sales model DO NOT have to be related to Products with a Foreign key
>> because we use Sales as Historic model too. So i need to take the data from
>> Products and save it in Sales. So, I think that I can rewrite the method
>> "save" in Sales model.
>>
>> But... In the Admin Site, in the Sales form, I need a dropdown box of
>> Products and when i choose one of them I need to populate the needed data
>> in the fields of the Sales form, where the user can (If he wish), for
>> example, add more text to Long Description field.
>>
>> How I can put data of Products in the fields of Sales form without any
>> relationship to Products, and how i can populate the fields based on the
>> selected product??
>>
>> Thanks in advance !!
>>
>> Rafael E. Ferrero
>>
>> --
>> 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/CAJJc_8VScv11s-cwRE%2BCFXn2oH-29KL12iUk-%2BJHzD6A3TgVhw%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALXYUb%3D3iBKz_m%3DKjcAru78rTDDG%2BFKuEqhoq6W0AURViNTJPQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


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})



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})



Re: How to view the generated SQL for test models?

2016-01-18 Thread Brutus Schraiber
Am Samstag, 16. Januar 2016 22:23:06 UTC+1 schrieb Vijay Khemlani:
>
> At least to me it doesn't make a lot of sense to define new models in your 
> tests, but I also don't know the particular problem you are solving.
>

I have an app, that defines a couple of *abstract models* and *mixins* in 
it's `models.py`, that are only used in other apps.

To test those abstract models and mixins I created concrete models (from 
`django.db.models.Model`), that use these abstract models and mixins, in 
`test.py`.

I created them in `test.py`, so that the test models don't get created in 
the DB outside of test running. I thought this the way to handle such 
things in Django?

At least for me this generally works fine. In a special case I get an 
`django.db.utils.ProgrammingError` from one of my test models though. To 
debug this, I wanted to take a look at the SQL Django generated for it.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To 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/384d01d0-711e-4310-bc1a-a887343e1990%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to view the generated SQL for test models?

2016-01-18 Thread Brutus Schraiber
Am Samstag, 16. Januar 2016 22:23:06 UTC+1 schrieb Vijay Khemlani:
>
> At least to me it doesn't make a lot of sense to define new models in your 
> tests, but I also don't know the particular problem you are solving.
>

I have an app, that defines a couple of *abstract models* and *mixins* in 
it's `models.py`, that are only used in other apps.

To test those abstract models and mixins I created concrete models (from 
`django.db.models.Model`), that use these abstract models and mixins, in 
`test.py`.

I created them in `test.py`, so that the test models don't get created in 
the DB outside of test running. I thought this the way to handle such 
things in Django?

At least for me this generally works fine. In a special case I get an 
`django.db.utils.ProgrammingError` from one of my test models though. To 
debug this, I wanted to take a look at the SQL Django generated for it.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To 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/16d20af4-064a-46b7-98ae-b5a9e8105e15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: date picker

2016-01-18 Thread 'Tom Evans' via Django users
On Mon, Jan 18, 2016 at 1:03 AM, sum abiut  wrote:
> Hi,
> i am having some trouble with my date picker. I probably missing someting,
> the form fields are displaying fine, but some how the datepicker is no
> displaying. probably something to do with my jquery. Please help
> [ ... ]
> class foregin_exchange_form(forms.ModelForm):
> class Meta:
> model =foreginexchange
> widgets = {'Value_date':
> forms.DateInput(attrs={'class':'datepicker'}),}
> widgets={'Done_Date':forms.DateInput(attrs={'class':'datepicker'}),}

This sets the *class* of the element to "datepicker".

> [ ... ]
>   
>   $(function() {
> $( "#datepicker" ).datepicker();
>   });
>   

This turns an element with the *id* "datepicker" in to a date picker.

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


Re: How to view the generated SQL for test models?

2016-01-18 Thread Michal Petrucha
On Mon, Jan 18, 2016 at 04:25:59AM -0800, Brutus Schraiber wrote:
> Am Samstag, 16. Januar 2016 22:23:06 UTC+1 schrieb Vijay Khemlani:
> >
> > At least to me it doesn't make a lot of sense to define new models in your 
> > tests, but I also don't know the particular problem you are solving.
> >
> 
> I have an app, that defines a couple of *abstract models* and *mixins* in 
> it's `models.py`, that are only used in other apps.
> 
> To test those abstract models and mixins I created concrete models (from 
> `django.db.models.Model`), that use these abstract models and mixins, in 
> `test.py`.
> 
> I created them in `test.py`, so that the test models don't get created in 
> the DB outside of test running. I thought this the way to handle such 
> things in Django?
> 
> At least for me this generally works fine. In a special case I get an 
> `django.db.utils.ProgrammingError` from one of my test models though. To 
> debug this, I wanted to take a look at the SQL Django generated for it.

Hi Brutus,

Could you perhaps post the full traceback of the ProgrammingError? It
smells a bit like your test models don't get imported early enough to
be fully initialized before database creation happens. And this might
be caused precisely by the fact that your models are not inside
models.py.

As for your original question, unless you put all your models into
models.py of an app inside INSTALLED_APPS, or at least import them
from within such a models.py module, they won't be considered at all
when generating migrations, or when dumping out the creation SQL.

When you run a management command, ``django.setup()`` is called, which
populates the model registry by importing the models module of each
installed app, not much else. Particularly not app.tests. So there's
no way for the ``sql`` management command to be aware of your test
models.

The tests module is only imported when running tests by the test
runner (unless you import it from somewhere else in your app, but
that's not a very usual thing to do). That happens after
``django.setup()`` has finished, at which point models should already
be properly initialized, which, obviously, is not the case with models
in tests.py.

In theory, it should work – the test runner tries to import all test
modlues before setting up the test database, so in case everything is
correct, all deferred model setup actions should still finish before
creating the database. However, if there is some kind of error, they
might not, and that means it will be harder to debug those situations.

Really, do yourself a favor, create a separate app for your tests,
with its own models, and its own settings. That is the most painless
way to have additional testing models.

You can take inspiration from the following section of the docs:
https://docs.djangoproject.com/en/1.9/topics/testing/advanced/#using-the-django-test-runner-to-test-reusable-applications

Regards,

Michal

-- 
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/20160118192319.GZ20308%40konk.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


django categories views(error page not found)

2016-01-18 Thread Xristos Xristoou


my task is to create on main page of my web site two list one list for my 
post and second list categories titles which belong my post. i create that 
and work fine,and i create post details connect and again work fine. but i 
cant to work category details if i want to see list from my post which 
belong specific category i cant show me error page not found.


my code


my model

class Category(models.Model):
 categorytitle =models.CharField(max_length=1,choices=CAT_CHOICES,unique=True)
 slug= models.SlugField()

class Posts(models.Model):
Title = models.CharField(max_length=100,blank=True)
slug= models.SlugField()
category = models.ManyToManyField(Category)


my view category


def view_category(request, slug):
category = get_object_or_404(Category, slug=slug)return 
render_to_response('blog/view_category.html', {
'category': category,
'posts': Posts.objects.filter(category=category)})


my urls category


url(r'^(?P[^\.]+)/$', views.view_category, name='view_category'),

-- 
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/b206b8e0-3fd5-47ab-80e2-99a06806ad97%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: date picker

2016-01-18 Thread sum abiut
Yes i want to have the date picker widget on both DateFields. The date
picker does not appear on both datefields. i have made changes, but still
date picker is not showing
widgets = {
'Value_date': forms.DateInput(attrs={'class': 'datepicker'}),
'Done_Date': forms.DateInput(attrs={'class':' datepicker'}),
}



[image: Inline image 1]


Cheers,


On Tue, Jan 19, 2016 at 1:46 AM, 'Tom Evans' via Django users <
django-users@googlegroups.com> wrote:

> On Mon, Jan 18, 2016 at 1:03 AM, sum abiut  wrote:
> > Hi,
> > i am having some trouble with my date picker. I probably missing
> someting,
> > the form fields are displaying fine, but some how the datepicker is no
> > displaying. probably something to do with my jquery. Please help
> > [ ... ]
> > class foregin_exchange_form(forms.ModelForm):
> > class Meta:
> > model =foreginexchange
> > widgets = {'Value_date':
> > forms.DateInput(attrs={'class':'datepicker'}),}
> >
>  widgets={'Done_Date':forms.DateInput(attrs={'class':'datepicker'}),}
>
> This sets the *class* of the element to "datepicker".
>
> > [ ... ]
> >   
> >   $(function() {
> > $( "#datepicker" ).datepicker();
> >   });
> >   
>
> This turns an element with the *id* "datepicker" in to a date picker.
>
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAFHbX1LP8XWTOcwgp3ZMdGOz7XP%2B9srKFEoJ_bWRS9YFbU5Tiw%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>



-

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


Re: date picker

2016-01-18 Thread Michal Petrucha
On Tue, Jan 19, 2016 at 08:28:00AM +1100, sum abiut wrote:
> Yes i want to have the date picker widget on both DateFields. The date
> picker does not appear on both datefields. i have made changes, but still
> date picker is not showing
> widgets = {
> 'Value_date': forms.DateInput(attrs={'class': 'datepicker'}),
> 'Done_Date': forms.DateInput(attrs={'class':' datepicker'}),
> }

Great, another thing you need to do is to follow Tom's advice:

> On Tue, Jan 19, 2016 at 1:46 AM, 'Tom Evans' via Django users <
> django-users@googlegroups.com> wrote:
> >  widgets={'Done_Date':forms.DateInput(attrs={'class':'datepicker'}),}
> >
> > This sets the *class* of the element to "datepicker".
> >
> > > [ ... ]
> > >   
> > >   $(function() {
> > > $( "#datepicker" ).datepicker();
> > >   });
> > >   
> >
> > This turns an element with the *id* "datepicker" in to a date picker.

Trips me every time (maybe when I'm old and wrinkled I'll be able to
remember off the top of my head that # is for the id and . is for the
class).

So yeah, use ``$(".datepicker").datepicker();`` here.

Good luck,

Michal

-- 
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/20160118213756.GB20308%40konk.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


Re: date picker

2016-01-18 Thread sum abiut
Thank heaps for your help. I have made the changes, still datepicker is not
showing on the datefields.

Cheers



On Tue, Jan 19, 2016 at 8:37 AM, Michal Petrucha <
michal.petru...@konk.org> wrote:

> On Tue, Jan 19, 2016 at 08:28:00AM +1100, sum abiut wrote:
> > Yes i want to have the date picker widget on both DateFields. The date
> > picker does not appear on both datefields. i have made changes, but still
> > date picker is not showing
> > widgets = {
> > 'Value_date': forms.DateInput(attrs={'class': 'datepicker'}),
> > 'Done_Date': forms.DateInput(attrs={'class':' datepicker'}),
> > }
>
> Great, another thing you need to do is to follow Tom's advice:
>
> > On Tue, Jan 19, 2016 at 1:46 AM, 'Tom Evans' via Django users <
> > django-users@googlegroups.com> wrote:
> > >  widgets={'Done_Date':forms.DateInput(attrs={'class':'datepicker'}),}
> > >
> > > This sets the *class* of the element to "datepicker".
> > >
> > > > [ ... ]
> > > >   
> > > >   $(function() {
> > > > $( "#datepicker" ).datepicker();
> > > >   });
> > > >   
> > >
> > > This turns an element with the *id* "datepicker" in to a date picker.
>
> Trips me every time (maybe when I'm old and wrinkled I'll be able to
> remember off the top of my head that # is for the id and . is for the
> class).
>
> So yeah, use ``$(".datepicker").datepicker();`` here.
>
> Good luck,
>
> Michal
>
> --
> 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/20160118213756.GB20308%40konk.org
> .
> 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/CAPCf-y5Ei%3D%2BGYhsggSDjZ9r1bObB3Yi68o7dP9brMZBSqfap4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: date picker

2016-01-18 Thread Michal Petrucha
On Tue, Jan 19, 2016 at 08:57:38AM +1100, sum abiut wrote:
> Thank heaps for your help. I have made the changes, still datepicker is not
> showing on the datefields.
> 
> Cheers

That's unfortunate – could you perhaps post the HTML output? Does it
contain the required JavaScript?

That template you posted in your original post, was that copy-pasted
from the actual template that is used?

Michal

-- 
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/20160118222011.GC20308%40konk.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


Re: date picker

2016-01-18 Thread sum abiut
Hi Michal,


here is my template.html, i believe it has all the required java script,
Yes the origin template was copy past from this template.






  











RBV Registry dasboard




  https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css";
integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7"
crossorigin="anonymous">


-








  /*
 * Base structure
 */

/* Move down content because we have a fixed navbar that is 50px tall */
body {
  padding-top: 50px;
}


/*
 * Global add-ons
 */

.sub-header {
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

/*
 * Top navigation
 * Hide default border to remove 1px line.
 */
.navbar-fixed-top {
  border: 0;
}

/*
 * Sidebar
 */

/* Hide for mobile, show later */
.sidebar {
  display: none;
}
@media (min-width: 768px) {
  .sidebar {
position: fixed;
top: 51px;
bottom: 0;
left: 0;
z-index: 1000;
display: block;
padding: 20px;
overflow-x: hidden;
overflow-y: auto; /* Scrollable contents if viewport is shorter than
content. */
background-color: #f5f5f5;
border-right: 1px solid #eee;
  }
}

/* Sidebar navigation */
.nav-sidebar {
  margin-right: -21px; /* 20px padding + 1px border */
  margin-bottom: 20px;
  margin-left: -20px;
}
.nav-sidebar > li > a {
  padding-right: 20px;
  padding-left: 20px;
}
.nav-sidebar > .active > a,
.nav-sidebar > .active > a:hover,
.nav-sidebar > .active > a:focus {
  color: #fff;
  background-color: #428bca;
}


/*
 * Main content
 */

.main {
  padding: 20px;
}
@media (min-width: 768px) {
  .main {
padding-right: 40px;
padding-left: 40px;
  }
}
.main .page-header {
  margin-top: 0;
}


/*
 * Placeholder dashboard ideas
 */

.placeholders {
  margin-bottom: 30px;
  text-align: center;
}
.placeholders h4 {
  margin-bottom: 0;
}
.placeholder {
  margin-bottom: 20px;
}
.placeholder img {
  display: inline-block;
  border-radius: 50%;
}
















  
  
  

  
  $(function() {
$(".datepicker").datepicker();
  });
  


  




  

  

  {%extends "loginpage.html"%}


 {%block content%}
  Add New Foregin Exchange Data

  

{%csrf_token%}


{{form.as_table}}






  

  {%endblock%}

  




https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js";>
window.jQuery || document.write('