Re: Customizing the Django Admin Interface

2012-09-16 Thread hevok
Its the correct way to copy the templates and static files into your
project folder, if you want to customize them. Otherwise the changes
would disappear as soon as you deploy or setup-up your project on a
different computer/virtual environment.

Try F5, CTRL-F5 or CTRL-R to reload CSS in the browser as they are often
kept in cache.

Best regards,
Hevok


On Sunday, September 16, 2012 8:25:18 AM UTC+2, JJ Zolper wrote:
>
> Hello,
>
> I was able to locate the Django files for the admin under contrib in the 
> source. I was curious if I could get some tips about customizing the 
> interface.
>
> One website I read said I shouldn't change any of the Django source but if 
> I want to set up a slightly different login page for example, to put the 
> admin files in my local directories that I'm working with.
>
> The real question is that I was able to edit some template files to change 
> some of the wording displayed but when I tried to edit the CSS files to get 
> a different design I did not see any changes when I restarted my server. Is 
> there some sort of collectstatic command that needs to be run? Any input on 
> how to propagate these CSS files through would be great.
>
> Thanks,
>
> JJ Zolper
>

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



Re: Newbie, trying [read: failing] to set up Django

2012-09-16 Thread hevok
You need the PostgreSQL database adapter for Python:

pip install psycopg2

or

easy_install psycopg2

Cheers,
Hevok


On Sunday, September 16, 2012 4:28:12 AM UTC+2, Helly wrote:
>
> Hello all,
>
> I've been trying to set up Django for quite some time now. I'm on Mac OS X 
> Lion 10.7.4. As to my level of expertise, let's just say I'm pretty new 
> to...computers. I guess I figured I'd just stumble around until it worked. 
> How hard could it be right? Wrong. It seems like you all don't mind helping 
> out newbies though, so I thought I'd give this a shot.
>
> I'm running into problems with synchronizing Django with my database. I 
> installed MySQL and MySQLdb. I created a database and edited the 
> settings.py file according to instructions in the tutorial. However, I 
> couldn't get it to work with the python manage.py syncdb command due to an 
> "architecture" error. Keep in mind that I had, at this point, spent a 
> really long time trying to set these babies up, and this is what finally 
> stumped me.
>
> So, I told MySQL and MySQLdb that I was taking my ball home if that's how 
> they wanted to play. I downloaded and installed Homebrew, Macports, and 
> postgreSQL (through Homebrew) with minimal fumbling. There was one error 
> with my PATH but I fixed it in my .bash_profile. As per the advice of the 
> internet and Homebrew's brew doctor, I amended "PATH so that 
> /usr/local/bin occurs before /usr/bin." This allowed me to start up psql 
> and create a database - at least it seemed like it worked, there was no 
> satisfying little message about its dimensions like in MySQL.
>
> Anyhoo, now when I do python manage.py runserver or python manage.py 
> syncdb it tells me lots of stuff and "ImportError: No module named 
> psycopg2.extensions." What does this mean, and how do I fix it? I am 
> totally at a loss.
>
> I'm sorry if the way I posed the question is long/confusing, but I wasn't 
> really sure what information would be important. I can post the whole 
> output from the terminal if it's helpful. It's really long though, and I 
> had a hunch the last part is the important part. Any help would be greatly 
> appreciated.
>
> Thanks
>

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



Re: Customizing the Django Admin Interface

2012-09-17 Thread hevok
Well, yes. The magic pony is doing everything for you, if you just treat it 
correctly!

Basically, put the modified admin templates and static files exactly there 
were you are serving your own templates and static assets normally in you 
project directory.
For instance, treat the admin as an app and place the customized templates 
into `templates/admin/`. Django will first look in your own directory and 
use the files there.

These two videos might be of interest regarding this topic:
1. http://pyvideo.org/video/576/customizing-the-django-admin
2. http://pyvideo.org/video/56/djangocon-2010--customizing-the-django-admin

There is also 
django-grappelli<https://github.com/sehmaschine/django-grappelli>which 
illustrates how to customize the admin in an excellent way.

Regards,
Hevok


