Welcome Guest ( Log In | Join )

Discover the best free computer help!
Learn more about Geeks to Go by taking the tour. Want to ask a question, reply to a topic, or remove all advertising? It's easy, fast and free. Join today!
Spyware, virus, trojan, fake security or privacy alerts? Please start with our malware cleaning guide.
     
 
Reply to this topicStart new topic
CSS not working in exe, I am programming in python using the django admin site
FutbolMolly
post Jun 24 2008, 09:38 AM
Post #1


Member
**
Posts: 33
From: Pennsylvania
OS: Windows XP Professional



Hey,

I have made an application (using the django admin site, programming in python) into an exe using py2exe. The site works until it becomes an exe, it then loses the CSS. I will post my main code to see if there are any problems. I would appreciate any help, thanks smile.gif

pyweb.py:
CODE
import os
import sys
import time
from django.core.management import call_command
import threading
import thread
from django.core.management.commands.runserver import Command
import webbrowser

sys.path += [r'c:\dev']
#sys.path += [r'p:\Hazard_Inventory']
os.environ['DJANGO_SETTINGS_MODULE'] = 'incidents.settings'

#t = thread.start_new_thread(os.system, (u'C:\\Python25\\python C:\\dev\\\\incidents\\manage.py runserver > nul', ))

#These are the Imports
import incidents.base.models
import incidents.base.views
import incidents.urls
import incidents.settings
import incidents.manage
import django.template.loaders.filesystem
import django.template.loaders.app_directories
import django.middleware.common
import django.contrib.sessions.middleware
import django.contrib.auth.middleware
import django.middleware.doc
import django.contrib.auth
import django.contrib.auth.backends
import django.contrib.auth.views
import django.contrib.contenttypes
import django.contrib.sessions
import django.contrib.sites
import django.contrib.admin
import django.contrib.admin.templatetags
import django.contrib.admin.templatetags.adminmedia
import django.contrib.admin.templatetags.admin_modify
import django.contrib.admin.templatetags.adminapplist
import django.contrib.admin.templatetags.log
import django.contrib.admin.templatetags.admin_list
import django.contrib.admin.views.main
import django.contrib.admin.views.auth
import django.contrib.admin.views.doc
import django.contrib.admin.views.template
import django.contrib.admin.urls
import django.contrib.humanize
import django.contrib.sessions
import django.contrib.sessions.backends.db
import django.core.cache.backends.locmem
import django.core.cache.backends.db
import django.core.context_processors
import django.conf.urls.shortcut
import django.db.backends.sqlite3.base
import django.db.backends.sqlite3.introspection
import django.db.backends.sqlite3.creation
import django.db.backends.sqlite3.client
import django.template.defaulttags
import django.template.defaultfilters
import django.templatetags.i18n
import django.conf.urls.defaults
import django.views.static
import django.views.defaults
import django.views.i18n
import email.mime.text
import email.mime.multipart
import email.iterators
import email.header
import email
import encodings
import encodings.utf_8
import encodings.cp1252
import encodings.ascii
import django.template.loader_tags
#End of Imports

class RunDevServer(threading.Thread):
    def run(self):
        s = Command()
        s.execute(use_reloader=False)

def start_dev_server():
    t = RunDevServer()
    t.setDaemon(True)
    t.start()

start_dev_server()

webbrowser.open('http://127.0.0.1:8000/admin/base/incident/add/')
time.sleep(1000)


setup.py:
CODE
from distutils.core import setup
import py2exe
import sys
import glob

if len(sys.argv) == 1:
    sys.argv.append("py2exe")

try:
    setup(
            options = {"py2exe": {"compressed": 1, "optimize": 2, "ascii": 1, "bundle_files": 1}},
            zipfile = None,
            data_files = [(".", [r"C:\dev\incidents\db.sqlite3"]),
                (r".\templates\admin", glob.glob(r"C:\Python25\Lib\site-packages\django\contrib\admin\templates\admin\*.*")),
                (r".\templates\admin\auth\user", glob.glob(r"C:\Python25\Libsite-packages\django\contrib\admin\templates\admin\auth\user\*.*")),
                (r"templates\admin_doc", glob.glob(r"C:\Python25\Lib\site-packages\django\contrib\admin\templates\admin_doc\*.*")),
                (r"templates\widget", glob.glob(r"C:\Python25\Lib\site-packages\django\contrib\admin\templates\widget\*.*")),
                (r"templates\registration", glob.glob(r"C:\Python25\Lib\site-packages\django\contrib\admin\templates\registration\*.*")),
                (r"admin_media\css", glob.glob(r"C:\Python25\Lib\site-packages\django\contrib\admin\media\css\*.*")),
                (r"admin_media\js", glob.glob(r"C:\Python25\Lib\site-packages\django\contrib\admin\media\js\*.*")),
                (r"admin_media\img", glob.glob(r"C:\Python25\Lib\site-packages\django\contrib\admin\media\img\*.*")),
                (r"media\admin\css", glob.glob(r"C:\dev\incidents\media\admin\css\*.*")),
                (r"media\admin\js", glob.glob(r"C:\dev\incidents\media\admin\js\*.*")),
                (r"media\admin\img", glob.glob(r"C:\dev\incidents\media\admin\img\*.*")),
                ],
            windows = [{"script": 'pyweb.py'}])
except:
    
    import time
    time.sleep(10)


models.py:
CODE
from django.db import models

class Hazard(models.Model):
    name = models.CharField(max_length=100)

    def __unicode__(self):
        return self.name

    class Admin:
        pass  

class HazardType(models.Model):
    name = models.CharField(max_length=100)

    def __unicode__(self):
        return self.name

    class Admin:
        pass

