django css: general query on CDNs and crispy forms

49 views
Skip to first unread message

clarkso...@gmail.com

unread,
Feb 24, 2016, 1:27:40 AM2/24/16
to Django users

I have set up a page and have implemented bootstrap using the CDN code that is recommended to access the online bootstrap server:

for the CSS:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">

Javascript:

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>

However eventually my site will have to go live and I'm not certain that this code will suffice when that happens and I feel I should download the actual bootstrap code.

Furthermore if I download the bootstrap code properly and put it in a hypothetical media folder called "css2" such that it won't interfere with my own custom css files, where do I then put crispy_forms.

As of now I am holding them in the downloaded crispy forms files within "media"- on the same level as "myproject" but the "{ load crispy_forms}" tag doesn't look in the media folder because the "CRISPY_TEMPLATE_PACK = 'bootstrap3'" does not specify a path to look for the crispy forms content... the crispy forms website tells to look up the django documentation for how to organise my media folder but searching the website under "cripy forms" returns nothing.....

Finally, I have added crispy forms to my installed apps:

    INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'myproject.myapp'
'crispy_forms',   ###Registered
 )

However when i migrate and run the server I get an error: 

 ImportError: No module named myappcrispy_forms

so I rearranged the order of the modules and then got this error:

 ImportError: No module named crispy_forms
  1. Should i download bootstrap properly or do the CDNs suffice?
  2. Where do I store the bootstrap code and how will it affect my own CSS code?
  3. How do register the module crispy_forms? and where do I store the crispy forms folder there is little documentation on this?

Lee Hinde

unread,
Feb 24, 2016, 1:36:55 AM2/24/16
to django...@googlegroups.com
On Feb 23, 2016, at 5:27 PM, clarkso...@gmail.com wrote:

  1. Should i download bootstrap properly or do the CDNs suffice?
Your call; but if you want to have a plan B, here’s an example:  http://www.hanselman.com/blog/CDNsFailButYourScriptsDontHaveToFallbackFromCDNToLocalJQuery.aspx

It’s about jQuery, but the same principal would apply for bootstrap.

  1. Where do I store the bootstrap code and how will it affect my own CSS code?
You put it the same place you’d have your other js/css files. Loading order matters. I usually load libraries first and then my files.

  1. How do register the module crispy_forms? and where do I store the crispy forms folder there is little documentation on this?

Mario Gudelj

unread,
Feb 24, 2016, 1:38:19 AM2/24/16
to django...@googlegroups.com
You're missing a comma after my app inside installed_apps. 

You can load bootstrap from cdn inside head, before your custom style sheet. Not a problem there. 

Pip install crispy forms. They'll end up in your site-packages folder. No need to download it and put it inside your project. 

Run collectstatic command to collect any css or js files that package has and put them inside your static folder


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

Adailton (Dhelbegor)

unread,
Feb 24, 2016, 10:55:08 AM2/24/16
to Django users
you have a problem here:

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'myproject.myapp', ###Missed the point ( , )
'crispy_forms',   ###Registered
 
)


Reply all
Reply to author
Forward
0 new messages