On Monday, September 17, 2012 10:57:30 PM UTC+2, JJ Zolper wrote:
>
> Hevok so what are the steps for doing this?
>
> Sure I know where the admin files are located but once I have copied them 
> does magic just happen and Django uses my new configurations?
>
> Thanks,
>
> JJ
>
> PS. apparently after I left my website alone for a little the CSS 
> propagated through and now I see this:
>
> http://www.madtrak.com/admin 
>
> Which has the red, different text color, etc.
>
> On Sunday, September 16, 2012 4:34:10 AM UTC-4, hevok wrote:
>>
>> Its the correct way to copy the templates and static files into your
>> project folder, if you want to customize them. Otherwise the changes
>> would disappear as soon as you deploy or setup-up your project on a
>> different computer/virtual environment.
>>
>> Try F5, CTRL-F5 or CTRL-R to reload CSS in the browser as they are often
>> kept in cache.
>>
>> Best regards,
>> Hevok
>>
>>
>> On Sunday, September 16, 2012 8:25:18 AM UTC+2, JJ Zolper wrote:
>>>
>>> Hello,
>>>
>>> I was able to locate the Django files for the admin under contrib in the 
>>> source. I was curious if I could get some tips about customizing the 
>>> interface.
>>>
>>> One website I read said I shouldn't change any of the Django source but 
>>> if I want to set up a slightly different login page for example, to put the 
>>> admin files in my local directories that I'm working with.
>>>
>>> The real question is that I was able to edit some template files to 
>>> change some of the wording displayed but when I tried to edit the CSS files 
>>> to get a different design I did not see any changes when I restarted my 
>>> server. Is there some sort of collectstatic command that needs to be run? 
>>> Any input on how to propagate these CSS files through would be great.
>>>
>>> Thanks,
>>>
>>> JJ Zolper
>>>
>>

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



Re: Strange rendering behaviour in template/user/auth

2012-09-20 Thread hevok
Hola Lachlan,
Are you passing the `context_instance=RequestContext(request)` to all 
templates? It should provide the user tag.

Bests,
Hevok

On Friday, September 21, 2012 12:20:04 AM UTC+2, Lachlan Musicman wrote:
>
> Hola, 
>
> I've noticed for a while that my home/index page wasn't registering 
> the {{ user }} tag when rendering the page: there was no "Welcome 
> Username. Change password / Log out" in the top right corner, and the 
> link to the admin interface that I'd put in the breadcrumbs for logged 
> in users wouldn't appear. 
>
> But that was the only page - every other page showed it fine - so I 
> wasn't too concerned, and gave it a low priority to fix it. 
>
> FWIW the whole site requires authentication (checked and confirmed in 
> another browser) - so Django knew I was auth'd - it just chose to 
> ignore some of the base.html 
>
> Yesterday I added some thematic changes - a little js and css, plonked 
> it in path/project/app/static/{js|css} as advised in docs and added 
> them to the base template with {{ STATIC_URL }}. 
>
> Suddenly the lack of auth recognition on some pages (turns out it was 
> more than one) is noticeable, because the graceful degrading of the 
> js/css is appalling enough to make it stick out. In particular, when I 
> "inspected element" I saw that the {{ STATIC_URL }} wasn't being 
> expanded - the resources were failing on bad paths. 
>
> I've tracked everything down that could be the problem - I've 
> confirmed half a dozen times that the pages in question are extending 
> the correct base_site.html, which is extending the correct base.html, 
> I even tried sending the request context in render_to_response with no 
> luck. 
>
> It was only this morning while doing some triage that I realised that 
> the pages without proper auth (no details in top right corner) where 
> also the ones with the wonky templating. 
>
> Any clues on what I'm doing wrong or new ways to track down where the 
> mistake is? 
>
> Cheers 
> L. 
>
>
>
> -- 
> ...we look at the present day through a rear-view mirror. This is 
> something Marshall McLuhan said back in the Sixties, when the world 
> was in the grip of authentic-seeming future narratives. He said, “We 
> look at the present through a rear-view mirror. We march backwards 
> into the future.” 
>
> http://www.warrenellis.com/?p=14314 
>

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



Re: Strange rendering behaviour in template/user/auth

2012-09-20 Thread hevok
Hiya L,
Your are welcome!

It is not obvious from the tutorial, but RequestContext as its name 
suggests also passes the request context to the template. The 
context_instance uses the auth middleware context processor and provides 
the user in the view. You could also refer to `{{ request.user }}` in the 
template, but I wouldn't recommend it. RequestContext automatically 
populates everything for you with nice variable names.

Cheers,
Hevok



On Friday, September 21, 2012 12:50:13 AM UTC+2, Lachlan Musicman wrote:
>
> On Fri, Sep 21, 2012 at 10:29 AM, hevok > 
> wrote: 
> > Hola Lachlan, 
> > Are you passing the `context_instance=RequestContext(request)` to all 
> > templates? It should provide the user tag. 
>
> Hi Hevok, 
>
> Thanks for the reply. 
>
> I did attempt to merely pass the request: 
>
> @login_required 
> def index(request): 
> """ 
> If users are authenticated, direct them to the main page. 
> Otherwise take them to the login page. 
> """ 
> daily_sessions = [] 
>
> for session in range(4): 
> daily_sessions.append([]) 
> daily_sessions[session] = 
> Session.objects.filter(date=today).filter(session_number=session) 
>
> return 
> render_to_response('tafe/timetable_today_detail.html',{'daily_sessions':daily_sessions,
>  
>
> 'request':request}) 
>
> but that didn't work. 
>
> I pass the RequestContext(request) for the forms I wrote to satisfy 
> CSRF stuff - I guess I just add something similar? 
>
> ...OK, I just added exactly the same as for the CSRF and it worked - 
> thanks Hevok! 
>
> cheers 
> L. 
>
>
>
> > 
> > Bests, 
> > Hevok 
> > 
> > 
> > On Friday, September 21, 2012 12:20:04 AM UTC+2, Lachlan Musicman wrote: 
> >> 
> >> Hola, 
> >> 
> >> I've noticed for a while that my home/index page wasn't registering 
> >> the {{ user }} tag when rendering the page: there was no "Welcome 
> >> Username. Change password / Log out" in the top right corner, and the 
> >> link to the admin interface that I'd put in the breadcrumbs for logged 
> >> in users wouldn't appear. 
> >> 
> >> But that was the only page - every other page showed it fine - so I 
> >> wasn't too concerned, and gave it a low priority to fix it. 
> >> 
> >> FWIW the whole site requires authentication (checked and confirmed in 
> >> another browser) - so Django knew I was auth'd - it just chose to 
> >> ignore some of the base.html 
> >> 
> >> Yesterday I added some thematic changes - a little js and css, plonked 
> >> it in path/project/app/static/{js|css} as advised in docs and added 
> >> them to the base template with {{ STATIC_URL }}. 
> >> 
> >> Suddenly the lack of auth recognition on some pages (turns out it was 
> >> more than one) is noticeable, because the graceful degrading of the 
> >> js/css is appalling enough to make it stick out. In particular, when I 
> >> "inspected element" I saw that the {{ STATIC_URL }} wasn't being 
> >> expanded - the resources were failing on bad paths. 
> >> 
> >> I've tracked everything down that could be the problem - I've 
> >> confirmed half a dozen times that the pages in question are extending 
> >> the correct base_site.html, which is extending the correct base.html, 
> >> I even tried sending the request context in render_to_response with no 
> >> luck. 
> >> 
> >> It was only this morning while doing some triage that I realised that 
> >> the pages without proper auth (no details in top right corner) where 
> >> also the ones with the wonky templating. 
> >> 
> >> Any clues on what I'm doing wrong or new ways to track down where the 
> >> mistake is? 
> >> 
> >> Cheers 
> >> L. 
> >> 
> >> 
> >> 
> >> -- 
> >> ...we look at the present day through a rear-view mirror. This is 
> >> something Marshall McLuhan said back in the Sixties, when the world 
> >> was in the grip of authentic-seeming future narratives. He said, “We 
> >> look at the present through a rear-view mirror. We march backwards 
> >> into the future.” 
> >> 
> >> http://www.warrenellis.com/?p=14314 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Django users" group. 
> > To view this discussion