class HighwayType(models.Model):
    name = models.CharField(max_length=100)

    def __unicode__(self):
        return self.name

    class Admin:
        pass

class Probability(models.Model):
        number = models.FloatField()
        name = models.CharField(max_length=100)
        funny_name = models.CharField(max_length=100)
    
        def __unicode__(self):
                return '%s\t|\t%s\t|\t%s' % (self.number, self.name, self.funny_name)

        class Admin:
                pass
        
class SourceOfHazard(models.Model):
    name = models.CharField(max_length=100)

    def __unicode__(self):
        return self.name

    class Admin:
        pass
    
class HighwayType(models.Model):
    name = models.CharField(max_length=100)

    def __unicode__(self):
        return self.name

    class Admin:
        pass
    
class SiteDistance(models.Model):
    name = models.CharField(max_length=100)

    def __unicode__(self):
        return self.name

    class Admin:
        pass
    
class LocationHazard(models.Model):
    name = models.CharField(max_length=100)

    def __unicode__(self):
        return self.name

    class Admin:
        pass
    
class PhotoDocumentation(models.Model):
    name = models.CharField(max_length=100)

    def __unicode__(self):
        return self.name

    class Admin:
        pass
    
class HazardProbability(models.Model):
    name = models.CharField(max_length=100)

    def __unicode__(self):
        return self.name

    class Admin:
        pass
    
class ConsequencesProbability(models.Model):
    name = models.CharField(max_length=100)

    def __unicode__(self):
        return self.name

    class Admin:
        pass

class Incident(models.Model):
        district = models.IntegerField(max_length=100)
        county = models.CharField(max_length=100)
        city = models.CharField("City/Township/Boro", max_length=100, help_text="Enter city, township, or boro - do not enter all three")
        sr = models.IntegerField("SR", max_length=100)
        seg = models.IntegerField("SEG", max_length=100)
        location = models.CharField("Location Description", max_length=100)
        hazard = models.ForeignKey(Hazard)
        other_hazard_if_applicable = models.CharField("Other Hazard if Applicable", max_length=100, blank=True)
        general_hazard_description = models.CharField("General Hazard Description", max_length=100)
        source_of_hazard = models.ForeignKey(SourceOfHazard, verbose_name="Source of Hazard")
        other_source_if_applicable = models.CharField("Other Source if Applicable", max_length=100, blank=True)
        location_hazard = models.ManyToManyField(LocationHazard, verbose_name="Location of Hazard or Problem Relative to Roadway")
        describe_conditions = models.CharField("Describe Conditions", max_length=100)
        highway_type = models.ForeignKey(HighwayType, verbose_name="Highway Type")
        other_type_if_applicable = models.CharField("Other Type if Applicable", max_length=100, blank=True)
        adt = models.IntegerField("ADT", max_length=100)
        posted_speed_limit = models.IntegerField("Posted Speed Limit", max_length=100)
        site_distance_ahead = models.IntegerField("Site Distance Ahead Station (ft)", max_length=100)
        site_distance_back = models.IntegerField("Site Distance Back Station (ft)", max_length=100)
        site_condition_description = models.CharField("Site Description/Site Conditions", max_length=100)
        site_restrictions = models.CharField("Site Restrictions", max_length=100)
        photo_documentation = models.ForeignKey(PhotoDocumentation, verbose_name="Photo Documentation")
        geologic_setting = models.CharField("Geologic Setting", max_length=100)
        subsurface_conditions = models.CharField("Subsurface Conditions", max_length=100)
        surface_conditions = models.CharField("Surface Conditions", max_length=100)
        probability_of_hazard_occuring = models.ForeignKey(HazardProbability, verbose_name="Probability of Hazard Occuring")
        probability_of_consequences_occuring = models.ForeignKey(ConsequencesProbability, verbose_name="Probability of Consequence(s) Occuring")
    
        class Admin:
                list_display = ('hazard', 'location', 'district', 'county', 'city')
                list_filter = ('hazard', 'location', 'district', 'county', 'city')
                search_fields = ('location', 'district', 'county', 'city', 'sr', 'seg', 'hazard', 'oher_hazard_if_applicable', 'general_hazard_description', 'source_of_hazard', 'other_source_if_applicable', 'describe_conditions', 'highway_type', 'adt', 'posted_speed_limit', 'site_distance', 'site_conditions', 'location_of_hazard_or_problem_relative_to_roadway', 'site_description', 'site_restrictions', 'photo_documentation', 'geologic_setting', 'subsurface_conditions', 'surface_conditions', 'probability_of_hazard_occuring', 'consequences_of_hazard_occuring', 'probability_of_consequences_occuring')


I think that should be enough, if you need to see more let me know and I will post.

Thanks!
Molly
Go to the top of the page
 
+Quote Post
FutbolMolly
post Jun 25 2008, 08:23 AM
Post #2


Member
**
Posts: 33
From: Pennsylvania
OS: Windows XP Professional



Solved
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Collapse

> Similar Topics

    Topic Title Replies / Views Topic Information
No New Posts   7 / 3,646 1st June 2008 - 05:59 AM
KingTheoden started - last by wardct
No New Posts 1 / 415 4th May 2008 - 02:55 AM
jacobt started - last by lem.rar
No New Posts   1 / 1,190 16th May 2008 - 02:11 PM
zestron started - last by starjax
No New Posts   0 / 62 29th December 2008 - 02:05 PM
Psppsp started - last by Psppsp

RSS Time is now: 7th January 2009 - 07:46 PM
Advertisements do not imply our endorsement of that product or service. The forum is run by volunteers who donate their time and expertise. We make every attempt to ensure that the help and advice posted is accurate and will not cause harm to your computer. However, we do not guarantee that they are accurate and they are to be used at your own risk.