Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

CSS not working in exe


  • Please log in to reply

#1
FutbolMolly

FutbolMolly

    Member

  • Member
  • PipPip
  • 33 posts
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 :)

pyweb.py:
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:
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:
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
  • 0

Advertisements


#2
FutbolMolly

FutbolMolly

    Member

  • Topic Starter
  • Member
  • PipPip
  • 33 posts
Solved
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP