Help Requried : FieldError at /admin/movie/movie/add/

2014-12-14 Thread Muhammad Ahmed
Hi Everyone, 

I am having Field Error while trying to have date field in my admin.py. 
There is some problem with Date Filed and I am unable to figure out what 
wrong I am doing. here is my code:

*MODEL.PY*


from django.db import models


import datetime
from django.utils import timezone


class Movie(models.Model):
movie_title = models.CharField(max_length=200)
movie_director = models.CharField(max_length=200)
movie_writer = models.CharField(max_length=200)
movie_musician = models.CharField(max_length=200)
movie_intro = models.TextField()
posted = models.DateField(db_index=True, auto_now_add=True)


def __str__(self):
return self.cd_movie


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


is_latest.admin_order_field = 'posted'
is_latest.boolean = True
is_latest.short_description = 'Latest?'











*ADMIN.PY *



from django.contrib import admin
from movie.models import Movie





##movie_title = models.CharField(max_length=200)
##movie_director = models.CharField(max_length=200)
##movie_writer = models.CharField(max_lenth=200)
##movie_musician = models.CharField(max_length=200)
##movie_intro = models.TextField()
##posted = models.DateField(db_index=True, auto_now_add=True)
#


class MovieAdmin(admin.ModelAdmin):
fieldsets = [
('Movie Info',   {'fields': ['movie_title',
'movie_director','movie_musician','movie_writer']}),
('Movie Intro',   {'fields': ['movie_intro']}),
('Date information', {'fields': ['posted']}),
]




list_display = ('movie_title', 'posted', 'is_latest')
list_filter = ['posted']
search_fields = ['movie_title']


admin.site.register(Movie, MovieAdmin)






I am having the following error:

FieldError at /admin/movie/movie/add/

Unknown field(s) (posted) specified for Movie. Check fields/fieldsets/exclude 
attributes of class MovieAdmin.

Request Method:GETRequest 
URL:http://localhost:8000/admin/movie/movie/add/Django 
Version:1.7Exception Type:FieldErrorException Value:

Unknown field(s) (posted) specified for Movie. Check fields/fieldsets/exclude 
attributes of class MovieAdmin.

Exception 
Location:C:\Python34\lib\site-packages\django\contrib\admin\options.py 
in get_form, line 654Python Executable:C:\Python34\python.EXEPython Version:
3.4.1Python Path:

['D:\\dp\\cricket',
 'C:\\Windows\\system32\\python34.zip',
 'C:\\Python34\\DLLs',
 'C:\\Python34\\lib',
 'C:\\Python34',
 'C:\\Python34\\lib\\site-packages']

Server time:

-


Thanks in AdvanceMon, 15 Dec 2014 11:57:49 +0500

-- 
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/fdaee0d3-edb0-43e7-8d92-e3218e7b9da0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django don't load css

2014-12-14 Thread Mario Gudelj
You may have an error in your css file if the link isn't 404ring when you
look at your console or the chrome tab...
On 15/12/2014 1:36 pm, "Jovana Andjelkovic" 
wrote:

> I am trying to run a site on Django development server but my css don't
> load. When I open dev tools in Chrome I see in network that css is loaded
> as text/plain and not as text/css.My link is good,because when I open it,it
> opens my css file.And my admin site don't have css also,and that can't be
> my mistake because I didn't do anything with it! As soon as I change
> something in css in dev tools css starts working but as soon as I reload
> the page it is gone!
>
> --
> 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/e5a23d51-5866-42d0-9e9e-2e69a8c3c340%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/CAHqTbj%3DiU097O52Zu0vDTBSK4me97H_9LOOStM7g7Wempsb6uw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Models not appearing in db. Am I missing something?

2014-12-14 Thread Shazwi Suwandi
I've added 'core' to settings.py file under INSTALLED_APPS too.

On Monday, 15 December 2014 15:10:12 UTC+8, Shazwi Suwandi wrote:
>
> from django.db import models
> from django.contrib.auth.models import User
>
> # CORE APPLICATION
> # Create your models here.
> class Member(models.Model):
> user = models.OneToOneField(User)
> description = models.CharField(max_length=250)
> date_of_birth = models.DateField()
> location = models.CharField(max_length=100)
> gender = models.CharField(max_length=15)
>
> class NewTable(models.Model):
> test = models.CharField(max_length=25)
>
> I've created some models and I used makemigrations and migrate. I went to 
> my db and checked that only the default tables are there (auth_group ... 
> django_session). I know that my connection settings are right and that I 
> see new rows being added to the auth_user table when I create users in 
> django admin page. 
>
> Is there something that I must have missed out?
>

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


Models not appearing in db. Am I missing something?

2014-12-14 Thread Shazwi Suwandi
from django.db import models
from django.contrib.auth.models import User

# CORE APPLICATION
# Create your models here.
class Member(models.Model):
user = models.OneToOneField(User)
description = models.CharField(max_length=250)
date_of_birth = models.DateField()
location = models.CharField(max_length=100)
gender = models.CharField(max_length=15)

class NewTable(models.Model):
test = models.CharField(max_length=25)

I've created some models and I used makemigrations and migrate. I went to 
my db and checked that only the default tables are there (auth_group ... 
django_session). I know that my connection settings are right and that I 
see new rows being added to the auth_user table when I create users in 
django admin page. 

Is there something that I must have missed out?

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


Re: how to learn django and I don't kill in the attempt,

2014-12-14 Thread Shazwi Suwandi
+1 to what Jorge mentioned. You can find books online but most of them (the 
ones I found) cover up till Django 1.6 and if you wanna use Django 1.7, 
some things won't apply. For example, things like South is already 
integrated into Django 1.7.

All the best :)

On Monday, 15 December 2014 05:49:50 UTC+8, Jorge Luis Callalle Torres 
wrote:
>
> how to learn django and I don't kill in the attempt,
> suggestions, recommendation.
> Do you know any resource, books videos for learn django from 0 ?
>
> 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/2eb6562b-bcc9-4b50-a677-79698c72539b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django don't load css

2014-12-14 Thread Jovana Andjelkovic
I am trying to run a site on Django development server but my css don't 
load. When I open dev tools in Chrome I see in network that css is loaded 
as text/plain and not as text/css.My link is good,because when I open it,it 
opens my css file.And my admin site don't have css also,and that can't be 
my mistake because I didn't do anything with it! As soon as I change 
something in css in dev tools css starts working but as soon as I reload 
the page it is gone!

-- 
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/e5a23d51-5866-42d0-9e9e-2e69a8c3c340%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can anyone give me a suggestion or a recommendation as to how I can access the current user's username in the models.py?

2014-12-14 Thread Russell Keith-Magee
On Mon, Dec 15, 2014 at 9:14 AM, Fred Stluka  wrote:

>  Collin and Russell (and anyone else),
>
> Do you have any opinion on this?
> - https://bitbucket.org/aptivate/django-current-user
>
> It was offered in an earlier post:
> - https://groups.google.com/d/msg/django-users/y7aIbN2_CsA/GtmrSjG1nq8J
>
> as a solution to exactly this problem.
>
> Makes the current user available to the save() method of all
> models.
>
> I read the code and it looks good, but I don't know the details
> of Apache/WSGI/Django/Python multi-threading well enough
> to know if it is thread safe.
>

I haven't deeply audited the code, but based on the approach, I can't think
of any reason it wouldn't be.

A signal is just a mechanism for registering pieces of code to run at known
points in object lifecycle (in this case, just before the internal
mechanics of save() are executed). There's nothing here that should trigger
any multithreaded or cross-process concerns AFAICT. These signals aren't
fired in a separate thread - it's completely linear code execution, via a
code path that has been injected via signal registration.


> Thoughts?
>

IMHO: It's much better than a thread local, but my own engineering taste
says I'd still prefer an explicit call.

I think the current-user package is a fine example of the possibilities
afforded by signals. The problem is that I don't like signals. I've been
burned by signal based frameworks in the past - if you lean on signals as
an engineering approach, it's *really* easy to get into an exponential
signal explosion (i.e., one signal causes 2 signals to be emitted, which
causes the first signal to be emitted again, and so on). Signals are
sometimes unavoidable, but as a matter of taste, I avoid them if at all
possible.

I vastly prefer an explicit argument, for two reasons.

1) It's very clear that it's being used, and where the value for the
argument is coming from. If you use the signal approach, and I'm reading
your code, and I don't know that you're using the CurrentUser signal
approach, then it will be completely opaque to me why and how the current
user is being specified - and there's no immediately obvious source of
places to start digging. I have to audit the entire codebase to find the
signal that is doing the job. This *could* be addressed with good project
on-boarding documentation... but when was the last time you got given a
complete and correct on-boarding document when joining an existing project
:-)

2) The signal approach won't (necessarily) work in all situations - an
explicit argument will. For example, if you want something on a form to be
pre-populated by the current user, there isn't a signal waiting to be used.
Best case, you'll have to define your own "pre-form-render" signal - which
is certainly possible, but it isn't something that is waiting to be used
out of the box, and you'll need to modify the Middleware to honour that
signal as well. This means your middleware will need to have a signal for
every possible way that a current user might be used, and signals aren't
free - a signal with no listeners still has a processing overhead.
Essentially, this means that Current-User *can't* be both high-performance,
*and* applicable to every situation. You either need to customise it for
every project where you use it, or wear a non-trivial overhead for
supporting signals you may never use.

Yours,
Russ Magee %-)

-- 
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/CAJxq84-hiAc-8rXw%3DihDg%2BM-f6ABbuLP8NzjJbA4v5TgoTLBgg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can anyone give me a suggestion or a recommendation as to how I can access the current user's username in the models.py?

2014-12-14 Thread Fred Stluka

Collin and Russell (and anyone else),

Do you have any opinion on this?
- https://bitbucket.org/aptivate/django-current-user

It was offered in an earlier post:
- https://groups.google.com/d/msg/django-users/y7aIbN2_CsA/GtmrSjG1nq8J

as a solution to exactly this problem.

Makes the current user available to the save() method of all
models.

I read the code and it looks good, but I don't know the details
of Apache/WSGI/Django/Python multi-threading well enough
to know if it is thread safe.

It basically uses django.db.models. signals.pre_save.connect()
to get a callback called just before each save(), and that callback
was generated by a middleware layer to know what the current
user was for a request, so it sets a model field with a name like
update_user to the current user just before the save().

If there were 2 concurrent HTTP requests, would this work
reliably?  Or would there just be 2 registered callbacks, that
would overwrite each other's values in the update_user field
before the save()?  If so, one user would be recorded for saves
done by both requests.

It seems to me that this would work fine if each HTTP request
was handled by a separate process, but not if handled by
separate threads that share the same memory, and presumably
the same signals and callbacks.

Thoughts?
--Fred

Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.

On 12/14/14 2:13 PM, Collin Anderson wrote:

Hi,

The "admin save handlers" refers to save_model() and there's actually 
a nice example of accessing the user.

https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_model

If you're using the admin, that's a good place to record this sort of 
thing.


Using a middleware is also helpful for a more general approach, though 
be careful because connections can now be re-used over multiple 
requests. Also, if you're deploying using threading, be sure what you 
are doing is thread-safe.


Collin

On Friday, December 12, 2014 5:29:35 AM UTC-5, malt...@gmail.com wrote:

Thanks Mike and Russell, this is very helpful for starters. Do you
have some more verbose code examples I can use as crutches while I
hobble along the path of understanding Django? Especially an
expansion on something like "All the admin save handlers" would be
much appreciated.

For me every change needs to be tracked, not just ones from the
admin realm, and the audit trail entry is written by a trigger
function which gets the current user name from a variable set for
the postgres connection. My quest so far was to find the magical
place where I have access to the request (for the username) and
the db.connection (for setting the database variable), which – if
I understand correctly – does not exist. So right now I was about
writing my own middleware class with a process_view. Would that be
the right place and how would I introduce the username into the
data flow?


Sincerely,

Malte

--
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/561482b8-a4bf-44fd-9c7d-ef2bbec54726%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/548E3609.8020509%40bristle.com.
For more options, visit https://groups.google.com/d/optout.


Odd subform caching problem

2014-12-14 Thread Gerald Klein
HI, I have a simple contact form with an address subform in the form of
"TabularInline" where you can add an arbitrary amount of addresses, after I
add a contact and an address and save, when I go to add a brand new contact
and address, the address that I just added will be there and if I add the
new contact it will over write not only the address but contact I added
previously, so it is keeping the entire record and updating it. It won't
fix itself until I stop the django server and start it again. Then I can do
the whole thing again with a new record.

I appreciate any that someone can give, thanks

-- 

Gerald Klein DBA


j...@zognet.com

708-599-0352



Arch, Gentoo I3, Ranger & Vim the coding triple threat.

Linux registered user #548580

Brought to you by the Amish Mafia

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


Re: django template auto format tool?

2014-12-14 Thread Mario Gudelj
PyCharm ide does a great job for all those file types.
On 14/12/2014 2:00 pm, "Abraham Varricatt" 
wrote:

> Hello,
>
> Is there any command-line based tool which would let one auto-format
> Django template files? Ideally, the tool should also be used to format
> HTML, CSS and .JS files too.
>
> I've recently inherited a bad-looking code base and want to clean it up.
> Have heard of the PEP8 autoformatter, but that just works for Python files,
> right?
>
> -Abraham V.
>
>  --
> 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/6ce7098d-5ab0-4223-8488-35f6688adc9f%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/CAHqTbjn%2BZ2rwmRd9qJy%3D_z_6yN4OiSF-oLuM4JRALw3iWYrkug%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to learn django and I don't kill in the attempt,

2014-12-14 Thread Jorge Andrés Vergara Ebratt
 I think the best way to start learning Django it's following the official
docs...

https://docs.djangoproject.com/en/1.7/

2014-12-14 16:49 GMT-05:00 Jorge Luis Callalle Torres 
:
>
> how to learn django and I don't kill in the attempt,
> suggestions, recommendation.
> Do you know any resource, books videos for learn django from 0 ?
>
> 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/814eb7df-c3a7-472f-9f46-5329ec5e2dd4%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
*Jorge Andres Vergara Ebratt*
*#SoftwareDeveloper (Or at least trying to be)*
*@javebratt*
*facebook.com/javebratt *

-- 
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/CAAeX05Gce8iip4a0Y-t5zJauK3P%2B%3DkpC8%2BC%3DpVVH874HBJJbrw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


how to learn django and I don't kill in the attempt,

2014-12-14 Thread Jorge Luis Callalle Torres
how to learn django and I don't kill in the attempt,
suggestions, recommendation.
Do you know any resource, books videos for learn django from 0 ?

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/814eb7df-c3a7-472f-9f46-5329ec5e2dd4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django-smart-selects

2014-12-14 Thread Jorge Andrés Vergara Ebratt
Yupp, that was what we ended up doing... tnx for the reply

2014-12-14 13:54 GMT-05:00 Collin Anderson :
>
> Hi,
>
> It's pretty normal for a 3rd party library to work fine and great until
> you need to mix it with another feature. I'd recommend using a library for
> one of those features and coding the other one by hand.
>
> It might make sense to use the (select2, chosen, jQuery Autocomplete)
> library, and handle the dependent selects on your own using your own code.
> The dependent-selects seems easier to me.
>
> Collin
>
> On Thursday, December 11, 2014 11:26:17 PM UTC-5, Jorge Andrés Vergara
> Ebratt wrote:
>>
>> Hello everyone...
>>
>> I'm using django-smart-selects for my dependent selects, you know, like
>> if you choose a Country only the cities from that country have to come up
>> in the second select. And it's working great, but now we've faced a
>> problem..
>>
>> We want to add search functionality to the selects, we managed to do so
>> with (select2, chosen, jQuery Autocomplete) all 3 work but they break
>> django-smart-selects functionality, I can choose the country, but then the
>> cities selects is empty...
>>
>> Anyone have been able to integrate them? Or do you know any other package
>> that has both functionalities in django?
>>
>> Thanks in advance for the help!
>>
>> --
>> *Jorge Andres Vergara Ebratt*
>> *#SoftwareDeveloper (Or at least trying to be)*
>> *@javebratt*
>> *facebook.com/javebratt *
>>
>  --
> 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/5f8638a5-e84f-46c6-a90b-5a5f425dab6e%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
*Jorge Andres Vergara Ebratt*
*#SoftwareDeveloper (Or at least trying to be)*
*@javebratt*
*facebook.com/javebratt *

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


Re: Caching for django.contrib.sites

2014-12-14 Thread Collin Anderson
Hi Tom,

It should work to set up your own sites model with the same table name, as 
long as you can change all foreign keys to point to _your_ site model.

Are you actually using more than one site?

Collin

On Friday, December 12, 2014 7:57:21 PM UTC-5, Tom McKenzie wrote:
>
> Hello All
>
> Is there a way to cache the database queries for django.contrib.sites?  We 
> are running 1.4.15 at the moment and we planning to upgrade to 1.7.x soon.
>
> Can I setup my own "custom" sites model with the same fields so I don't 
> have to change the database table name?
>
> I have been trying Cache machine with good success on our other models. 
>  Ideally I would like to use it for the sites too.
>
> Thanks,
> 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/130ff7c2-1d4c-48ba-9d85-f25f65a639b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can anyone give me a suggestion or a recommendation as to how I can access the current user's username in the models.py?

2014-12-14 Thread Collin Anderson
Hi,

The "admin save handlers" refers to save_model() and there's actually a 
nice example of accessing the user.
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_model

If you're using the admin, that's a good place to record this sort of thing.

Using a middleware is also helpful for a more general approach, though be 
careful because connections can now be re-used over multiple requests. 
Also, if you're deploying using threading, be sure what you are doing is 
thread-safe.

Collin

On Friday, December 12, 2014 5:29:35 AM UTC-5, malt...@gmail.com wrote:
>
> Thanks Mike and Russell, this is very helpful for starters. Do you have 
> some more verbose code examples I can use as crutches while I hobble along 
> the path of understanding Django? Especially an expansion on something like 
> "All the admin save handlers" would be much appreciated.
>
> For me every change needs to be tracked, not just ones from the admin 
> realm, and the audit trail entry is written by a trigger function which 
> gets the current user name from a variable set for the postgres connection. 
> My quest so far was to find the magical place where I have access to the 
> request (for the username) and the db.connection (for setting the database 
> variable), which – if I understand correctly – does not exist. So right now 
> I was about writing my own middleware class with a process_view. Would that 
> be the right place and how would I introduce the username into the data 
> flow?
>
>
> Sincerely,
>
> Malte
>

-- 
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/561482b8-a4bf-44fd-9c7d-ef2bbec54726%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Determine content-type of page in middleware class Django

2014-12-14 Thread Collin Anderson
Hi,

It looks like for 304 (not modified) Django specifically deletes the 
content-type header.

https://github.com/django/django/blob/0fc188251069b73b293f79dba6f3e9e331ad7e91/django/http/response.py#L458

It would probably be better to say:

if response.get('Content-Type', '').startswith('text/html'):
pass

Collin

On Friday, December 12, 2014 3:57:49 AM UTC-5, Artie wrote:
>
> Well, I have middleware class which is required to determine content-type 
> of rendered page and if it is 'txt/html', then do some action. I've started 
> just from seeing what content-types do I have on page and here is first 
> problem I faced:
>
> class StatsMiddleware(object): 
>def process_view(self, request, view_func, view_args, view_kwargs): 
>   response = view_func(request, *view_args, **view_kwargs) 
>   print response['Content-Type']
>
> Executing this, I get few messages about content-types of page elements, 
> like text/html, application/javascript and also tons of errors like key 
> error: content-type and after that - broken pipe
>
> So I assume that not all elements of page have such header Content-Type 
> and my question is following:
>
> Is there some general Content-Type that says 'That page is text/html' or 
> there are a lot of content-types on page ?
>
> And also if this is a proper way to deterimne content-type of page like 
> this:
>
> if response['Content-Type'] == 'text/html':
>  pass
>
>

-- 
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/70d3c96e-f107-4c2b-af25-af003e1af812%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django-smart-selects

2014-12-14 Thread Collin Anderson
Hi,

It's pretty normal for a 3rd party library to work fine and great until you 
need to mix it with another feature. I'd recommend using a library for one 
of those features and coding the other one by hand.

It might make sense to use the (select2, chosen, jQuery Autocomplete) 
library, and handle the dependent selects on your own using your own code. 
The dependent-selects seems easier to me.

Collin

On Thursday, December 11, 2014 11:26:17 PM UTC-5, Jorge Andrés Vergara 
Ebratt wrote:
>
> Hello everyone...
>
> I'm using django-smart-selects for my dependent selects, you know, like if 
> you choose a Country only the cities from that country have to come up in 
> the second select. And it's working great, but now we've faced a problem..
>
> We want to add search functionality to the selects, we managed to do so 
> with (select2, chosen, jQuery Autocomplete) all 3 work but they break 
> django-smart-selects functionality, I can choose the country, but then the 
> cities selects is empty...
>
> Anyone have been able to integrate them? Or do you know any other package 
> that has both functionalities in django?
>
> Thanks in advance for the help!
>
> -- 
> *Jorge Andres Vergara Ebratt*
> *#SoftwareDeveloper (Or at least trying to be)*
> *@javebratt*
> *facebook.com/javebratt *
>  

-- 
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/5f8638a5-e84f-46c6-a90b-5a5f425dab6e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django template auto format tool?

2014-12-14 Thread Jose Regalado
Install vim-autoformat plugin
https://github.com/Chiel92/vim-autoformat

install
sudo  apt-get install python-autopep8 pep8 node nodejs

sudo npm install -g js-beautify

try:

1. create a vim file and put insde file:

:Autoformat python
:wq

save and name it: indent.vim

2 now:
vim -s indent.vim my_python_file.py

Now, for python works fine, but for html, I not yet test.


2014-12-13 22:23 GMT-04:30 Abraham Varricatt :
> Hello,
>
> Is there any command-line based tool which would let one auto-format Django
> template files? Ideally, the tool should also be used to format HTML, CSS
> and .JS files too.
>
> I've recently inherited a bad-looking code base and want to clean it up.
> Have heard of the PEP8 autoformatter, but that just works for Python files,
> right?
>
> -Abraham V.
>
> --
> 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/6ce7098d-5ab0-4223-8488-35f6688adc9f%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
José Luis Regalado
bashman
Linux User nº 280381
WhatsApp / Telegram  +58 416 1705119

-- 
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/CAG7DY1iJ6%3DXf1QZ2JE8xyO2-QQx3R944bzHCNoME2CqvEXO2fQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: python manage.py runserver ImportError

2014-12-14 Thread Mohammad Shariq
try running:
python manage.py runserver --settings=

On 14 December 2014 at 14:56, Saki Fu  wrote:

> I run python manage.py runserver and got the following error.
>
> ImportError: Could not import settings 'myapp.settings' (Is it on
> sys.path? Is there an import error in the settings file?): No module named
> myapp.settings
>
> What's wrong with it and how can I solve the problem?
>
>
>  --
> 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/7d1d87f3-e5c7-4969-a2ab-04df4f7ad5ff%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/CAEeLb7NES0BbYRWyH6KLe2gc08GDvK0-UNugnSF8Ffbhf1jMKw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


python manage.py runserver ImportError

2014-12-14 Thread Saki Fu
I run python manage.py runserver and got the following error.

ImportError: Could not import settings 'myapp.settings' (Is it on sys.path? 
Is there an import error in the settings file?): No module named 
myapp.settings

What's wrong with it and how can I solve the problem?


-- 
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/7d1d87f3-e5c7-4969-a2ab-04df4f7ad5ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


python manage.py runserver ImportError

2014-12-14 Thread Saki Fu
I run python manage.py runserver and got following error.

ImportError: Could not import settings 'myapp.settings' (Is it on sys.path? 
Is there an import error in the settings file?): No module named 
myapp.settings

What's wrong with it and how can I solve this problem?


-- 
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/d1e7c5f6-a97c-4dac-8d81-ad476cfc47c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.